/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

inductive.no/jai/
youtube.com/watch?v=Y0XpL8j6MdM
fghj2.neocities.org/gra/index.htm
github.com/Yardanico/nimpylib
doc.rust-lang.org/std/primitive.pointer.html
godbolt.org/g/Lua1Ka
godbolt.org/g/QyRJQR
dlang.org/spec/simd.html
twitter.com/SFWRedditGifs

First for D

r8:
fn group_anagrams> where I: IntoIterator

fuck opengl though

> D
> Lain
Ohhhh yeaaah.

Where my HKTs at

God I feel stupid...
I spent almost 3 days reading through my code trying to figure out why it didn't work and it came down to a syntax error.
What compiler warning can I add, so it will catch this the next time I fuck up?
void should_warn_func(int var)
{
var = 3;
}
void what_func_should_be(int &var)
{
var = 3;
}

I'll think about it actually, firstly I will improve on the text_io to include some common function macros

Then again, I don't think people will accept my RFC. They would have done it ages ago. It's just a waste of time

never desu. people (of color) are already complainging about rust being too hard.

Just use -Wall and -Wextra, Maybe -pedantic too if you really want to catch everything.

>if you really want to catch everything
then you should use rust or ada

>friend who is a programmer calls me a leddit faggot for going python as my first programming language

but i got python from Sup Forums...

That's not a syntax error.

Can anyone explain to me document.body.childNodes[0]); in javascript? Thanks

trying to get subversion to work
it isn't going well

Stop LARPing

I'm a rustfag too but is obviously learning C, you can't recommend him to use rust in this case.

>Sup Forums
>live action

He's no Steve, he's just shitposting. Even his tripcode can tell you the story

You get the first element of the body. What more needs explaining?

I don't want rust I just want C with Lisp macros, unwind-protect, multiple inheritance and multimethods.

Maybe you'll like Jai then.

In this syntax:
document.body.insertBefore(this.canvas, document.body.childNodes[0]);

depends on what he's passing it

>Jai
Isn't that a github blog?

Insert the canvas at the top of the body. The canvas will most probably be the first visible element.

Nah it's a programming language made by John Blow inductive.no/jai/

so it could be skipped right? I can just make canvas go first without all this childNodes[0]. Thanks a lot

>all these editor plugins, but no compiler

Yeah if you put the canvas directly in the HTML code this can be skipped. But you're probably better of learning Javascript first.

Yeah it's weird. I'd understand an emacs mode since it's what Blow uses but the rest is just weird.

Can we all agree that Eclipse is the best IDE?

No.

yes

>decided to major in embedded electronics
>I'm shit at physics and math
How fucked am I?

I was planning to teach myself C but a free Java course has become available to me. Can I learn both at the same time or should I just learn C after I finish the course?

>suck at math
>still try to learn html, css and python

You can learn C after Java, syntactically they are almost the same.

Yes you can learn both but you might end up giving up on C, which is probably not a good thing.

From what I understand, Jai is still in active development. Blow hasn't released any of the early versions. I don't think the website is official - just a collection of resources collected/created by fans.

Great, thanks.

Why would I? I already know it's better.

It's not "too hard" but it certainly is high friction.

What makes Lisp so good? Is there a good book to learn it?

Tell me rustfag, is there a specific data type for pointers? Or should I just use an usize?

Java is very easy to learn once you understand C and very difficult to understand if you don't.

The course starts tomorrow, it's either both at once or C second.

C isn't better than Java. It's just different.
You might grow frustrated with C because writing the small kind of software that is written when you learn programming languages is faster in Java than in C.

>I already know it's better.
Better in what?
You've got to perform manual memory management in C. Strings don't exist - there are char arrays, so you can talk about array manipulation rather than string manopulation.

No languages with the following syntax:
name func(a int, b int) int:
return a / b if (b ≠ 0);
return b / a;

I guess Java but honestly that sounds like a bad idea.

>dpt

I'm learning Rust. This thing is great.

>return a / b if (b ≠ 0);
dumb python poster

return b != 0 ? a / b : b / a;

I guess I fell for Sup Forums's shilling. I think I'll try to learn both at once.

I've met middle schoolers who knew the basics of Java, how bad can it really be?

Java's easy to understand. That's why it's popular. I don't think anyone would criticize it for being overly complex. It's bad because of all the boilerplate.

Will knowing Java help me learn C?

how many universities did you apply to for grad school? i'm thinking of just applying to CMU and a good local university. i'm only going to attend if i get a particular scholarship i'm aiming for offered at both though

happen to think about same shit back then
but ended up learn c++

never got idea to learn 2 languages at once
whats the fucking point

A little bit.

Yes.

usize is an unsigned int the size of a pointer, like size_t in C. It doesn't have a (void) pointer type or anything like C though. Generic unsafe allocation is usually cast to u8.

You probably want Box; it depends on what you're trying to do.

>I've met middle schoolers who knew the basics of Java, how bad can it really be?
You can teach a middle schooler to write hello_world and for loops in any language pretty easily. If you're going to do a deep dive on Java, it would behoove you to understand C first.

Yes but not as much as knowing C will help you learn Java.

in a very limited sense. you'd have to google 'how to print in C' every other minute, so not really

Which is best?

Git bash.

Learn to use fucking asserts

youtube.com/watch?v=Y0XpL8j6MdM

rate my game:
fghj2.neocities.org/gra/index.htm

We need a new api.
Not vulkan. An opengl replacement that's meant for just (relatively) trivial applications. No compromise between the performance enthusiasts and people who care about the api being convenient. Give driver authors silly amounts of freedom.
And good error messages.

I asked the teacher if we could learn C instead, he said he'd have to check (a few people are going for some exam). Hopefully it works out.

Otherwise I guess I'll do it this way.

Pedantic doesn't catch it.
In my real code, I am setting the reference inside the function instead of returning it, but if it isn't a reference, I don't set the variable.
I know it is valid syntax, but it doesn't behave as I want it to and it is far too easy to miss a single char in a large project. To me, it would be equivalent to using if(var = 5) always_run();
It is valid, but it warns me if I would ever type something like that.
Is there really no such option?

Significantly.
But they differ a lot as far as programming languages go. They both allow for imperative styles of programming though so you will absolutely have a lot to gain from either.

Netbeans by a country mile.
I could say eclipse, but lacks many tools, like remote working and it has many stability issues.
Randomly hangs or usually hogs 1 thread at 100% for nothing.

What's the difference?

>I asked the teacher if we could learn C instead
they're different paradigms, you can't just swap them out

Use all my options.
tmp.c: In function 'should_warn_func':
tmp.c:1:27: warning: parameter 'var' set but not used [-Wunused-but-set-parameter]
void should_warn_func(int var)
^
tmp.c: At top level:
tmp.c:5:30: error: expected ';', ',' or ')' before '&' token
void what_func_should_be(int &var)
^

GCC or clang?

Stop using mutation.

BBC

Yeah, I'm confused as to what kind of teacher is going to cover Java or C and Java at the same time, but somehow C by itself is a special order. That's a really weird arrangement.

It depends. The exam could just involve writing a piece of code in whatever language you want.

See my original post
I'm going to teach myself C.

here is a thing

Don't try to learn both at the same time.

I'm going to learn C after unless the teacher can miraculously teach C instead of Java.

Asserts might have helped if I knew what to check for.
The problem is that once I found the error, it was simple to fix, but finding the error was the problem.
I had an assert in the function, but that didn't help me as the variable was set, but not the reference like I wanted.

why is it upside down

Python standard library got ported into Nim
github.com/Yardanico/nimpylib

I did.
The "int &var" is legal in C++, it allows you to use the reference of a variable.
#include
void should_warn_func(int var)
{
var = 3;
assert(var != 0);
}
void what_func_should_be(int &var)
{
var = 3;
assert(var != 0);
}
int main()
{
int var = 0;
what_func_should_be(var);
assert(var != 0);
var = 0;
should_warn_func(var);
assert(var != 0);
return 0;
}

The assert inside the functions will succeed as the variable is set inside the function.
The first function will also succeed in the main function as the reference is given, so the function input is used as an output.
The other function will fail as the var in the function is a separate variable on the stack.

Call me when it'll have STD.

>We need a new api
>Not vulkan. An opengl replacement that's meant for just (relatively) trivial applications
this is a job for a software API. implementing another hardware API which could be far more easily implemented using any one of the existing APIs in software would be ridiculous, especially now with Vulkan which more than fully encapsulates the functionality of OpenGL and sits at just the right layer of abstraction to act as an ideal backend for a "simplified/cleaned up OpenGL" kind of API
>And good error messages
this is another thing that a software API can provide. Vulkan's validation layers address this far better than OpenGL, and while you're quite right that Vulkan is not suited or intended for trivial applications, a more approachable framework implemented using Vulkan as a backend would be able to propagate this benefit to its users

of course there is:
doc.rust-lang.org/std/primitive.pointer.html

>mfw I want to switch from teaching C to teaching Python to my newb
He's not going to love manual memory management, he even barely progresses at all.

inserting all warnings from the man page and removing everything that is c/c-obj only seems to show there is no such warning.

Reminder that it is 2017 and none of the shilled "modern" languages supports natively built-in SIMD.

...

I don't give a fuck about politics and everyone who does is a CIA nigger desu

godbolt.org/g/Lua1Ka

godbolt.org/g/QyRJQR

Yes? Did you have something to reply?

dlang.org/spec/simd.html

D's by far the best attempt at it but it's still far from satisfactory.