/dpt/ - Daily Programming Thread

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

Attached: 1560968098107.png (1440x810, 1.65M)

Other urls found in this thread:

learn-c.org/en/Strings
dlang.org/phobos/std_functional.html#partial
developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays
mercury-in.space/crash.html
stackoverflow.com/questions/18281412/check-keypress-in-c-on-linux
twitter.com/NSFWRedditVideo

a lot

>this makes /dpt/ seethe

based snek

Attached: pyy.png (400x400, 114K)

anime is for faggots

faggot website

Attached: 1552410468458.jpg (680x1242, 108K)

Why haven't you joined the programming club, Jow Forums?

Attached: anon joins the programming club.jpg (1280x720, 372K)

sorry user,
I'm already a member of the amusement club

Attached: 1544233982161.png (1916x3886, 2.97M)

and that's a good thing!

you're right
so i fixed it
universe u

inductive l (a : Type u) : Type u
| nil {} : l
| cons (x : a) (xs : l) : l

def h {a : Type u} : Π {xs : l a}, (xs ≠ l.nil) a
| l.nil g := by contradiction
| (l.cons (x : a) (y : l a)) g := x

Snek master race.

Attached: BFC8F422-D62B-4F53-A9B6-F6646CA0E4E4.png (515x496, 88K)

>java top
>c# corporate
lol

What does bootstrapping a compiler really mean?

learn-c.org/en/Strings

is it just me or is this guide on strings fucked? the example question uses the same methods to initiate as well

Want take compiler for C
Want to write it in C
>There is no fucking C compiler yet
Write compiler in ASM
Compile C compiler
Rewrite C compiler in C
Compile C compiler with ASM compiler
>you now have a C compiler written in C

when you make a programming language, first you have to write the compiler or interpreter in another language. bootstrapping is when you then rewrite it in your new language, and hence have a compiler or interpreter for your language written in your language.

writing enough code so that your compiler supports all the language features it uses so that it can compile itself

pointlessly imprecise. The author probably understands more than he's showing, but he's not taking the care to be correct.

god tier: intel syntax
nigger tier: at&t syntax

Attached: gnm8.jpg (1280x720, 123K)

yeah, like the tutorials kinda assume you have some prior knowledge (which i do) but yeah its kinda confused me. i tried reading bjarnes book but it wasnt my jam

Ok. I'm writing a JVM language and my compiler is already in Java bytecode but I wrote it in Java rather than my language. Does that count as bootstrapping?

Attached: 1566413452824.jpg (576x551, 25K)

find a better guide, he's not using the correct terms to refer to things
char *str = "faggot";
is string literal and trying to modify it is undefined behavior, for example

Today, I'm going to make sure Anone finishes his JavaScript practices!

Attached: af02a9b86b45c0c6f5b6dce480c03f6c.jpg (1152x2048, 286K)

I don't know much about the ubuntu aptitude system; if my computer currently has cmake 3.10.2 installed, will it eventually upgrade to a newer version, or do I need to upgrade it myself?

yes

Indeed.

now write the same compiler in your own language and compile it using the compiler you already have. Then you bootstrapped it. Also checked.

no. write a new compiler using your language, and use the compiler you've just made now to compile it, then it's bootstrapped

Does currying in Haskell let me apply unlimited number of arguments on the function?

Attached: 1535660517558.gif (634x374, 420K)

Ok thanks, my language will compile to java bytecode anyway so the class files of the original compiler and the boot strapped compiler should be functionally the same.

the missing piece is compiling your compiler using that bytecode (which in your case should give the same bytecode as output, and is a good sanity check)

No. Currying just means that arguments are applied one at a time, i.e. every function takes exactly one argument and functions of multiple arguments are just functions that return functions until all arguments are given.

no, that's unrelated
you can use type classes for this by overloading the return type

>have function of N arguments
>currying lets you supply 0..N arguments
is 0..N an unlimited range, user? of course not.
you can't 'add' arguments to a function, but by wrapping a function in a lambda you can require an additional argument. so: lambda "lets you supply unlimited arguments", as many as you have lambdas.

That's mostly irrelevant. A C compiler and ASM compiler also both evaluate down to machine code, yet they're not the same

Ok great I'll do it

>Not Snek and C master race

>currying just means precisely what it means in Haskell
in Mercury there's none of this "functions only take one argument" nonsense, but you still get automatic currying as a language feature, just by supplying fewer arguments to an expression with a higher-order type. Any compiled language could have this. Probably D already has it.

Sorry, I was retarded, Java's compiler will probably optimize much better than yours, so the bytecode will certainly be different.
Still, it's a good thing to try.

what is the best tech to make me AI gf so i can have someone to talk to?

>Any compiled language could have this.
As long as it doesn't have variadics, I suppose.

>ASM god tier
You've never programmed in assembly. Assembly has no abstraction whatsoever. Assembly requires you to manually designate registers, which you cannot possibly do faster than a computer. You put that there to appear more intelligent and have failed miserably.

>JS, Java, Bash top tier
you're 15

What's with the Mercury shilling lately?

well variadics add ambiguity, but there's already ambiguity in Mercury since it has named-by-arity functions, so foo(A, B, C) and foo(A) can refer to completely different functions from the same module. In Mercury there's also ambiguity from importing modules into the same namespace: foo(A) could refer to one of three different foo/1 functions in three different modules.
so you could have variadics and implicit currying if you're willing to pay the cost Mercury already pays, which is that you occasionally have to add type annotations to resolve such things.
nah dlang only has explicit currying: dlang.org/phobos/std_functional.html#partial
(why'd they change the name to 'partial'? I also found an old tutorial where it's called curry. Partial suggests that you could supply other than only the leftmost argument to a function...)

Assembly's difficulty is what makes it fun.

Agreed, JS should be God Tier.

>talking about other languages is just normal stuff
>talking about Mercury is shilling
I like it. Surprisingly 1-2 other anons have mentioned it.
also I receive a stipend of $10k USD from the University of Melbourne for my online advocacy efforts. Please say something nice about the language so I can clip it and show them that I'm working hard.

I think it's just one very bored user. It's nice to see other languages being talked about though.

but I refuse

>bitwise shift is broken on unsigned int arrays in javascript

Attached: 1564728286721.jpg (1280x720, 62K)

JavaScript has no unsigned int you dingus

C is the only programming language you will ever need

other than Haskell

let x = new Uint32Array(length);

What are you talking about?

Attached: 1565041242999.jpg (560x600, 42K)

how would you make this typecheck? you'd need an infinitely long type signature, right?
Is it possible to define some kind of recursive type that does that?

>Uint32Array
Standard ML
First appeared 1983; 36 years ago

you misspelled C++

does C++ really count as a language you can learn and then only ever need?
you know that with every passing year your C++lastyear will become shameful and pathetic?

developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays

Do you believe it exists now?

Broken how?

bumping my question

>C freshman h4x0r larper tier
>ASM god tier
This is terrible bait

For an array x if x[0] contains the value 0x01 shifting right by 1 results in x[0] containing 0x04 instead of 0x02.

t. freshman h4x0r larper

Attached: 1553770883285.png (1330x1080, 821K)

*left obviously

professional software development workflow:
>boss shouting at your team
>pull some spaghetti code out of your butt
>it's half broken and has no docs or tests, but you will fix it in the next sprint, promise

that answer to that is that it depends
various groups have various standards
personally i like how llvm does it - mirroring the structure of the traditional folders include,lib,bin etc - none of that src nonsense

>instead of 0x02
that would be the result of a left shift, not a right shift.
I'm getting an 'unreliable narrator' vibe here.

What the FUCK do I need to do to get a simple kbhit() in C++ in Linux?

See

1. ncurses
2. termios and stdio
3. system("stty raw"); and stdio

People either love or hate Assembly only because it's hard and lacks abstraction. It's only for people who really enjoy putting their autism to the test.

You read other people's code, write your own code, and reflect on it. After doing this long enough, you'll understand the conventions of the programming language you're using, and know how to structure your own projects.
For most software, there's no "best way" but just a series of trade-offs. I'd recommend contributing to open source as a way to quickly improve and get feedback.

post the code

>Please say something nice about the language so I can clip it and show them that I'm working hard.

I've looked at Mr. Becket's tutorial some and I'm getting a feeling that it's a functional programming language but with some prologgy bits here and there. I don't hate it.

Larpers don't have the patience to learn ASM.

Attached: unknown.png (488x287, 10K)

sweet. one less fake clip.
mercury-in.space/crash.html introduces more of the language faster but the format might not be to your taste.

Attached: advocacyresult179.png (806x142, 30K)

Thanks.

>contributing to open source as a way to quickly improve and get feedback.
I've heard this meme numerous times, I don't even know how to start with this.

I admit, me and Prolog have had a tense relationship, but I'm willing to look at this. I've saved the page to check out later.

32 bit machines are simpler than many programming languages.

I'm using a (lazy) singleton.

When it is initialized, it gets information about the processor, the operating system and the environment, it stores everything as static variables and it has only static methods.
It's not possible to change the state of this singleton.
I never pass the singleton as an argument, for instance, if an object needs to know the number of cores in the cpu, I'll pass as an argument the return of the static method mySingleton::getNumCores(). This way, my code is not coupled and everything is easy to test.

So, is my singleton a good singleton?

hey GEE
If I just made a hello world or whatever in Java, in how many hours would I be able to run it on my (or a friend's) Android?

let x = new Uint8Array(1);
x[0] = 0x01;
x[0]

This shit? stackoverflow.com/questions/18281412/check-keypress-in-c-on-linux

I mean, it's pretty obvious when someone is larping, since there is no 'assembly': there is amd64, risc-v, arm, power, mips, obscure dsp architectures, etc. Some very different from others.
Just saying 'assembly' means nothing.

umirem

yeah the tcgetattr stuff looks good. depending on your application you can do that for every single getch(), rather than turning it on at program start and resetting the terminal at program exit.
seems like a waste of memory desu.

$ node test.js
2

I depends on what you mean by "larping." I took a class once where the class project was to write a game in an assembly language for a fake architecture that doesn't exist in the real world; so I would naturally tend to call it just "assembly" even though the architecture does have a name.

Attached: unknown.png (585x60, 3K)

btfo

your js engine is broken

Attached: Capture.jpg (233x82, 5K)

Doesn't seem to be a general bug then, my Firecucks install must be borked but I don't see how something so simple could be fucked up in their javascript engine. Thanks anons.

Attached: 1494853390612.png (2015x2204, 568K)

Why? I use Intel 64 and say Assembly all the time.

Nope, is from Firefox, nothing is broken there.

>couldn't afford college
>get an industrial mechanic job making 60k/yr
>fucking hate it so goddamn much, and can't advance any further in current position
>self taught HTML, CSS, JS, Node, React
>build portfolio
>apply for jobs like crazy
>nobody will even look at me without a degree

What do I have to do, bros?
Haven't I been punished enough?

Attached: 20190821_154353.jpg (1080x710, 214K)

Being readable, easy to test and to maintain is more important than memory in my project.

what makes you think it's the degree

>nobody will even look at me
correction: HR will not even look at you
you've got to get past HR somehow.

>nothing is broken there.
On the version you're using