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

КОМЕНТАРІ • 1 тис.

  • @richardfairthorne7021
    @richardfairthorne7021 Рік тому +1

    The original C was readable by an infant. I need an encyclopedia of the history of programming methodologies to understand his C++ refactor.

  • @feschber
    @feschber Рік тому +1

    You don't have to debug Haskell because either

  • @k98killer
    @k98killer  +415

    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.

  • @BenVisness

    7:47

  • @uzbekistanplaystaion4BIOScrek

    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.

  • @tokiomutex4148
    @tokiomutex4148 Рік тому +305

    It's amazing how C++ allows you to turn straightforward programs into something very close to APL programs.

  • @Euphorya
    @Euphorya Рік тому +599

    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.

  • @grim.reaper
    @grim.reaper Рік тому +305

    Prime: “c++ Longest way to say the shortest thing”

  • @blarghblargh
    @blarghblargh Рік тому +168

    "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.

  • @maninalift
    @maninalift Рік тому +106

    "iota avoids off by one errors.... Oh, by the way, don't forget to add one to top if you want an inclusive range"

  • @jon9103
    @jon9103  +25

    7:50

  • @willful759
    @willful759 Рік тому +42

    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

  • @Gabriel-wq4ln
    @Gabriel-wq4ln Рік тому +71

    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.

  • @heron619
    @heron619 Рік тому +41

    I just learned the term "React Andys" from chat and I'm gonna use it to harass Theo and his audience!

  • @aarorissanen930
    @aarorissanen930 Рік тому +12

    9:25

  • @brady1123
    @brady1123 Рік тому +58

    That C++ calculate function is an abomination.

  • @ionized8744
    @ionized8744 Рік тому +186

    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

  • @cas1652
    @cas1652 Рік тому +46

    Kotlin is also very nice:

  • @gogl0l386

    This has been an emotional roller coaster as a mathematician (so haskell feels the most natural for me).

  • @thomassynths
    @thomassynths Рік тому +127

    To make the Haskell code more explicit, here it is: