Prime Reacts: From C to C++ to Rust to Haskell
Вставка
- Опубліковано 19 лют 2023
- Watch the original: • From C ➡️ C++ ➡️ Rust
Amazing author: / @code_report
Recorded live on twitch, GET IN
/ theprimeagen
MY MAIN YT CHANNEL: Has well edited engineering videos
/ theprimeagen
Discord
/ discord
The original C was readable by an infant. I need an encyclopedia of the history of programming methodologies to understand his C++ refactor.
You don't have to debug Haskell because either
That c++ refactor was the most ridiculous and hilarious thing I've seen in a while. I burst into laughter at the exact same time Primagen did.
7:47
what i've learned: C is evergreen, can look really nice and is super readable, but will spontaneously transmute into a nuclear bomb if you look away for an instant. rust is the new kid on the block with fancy hair, but is still just C's cousin on mood stabilisers. haskell is an eldritch horror that will annihilate your mind but in return allows you to astrally project your code into a pocket dimension were it runs optimally. c++ is a hulking, grotesque abomination enslaved by sadists to run the entire world at our peril and would benefit from being taken round the back of the shed and shot squarely in the base of the skull.
It's amazing how C++ allows you to turn straightforward programs into something very close to APL programs.
Haskell does require you to pretty much throw away everything you know about imperative programming. It's a completely different paradigm, but once you do learn how it works the code here is very readable. I recommend learning a bit of Haskell just because it requires you to think so differently about solutions.
Prime: “c++ Longest way to say the shortest thing”
"readability is a function of experience" this is the truest thing I've heard this week. how have I been programming for 30+ years and never, ever heard any dev say this? I say it all the time, and everyone just smiles and nods when I do, and acts like I need to get back to my fucking nursing home.
"iota avoids off by one errors.... Oh, by the way, don't forget to add one to top if you want an inclusive range"
7:50
Expanding a bit on the haskell syntax, indeed haskell is a language that requires you to think very differently about programming, and as such, its syntax tends to look ugly, but once you start using it and understanding it, you can see that it is actually quite clean
I can't believe there was a clean C++ program with LITERALLY a "for" and an "if" and the dude turned it into a program with functions which you gotta search what the parameters mean, passed functions as arguments to the said functions, declared a namespace (which you also gotta see what exactly it is) and brought a lot of new syntax that only works on the last versions of C++. It also takes 10x more to understand the "upgraded" version.
I just learned the term "React Andys" from chat and I'm gonna use it to harass Theo and his audience!
9:25
That C++ calculate function is an abomination.
Considering how much you love rust I really suggest at least giving Haskell a chance. On it's own it's not the most useful language but it is really elegant and fun when written properly. And for some use cases, such as compilers, it is crazy good
Kotlin is also very nice:
This has been an emotional roller coaster as a mathematician (so haskell feels the most natural for me).
To make the Haskell code more explicit, here it is: