/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Last thread:

Attached: 1539490174004.png (1452x1518, 1.33M)

Other urls found in this thread:

developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat
devdocs.io/javascript/global_objects/array/flat
en.wikipedia.org/wiki/List_of_wars_involving_France
duckduckgo.com/?q=nightmare of move semantics in simple classes
en.wikipedia.org/wiki/Non-English-based_programming_languages
twitter.com/SFWRedditVideos

fuck opengl

Javascript and Python are the only languages you need in today's world. Only retarded boomers use shit like C/C++/Java.

>What are you working on, Jow Forums?
Vulkan, file size graph, opengl model viewer (because vulkan is hard). Can't wait to get my cast off on Monday!

Attached: hand_xray.jpg (4032x3024, 2.73M)

>compiles c++ to wasm
Nothin personnel kid.

Is this that delectable Jow Forums banter I have been hearing about. Just got off the train from Jow Forums, and am stopping through.

Yes but companies will still make you use Java.

this

JS is the best
const flatten = ([first, ...rest]) => [
...(Array.isArray(first) ? flatten(first) : [first]),
...(Array.isArray(rest) && rest.length ? flatten(rest) : []),
];

flatten([[1,2,3], [[4,5,6], [7,8,9]], [10,11,12]]);
// [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]

Woah, Anone! Thank you for this big drink! I'll drink it all while learning JavaScript with you!

Attached: 3df509ac0bc5fad9ecbf1466bd883cee.jpg (1366x2048, 255K)

Zoomer mentality

WASM in all browsers is implemented in JS . HAHAHHAHA SUCK IT LOSERS
Only shit boomer ones. Web is the future.

In JS this is just
[[1,2,3], [[4,5,6], [7,8,9]], [10,11,12]].flat(Infinity);

Ur gonna get fat then I'd never fuck you let alone play javascript anone

fuckin goofy giraffe neck ass bitch

what

>.flat is not a function

what did you do

inb4
>it is in es6

developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat

fisted a goat. Did you know the goats sphincter is one of the strongest muscles in the animal kingdom. Golly color me happy. Monday woot!

eww, this is disgusting

devdocs.io/javascript/global_objects/array/flat

Attached: unknown.png (404x65, 3K)

that's unfortunate, hope your hand gets better user

Thanks. I can't wait to get back and be 110% again.

nevermind
I tried in node v10.16.0 and it threw an error

but it works in the browser console

why can't node keep up with the times

because you're two major versions behind

ES6 is half a decade old. The language didn't stop there.

I don't know what kind sick of enjoyment you get turning an O(n) problem into O(n!) but you should stop doing this

gonna update brb

>why can't node keep up with the times
I mean it's node

Objective truth incoming, universities follow this (STEM).

1. Learn C, a very simple language, but full of pitfalls. It teaches you to pay attention and plan ahead. It gives you a simple, if outdated, model of a computer.
2. Try modern C++. If you feel this fixes your grips with 1., then stay here.
3. Learn Python. You know how to pay attention, but you dont really need to? Yep, this is it. Stay here if you dont plan on leaving STEM usecases.
4. Javascript
5. Haskell

Imagine the faggot who would actually type this out.

Attached: 1565188515340.jpg (125x155, 4K)

Yeah, so.

How exactly do I use quaternions?
It makes sense to store orientation with them but then when I want to rotate an object I'm not going to pull an exact direction out of my ass.
I still have to rotate around X, Y and Z axis which defeats the point.

Attached: mike.jpg (625x415, 44K)

Nevermind. Turns out I didn't understand exactly how gimbal lock works.

No matter how much time I spend on something I always figure it out right after I post a question.

cope, its less of a clusterfuck that is direct3d, granted the implementation is better.

multiply by a rotation i'd assume

>WASM is implemented in JS
>implying

I dare anyone to re write this function without the spread operators and recursion
it's impossible

tried this but no work
function flatten([first, ...rest]) {
if (Array.isArray(first))
if (Array.isArray(rest) && rest.length)
return [...(flatten(first))]+[...flatten(rest)]
else // the fuck
if (Array.isArray(rest) && rest.length)
return [...([first])]+[...([])]
}

