/dpt/ - Daily Programming Thread

Old thread: What are you working on, Jow Forums?

Attached: 1558555986252.jpg (724x1024, 156K)

Other urls found in this thread:

github.com/kostya/benchmarks
cplusplus.com/reference/array/array/size/
en.wikipedia.org/wiki/Operator-precedence_parser
twitter.com/NSFWRedditImage

>github.com/kostya/benchmarks
>first bench has kotlin (slower than Java) #1 and C++ #2
yikes

>You want to know that something won't affect state outside of the function.
It won't though

Attached: 2019-06-27 23_09_41-C# 7 Series, Part 8_ “in” Parameters – Mark Zhou's Tech Blog.png (1025x1145, 171K)

JVM does wonders at times.

It's pass-by-value though. Who the hell cares if it's const inside of the function?

JVM HotSpot is written in C++. You can't do more work and expect better time results unless the C++ code is written by mongrel.

You would be right if it were a pure interpreter, but it also does JIT compilation.

Why does elm-live not work for me?
It detects changes, says "server restarted"... but when i ctrl+F5 I get the same page?

People who care about correctness and aren't shut-in neets who never work together with other people ever.

Asking again

I wish I were

Attached: images - 2019-06-27T025631.190.jpg (236x265, 10K)

>kotlin timing is done in code
>kotlin code does warm-up (not included in timing)
Pajeets are as trust-worthy as always it semms.

I can guarantee that thousands of experienced JVM writers write better C++ than you alone ever will

and that ad-hominem will make JVM programs not require loading class libraries, time for JIT, time for GC, and time for execution? Sure showed me.

Attached: scrotum.jpg (993x434, 136K)

Now make your parameter a reference type retard

Attached: 1561638619359.webm (1280x720, 1.72M)

>it's easier to email yourself something than send a file between 2 computers right next to each other

Attached: 1558102794480.png (240x240, 107K)

Huh, so I'm not the only one then.

use ssh and scp or sshfs

That's actually incredibly unfair. If they wanted to try to be a little fair they should at least do pgo on the languages that allow it.

scp some-file.txt other-computer.local:.
No?

Attached: 1453303001612.png (700x700, 362K)

Yes computers are fucked.
I can't wait to be rid of them after the event.

JITC requires even more time to do proper codegen hence mixed-mode is better especially for startup time.
Again, you can't waste thousands of cycles and expect less execution time.
Everybody forgets what is fair when it comes to benchmarks.

sshfs

my wife karen is so cute

is there a more /comfy/ language than common lisp?
they should have called it comfy lisp heh heh

WHY IS GETTING THE LENGTH OF AN ARRAY SUCH A PAIN IN THE ASS IN C++

how can you parse infix operators elegantly?
do you do a second pass where you transform your tree or what?

Go learn what a language grammar is and how parsers work.

Dude just use std::size lmao

dude just use lisp lmao

They didn't feel like improving C. They just wanted control. So the answer a C++ programmer would give is that you should embrace the stds.
Don't use C arrays, use std::array.

>how can you parse infix operators elegantly?
Infix notation isn't elegant so you can't.

Attached: 1561464840076.jpg (700x979, 98K)

dont ever reply to me again you useless fuck

That's what you get for using a garbage language despite /dpt/ warning you not to do so

Go learn what a language grammar is and how parsers work.

Why am I the only fucking person in the world with this problem.
I literally just follow the instructions on their repo. Install this, install that, run the thing and it should work.
BUT IT FUCKING DOESN'T. Why does it not work by default, and why apparently only for me UFKC FUCK FUCK FUCK.
I HATE bullshit like this, why is 90% of programming just wrestling with retard programs made by retards devs that don't work.

>Probably the overall most widely used programing language in the world
>bad

>

Attached: iq-curve.png (1306x700, 42K)

cute karen

I'm not going to explain quite a significant chunk of CS theory to you.
Search for it yourself; I was trying to give you the keyword "grammar".

Attached: 1546506543052.jpg (1280x720, 231K)

cplusplus.com/reference/array/array/size/

What the fuck is so difficult about scp?

whats the difference between this shit and just using a "normal" array[]

Because C arrays don't have lengths.
Use std::array or std::vector

en.wikipedia.org/wiki/Operator-precedence_parser

thank you

>a "normal" array[]
It's a legacy C-compatibility baggage. You should never use legacy arrays. Use std::array and std::vector

funny because he's actually talking about C, not C++.

C is shit, so C++ came and fixed it.

But like I said you can just use std::size on a C array.

C++ fixed fucking nothing lmao

>so C++ came and fixed it
AHAHAHAHAHHAHAHAHHAHAHAHHAHAHAHHAHAHAHAHAHHAAHHAHAHHAHAHHAHAHHAHAHAHAHHAHAHHAHAHHAHAHHAHAH.
You can't be serious.

Attached: 1558996436814.jpg (682x761, 324K)

And std::span (currently gsl::span) for passing views of arrays of arbitrary sizes once C++20 comes around.

>raii
>tempates
it did.

C++ is a massive step up, and indefinitely superior to C, to the extend that C is no longer self hosted

You're literally replying to an example of how it did.

>Invisible state changes
>Bloat generator
What? How on earth is that fixing anything?

Attached: 1399960207051.png (320x442, 50K)

>Always use std::array

array is fucking shit, Like how do i even make a function that returns such an array but doesnt have a defined length? Like for example i pass in a 2 element array i want it to give me back a 2 element array but when i pass in a 4 i want it to pass me a 4 element one

That's what vector is for.

those 'invisible state changes' are great for locks and resource management in general

template
std::array foo(std::array arr) {...}

Use spans or templates.

typedef struct array {
int length;
char *data;
} array;

Here's your array bro :^)

template
std::array foo2(const std::array &arg)
{
return {};
}

Why am I born in a time period where I need to choose between learning meme shit or becoming a pajeet??

Fuuuuck.

Attached: dauaw41-63114a51-d026-494e-974d-755a1d4a4c70.png (200x200, 40K)

retard

struct array {
size_t len;
alignas(max_align_t) unsigned char data[];
};

At least do it properly, dumbass.

>Needing to generate another version of the function for each size of array
Are you fucking serious? How on earth do you sepplescucks defend this?

Attached: 1537975511081.png (211x239, 5K)

Just learn C++ you dimwit

>At least do it properly, dumbass.
It's more portable :^)

Mine is perfectly portable, and only requires a single allocation.

why use const and & arg when just using array arg works the same way

Congratulations, you made a char array
Now make array for every other types in the stdlib and your custom types
You fucking dumb fuck cnile LOL

Attached: 1537771566378.png (1200x1400, 502K)

template
struct array {
size_t len;
alignas(T) T data[];
};

At least do it properly, dumbass. Stop writing inefficient code, you don't need an alignment that big.

Mine is generic, though. With the unsigned char, I can treat it as a block of raw memory and just put whatever the fuck I want in there.

>[]
That is not standard C++, moron.
I'm not even a sepplescuck, and I seem to know your own language better than you do.

Won't compile on my 386 :^)

>Now make array for every other types in the stdlib and your custom types
Macros :^)

>That is not standard C++, moron.
It certainly is standard C++, it's just not idiomatic C++.

what the fuck is size_t in C++, visual studio writes it automatically instead of int when i use a for loop

bra

Attached: file.png (1184x366, 34K)

Wait, nevermind, I blindly typed that out, I see what you're talking about now.

$ cat shit.cc
struct a {
int n;
int data[];
};
$ g++ shit.cc -c -std=c++17 -Wpedantic
shit.cc:3:6: warning: ISO C++ forbids flexible array member ‘data’ [-Wpedantic]
3 | int data[];
| ^~~~

You can always just do this.
void foo(span);
array bars;
foo(bars);
A single function gets generated still. You can build a nicer interface around this with templates; it'll get inlined to nothing.

Typedef for an unsigned integer which is big enough to represent the size of any object in units of chars.

>Now make array for every other types in the stdlib
Just cast it and use sizeof to calculate the length.

Attached: 1561505908622.jpg (734x354, 23K)

>All those casting
Enjoy your inefficient trash LMAO
Nobody takes you cniles seriously

Even C compilers are now written in C++.

Why does in C++ :
void BubbleSort(array &data)


change my original Array so i dont have to return

and

void BubbleSort(array data)


doesn't. Isn't the & symbol supposed to give back the memory address? Fuck this has to do with anything here

...

That's a reference declaration. It's like a pointer except it behaves implicitly.

>the virgin flexible array safety
>the chad realloc contiguous arrays overwriting everything

Learn C++ you retarded fucking sack of shit

>Enjoy your inefficient trash LMAO
Still faster than sepples :^)

oh, thats how you pass by reference in C++ then, thats neat, is there even any difference between passing by reference and passing a pointer

The first signature passes data by reference, while the second you do a deep copy and are only working on the copy.

>Even C compilers are now written in C++.
True for LLVM/clang, but in the case of GCC, the extent of sepples they use is basically just vectors.

Passing pointers is what you do in C.
Passing references is what you do in C++.

References are "stricter" than pointers (read: more typesafe).

If you pass by reference you don't have to write & at the call site and you don't have to write * every time you use it in the function.

No, they're less capable.
C++ references are especially cancerous, as they literally facilitate invisible state changes,

That's exactly what he said though.

The most important difference is that references cannot be null, while pointers can. Of course you can *foo a null pointer and create a nulled reference but you’re in undefined behavior from that point on.

Check your eyes!

>in the case of GCC, the extent of sepples they use is basically just vectors.
That's still pretty bad and means you need a sepples compiler.