/dpt/ - Daily Programming Thread

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

Attached: 1541483607240.jpg (1000x1100, 114K)

Other urls found in this thread:

youtube.com/watch?v=C_BI3jsbzBU
pastebin.com/upiXexML
en.wikipedia.org/wiki/Dunning-Kruger_effect
en.wikipedia.org/wiki/Inferiority_complex
myredditvideos.com/
twitter.com/NSFWRedditGif

I love you anons

Attached: 1453577364718.jpg (1920x3272, 2.01M)

Thinking of devoting myself to my autism and writing a toy language from scratch. What books, guides, etc should i use and where should i go for advice/opinions?

Ah, you're here to write JavaScript with me?

Attached: cc118d4340dd8f518505348b637786b6.jpg (1000x1500, 116K)

Unfortunately I actually have been writing a little bit of Javascript.

Attached: 1554603072187.png (880x534, 17K)

Working on porting the GNU toolchain to my operating system. As of today I can finally build and run C++ GUI programs.
Performance is pretty shit, I have a lot of things to profile and fix. Need various caching layers, etc. But it works!
I'm getting closer and closer to self-hosting. :)
Demo: youtube.com/watch?v=C_BI3jsbzBU

Attached: Screenshot at 2019-04-28 02-24-02.png (1026x801, 608K)

cute doll!

import random as rand

def main():
lotNums = list(range(7))

for index in lotNums:
lotNums[index] = rand.randint(1, 9)

print("Your lottery numbers are: ", lotNums, sep = '')

main()

import random as rand

def main():
lotNums = [0] * 7

for index in range(len(lotNums)):
lotNums[index] = rand.randint(1, 9)

print("Your lottery numbers are: ", lotNums, sep = '')

main()

import random as rand

def main():
lotNums = [0] * 7
count = 0

while count < 7:
lotNums[count] = rand.randint(1, 9)
count += 1

print("Your lottery numbers are: ", lotNums, sep = '')

main()

which one is less niggerly

>python
neither

>neither
This is syntactically incorrect. Neither is a statement defined upon a pair of mutually exclusive options which returns Neither of them. The word you were looking for was None.

Attached: DE9A6127-AC6C-41CB-82CD-68E6898C2BB8.png (672x656, 383K)

Thinking of devoting myself to my autism and writing a toy language from scratch. What books, guides, etc should i use and where should i go for advice/opinions that is probably not here?

Attached: ..jpg (480x360, 25K)

good compiler

>This is syntactically incorrect
Wrong. it conforms perfectly fine to English grammar.
The problem is that it's semantically incorrect.

Please stop doing this.

Please keep doing this.

Please.

󠘁

󠘁

data Neither a b

What is the modern way of programming in Java? I don't want to have an interface for every class.

Programming in C#

Grow the fuck up, throw it in the garbage, and use a real language.

I work for a big bloated corporation and I have to use Java.

God help you

Get a real job.

What's the best possible desk + monitor + keyboard/mouse setup money can buy for working productively at a real 8 hour per day technical job?

Attached: img_20180413_1001501.jpg (1273x768, 138K)

You should use your autism to do something more useful, like give us a systems language more usable than C++ that doesn't take an hour to compile.

By programming in Kotlin, Clojure, literally anything other than base Java.
Hell you should seriously consider C# now that it's crossplatform and the tools are free.

Why would anyone want to do that? Regardless of Jow Forums's autism, C and C++ are very desirable and often-used languages in many professional environments

What type of language are you thinking? I hope it's not yet another imperative piece of hot garbage.

It depends on the job and your personal workflow. I automate shit in VBA for my low level reporting job and usually have multiple spreadsheets open and our CRM if I need to look into something. 2 monitors + occasional laptop screen is fine. If my load is heavy I have email or chat open on the laptop and whatever I'm working on up on the monitors.

But user, C++ is the objectively best language.

Attached: DragonBook.jpg (386x499, 45K)

this even barely relates to the question

Fuck off

Working on my suicide note in LaTeX.
I was unsure if I was going to go through it before, but after deciding on and using LaTeX I no longer have any second thoughts

what is imperative?
I'm thinking something that feels nice to write in, like:
let f(x) := x^3 + x^2 + x;
Its a toylang because i haven't really thought of any practical uses or purposes. Just something with nice syntax, types, functions, etc that doesn't do:
This: System.out.println(x.toString());
This: ($s1 -gt $s2) { $c = "Shrank", $v1 = $s1, $v2 = $s2 }
or
This: std::vector list
Something that combines the nice bits of different modern languages from a functional paradigm, that tries to avoid the ugly stuff.

Who cares about suicide notes.
The correct way to off yourself is to leave your computer unlocked and your porn stash open with full size thumbnails.

which edition?

Seems like a cruel thing to subject someone to my porn stash.
I'd rather they just find my dead body

Just use org-mode and export to LaTeX. Why work harder than necessary in your final moments?

better idea: print your porn stash, shove it up your ass, then jerk it and when you cum as a naked form on your bed shoot yourself in the head.

First edition uses pseudo code and C, the second uses Java. Either one is probably fine to start with, I've heard that some of the examples in the second aren't as clear, but it includes additional topics.

is right, you should at least masturbate one last time before you kill yourself.

C++ is objectively the most harmful language. An operating system written in it is extremely harmful.
>C and C++ are very desirable and often-used languages in many professional environments
I didn't say anything about C. Professional environments also use windows, java,xml and other harmful garbage. C++ is part of the reason why the stuff they put out sucks so much.

>Harmful
>>>/cat-v/

I need to make a conditional statement that scans a string for an answer. I don't know how to state the If. When I run, doesn't matter the answer, the program never switches to Else.

#include

int main (void){

char r; //register test
float troco; //change
float pagamento; //payment
float item = 1;
float total = 0;

printf ("CAIXA REGISTRADORA\n"); //cash register
printf ("------------------\n");
printf ("Informe os valores dos itens.\n"); //inform the prices of the itens
printf ("Entre com 0 para finalizar.\n"); // enter 0 to finish listing itens

while (item != 0) scanf ("%f", &item), total += item;

printf ("O cliente e cadastrado? s/n "); //are the costumer registered? y/n
scanf ("%s", &r); //y

if (r = "s"){ //if y
total *= 0.9;
printf ("O cliente tem direito a dez porcento de desconto!\n"); //costumer have 10% off of bill
printf ("O total das compras e R$%.2f.\n", total); //new bill with discount
printf ("Informe o valor do pagamento. "); //inform the payment
scanf ("%f", &pagamento);
troco = pagamento - total; //change = payment - total
printf ("O troco é R$%.2f.", troco);
}
else{ //same thing but no discount
printf ("O total das compras e R$%.2f.\n", total);
printf ("Informe o valor do pagamento. ");
scanf ("%f", &pagamento);
troco = pagamento - total;
printf ("O troco é R$%.2f.", troco);
}
return 0;
}


Regardless of what is scanned for r, costumer always get a discount! Is he a kike?!
Please, help.

Yeah if I'm ending it, I might as well try shoving stuff up my ass
Try that prostate orgasm thing.

Because I deserve to suffer.
If wanted to make it easy for me, I wouldn't be using LaTeX.

Why do we still allow monkey languages like this to exist in 2019?

See this is why it was a mistake to make "=" assignment. People make this fucking mistake over and over and never notice it.
If you ever make a language, make := assignment and save everyone the hassle.

Attached: ll.jpg (2048x1129, 399K)

