old thread: What are you working on, Sup Forums?
/dpt/ - Daily Programming Thread
Is compiling to C a lot easier than compiling to LLVM or assembly?
nth for clojure
nth+1 for Rust
GIVE ME A PROJECT TO WORK ON
I'LL HELP YOU FOR
F
R
E
E
How wasteful is it to call a function multiple times in a higher order conditional statement just so you don't have to create another variable?
Probably. But it depends of the source language. If you rely on TCO C89 is not the best target.
Shinobu-chan a cute!
I post this a lot. But it's because I think it's good.
Learning how to guide yourself through a design without pre-planning (which is often something you need to revise anyway) is something that comes with experience. But you can help yourself by having a better perception of where you are with your code exactly and what information you can extract from your work.
I recommend watching
hero.handmade.network
Episode (day) 27. It's probably the best day so far. Most of this series is about game engine development. Most of what's done is done for reasons which may not be all that apparent to someone who just wishes to make something. The goal of the series is really to teach programming as a craft. How to do exactly what you find you're having trouble with.
But spending 300*1.5+ hours to gain an understanding of this by osmosis may be way too much. So I recommend this one episode. It's the most information dense episode in this regard. Episode 26 explains game engines in general and why he has chosen to do certain things this way so far. So it's slightly less relevant but I'm just putting it out there as the second best.
The forums on that site is very helpful for new developers (who already know their languages) too. Especially if you have well formed intelligent posts.
How to explore software solutions is something that you rarely get concrete tips on. My mom has been in software since they had punch cards and she told me that she didn't get this until she had been at work for at least 10 years. It's far too long. Which is why I really like this show. It's a person with good merits who teaches what he loves.
>If you rely on TCO C89 is not the best target
What? Why?
Make me a sandwich
Where should I mail it?
The thing with llvm is that as long as it's not broken the optimizer can do lots of good things. With C you're implying a bunch of things in your code. Often this can hinder a compiler from making what you really wanted.
Outputting asm isn't too hard. Optimized asm is harder.
Isn't there some Scheme which compiles to C?
depends on what you're doing.
A lot of modern languages have very nice bindings to LLVM.
If you're at all familiar with Haskell, it's actually a great language for compilers. Very easy to make parsers, full AST transformations with plated (not to mention how useful lenses can be for complex transformations), easy to make repls, easy to use LLVM bindings.
How do we get more anime girls into CS?
Is pluralsight good?
I want to learn python and they have a path to learn it or something like that.
Make company policy to reward every bug free commit with sweet parties.
That's what I'm writing it in. I'm almost done with the core language and interpreter.
Should I try compiling a simple imperative language first?
Depends entirely on how much work the function is doing and how many times you call it, but it's probably fine.
Completely sincere answer: There are multiple tradeoffs.
The obvious upside of compiling via C is that it makes portability easier. If you don't have the manpower to maintain different backends for different architectures, and you need to compile for unusual targets, like AVR, then this is a good point in C's favor.
The downsides are numerous. LLVM has a well defined code generation API that makes it easy (relatively) to avoid undefined behavior. I don't know of any such libraries for generating C. If you roll your own, you're likely to shoot yourself in the foot by tripping over the many "gotchas" in C semantics. At any rate you will find the optimization passes in C compilers to be unreliable for your code, and you'll have to introduce your own optimization passes, which would not be a problem in LLVM.
If your language is intended to be used for low level code, there are all kinds of low level operations that aren't supported by C. In some cases, like bit rotation, you can hack these together yourself, but a C compiler won't necessarily recognize them and turn them into an efficient operation on the target CPU. You can fix this with target-specific assembly, at the risk of potentially much more horrible undefined behavior. This will not be fun to debug.
If your language is intended to run on x64 and ARM, and you're just compiling via C because you heard LLVM was unfashionable, then you're an idiot.
Listen to this guy user. This is a good post.
The only thing I've found is that there's much more documentation for imperative-ish languages than functional languages out there.
I've never made a particularly complicated functional compiler, but I don't think it would be too hard if you're willing to study (possibly in the form of reading the code of existing compilers).
why cant i access self paced courses on edx?
I got the link from the git thingy that someone linked in the old thread
github.com
the courses didnt start yet so i assume there are old versions of the courses they link to, otherwise why would they tell me to do a course which they cant know is good.
Is there a difference between the CoC and dependently typed lambda calculus?
Yes.
Much much easier.
LLVM is a huge clusterfuck to learn and just outputting C is a whole lot easier than learning how to use LLVM.
lol @ "programming" in python
Thank you for this, Ill check it out.
>tfw to intelligent for hasklel
good lad
You're not wrong. My post was from the point of view of using it in production. If it's primarily a learning project and he just wants to get up and running, C might be the easier way forward.
Edwin, is that you?
What did you rewrite in Rust today /dpt/?
Yes it is me.
Abandon all who do not preach the way of Dependent Types™
Who would win in a programming fight between you and Edward Kmett?
I'd knock that chubby manlet on his ass.
>decide to try VS2017
>mfw
HOW THE FUCK DO I GET 2015 BACK
FUCKING SHIT
are there any actual working people here or is this general filled with NEETs who can write fizzbuzz in C and spam anime pictures only?
Professional OCaml coder here.
>ass
>not arse
Impostor!
I work in the CVS call center, if that counts
Writing a LCD driver for the PL111 LCD interface now, to understand how LCD's work.
Professional Haskell coder here, get rekt
Professional Android coder spamming anime pictures here.
I am not jealous of your lazy language.
>working people
People whose day consist of mindlessly developing some shitty "app" tend not to have programming as a hobby.
>android coder
How can you even stand Casey talking?
The constant smacking, gulping and other stupid habits that he does every 5 seconds or so are so unbearable.
It's great if you get it for free
there's easier ways to get attention user, like sucking my cock
I import GitHub libraries, glue them together with StackOverflow code snippets and get paid. That makes me a coder :^)
Should the undo operation of a hex editor undo every single edited/inserted/deleted byte separately or should it undo chunks of edited/inserted/deleted bytes?
Definitely the latter. There have been text editors that worked the other way. They're horrible to use.
What's a good way to get started with data science?
Alright, I'm done with visual studio
Where do I go from here, codeblocks?
For C++
GNU Emacs.
Clion
VS Code
Qt Creator tbqh.
Even if you don't use qt.
...
but who are the respondents
does 64% of earth's population really use rust
official survey
if it's an official rust survey on www.rust.com asking www.rust.com users if they use rust do you think the results are going to mean anything
It shows a crumbling community.
>3k
>population of earth
hmm
Are you acquainted with the concept of statistically significant samples, user?
>try making a program that uses a singleton
>it keeps opening itself, creating hundreds of singletons
oh god what have i done
singleton was a mistake
your a mistake
b t f o
we did it reddit
Trying to solve fizzbuzz.
gitla.in
Currently figuring out image scaling. Can't use glOrtho tho because it's deprecated in OpenGL 4.5, gotta calculate the transform matrix manually and hand it to OpenGL with glUniformMatrix4fv.
Anybody knows what is the different between this two things? they give different results.
public class Test{
Test(){
//constructor
}
public void methodA(){
//stuff
}
public void methodB(){
Test test = new Test
test.methodA();
//Calling methodA with Test Class's object
}
}
and
public class Test{
Test(){
//constructor
}
public void methodA(){
//stuff
}
public void methodB(){
methodA();
//Calling methodA directly.
}
}
shit wrong code let me fix the first code:
public class Test{
Test(){
//constructor
}
public void methodA(){
//stuff
}
public Test methodB(){
Test test = new Test
test.methodA();
return test;
//Calling methodA with Test Class's object
}
}
>calls new Test being itself a Test
Why is this retardation allowed?
>object
Test test = new Test();
>The language is ~~~, and I'm now going off Sup Forums to research this baby tier question by myself.
ftfy.
I'm working on a program that helps me simulate tabletop adventures.
The tabletop game I designed myself, the app helps me run the game online since my friends and I can't always meet up. we run the campaign over kik or Facebook. The app allows me to take all their stats into consideration and make the calculations for me.
Like for a luck roll, its usually just "whats your luck? well you need to roll this to make this happen"
the app will allow me to make it more complex (because fuck it why not)
and compare your luck to your opponents luck and the situation at hand and other factors like speed reflex of the character intelligence etc.
>The language is ~~~
you can say "sh*t" on here, buddy
If you do this
Test test;
test.methodB();
The second example will call have methodB call methodA on the same object. The first example with create a new instance of Test and call methodA on that instead.
I wonder the same thing here.
Suppose one knows java, and they want to learn android development; can they just look at some online docs and start programming right away, or should they read a book about the topic?
Can you upload it please? I can only find samples of it.
i am a beginner did i ask something wrong?
>baby tier question
can you give me the keywords so i can google it.
i thing i get it(i think). I have to use another class to call methodB like the fist code.
btw thank you for being polite :3
how can i get beyond beginner level?
send help
im stuck
what book, what course, what video series? ;_;
HtDP
SICP
>what video series
None
just like make things
SICP is a beginner book though.
You can't get beyond the beginner level if you haven't read it however.
>what video series?
this must be the last option.
Beginner level of what?
Some user asked for help with this on the last thread. It looks like the equations on the image are wrong; this code makes the correct plot. Just make sure you have gnuplot installed.
#include
#include
#include
#define N 10000
int main(void) {
FILE * plot = popen("gnuplot", "w");
fprintf(plot, "plot '-'\n");
double xn = 0.1, yn = 0.1, x, y;
for (int i = 0; i
pretty cool
>i thing i get it(i think). I have to use another class to call methodB like the fist code.
Without knowing what you're trying to accomplish, it's hard to give real advice. But it will probably help to understand how the syntax of a method works. Methods have a hidden parameter for the object it's being called on.
Test test;
//so this
test.methodA();
//is the same as
Test::methodA(&test);
That parameter is called "this" and is a pointer to the type of the object. Methods use that pointer to get the correct members and methods to work on.
methodB(Test *this)
{
methodA(); //same as this->methodA(); //same as Test::methodA(this);
Test test;
test.methodA(); //same as Test::methodA(&test);
}
In this example, this and &test are both addresses of Tests but test is a new object that was declare in the method.
>btw thank you for being polite :3
LONDON
O
N
D
O
N
>i thing i get it(i think). I have to use another class to call methodB like the fist code.
Without knowing what you're trying to accomplish, it's hard to give real advice. But it will probably help to understand how the syntax of a method works. Methods have a hidden parameter for the object it's being called on.
Test test;
//so this
test.methodA();
//is the same as
Test::methodA(&test);
That parameter is called "this" and is a pointer to the type of the object. Methods use that pointer to get the correct members and methods to work on.
methodB(Test *this)
{
methodA(); //same as this->methodA(); //same as Test::methodA(this);
Test test;
test.methodA(); //same as Test::methodA(&test);
}
In this example, this and &test are both addresses of Tests but test is a new object that was declare in the method.
>btw thank you for being polite :3
LONDON
O
N
D
O
N
I have a coworker who riddles code with debug messages like System.out.println("a") can I report him to management?
Nice. But what is it?
I want to shotgun approach my CG and system programming courses with one project. CG requires the project to be done in WebGL with some shitty JS frameworks I don't know shit about. How do I access Linux syscalls from JS?
I found this demo. s3.amazonaws.com
Looks like it downloads and compiles something at the initialization. Idk if it's a part of the web app compiles on my machine and then runs while the controller/view stays in browser or what? If it's so then how much can I do with this? can I use my syscalls here, like open files, fork and maybe write a simple (local cause idk shit about networks) server that would communicate with multiple instances of my web app with POSIX/SystemV IPC?
a sharkfin