Attached: 1565350085797s.jpg (250x220, 3K)

A time-series database. Influx is pretty good, and it's written in Go, so if I use a language with generics I should have a pretty easy time of it, eh?

>rewrite a naturally recursive algorithm to not be recursive
Put the stack in your code instead of relying on the call stack.

It's upsetting that programming is done in english.

There'd be less Indian competition if French were the lingua franca (no relation) of programming I guess.

>French
holy shit even worse.

In the Raku programming language:
sub flatten(\arr) { gather arr.deepmap(*.take) }

my @a = [[1,2,3], [[4,5,6], [7,8,9]], [10,11,12]];
flatten @a;
@a.&flatten;

Attached: camelia-raku-mascot.png (1200x877, 94K)

>even worse
For who? Germans?

everyone.

Perl 6 was a mistake.

It's not even worse for French people.
Just come out with your preferred mudpeople language already. You've already confessed to not being English or French.

Literally no one in this world likes French. You're country is shit. You're people are wimps. You can't even win a war unless it's against yourself. Any french programming langauge would be more of a cuck than Rust is.

Lisp is the most powerful programming language.

literally retarded

Prolog is the most canonically French language. Try and describe your beef with Prolog without using facts or rules or exhibiting goal-seeking behavior. No backtracking either, motherfucker.

but it's true

it's upsetting that web development is done in javascript.

>t. frenchie

doesn't have to be

Elm, Reason, Nim.
You gotta know JS anyway, but it's not such a bad language (like PHP or C++) that mere knowledge of it is harmful to the soul.

en.wikipedia.org/wiki/List_of_wars_involving_France
it's not and that wimp, can't win a war crap makes you sound like a inbred american
the rust cuck stuff only makes you sound dumber
i'm not

You're definitely a buttmad frenchfag.

What are your opinions on vlang?

vaporlang.
pretend it doesn't eVen exist lang.

function flatten(array) {
const { isArray } = Array;
const result = [];
const stack = [array];
let i, len;
do {
const value = stack.pop();
if (!isArray(value)) {
result.push(value);
continue;
}
for (let i = 0, len = value.length; i < len; ++i) {
stack.push(value[i]);
}
} while (stack.length);
return result.reverse();
}

>flatten
>recursive
ok retard

>C++
>mere knowledge of it is harmful to the soul.
why? I've heard the nightmares with php and how you can literally be a worse programmer for learning it but C++ is what I was thinking about learning next

duckduckgo.com/?q=nightmare of move semantics in simple classes
Imagine always having to decide between the optimal but impossibly onerous outcome, or the most reasonable but pointlessly wasteful outcome.

Yuki doesn’t paint her nails

function flatten(arr) {
const { isArray } = Array;
const visited = new WeakSet;
const result = [];
const stack = [arr];
let i, len;
do {
const value = stack.pop();
if (!isArray(value)) {
result.push(value);
continue;
}
if (visited.has(value)) continue;
visited.add(value);
i = 0, len = value.length;
while (i < len)
stack.push(value[i++]);
} while (stack.length);
i = 0, len = result.length - 1;
while (i < len) {
const temp = result[i];
result[i++] = result[len];
result[len--] = temp;
}
return result;
}

>dudebro sends big pull request on github
>abysmal code quality, doesn't follow project guidelines, styling, nothing
>but the fix was very smart
How do I fix all his shit but keep his authorship? I'm very new to GitHub.
Pull his branch locally, fix, add a commit on top of it, force push to his branch (can I do that?), or how does it work

Attached: picrelated.jpg (780x438, 112K)

>Hey Tim, great work! Could you please rewrite this commit following the guidelines to ensure consistency throughout the code base?

>Thanks!

this is still a problem for me, relinking
i have devoted two hours to programming every day, and my schedule is coming up again. i need to know if this book (the one in the op of this thread actually) is still relevant or if there is a better book to learn this language from. please respond

merge pull request and fix it asap

I would thank him for his fix but then make him do the cleanup as it’s his responsibility. He can then send a new PR after that.

the book is fine, you're just dumb

Those examples should both work. What are your actual errors? Use ctrl-d at a (Unix) terminal to end input to the program, or pipe input into it.

>fuck off
>permanently closed

>literally copy the text into a .c file
>compile with gcc
>doesn't work
how does that mean the book is still fine?

the first two programs are supposed to count the number of characters you type. the third program is supposed to count all newlines. how the first and the third programs behave once compiled is that they simply dont count anything, printf is not outputting the value of n1 or nc. simple programs and not useful to me yet BUT this is the first chapter and im already having problems which is worrying me. i dont want to get halfway through the book to find out a lot more than syntax has just changed

What's the difference between interpreted and JIT? Doesn't interpreted code HAVE to be translated to machine code at some point to be able to run

I'm sure there must be a more Perlish way of doing it. I could use the .flat method but it only flattens non-containerized Iterables. Thus this will work fine (Lists don't containerize its items. Arrays do):

my $a = ((1,2,3), ((4,5,6),(7,8,9)), (10,11,12));
say $a.flat;


>Perl 6 was a mistake.
Indeed. However, so are all other programming languages. Raku is just a tool after all but it's the tool that works for me right now. It might not be in the future but that's that. It's just a matter of choosing the most appropriate tool for whatever task you have.

>doesn't work
Stop saying this. It works. What are you actually doing?
Try this.echo hello | ./a.out

it works fine
$ cat text
foo
bar
$ ./test < text
8
$ wc -c text
8 text

Russian programming language when?

No, interpreted doesn't need to translate your program to anything at all. J f.e. interprets strings every single time, not even parsing them into an AST to then retain internally.
Machine code is always involved. If it's JIT, some of the machine code corresponds to your program. Otherwise, the machine code is only the interpreter.
Go through Crenshaw's Let's Build a Compiler series and you'll write a simple interpreter, and also compile to whatever. Obv. very different tasks.

I don't want to put that burden on him, I don't mind fixing it myself. But to be honest I think he's too dumb to fix it lol. Like I can't be fucked to exchange 30 to 50 more comments and pulls with him until he gets it right.
Sounds like a good idea

You could also merge it into your own new branch, fix it there, then merge that into master.

the soviets developed a few languages, they also had a russian ALGOL.
en.wikipedia.org/wiki/Non-English-based_programming_languages
ПPOЦ CTAPT()
BЫBOД: 'Пpивeт, миp!!!'
КOH ПPOЦ

oh alright, i thought it was supposed to count it realtime like the second example program actually does. i cannot get the line counter to work but i bet this is another mistake on my part ill look at later. thank you guys

Attached: Screenshot_2019-08-09_13-57-22.png (797x620, 111K)

Kotlin. It's even in the name.

The problem with your first attempt is that you're waiting on EOF -- end of file, no more input. Hitting enter doesn't result in no more input. Try that again but hit ctrl-d instead of ctrl-c.
In the future use strace (-p in another terminal, for easier reading) or add some output to your loop to see what's going on.

do you not know how to use an auto formatter XD

Kotlin is all english and latin characters

thats got nothing to do with his problem
its about keeping authorship and not being an asshole that steals commits

based yuki op poster

based javascript doll poster

based based posters

What the fuck is authorship, how can you steal commits?

Is this actually a problem that people get angry about?

Attached: 1539460128168.jpg (540x540, 31K)

Yes because MUH NAME RECOGNITION. Github is a joke it's nothing but social media for programmers for showing off how many programs they work on.

If anyone ever submits a pull request against your project deny it and then copy their solution if it's worth keeping. Fuck them.

Oh I see, the poster was just retarded and didn't know how to accept their code so they can format it after.

if it doesn't have greek symbols, it's shit

merge into a branch, fix it, rebase into master. what is hard about this?

I'd accept bug-fixes as they are if they don't break anything else.
For cleanliness or style, just make another commit on top.

Is this js these days?
what is
const { isArray } = Array
supposed to do?
how come you can use pop on a "const stack"

const isArray = Array.isArray