old thread: What are you working on, Sup Forums?
/dpt/ - Daily Programming Thread
Other urls found in this thread:
github.com
blog.explodingads.com
twitter.com
[Reserved]
I want to learn assembly so I can make a compiler or something.
Now wouldn't that be neat.
You need to know assembly to make a compiler, right? Or can you just transpile to C.
What's normally done?
I'm going to be making a compiler for class in the fall but I don't know what else to do now.
Any of you guys made a compiler for a toy language?
What language can I use to control a dick sucking robot?
What controller should I use?
C, obviously.
>What are you working on, Sup Forums?
Recursion coin problem and other HW.
You have a few options when it comes to compilation.
1. You can compile to bytecode for a virtual machine, such as the JVM or the CLR.
2. You can transpile to another language, typically C or JavaScript.
3. You can compile to native code. This in turn can be done with:
3a. Your own backend. This requires you to have a good knowledge of the target ISA.
3b. A pre-existing backend, such as LLVM.
I'm working on a compiler right now for a class right now. Fun shit.
One small mistake and it will rip your dick off.
"Working as intended"
top kek
>robot
>anything other than C
Oh lord. Reminds me of those high school robotics teams that used Java.
At least we know the robot won't randomly slow down for a few seconds every time it collects your garbage.
Test product on dildo before testing in real thing.
Actually, nevermind, that sounds pleasant and preferable.
>>robot
>>anything other than C
Yes, we have low-level languages without garbage collection that aren't complete and utter shit, now.
It's 2018, Grandpa.
Ok, now how can I connect to it?
I'm building the device with electromagnets. I'm hoping the magnetic radiation isn't as severe as I hear. A little malignant growth on the wiener would serve some people well though.
Like what? I know there are some but I don't know what they are.
C++14 and Rust would be the best alternatives to C.
Rust, mang.
I was thinking of Rust, yeah. I suppose I agree about C++14 too. Looking over new additions to C++14, why is it specifically better? Generic lambdas are neat as hell though.
Maybe I should look into it, not that I like C++'s ugly syntax
>Maybe I should look into it
It's actually awful, but it fits the bill. Nothing will ever compile the first, second, or third time.
Java garbage collector is literally faster than shitty shared pointers from C++. It's actually ridiculously fast, definitely the fastest gc in the world.
I said C over Java, not C++
I don't know anything about shared pointers
Shared pointers are used very much in modern C++. Java being slow is a relic of history.
Maybe I should get into C++, this is so fucking cool for a compiled language
#include // yes i don't know how to use cin/cout properly, I get how they work though
int main() {
int a = 10;
auto isa = [a](auto arg) -> auto { return arg == a; };
puts(isa(5) ? "yes" : "no");
return 0;
}
C++14 has enhanced constant expressions, unless of course you use Visual Studio. It also has a free useful additions like std::make_unique. It's fairly comfy...
You can use your own custom allocators for smart pointers if you want, which would be able to compete in speed, while offering determinism, which is one of the main advantages of RAII.
Also, Java can't stack allocate objects or make vectors that don't suck.
>anything related to graphics
I know it gets said a lot, but we sure do spend more time arguing about languages than programming. Most modern languages (C++, Java, C#, Go, D, etc) offer fairly equivalent feature sets now.
>only half the languages mentioned are useful
Seriously? You do realise most graphic work is done through OpenGL which is written in C... And Java uses OpenGL through JNI, which can call native libraries.
slowly
No it's not. You have no idea what you're talking about.
p
You can do it in C as well, GNU C and Clang support nested functions, which you can abuse and use like lambdas.
#include
#define lambda(return_type, function_body) \
({ \
return_type __fn__ function_body \
&__fn__; \
})
int main(void)
{
int (*max)(int, int) = lambda(int, (int x, int y) { return (x > y) ? x : y; });
printf("max: %d\n", max(192, 4));
}
>half
There are 5 there. Which one is half useful?
I know about lambdas using the extensions, but it's not standard, so of course I feel uncomfortable using it.
You should know this.
javatards will make java 'fast' and popular if it means optimizing the hardware just to run it specially
>have mod tools on StackOverflow
>never use them
>decide to check them out
>shit with extreme votes
>all these pajeets literally copy pasting other people's answers's code minus any explanation
what the fuck I hate these faggots
I'm guessing Go and D are useless
>SO
what did u expect
Damn you OP I'm pretty sure Hime is turning me gay
expected a lot less shitposting than I see here at least
>Go
>useless
I'd ask the companies and the people using it
>dpt
>reality
Does clang support the compound statement expressions needed to make this work?
I need a project guys.
I know java, JS, perl, sql, bash, swift, xcode.
Shoot me ideas.
Go brings nothing new to the table, the language is a failure and only works well for a specific niche. Sure some companies bought the hype but really it's nothing.
and python. Sorry about that.
>XCODE
Make an App.
we dont need new projects. just contribute to an existing project.
Ok....an app for what?
I hate contributing to things that are typically already shit and that take more time to understand than to fix.
write a java program that writes JS that writes perl that writes sql that writes bash that writes swift that writes xcode that writes python that writes java... and so on
>>Go brings nothing new to the table
real stability, and security by default. surely it's not Rust, but who needs Rust when you have Go... different langs for different needs.
>>the language is a failure
>hurr durr there is nothing new so it's a failure
>hurr durr muh innovation
see >>only works well for a specific niche
uhm, have you seen the shitload of IT projects that use Go?
>I hate contributing to things that are typically already shit and that take more time to understand than to fix.
deal with it. that's the reality of modern programming. otherwise go make your phone apps from scratch. if you're still some noob you can roll a project to learn.
I've done plenty of apps to learn on. Learning isn't the goal here. I need something new, something that's needed.
contributing
that's literally it
>take more time to understand than to fix
I used to hate that, but I got good at exploring new codebases and actually enjoy understanding my favorite software projects now.
Yeah, sorry but your language is already dead. Go was supposed to be the C killer. I predict no one will be using Go after maybe 5 years and that will be when Google finally decides to retire it.
>Go was supposed to be the C killer.
Go was supposed to replace C++ for incompetent Google employees.
Beginner programmer here.
How do I get my code to print more than 19 bottles of beer on the wall?
var singles = ['Zero', 'One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten', 'Eleven', 'Twelve', 'Thirteen', 'Fourteen', 'Fifteen', 'Sixteen', 'Seventeen', 'Eighteen', 'Nineteen'];
var tens = ['','','Twenty', 'Thirty', 'Fourty', 'Fifty', 'Sixty', 'Seventy', 'Eighty', 'Ninety'];
for (i=99; i > 0; --i){
if ( i < 20){
console.log(singles[i] + ' bottles of beer on the wall');
} else if (i > 20){
var x = i[0];
var y = i[1];
console.log(x, y);
console.log(tens[x], + singles[y], + ' bottles of beer on the wall');
}
}
Should I make a array variable and split it instead?
>the C killer
I pity the fool.
Go can be the Java killer already, at least for part of its market.
why are you waiting for someone else to show you the way things are done? programming is almost pure logic, in a practical way. think about it.
I'm not expecting to be spoonfed the answer.
I literally do not understand what is going wrong.
Is this Javascript?
>i[0];
>i[1];
What
That's likely the problem. You're trying to take the digits of the number, correct?
>those arrays
There's a pattern to the written number names.
If I remove my x and y variables though, I end up with undefined NaN NaN
Convert it to a string and then take the digit.
numStr = i.toString();
firstDigit = numStr[0];
secondDigit = numStr[1];
... or just don't learn JS as your first programming lang, because it sucks. if you want to get the first and second digits, you use % and /.
var x = i/10%100;
var y = i%10;
This is probably a stupid question for some of you. I want to write a program that uses an api. The is in several different languages. But I only know c, c++, and java.
The API is available in .net, Go, Node.js, PHP, python, ruby, and scala.
is there a way to use C or C++ with these api? how challenging is rewrite an api to a different language?
but wouldn't modulo only pull the ten twenty thirty etc. strings?
>console.log(tens[x], + singles[y], + ' bottles of beer on the wall');
why. remove the ,'s
err,
var x = Math.floor(i/10%100);
...
What kind of API? HTTP?
>how challenging to 'rewrite'
very
you're limited to those langs im sure
Yes . It's the unofficial discord api. Wanted to make my own bot
I have never used an api before,
>horrible english
>discord
either 12 or pajeet
Continuing work on my Torrent tracker in golang. Finishing up adding SQL support.
No jus t drunk
I did that and changed my variables inside my console.log, now it's printed me
Ninety NaN bottles of beer on the wall
Ninety NaN bottles of beer on the wall
Ninety NaN bottles of beer on the wall
Why doesn't singles adjust on in the else if condition?
>Which one is half useful?
C#
>Ninety NaN
lmao
... /sci/cko mean anything to you?
No you're not limited to those languages. That just means they got clients written for them in those languages, but you can simply use networking to talk to Discord directly following their protocol.
Ninety NaN bottles of beer on the wall
That is actually hilarious
Maximum over quads m8
>pajeet
The fuck's a pajeet
Thought I'd update you from last thread.
My local (not at work) openwrt/mips toolchain build finished, and I statically cross compiled a simple program to test the output file sizes. With just stdio (printf used) the output is 152K, with stdlib (malloc, free used) it's 290K ... dynamically it's 6.8K.
I'm not sure the dynamic linking will end up being an issue anyway; I'll actually test it on Monday.
Are you sure the api doesn't return a json or xml string or something and they just have libraries available for using it in those languages? (also drunk)
>ninety NaN
top fucking kek
Your code gets an A in my book.
hes trying to say i am an indian not the trail of tears kind
x = 0
def f(y):
return x + y
def g(z):
x = 1
return f(z)
g(1) # evaluates to 1, not 2
This gave me cancer
What are you getting at?
>The fuck's a pajeet
welcome to /dpt/
When you call g(1), it should set x to 0, but f's x is set when f is defined, it doesn't use the current value of x
I think
variable scope in python
Why wouldn't it? "x = 1" is local to g and "x = 0" is global, so f(y) is taking x from the global scope.
Sorry I am looking over it now
This is the best developed one. Discord hasn't put out an official api, but I don't want to wait around forever.
github.com
I am not really sure how it works kek
I have been looking it over trying to understand how it works. But I don't know any .net
I hope it's terminal
x = 0
def f(y):
global x
return x + y
def g(z):
global x
x = 1
return f(z)
>x to 0
x to 1*
The x in g should be the x in the global scope (it is), and it's being set to 1 before calling f
You're telling me the assignment to a global variable is local to a function?
it brings productivity along with some useful features
blog.explodingads.com
Complexity is the bane of large scale software development. Functional languages (and more complex languages like rust, c++, etc.) are good for small teams, but not large teams where new people keep coming
So this is what happens when declaration is only done by assignment in Python?
Python is a quick language to write in and it's easy to use, but shit like this makes me loathe it.
It'd work as expected if python was dynamically scoped. :^^)
shadowing m8
Is there a quick-to-write language that isn't extremely convoluted? Haskell maybe?
I can't read .NET, so I'm not sure, especially now, but it looks like there's some way to get JSON from discord, or the dude is storing his data that way, I can't tell right now.
In any case, if you can at least dissect it you can roll your own.
Nothing wrong with this desu.
>The x in g should be the x in the global scope (it is)
Why "should" it be? (It isn't)
POSIX shell
ok cool, if I can't figure it out I guess I can learn a new language