/dpt/ - Daily Programming Thread

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

Attached: 1566494750002.jpg (623x600, 178K)

Other urls found in this thread:

github.com/xi-editor/xi-editor/blob/master/rust/rope/src/rope.rs
haxe.org/manual/target-cpp-getting-started.html
ziglang.org/
caml.inria.fr/pub/docs/manual-ocaml/stdlib.html
docs.python.org/3/tutorial/
twitter.com/SFWRedditImages

What is man supposed to use when here's just no good statically typed and compiled language?
>sml
no good implementaion
>ocaml
sml with shitty syntax, also does not support native threads
>lisp
not even statically typed, pretty much locking yourself to one implementation
>c
decent but manual memory management is annoying in prototyping phase
>sepples
cluster fuck that no sane person would touch
>d
can't decide if it wants to have gc or no
>rust
better stay away from it because it attract lot of crazy hipsters, also uglier than sepples
>any jvm/clr lang
requires huge vm
>go
Rob Pike is faggot, also no macros
>haskell
generates garbage 1GB/s
>chapel
cannot use libraries that was compiled with it...
>ats
Jesus Christ
fun{
a:t@ype
} list_length
{n:nat} ..

use rust

Attached: 2_1024x1024.jpg (700x520, 38K)

RUST enforces CAPITALISM by not allowing any shared owenership of resources and encourages private ownership.
Learn Rust.

did she actually become a dev?

No, she wanted me to become a web/mobile dev. Before breaking up, she also wanted me to make an app and made a powerpoint slide for me to help visualize the app.

I hope the poor girl is doing alright. She's really easy to manipulate.

vector split(const string&); // function declaration
vector v; // initialization

v = split(line);
// on entry, initialization of split's parameter from line;
// on exit, both initialization of the return value
// and assignment to v


I don't quite understand the
>initialization of the return value
part.

Split takes a copy of line as input, does something to it, returns a copy (?as opposed to the copy?) and then whatever the value of v was given by default constructor is exchanged with the said copy.

What does it mean it returns a copy?

use rope

Based. Rust has one of the best implementations of the Rope Data Structure.
github.com/xi-editor/xi-editor/blob/master/rust/rope/src/rope.rs

Oh, i think i get it now.

For example, if we had a local variable declared inside split to store the return value, when we actually return it this local variable is destroyed, so we need to copy it somewhere temporarily only to then assign it to v. Am I correct?

Is there a way to use traps in c# or .net in general? My empty waiting conditions for a thread to change state keep the CPU idling at ~50%.
I can bring it down with sleep instructions > 20ms but that seems like a low quality solution

or are there other synchronization tricks that an embedded guy wouldn't be aware of?

still need an answer bro?

compiler dependent because compiler is allowed to ignore inline.

I like staring at well documented and formatted code

what is the most aesthetically pleasing programming lang?

retard

OCaml and C#

Only if your pajeets are using LINQ

Haskell and Scheme.

God I wish that were me

Attached: collarbones.jpg (1600x915, 155K)

lol no it doesnt

Why can't I do
void test(const char * const **argv) {}
int main(int argc, char **argv)
{
test(&argv);
}

Attached: 1564640828738.jpg (401x438, 28K)

if T** decayed to T const** then the following would be legal
int const x = 0;
int *p;
int const **pp = &p;
*pp = &x;
++*p;

How hard would it be to make a music player that competes with musicbee if i have no prior coding experience

cute programmer

Every language except Haskell:
bake_cake() and you get a tasty cake.
Haskell:
bakeCake, here is your cake recipe.

im going to fill this crab with my love juice

Unironically lisp

not an argument

The address of a pointer to a pointer isn't the same as the pointer itself.

#include

void dumb_user(char **argv)
{
printf("%s\n", argv[0]);
}

int main(int argc, char **argv)
{
dumb_user(argv);
return 0;
}

Haxe
haxe.org/manual/target-cpp-getting-started.html

Zig
ziglang.org/

Swift

Lisp is the most powerful programming language.

1. Faceshit PHPshit
2. Version 0.-5.0
3. Appleshit iLang

>Haxe
>Haxe is like magic. Developers can publish native apps and games to every major platform without hassle.
Sounds like shit.
>Zig
vaporware
>Swift
Appleshit

Scheme is prettier than Lisp because it doesn't have the clutter or defun/defvar/setq.

>define a list operation
>have a parameter that is just a list
>call it 'lst' because you're a filthy Lisp-1

You can use `list' as a parameter name if you want.

It's a bad idea to shadow global names IMO.
What's an example of a situation where list is the best name you can give a variable though?

>What's an example of a situation where list is the best name you can give a variable though?
I don't know if it's the best but sometimes it feels more idiomatic to just call a list a list, particularly if it's a small toy function you're writing.

Nah, I'm not a faggot. And! have a taste.

Discuss:
Since WG21 already changes the c++ language direction with every cppCon, it's time to completely deprecate char and std::wstring and favour
byte one_byte {127}
ascii_t ascii_sign {'u'}; //instead of char
utf8_t utf_sign {'ü'};
utf16_t utf_sign {'ü'}; // instead of char16_t
utf32_t utf_sign {'ü'}; // instead of char32_t

>_t
pls don't

Anyone here use OCaml? I'm going through the Real World OCaml book and in the new version the use a different standard library that they developed at their firm. The problem is, the library is horribly documented which and all the resources other than the book are assuming you're using the regular standard library so I'm stuck for like half an hour trying to figure out how to do something in this new library instead of learning. Honestly I'm considering just learning SML instead

#include

int main(void) {
int x = sizeof(char[printf("wow what a great language\n")]);
printf("%d\n", x);

return 0;
}

is there a way to have a program send mouse and keyboard inputs to an inactive window in kde plasma/kwin?
i want to be able to run my bot written in bash using xdotool (recently ported it to python with pyuserinput) in the background, sending it's inputs to the specific inactive window, and still have access to my mouse and keyboard and the ability to do other shit in other windows.

>Lisp is the most powerful programming language.
You can even build a text editor on it. Oh wait not really... Still, at least you can use character combinations that the ADL doesn't like.

Push comes to shove, you could pretend you wrote something in Lisp and it's actually a superior language, like Haxe-compiled Coffescript running an emscripten-compiled Java VM that inteprets Python-on-Rails to serve XSTL templates to render VBA macros.

Attached: civilized parentheses to enclose lispy kikes with.png (314x265, 43K)

what did you expect?

$ cc test.c; ./a.out
wow what a great language
26

What did C mean by this?

>not using the return value from printf to index your arrays
Scrub.

Attached: brian-kernighan.jpg (900x600, 71K)

That's a consequence of having VLAs in the language. It would be inconsistent if that didn't work.

Can you use F# instead? Basically the same language but with .net and Microsoft support

>You can even build a text editor on it. Oh wait not really...
wtf?
climacs, hemlock. I think lighttable is written in clojure but clojure is not real lisp.

VLAs were a mistake. Just use alloca.

Don't use windows so nope

F# is also available on Linux with .net core

So you could have a wrapper that translates your strings to N-length strings and switch on strings... hmmm..

there's a dev version of RWO that might be better, but even 1-2 years ago it was already bitrotten. I just followed along with the standard library and ignored the Core stuff. OCaml's own library documentation is fine: caml.inria.fr/pub/docs/manual-ocaml/stdlib.html

int main()
{
return (int)main;
}

Attached: 1565694528008.jpg (1005x794, 162K)

class Sepples {
~Sepples() {
delete this;
}
}

this

>this many errors
class Sepples {
public:
~Sepples() {
delete this;
}
};

int main () {
Sepples x;
}
a splendid segmentation fault.

int main()
{
return main();
}

What are the best programming books for beginners? I've done a little bit before, but it was a very long time ago and I don't remember much.
I remember K&R C being too confusing and not explaining anything very well, then I remember C: A Modern Approach being too bloated and over-explaining everything, and I remember dropping SICP when I heard that you need to know calculus.

Attached: 1522974493601.jpg (619x417, 52K)

start by not learnign C

int main(int c, char **v)
{
return puts(v[0]);
}

Attached: typical c programmer.jpg (1160x1160, 948K)

I don't think there is a best book but the official python tutorials are pretty clear and go step by step - docs.python.org/3/tutorial/

>You can even build a text editor on it. Oh wait not really...
where did this bait come from again?

it came from the website that was the sole reason that we have mass shooters. A stupid GUI text editor was requested and the only solution was some half-baked Racket.

New meme: chaining the return values of hundreds of programs together to print a string. It adheres to the unix philosophy because each program would print only 1 character

>better stay away from it because it attract lot of crazy hipsters, also uglier than sepples
If your best argument are "it's slightly uglier than C++" and "hipsters use it" then it seems pretty damn good

not surprising

what's the best way to index somewhat large amount of text data that are encrypted using nondeterministic encryption without giving too much insight? Is it even possible?

Attached: 5b3400058e8f2.jpg (657x387, 60K)

>Started first proper Dev job
>A month in
>Feels like I'm just looking at what other people do and copy/pasting it for my own shit
>Wouldn't feel like I'd know where to begin with building a new project or entire module
Is this normal for grads or am I just fucked? The entire codebase seems so complicated

Hey, anyone here can help me out?
I have been trying to build Slic3r software, but I keep getting this error, I even added ExtUtils::Typemaps::Basic to Build.PL.
It tells me that this module could not be found, even tho it is in the required folder.

Attached: Capture.png (1308x1006, 353K)

every industry project starts as an innocent idea and quickly grows into a monster

>it came from the website that was the sole reason that we have mass shooters
what, Altavista? Geocities?

Attached: 236104cdbff3806e31065d893745c448.jpg (480x468, 16K)

add it to your perl lib path or use a proper tool to download and install the library for you

>sees "also uglier than sepples"
>reads "slightly uglier than C++"
that 'slightly' must be the cry of your soul.
hipsters use everything, but not everything "attract lot of crazy hipsters".
Rust is hard to argue against because the real faults won't be seen until you're waist-deep in a Rust project.

that's exactly why rust will not be used

static typing is a meme

#include
#include
#include

int main(int argc, char** argv) {
int i = atoi(argv[1]);
printf("%d ", i);
char num[12];
sprintf(num, "%d", --i);
char call[80];
strcpy(call, argv[0]);
strcat(call, num);

return system(call);
}

Alright! Thanks, I finally built it! I was stuck on this since last night.

Attached: Capture.png (801x311, 66K)

>writing C
>invoking self
>not using fork/exec
>not using posix_spawn
>using /bin/sh
you belong with NodeJS.

not a problem

Is this irony?

Attached: 1245678551024.gif (400x400, 3K)

nah it's the bitter cry of a stinking savage whose twine-and-grass tools have been overtaken by metal tools.

>return syscall(rand());

Attached: 1566315229974.jpg (1280x720, 99K)

static typing is unproductive thinking about what type to use is too hard the language should decide what it wants to do instead of the programmer

just woke up

Attached: 1565928988792.jpg (209x250, 8K)

static typing only stifles creativity
on the contrary, dynamic typing allows maximum creativity, and the ability to quickly paint your ideas on the digital canvas
static type systems are the equivalent of handcuffs
why let a fallible human make a decision about the type of a program's object instead of the computer? why not give the computer the chance to decide?
stop treating computers like second class citizens. they deserve equality like anyone else

>thinking about what type to use is too hard
stinking savage confirmed.
:- type result
---> multiple(int)
; high
; low
; holy_fuck.
a function producing a 'result' value. What does that look like? You can see it right here. How many different kinds of results do I need to handle? Four -- you can see them, right there. What if I want to add a new result? In that case I edit the code above and then the compiler guides me to every piece of code that needs to be updated. The compiler is an eager assistant, not a bored inattentive loser that can't even tell me about blatant typos that will cause runtime crashes after deployment because the typo was in an infrequently-used control path.

Exercise: Write a C program that sends a kill signal to a random PID.

Attached: 1564682260712.jpg (600x600, 32K)

Why not?

#include
int main(int argc, char** argv) {
execv(argv[0], argv);
}

In the previous thread I posted this and an user suggested to use mov r/32, imm instead since its a 5 byte instruction instead of 10 bytes
after fixing the Linux syscalls to use syscall instead of int 80h I changed the immediate moves to a r/32 so I was expecting to see a ~40 byte smaller executable
but the executable is still the same size after striping it, 672 bytes. I opened it up in IDA and the instructions are encoded in 5 bytes as expected but Im not seeing the file size change.
What is doing on here?

as a reference these are the syscalls now, the sys_write in get_numbers was updated like the first sys_write as well.
mov eax, 1 ; sys_write
mov edi, 1 ; uint64 fd, 1 = STDOUT
mov rsi, prompt ; const char *buf, needs to be mov r/64 since its a pointer?
mov edx, promptLen ; size_t count
syscall


mov eax, 60 ; sys_exit
mov edi, 0 ; int error_code
syscall

>I was expecting to see a ~40 byte smaller executable
>but the executable is still the same size after striping it, 672 bytes. I opened it up in IDA and the instructions are encoded in 5 bytes as expected but Im not seeing the file size change.
Compare them side by side using hexdump -C, the instruction is probably padded with zeros or something.

Attached: 1566164236360.webm (638x720, 410K)

>linux shit
Just no.

why exactly can't you put endl after cin?

based static typers obeying the computer that's taking their jobs

I think you could save a bit of space by using RIP relative addressing to get the prompt pointer, apparently that takes less space than using a 64 bit immediate