/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Last thread:

Attached: prog.jpg (473x496, 105K)

Other urls found in this thread:

doc.rust-lang.org/reference/behavior-considered-undefined.html
plv.mpi-sws.org/rustbelt/
godbolt.org/z/8Ul2sR
en.wikipedia.org/wiki/Triangular_number
twitter.com/SFWRedditVideos

I'm never ever using anything from Jow Forums written in C. Most of the people don't even know what UB is.

Second for scheme

Attached: THE SUSSMAN.jpg (206x300, 21K)

Yes use my language instead

Attached: aftergoogle.jpg (838x855, 80K)

post yer code

Attached: scrot.png (534x748, 14K)

Rust doesn't have these issues.

Nothing right now, but I need something to work on so I can get better at C. So far I can only work with shell scripting, matlab, and a little bit of C

Rust is for babies

At least it doesn't have undefined behavior that can allow your compiler to spawn an image of a dragon dildo all over your monitor if it chooses to.

Of course it has undefined behavior. It just hasn't been discovered yet.

I know it's just a game but seeding with something predictable like current time is a game hack waiting to happen. Some 9yr old kid can now aimbot your apples

It does though

It doesn't though. The Rust standard is well defined as to what the compiler can do.

Yes it has.

There's no such thing as a programming language without undefined behavior.

JavaScript rocks!

Attached: js-rocks.png (1000x494, 286K)

You're an idiot who doesn't know Rust.
Raw pointers can be null
References can't be null
Now cast a raw null pointer to a reference. BAM, easy UB in Rust.

That's not true though. A well defined language would enforce the compiler having to signal error on behavior that is not allowed rather than letting it compile as undefined behavior.

I would like a language easy enough for babies to use but I don't believe you.

>A well defined language would enforce the compiler having to signal error on behavior that is not allowed rather than letting it compile as undefined behavior.
So basically what you're saying is that Rust isn't well defined.

>Rust: The programming language that empowers everyone to become a systems programmer.

The only way to determine what Rust is, is to look at the one and only implementation of Rust. Which is constantly changing and assuredly contains bugs.

doc.rust-lang.org/reference/behavior-considered-undefined.html

#include
int foo(int x, int y) {
return x++ * x++ + y;
}

What is the output of foo(3,4) in C17?

32

doesn't compile since there is no main function

At some point, in the context of developing on commodity hardware using mainstream operating systems, you need to trust something and use unsafe. There's no way around it. Now you're open to LLVM undefined behavior that can contaminate the rest of your program (ie: crash it with ub ). It's very possible in Rust unless you never use Vec, never have unsafe blocks, write only for a VM.

Idiot. Incorrect answer.

plv.mpi-sws.org/rustbelt/

Do you think libraries have main functions too? retard.

Lisp is the most powerful programming language.

(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status

HAHAHAHAHAHHA

See? Compiled successfully.

I first saw the LISP in emacs. Alluring in form, but grotesque in detail, I dare look upon it only when contained safely within my dotfile, and then only in the light of day. My curiosity and lust grew stronger, though, and I knew I would not resist forever. I groveled before the great dread Web Crawler, trading away the trickling sand of my life for some merest knowledge, seeking some light in the darkness. And I found it shining bright: the LISP of the Commons. So similar in shape to the miscarried darkness, but somehow smoother, more uniform and pleasing in texture. And unlike the malign presence of my prior engagements, this LISP remained pleasant... nay, became more beautiful... the closer I looked. Each peek into the implementation revealing a beautiful symbolic web, fractally resplendent, unblemished by base concerns of state or mode. Here was true beauty, and yet so similar to such abomination. Shaken by the experience, I turned to the Incremented Sea... which most marvelously contains both the glorious and the profane united in syntax.

>linking is the same thing as compiling
kys

godbolt.org/z/8Ul2sR

Works for me.

What is the Chad language of 2018-2019? I want to make 100k+

C is greatest language

Did you write your own ncurses wrapper? I don't remember addstr taking keyword arguments in chicken.

>Chad has two official languages, French and Modern Standard Arabic, and over 120 indigenous languages

I’ve never even done a map reduce job in my life. I’m asking simply out of curiosity. Why is Scala so popular in the big data world? Why not f# or even Haskell or a lisp?
I’ve seen code from a few quants and they aren’t using anything that those languages can’t do.

Webdev!

Attached: file.png (1230x571, 69K)

F# is shit and microshafts slave
Haskell has weird syntax and is slower than the JVM
Lisp has even weirder syntax and is slower than the JVM.

OCaml or Haskell.

so black

> Why is Scala so popular in the big data world?
So you can use the enterprise-level libraries and frameworks that exist in the Java world instead of whatever ad hoc solution those academic languages have.

How come f# is shit? It’s way saner than Scala and has much better type inference. Dot net core also runs faster than java on Linux.
Lisps have very nice syntax once you get used to them

>Being slower than the JVM
Holy shit, how fucking pathetic can one language be?

Dot net core is not academic. It’s open source and considerably better than oracle crap
The only reason why I think Scala is popular is because when big data blew up, around 2012 or so, f# and the Microsoft ecosystem was indeed much worse than java

>he uses Oracle JVMs
yikes

Well for one, dotnet core is relatively new. Momentum's a big thing for languages.

return 3++ * 3++ + 4
return (9++)++ + 4
return 15

Attached: wtf.jpg (640x640, 167K)

Yeah that’s what I was thinking. Scala was miles ahead 5 years ago, I guess they’re just running on that inertia. such an ugly language, it’s vomit inducing

>Lisps have very nice syntax once you get used to them
Lisp has one of the most consistent syntaxs you can find, but that doesn't mean people who are used to C languages are going to immediately love it and even want to bother with it.

You can pre/post-increment constants? Well that's pretty retarded. What exactly is the use case? Do they just allow it because it's something that you technically can describe using implicit lvalues or whatever?

No, he's an idiot.

It's actually 16

16. Because * is commutative, it doesn't matter that its operands could be evaluated in either order.

I.e. it ends up being (3 * 4) + 4 or (4 * 3) + 4 but of course they are both equal to 16.

These are all wrong answers.

Doesn't compile in my compiler.

In C, if I have 3 int arrays how do I create 2D array that points to them?
I tried several solutions in this style but nothing worked
int a[MAX],
b[MAX],
c[MAX],
array[3][MAX];

array = a;
array+1 = b;
array+2= c;

Why would it be either? Isn't order of operations explicitly defined as doing multiplication left-to-right in C++? Why are you bringing a generalized abstractions when talking about post-increments which only exist in specific computer languages?

Surely f(x++, x++) is generally unspecified and not undefined.

It's not order of operations that changes, it's evaluation order, which is not necessarily left to right or right to left or either.

You're treating arrays like pointers.

int *array[3] = { a, b, c };

int (*array[3])[MAX]

int (*array[3])[MAX] if you want to be specific about size and int *array[3] if you don't

sequence points are ub

Thanks
I've read 2 books on C, including C The Programming language, and I still don't get this stuff.

Holy shit /dpt/ is clueless in anything relating to actual programming.
No surprises there.

I don't think that's the case here. Something like x = x++ * x++ would be undefined, but I'm pretty sure that the RHS itself is fine.

C has really dumb quirks that will entrap you.

Why wouldn't evaluation order be well-defined? Because that would limit the compiler's optimization options? Well, you shouldn't be typing out shit as retarded as "x++ * x++" anyway. I'm not going to fault the language for not handling execution-time mutations within a single operation string in a predefined way.

x doesn't need to be the LHS to be a sequence point. y = x++ * x++ is ub. x++ * x++ +y will also be ub regardless of LHS.

how is this garbage undefined
isn't it the same as
x = x*(x+1)

do people really write code this way, 'le i'm so pro in C guys, seasoned C programmer here' ++++++

>I don't know how arrays are stored in memory

"Programming" isn't about knowing tiny details about compilers and languages. It's the engineering/logical skill to build well functioning program abstractly to later apply in any language.
Leave language specifics for code monkeys

It's unspecified because of optimization, yes. A straightforward reason is because of different calling conventions. For instance, if a calling convention takes arguments from the stack, depending on which order it expects them to be on the stack it will be more efficient to compute and push them onto the stack that way. If a calling convention takes some arguments by register and some by the stack, it will be better to compute the arguments by register last so that those registers can be used for computing the arguments passed on the stack.

I see, so f(x++, x++) is unspecified because the function call is a sequence point but x++ * x++ is undefined because * is not a sequence point.

>tiny
huge and very important*
Spout all the shit you want, but an actual good programmer worth his shit knows it like common knowledge.

The language is something like "thou shall not modify the same object more than once unless separated by a sequence point" x++ modifies the object so you can't do it twice like that.

Wait, never mind, I think f(x++, x++) should still be undefined. f(x++) * f(x++) would be okay though.

why would you ever want to do any of these though

x++ * x++ + y;
x * (x + 1) + y;
3 * 4 + 4
16

You wouldn't. In fact, I see no reason why a compiler wouldn't be able to catch when this happens, since it would require no interprocedural analysis (because function calls are sequence points).

Is C++ worth learning?

My life has no meaning, awake I mean dreaming:

function basicOp(o, a, b) {
return eval(a+o+b);
}

>EVAL

No.

I dunno, I learned C and never used it, then we back to JavaScript.

Those two first lines have different meanings.

Are the h4x0rz going to pwn codewars through me using eval on a shitty problem?
const findNeedle = haystack => `found the needle at position ${haystack.indexOf('needle')}`;

Start with C, see if you like that level of control. If so and you want to make some huge, sprawling project such that the abstractions of C++ are "necessary" consider learning C++. It's an ugly language in many ways, but it's powerful.

calm down, most of the answers given in the last thread were perfectly reasonable. It's undefined. We can hazard guesses at its behavior (although we shouldn't in practice), but all of those guesses will circle back around to "it's undefined"

ok

Attached: 2018-12-22-133540_3120x1920_scrot.png (1916x1165, 143K)

Fuck, the next fgt problem is optimally solved through: en.wikipedia.org/wiki/Triangular_number

I don't get this shit intuitively. Goddamnit.

People who use Plan 9 unironically should neck themselves.

>global mutable state
disgusting.

I'm not using plan 9 you imbecile

pardon, tell me where you see global mutable state anywhere in my code?