>I'm thinking something that feels nice to write in, like:
This type of simple language with functions, conditionals, variables, etc. is covered in a lot of tutorials, just depends on what language you want to implement it in or what languages you are comfortable with reading. Looking into an "LLVM Kaleidoscope" tutorial for your language of choice is always a good idea for learning how to compile a simple imperative language to LLVM, they exist for quite a bit of languages as far as I know. Also learn Lisp just to be able to understand code for the massive amounts of toy interpreters other people have written for it in different languages, you can easily look them up on google. If you're comfortable with basic Haskell, check out "Write you a Haskell" and "Write yourself a Scheme."

Based
Pascal was robbed

>People make this fucking mistake over and over and never notice it.
I've never seen people make this mistake.
I've seen retards make that mistake though. But good thing retards don't matter.

There is nothing hard about LaTeX though. It's just too much rote for something as simple as a suicide note.

Compilers warn for questionable uses of =, making it a non-issue, but people need to be using -Wall to get that.
Beginners need to be told to use that flag ALL of the time, because it eliminates such a huge class of common errors.
>:=
That looks like a penis, so the SJWs aren't going to like that. Why do you think Rust still uses = for assignment?

Because rust is a piece of shit more concerned with solving non-problems than helping people write good software

Don't be such a drama queen. Go start working out, talking to girls, learn more about programming and other things your interested in.
pretty sure it should be r = scanf("%s"); and the if should be if(r=="s")

>troco
>pagamento
I don't help subhumans.

but == gives me the same error, but now there's no discount for y or n

Subhuman is too generous.
They're monkeys.

Even when replaced with ==, that's still wrong.
== on strings is just going to be comparing pointers, which certainly always going to be wrong.
strcmp() is the function (found in ) for comparing strings, or in this case, you may just compare the single character.
if (strcmp(r, "s") == 0) {
if (r[0] == 's') {

"s" is a string, 's' is a character
when you evaluate a string, you get the address to the first character in the string.
when you evaluate a character, you get a byte.

Show us your operating system then

:= takes more effort than = for assignment.

why would i compile to LLVM though?

I'm not interested in spending huge amounts of time making something that will never be nearly as useful as currently available options.

this worked if (strcmp(r, "s") == 0) {


but the second alternative did not. this is how it goes with the first option:
#include

int main (void){

char r[1];
float troco;
float pagamento;
float item = 1;
float total = 0;

printf ("CAIXA REGISTRADORA\n");
printf ("------------------\n");
printf ("Informe os valores dos itens.\n");
printf ("Entre com 0 para finalizar.\n");

while (item != 0) scanf ("%f", &item), total += item;

printf ("O cliente e cadastrado? s/n ");
scanf ("%s", &r);

if (r == 's'){
total *= 0.9;
printf ("O cliente tem direito a dez porcento de desconto!\n");
printf ("O total das compras e R$%.2f.\n", total);
printf ("Informe o valor do pagamento. ");
scanf ("%f", &pagamento);
troco = pagamento - total;
printf ("O troco é R$%.2f.", troco);
}
else{
printf ("O total das compras e R$%.2f.\n", total);
printf ("Informe o valor do pagamento. ");
scanf ("%f", &pagamento);
troco = pagamento - total;
printf ("O troco é R$%.2f.", troco);
}
return 0;
}

It would be easier for me if this one worked but it's ok. I'm half way through the pascal-to-C exercises.

SAD!

Attached: xhkzt5e8w9a21.jpg (500x353, 32K)

at least you’re self aware enough to realize you could never make anything good

>char r[1];
>scanf ("%s", &r);
You're almost certainly running into a buffer overflow here, since you literally only have space for the null terminator and scanf's %s is inherently dangerous.

The bare minimum change for that to work properly is
char r[2]; // 1 character + null terminator
...
scanf("%1s", r); // Maximum 1 character string + null terminator

I mean idk what you mean by technical and I'm not gonna go look at prices for you. If you're looking for functionality it mostly depends on what you do and how you do it

>String, &String, &str
RUST GOOD

Attached: wojakmonkey.jpg (638x558, 64K)

Nice selfie.

you dumb fucking bean
> char r[1]
fucking why
> troco, pagaento
nigger
> integer item is a float
> integer total is a float
double nigger
> one line while
fuck you

explain what you're trying to do you dumb dumb

>why would you want to be able to add two strings together

Attached: brainlet.png (621x702, 56K)

Adding strings is honestly pretty pointless.
I'd rather concatenate them.

>Adding strings
I don't even want to defend Rust, but are you fucking retarded?
>Wojack
Why did I even ask?

Same but I have to use Object Pascal. Please kill me.

>you dumb fucking bean
I'm brazilian
>fucking why
I'm learning. That's what I was told to do here.
>nigger
portuguese is a beautiful language
>> integer item is a float
>> integer total is a float
>double nigger
item is not could not be an int. prices are like 4.99 or 7.49
>> one line while
>fuck you
no, fuck you

>explain what you're trying to do you dumb dumb
no, read the thread

I'll try it. I'm practicing French right now. I also need to eat. I've been exercising code for 10+ hours.

Attached: 5bc67339dd677.jpg (1242x1066, 187K)

>Comparing strings
>Not using hash to convert each string in your code into integers and those values instead
Its like you guys aren't even trying
C'MON! Don't you wanna LEAVE CODEMONKEYS BEHIND?

Attached: 1523590012849.png (292x292, 86K)

literally not even correct

>char[1]
Found my new favorite way to bait Jow Forums

Oh yeah?
Prove it Pajeet

Attached: SUCC.jpg (500x600, 51K)

System.out.println("0-42L".equals("0-43-")); // false
System.out.println("0-42L".hashCode() == "0-43-".hashCode()); // true

>implying I know how to write a hash function

Just sum the characters up and compare them

That way it would correctly account for typos, e.g: comparing tomato to tomaot would yield true

>Just sum the characters up and compare them
That is a form of hash, although a very poor one.

>tfw if(a=b) compiles just fine and in 10% of time the it works just like the comparison

>Using someone else's trash hash function instead of your own
YOU FOOL

Then read up, boy

Attached: Rich.jpg (1200x675, 77K)

hello dunning-kruger

Rate my integer hashing function:
int hash_int(int n)
{
return n;
}

>Brainlet thinks I'm the one that came up with this technique
GOOD FUCKING MORNING CODE MONKEY

it's valid

>officially a contributor to two somewhat well-known open source projects
I'm doing it, Jow Forums

first one desu

this is what an error for an English compiler would look like

>advice
dragon book
>opinions
hacker news

Attached: 1416671571121.png (1002x798, 156K)

Anons, does Red Hat certification branch into anything higher or is it essentially the final segment of its specialization branch?

Hi guys, newbie here. So I am following the LazyFoo SDL tutorial, and I am at part 3, "event driven programming". So far so good, but for some reason, the program doesn't close when I press X.. So I was wondering if you guys could give me a hand here. I am using C, on debian, if that helps.

pastebin.com/upiXexML

you gotta be kidding me. this is so much easier to do in Pascal. at least I was able to finish it using this library but all the probable simple ways did not work.
And this niggas jesus christ.
I literally started studying C yesterday so please go measure your e-penises in another thread.

Attached: 856.jpg (500x281, 45K)

en.wikipedia.org/wiki/Dunning-Kruger_effect

>>officially a contributor to two somewhat well-known open source projects
>I'm doing it, Jow Forums
Nice. What were they, if you don't mind answering?
I've done a bunch of shit towards wlroots, but there is always this one fag that seems to complain when I bring it up here.

>please go measure your e-penises in another thread
This is literally the thread for that purpose.

en.wikipedia.org/wiki/Inferiority_complex
Just cause you don't understand something, does not mean the other person has Dunning-Kruger

Guess I'll move to dumb questions.

Attached: mqdefault.jpg (320x180, 7K)