C Is Not A Language Anymore

Поділитися
Вставка
  • Опубліковано 15 вер 2024
  • Recorded live on twitch, GET IN
    Article
    faultlore.com/...
    By: Aria Beingessner | / gankra_
    My Stream
    / theprimeagen
    Best Way To Support Me
    Become a backend engineer. Its my favorite site
    boot.dev/?prom...
    This is also the best way to support me is to support yourself becoming a better backend engineer.
    MY MAIN YT CHANNEL: Has well edited engineering videos
    / theprimeagen
    Discord
    / discord
    Have something for me to read or react to?: / theprimeagenreact
    Kinesis Advantage 360: bit.ly/Prime-K...
    Hey I am sponsored by Turso, an edge database. I think they are pretty neet. Give them a try for free and if you want you can get a decent amount off (the free tier is the best (better than planetscale or any other))
    turso.tech/dee...

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

  • @DeusEx3
    @DeusEx3 4 місяці тому +1840

    Alternative title: dyslexic man quits job to read articles full-time

    • @usmanmehmood55
      @usmanmehmood55 4 місяці тому

      We all have "dyslexic man that quit his job to read articles to us while we drive to work"-itis

    • @usmanmehmood55
      @usmanmehmood55 4 місяці тому +90

      Either that or ligma.

    • @DeusEx3
      @DeusEx3 4 місяці тому +26

      @@usmanmehmood55 what's ligma?

    • @usmanmehmood55
      @usmanmehmood55 4 місяці тому +170

      ​@@DeusEx3ligmaclang

    • @pixelcatcher123
      @pixelcatcher123 4 місяці тому

      ligma nutz

  • @ovalteen4404
    @ovalteen4404 4 місяці тому +439

    Back when humor wasn't banned from compilers, I had heard of the "long long" and decided to see what it thought of a long long long. The error message was "long long long is too long."

    • @skhotzim_bacon
      @skhotzim_bacon 4 місяці тому +67

      Such a shame. We need to bring back humor and easter eggs

    • @Sven-W
      @Sven-W 4 місяці тому +63

      And long long is two long :^)

    • @skhotzim_bacon
      @skhotzim_bacon 4 місяці тому +38

      @@Sven-W Long long long long would be two too long :^)

    • @BruceHoult
      @BruceHoult 4 місяці тому +3

      That one is, sadly, not from MPW C.

    • @SpocksBro
      @SpocksBro 3 місяці тому

      C love you long^2 time max

  • @Redyf
    @Redyf 4 місяці тому +938

    C isn't a programming language... It's a lifestyle

    • @amj864
      @amj864 4 місяці тому +78

      yes, skill issues in C lead to programming in rust.

    • @VivekYadav-ds8oz
      @VivekYadav-ds8oz 4 місяці тому +43

      C is a mindset. C is a grindset.

    • @Seven-ez5ux
      @Seven-ez5ux 4 місяці тому +3

      - said no one, ever

    • @ScottLovenberg
      @ScottLovenberg 4 місяці тому +8

      Rawdogging bits 4 lyfe, Bois!

    • @rationalagent6927
      @rationalagent6927 4 місяці тому +2

      Like putting a label on a lifestyle. So they can water it down

  • @OCTAGRAM
    @OCTAGRAM 4 місяці тому +191

    18:51 C++ increments the value of C, but yields the old value

    • @profilore
      @profilore 4 місяці тому +12

      Why do i love this comment, i must have clang for brains

    • @____uncompetative
      @____uncompetative 4 місяці тому +14

      Bjarne Stroustrup should have called it C-- as it yields C and then by the subsequent sequence point every new feature makes it worse.

    • @steffenbendel6031
      @steffenbendel6031 2 місяці тому

      And the funny thing, it increments after the ; for elemental types, but for classes it does it immediately. (OK, C has no classes, and C is not a subset of C++)

    • @Apuryo
      @Apuryo 2 місяці тому

      @@____uncompetativec-- is another language too 😅 it is how haskell gets compiled

    • @headlibrarian1996
      @headlibrarian1996 Місяць тому

      @@steffenbendel6031 C is mostly a subset of C++, with some silly divergence making C less ergonomic because the standards body didn’t want mangled symbols. There’s also a few “hidden” differences that may on occasion bite you: for example, character constants are still type int in C, but are rather sensibly type char in C++. Plus even if you never touch classes templates & variadics, type introspection, and proper function overloading push C++ over the top for me.

  • @ragectl
    @ragectl 4 місяці тому +125

    Two programming languages kissing each other and realising they are both C is like having two blind folded cousins in a kissing booth.

  • @utubekade
    @utubekade 4 місяці тому +217

    "Sometimes, I don't think I realize, just how much of shoulders we stand on"... So true.

    • @Asto508
      @Asto508 4 місяці тому

      Ugly malformed shoulders

    • @macchiato_1881
      @macchiato_1881 3 місяці тому +7

      Probably at least an intmax_t amount of shoulders.

    • @theseangle
      @theseangle Місяць тому

      ​@@macchiato_1881 undefined amount of shoulders

  • @travis8106
    @travis8106 4 місяці тому +74

    I have to say as a newbie that learning C has made me understand a lot of fundamentals better. In other languages it felt like the added abstraction didn't really allow me to see the inner workings as clearly.

    • @eightsprites
      @eightsprites 4 місяці тому +15

      Not only as a newbie.. It gives you so much understanding of how computers work its silly.

    • @JerehmiaBoaz
      @JerehmiaBoaz 4 місяці тому +3

      Yeah, it makes you wonder why the geniuses who knew the hardware intimately by writing assembly all day were desperate for high-level languages with lots of high-order abstractions, doesn't it?

    • @jnharton
      @jnharton 4 місяці тому +9

      @@JerehmiaBoaz They probably weren't actually desperate for "high-level languages with lots of high-order abstractions".
      It's more likely that someone else wanted them, so they begrudgingly created them.

    • @AntsanParcher
      @AntsanParcher 3 місяці тому +5

      That's a trap. C is very far from the metal in very important respects and if you think that it works like the hardware below it does, you're in for some really nasty surprises. You expect an integer overflow to result in a wraparound? That's not in the spec, and a lot of compiler optimizations will actually show you that C does not work like the underlying hardware there.
      If you wanna know how hardware works, ~~learn~~ write a Forth.

    • @cozyfalcon
      @cozyfalcon 22 дні тому +5

      I'm an old fart, and trust me... don't fall into the immature type of zealotry you get with stuff like this article. The fact is, C is the reason we have lot of the tech we have today - period. You could argue its time has passed and things evolve (as they should) but hating on something that served us is no better than hating old buildings that don't meet modern standards. It's a great language that's just dated. Should we move on? Yes. Does it help to learn it? Yes, for educational purposes. Should you learn something else too? Yes. Don't listen to the zealots. They're going nowhere in life and will only have their rants online where nobody successful cares.

  • @tinrab
    @tinrab 4 місяці тому +286

    "Hey, why doesn't Rust have a stable ABI?" Oh, hold my beer...

    • @nordgaren2358
      @nordgaren2358 4 місяці тому +9

      This has been coming up a lot recently. :(

    • @zaper2904
      @zaper2904 4 місяці тому

      ​​@@nordgaren2358Wow it's almost like systems programmers have been telling rustaceans for years that they need to have a stable ABI ...

    • @platin2148
      @platin2148 4 місяці тому +3

      Because it has only one implementation and that one is not good. And as it has only one it can destroy abi easily.

    • @nordgaren2358
      @nordgaren2358 4 місяці тому +8

      @@platin2148 Rust doesn't have an ABI.

    • @kippers12isOG
      @kippers12isOG 4 місяці тому +17

      Every binary you can interface with has an ABI. I think you mean that it doesn't have a defined or stable ABI

  • @zaper2904
    @zaper2904 4 місяці тому +448

    Congratulations you discovered why C can run on literally anything with some sort of processing unit and memory (it's because the entire standard is up to the hardware's implementation).

    • @Waine2000
      @Waine2000 4 місяці тому +72

      So true, this is the reason for so much different ISAs and even different architectures, such as GPUs ou DSPs, using C language most of the time. They can use C programming model and adapat it to the ISA/model specifics.

    • @vonnikon
      @vonnikon 4 місяці тому +77

      Good luck running all those modern languages on a DSP with 40bit integer and 16bit char.
      C can handle it beautifully.
      It is not C which has a problem. The problem is the false hardware assumptions in the other languages.

    • @gagagero
      @gagagero 4 місяці тому +44

      ​@@vonnikonThe problem is that the author fundamentally doesn't understand ABIs.

    • @WHYUNODYLAN
      @WHYUNODYLAN 4 місяці тому +36

      NO! This is a complete misunderstanding. It takes an immense amount of backend compiler work to support even a single target, and this isn't made easier by C's type system since the stdint types still have to be supported. The ideal, rewrite history scenario is 1) C's types always functioned like stdint types and 2) compiler authors didn't name targets the same thing if they had different ABIs.

    • @zaper2904
      @zaper2904 4 місяці тому +24

      @@WHYUNODYLAN It's not easier *today* when all architectures work in a broadly similar way there is a reason the original type sizes in C were implementation defined and that's because you could have an old supercomputer from the 70s that only worked with 24 bit words as its smallest addressable memory unit and you needed to support that.

  • @bofh139
    @bofh139 4 місяці тому +285

    To C, or not to C.

    • @blobglo
      @blobglo 4 місяці тому +20

      we should C# 😔

    • @juanmacias5922
      @juanmacias5922 4 місяці тому +19

      @@blobglo I just barfed in my mouth, a bit.

    • @Jetsetbob3
      @Jetsetbob3 4 місяці тому +16

      "C? Why not A?" Asian dad.

    • @thingsiplay
      @thingsiplay 4 місяці тому +8

      I C what you did there.

    • @gcxs
      @gcxs 4 місяці тому +9

      to C is to believe

  • @epolpier
    @epolpier 4 місяці тому +133

    "Nothing better than C" - Linus Torvalds

    • @thingsiplay
      @thingsiplay 4 місяці тому +16

      This quote and how he is saying it, always pops up in my head. But I think the quote is taken out of context and Linus actually means: "Nothing better than C for Linux Kernel."

    • @soulextracter
      @soulextracter 4 місяці тому +5

      @@thingsiplay That is because 90% of people who are quoting it are getting the quote from the same video that's been recommended to everyone and their grandma at this point. I don't even think most people actually watch the video. They just see the title and it sticks.

    • @rusi6219
      @rusi6219 4 місяці тому +3

      @@soulextracter it's so annoying along with that atrocious quote by Stroustrup about people complaining about languages (I'm team C)

    • @poggarzz
      @poggarzz 4 місяці тому

      @@rusi6219 whats the quote?

    • @rusi6219
      @rusi6219 4 місяці тому +2

      @@poggarzz something about languages that aren't complained about aren't in use

  • @MarekKnapek
    @MarekKnapek 4 місяці тому +114

    What is long? It holds at least 32bits worth of data, says the C standard. It holds exactly 32bits of data, says Windows. It holds exactly a pointer, says Linux.

    • @plaintext7288
      @plaintext7288 4 місяці тому +5

      What if I'm compiling for some tiny 8/16 bit cpu running Linux?

    • @amor76
      @amor76 4 місяці тому +17

      ​@plaintext7288 you use a uint8_t and uint16_t

    • @MarekKnapek
      @MarekKnapek 4 місяці тому +14

      @@plaintext7288 Linux doesn't support 16bit computers.

    • @chikinrasshu
      @chikinrasshu 4 місяці тому

      @@plaintext7288 you can still emulate larger types. (that's how we used 128bit types before)

    • @turun_ambartanen
      @turun_ambartanen 4 місяці тому +12

      @@plaintext7288 long is at least 32 bits. Your compiler may throw an error or insert code to do the math for a 32bit number with a 8/16 bit cpu. This will be horribly inefficient, but it will work.

  • @isaacyonemoto
    @isaacyonemoto 4 місяці тому +123

    > You can't parse a c header
    Zig: skill issue

    • @scottfranco1962
      @scottfranco1962 4 місяці тому +11

      I build I c header parser a long time ago. The first try was just to recognize keywords and attempt a translation, much like a macro processor. I klash-trashed around with it for some time, and the program got quite large. Finally I decided that it wouldn't work in terms of handing all case, so I realized that the program needed to be the top half of a C compiler with the bottom (actual code generation) chopped off. I rewrote the program as a scanner/preprocessor followed by a syntax follower. That worked much better.

    • @mgord9518
      @mgord9518 4 місяці тому +18

      Zig does a lot of things that might as well be magic
      Macros? Nah, just use the Zig but tell it to do it at compile time
      Cross compiling? Yes and fuck it, use Zig as a C or C++ cross-compilation toolchain too
      Build system? Just use Zig for that too, and use it to build anything, including things that aren't even written in Zig
      Binary size? Smaller than C in most cases
      Absolute madness.

    • @ovalteen4404
      @ovalteen4404 4 місяці тому +6

      So... the author is crying because it takes more than a couple of lines of code to do that? The typical solution is... a library. Maybe something like llvm.... If you're doing compilery stuff, why complain that you might need to employ a complier library?

    • @ITR
      @ITR 4 місяці тому +15

      @@ovalteen4404 Because the purpose *isn't* to compile c++. The purpose is to communicate with an ABI.

    • @ovalteen4404
      @ovalteen4404 4 місяці тому

      @@ITR But as should have been made painfully clear in this article, communicating with an ABI is NOT a simple thing. You NEED a compiler library to do something like that. And further, the point is that this would be true even if C were NOT the 'de facto' ABI for the system. And libraries like LLVM can do that. You could use it to snarf up a C++ header and then emit code in your own stuff where needed to interact with the interface in that header.

  • @mattias3668
    @mattias3668 4 місяці тому +31

    size_t: unsigned integer type than can address any offset within any memory section.
    ssize_t signed integer that covers at least [−1, ½(SIZE_MAX−1)] (NB!, the only negative value that is guaranteed to supported is −1)
    rsize_t: intersection of size_t and ssize_t.
    intptr_t: signed integer type that express any memory address and uses two's complement.
    uintptr_t: unsigned version of intptr_t.
    ptrdiff_t: this one is a real mess.

    • @dixaba
      @dixaba 4 місяці тому +1

      Wait, intptr_t is actually defined as using two's complement? While regular numbers are like "Ehh, we don't know what we want and what we are, we just exist"?

    • @irnehhenri
      @irnehhenri 4 місяці тому +4

      ​@@dixaba C23 finally requires two's complement representation for all signed integers, idk about intptr_t in the old standards tho

    • @kodirovsshik
      @kodirovsshik 2 місяці тому +1

      ptrdiff_t is just whatever is most relevant for storing the pointer subtraction result, and is always a signed type.
      (Come to think of it, it is actually a stupid idea to have it be signed, because if it is of the size of a pointer (which makes sense and is how it usually is) but signed, it can only handle differences whose absolute value is not more than half the memory size, and everything beyond that is either overflow or underflow which is UB for signed types. It would make much more sense to have it be unsigned so that wraparound on it is well defined and it produces the right result but without worrying for signed integer overflow/underflow)

  • @jalvo2004
    @jalvo2004 4 місяці тому +38

    I worked on a commercial product, started in 1980s. The first public version was on the IBM AS/400 [now I5 series] and it used 128 bit addresses. The pain making it work was severe. Later on it was published for s390, Linux,Unix,Windows... both 32 and 64 bit... and that was relatively easy. The hard work had all been done.

  • @rrraewr
    @rrraewr 4 місяці тому +367

    Yah, C is the supreme authority from which all other languages, tools, apps are derived.

    • @juanmacias5922
      @juanmacias5922 4 місяці тому +13

      Mother ship.

    • @Leonhart_93
      @Leonhart_93 4 місяці тому +61

      The thing that I don't get is the obsession of making a new language for every single niche task these days. It's a lot like the web dev, "how to lose focus on mastering a single thing".
      Ideally I want to go back to a standard few powerful languages and just use a well defined lib for a certain task.

    • @thingsiplay
      @thingsiplay 4 місяці тому +3

      C was great in the past.

    • @notuxnobux
      @notuxnobux 4 місяці тому +20

      If you create a core library that you want others to use to create programs with and if for example it's a library implementing a new protocol or part of it then it should be written in C. If it isn't then I assume the library isn't a serious project. Core libraries need to be fast, use small amount of memory, not crash on a failure (looking at you rust, with panic on memory allocation failure), be able to use on any system and platform and from any programming language.

    • @CyberDork34
      @CyberDork34 4 місяці тому +15

      LLVM is part of it. You don't actually have to make a full compiler anymore. You can make a language parser for any syntax, plug the result into an LLVM backend, and claim your new language has "comparable performance to C".

  • @joshuaclayton6940
    @joshuaclayton6940 4 місяці тому +149

    Sadness. Don't blame C for only solving 90% of "computers are not all the same" problems. It was never a problem with C. Heck, as a C programmer, I also hate dealing with linkers, calling conventions, and ABI's. Its the ugly underbelly of software engineering. The alternative is we hard-code binary interfaces for every piece of hardware we might expect to interface with. Its the very reason libraries, drivers, and operating systems exist.

    • @cat-.-
      @cat-.- 4 місяці тому +12

      im sure gcc, clang hardcode it already, and by the look of this article so does every other language. (Either that, or they use C). So its just hard code all the way down

    • @VFPn96kQT
      @VFPn96kQT 4 місяці тому +2

      You can use FIDL to describe ABI and allow automatic tools to generate required bindings. That's what Fuchsia uses.

    • @edwardcullen1739
      @edwardcullen1739 4 місяці тому +13

      Agreed.
      The author doesn't really understand the distinction between the System Call Interface and the C wrapper library that most people interact with.
      He does not understand that all C implementations are exactly that and they have freedom to do their own thing.
      This is not a failure of C or even other languages, it is the nature of the beast and he is simply unaware that people "don't bother" writing their own SysCall wrappers - they just reuse glibc or whatever.
      The Linux System Call Interface is fixed and Linus does a LOT to ensure it never breaks (the rants he has about this 😅...)
      There is nothing to stop Rust from implementing a SysCall wrapper library that bypasses glibc. They just haven't done the work.

    • @gnuemacscoin
      @gnuemacscoin 4 місяці тому +5

      The article wasn't attacking the idea of a portable binary interface specification language, it was pointing out how insane C must appear to be in fulfilling that role. In web programming there's protobufs, graphql, openapi, none of which demand that you parse an unparseable language if you wish to interact with the system exposing the API.

    • @cat-.-
      @cat-.- 4 місяці тому +1

      @@gnuemacscoin interesting. i was wondering what would happen if linux kernel exposed a protobuf api when I saw that linux interface.

  • @rainerwahnsinn2150
    @rainerwahnsinn2150 4 місяці тому +128

    At which point do we throw everything away and do THE big rewrite?

    • @AlFasGD
      @AlFasGD 4 місяці тому +71

      It would be funny if history just repeated itself even after THE big rewrite

    • @sidma6488
      @sidma6488 4 місяці тому +17

      never

    • @moussaadem7933
      @moussaadem7933 4 місяці тому +45

      ​@AlFasGD i approve of a big rewrite every 64 years

    • @hardbrocklife
      @hardbrocklife 4 місяці тому +2

      Things like extreme archaic ISO standards and all the industrial applications C is used it keep it from evolving.

    • @tc2241
      @tc2241 4 місяці тому +9

      The amount of times I think about this is unhealthy.

  • @djin81
    @djin81 4 місяці тому +29

    Well, the optimal C implementation for the hardware in a toaster and the hardware in a supercomputer are completely different, that's why its vague there isn't a one size fits all solution. C's flexibility for HW manufacturers was always its appeal.

    • @techrev9999
      @techrev9999 3 місяці тому +1

      Any language can be compiled to run on any hardware. Just need to have a written compiler. Which is pretty standard. People choose C, because of what it can do - compared to other languages. It's a mid-level language. It allows you to interact directly with hardware. Something other languages abstract, meaning you have no ability to do much of anything advanced. You can't write drivers in Java.

  • @actually_it_is_rocket_science
    @actually_it_is_rocket_science 4 місяці тому +24

    Me overhere using custom types for everything and never using built-ins..... Ahhh i love c

    • @steffenbendel6031
      @steffenbendel6031 2 місяці тому +1

      Do you write your own string class as every programmer did in the 90th?

  • @XiremaXesirin
    @XiremaXesirin 4 місяці тому +4

    9:00 When I was a programming student, I had a friend I'd correspond with by email every now and then exchanging homework assistance, and I'd just gotten introduced to C (via GCC) coming from Java experience in high school, and I personally maintain that the funniest exchange she and I had ever had was when I was messing around with the type system in C, learning about the sizes of different types, and managed to get back the error message "'long long long' is too long for GCC". Like "oh, 'long long', that's fine, but 'long long LONG'??? That's going too far buddy!" 🤣

  • @imbahere7250
    @imbahere7250 4 місяці тому +8

    I don’t C any problems here

  • @treelibrarian7618
    @treelibrarian7618 4 місяці тому +115

    The article author doesn't seem to know that the C libraries are themselves just a wrapper for the syscalls that actually connect to the kernel. the kernel is entirely language agnostic, but has a method that is specific to each CPU/ISA it's ported to that enables a function call to a protected kernel runtime level on that ISA (in x86_64 that is: load the function arguments and a code that specifies the function to be called into specific registers and then execute the SYSCALL instruction, but since this is specific to x86_64, different methods get used for arm, risc-V, MIPS, PPC, even x86_32). If you want to compile and create an executable without using the C libraries and their ABI, the answer is simple: implement the kernel interface directly. If you don't want to implement them all directly with your equivalent of an asm() directive, just implement one generic syscall instruction in your compiler that will spit out the right instructions for each architecture/OS you want to support and then make wrapped functions for each of the kernel routines you want to access. It'll be some work, but you can stop bitching for a while.

    • @krumbergify
      @krumbergify 4 місяці тому +4

      Go does this, right?

    • @retropaganda8442
      @retropaganda8442 4 місяці тому +9

      ​@@krumbergifyDo a degree, yes, but it's kinda impossible on some platforms where the syscall interface is undocumented or unstable, in which case, it still uses whatever wrapper library exists to make the syscalls.

    • @phillipsusi1791
      @phillipsusi1791 4 місяці тому +26

      "The article author doesn't seem to know that the C libraries are themselves just a wrapper for the syscalls that actually connect to the kernel.", no the vast majority of C libraries do far more than just "call the kernel".

    • @ade5324
      @ade5324 4 місяці тому +5

      How about using hardware api's like opengl? i'm pretty sure that all GPU vendors wrote their opengl API implementations for their gpus in C

    • @edwardcullen1739
      @edwardcullen1739 4 місяці тому +7

      ​@@phillipsusi1791 You're suffering the same lack of understanding that the author of the article does.
      Whatever standard library has will provide all the same kinds of functionality as glibc, except it relies on glibc to handle syscalls.
      There is nothing stopping the Rust maintainers from implementing their own SysCall wrappers.
      Easier on Linux/Unix, not so easy on Windows... But if Rust really is "the future", Microsoft will start to implement a native Rust interface anyway...
      As to the question of "unstable SysCall interface"... This is answered by Linus MANY "do not break userland" rants; if this is an issue, use a better-managed OS/kernel.

  • @kayakMike1000
    @kayakMike1000 4 місяці тому +17

    C avoids any ABI by design. Its up to the OS and architecture to do the ABI. The function calling convention (part of the ABI) is the prologue and epilogue the architecture probably suggests to include...

  • @2jpu524
    @2jpu524 3 місяці тому +3

    C (and sometime C++) is the lingua franca of embedded systems. Of all the dozens of embedded processor in your computer right now, most of them are written in C. (flash management processor, hard disk drive processor, PCIe PHY controller, touch panel processor, etc , device drivers.. to name just a few)

  • @salsaman
    @salsaman 4 місяці тому +5

    size_t is the same size as the memory address size - 64 bit or 32 bit; It's also the type which the sizeof() macro returns. There is an equivalent signed version, ssize_t which is for functions which want to return a size in bytes or a negative error value

  • @mywave82
    @mywave82 4 місяці тому +9

    The fun starts when you work on systems were the smallest addressable memory cell is 16bit wide, so your "char" is 16bit; this is true from some DSPs. This gives the mind blowing results that sizeof(uint16_t) is 1, and sizeof(uint32_t) is 2..

    • @jamesburgess9101
      @jamesburgess9101 3 місяці тому +1

      Back in the early 90's the Texas Instruments C40 DSP C compiler had char at 32 bits. Actually was a pretty nice dev environment though, I enjoyed it. It had an interesting harvard-like yet flat single address space

  • @horazon_
    @horazon_ 4 місяці тому +22

    Isn't __int128 a compiler extension? So different implementation in different compilers is expected. And you don't need glibc to create file you can make syscall directly

    • @phillipsusi1791
      @phillipsusi1791 4 місяці тому +3

      Sure, you can make a syscall directly... if you know what ABI the kernel that you are running on speaks. And even the same kernel running on the same CPU can speak different ABIs.

    • @digama0
      @digama0 4 місяці тому

      Ok... this observation doesn't make it any easier for languages that aren't C to be able to call functions defined in C header files that contain the text "__int128" in them

    • @digama0
      @digama0 4 місяці тому +7

      Also, calling syscalls directly is not supported by any OS except linux IIUC. For example windows requires that you link to KERNEL32.DLL and call functions there instead of syscalls, and the API for it is defined in windows.h which I'm sure contains every possible horror you can find in C.

  • @mike200017
    @mike200017 4 місяці тому +54

    The ABI suffers from having to continue to be "C". And C suffers from having to continue to be "the ABI". It feels like we'd need a software equivalent of the phonetic alphabet, i.e., a synthetic language that nobody actually uses, and doesn't even make sense on its own (no "grammar"), just for the purpose of creating well-defined interfaces. But then, that language would probably have to "talk C" too. Sigh...

    • @peppy3519
      @peppy3519 4 місяці тому +16

      If the ABI is well written, it does not need to talk C but C needs to talk the ABI. The ABI comes before C. C is just a language like any other

    • @nikolaiartemiev5306
      @nikolaiartemiev5306 4 місяці тому

      Nn

  • @jameshertz2461
    @jameshertz2461 4 місяці тому +9

    5:03 I would argue that's partially untruth. You could just do a wrapper around single every system call (this would require writing assembly) and you would be good to go. The major question is: are you willing to do that?

    • @ChrisStavros
      @ChrisStavros 4 місяці тому +4

      Her core thesis is that writing a standard library for systems is impossible because you HAVE to either use libc or write assembly, and "of course" writing assembly is impossible, therefore it cannot be done without C.

    • @AntsanParcher
      @AntsanParcher 3 місяці тому +2

      Everyone gets so hung up on the syscall example and completely misses the FFI thing, which is not about syscalls only, but also about how you make different programming languages *of any kind, in any situation* interact with each other. I don't know about you, but when I'm programming in CL and trying to get a compute shader to run, I'm not gonna try and figure out how to do it in Assembly, especially if I want what I'm doing to be portable.

  • @shavais33
    @shavais33 4 місяці тому +10

    I remember arguing with a professor's assistant decades ago about the notion of wobbly definitions. I felt, and still do to this day, that programmers need to know how big a number they can store in a given type, and they need to be able to rely on that. He made a vague, hand waving argument about how they don't really, and how software can be more portable if wobbly definitions are used. More portable? The definitions for things *change* when you port, and that makes software *more* portable? That's not obviously fallacious? Either I was missing something that I'm still missing to this day, or that fellow was just kind of ideologically captured.
    That reminds me of an argument I had with a high school calculus teacher about a theoretical baseball out in space slowing down on it's own with no external forces acting on it. I said if there's no friction or gravity or anything, won't it just go on in a straight line at the same speed forever? No, there would be some rate of change of it's speed, the teacher insisted. Sure there would, I said, but it would be zero. No, they insisted. It would be almost zero, but not quite zero. It would be an epsilon. (The closest thing to zero that's not zero.) Ok, so if it's non-zero, in what direction will it be? In the direction opposite the one it's moving in. Really? Moving relative to what? The ether? It seemed to me that the analogy he was making to try to explain what epsilon is was breaking down a bit. "Maybe we should be talking about a circumstance under which the formula describing the values we're tracking actually involves epsilon?" I got told by him and by class members not to argue with the teacher. I think I facepalmed at the time, and I still facepalm remembering it. Fortunately the calculus/physics teacher at the community college affirmed my understanding. I didn't tell my high school teacher. (One facepalm was sufficient.)

    • @PassifloraCerulea
      @PassifloraCerulea 3 місяці тому +4

      Hah! I'm sure many of us have had terrible arguments with teachers when we catch them out on their own lack of understanding. I agree that code usually needs to make some assumptions about the ranges of values you can store. It's not usually *dire* because `int` is often big enough and a smaller computer will naturally not be able to work on as large a data set, but you're not wrong.
      That said, there is some truth to increased portability from "wobbly definitions," but it's more about the language itself. You see, C comes from a time when some major hardware platforms had a 36-bit word size and you couldn't count on a (hardware-supported) 8-bit value or maybe any power-of-2 type size. Two's complement wasn't universal either. If C had demanded exact bit sizes for each type, or two's complement, then no C for you! Computer hardware looks a lot different-and a lot more uniform-50+ years later, and it's easy to forget why certain things don't make as much sense anymore.

    • @shavais33
      @shavais33 3 місяці тому +3

      @@PassifloraCerulea That, sir, is a very good point! And, gosh, C is still used in all kinds of crazy embedded environments. I feel a bit stupid now. I suppose it does make sense to have a non-specific "int" type, and then have platform-dependent types like "int8" and so on.

    • @arnerob123
      @arnerob123 2 місяці тому +1

      @@PassifloraCerulea Yeah, such teacher things come in my mind a lot. Even though most of my teachers were really good, I seem to remember most vividly the bad ones because I felt strong emotions. I wish it was the other way around.

    • @KanjiCoder_RTFM
      @KanjiCoder_RTFM Місяць тому

      I think the wobbly definitions make the code portable in really trivial cases . Like a for loop that doesn't go past 255 or something .
      I always use stdint.h for uint32_t . I also never use enums because it makes me uncomfortable going "they are probably 32bit ints" .
      Probably ? That's going to be bad news if I want to bit pack those enums .

    • @TheGrimravager
      @TheGrimravager 26 днів тому +2

      yeah the non-zero friction is actually due to virtual particles popping in an out of existence. It's a very weird phenomenon that's only recently been discovered/confirmed/whatever

  • @drxyd
    @drxyd 4 місяці тому +53

    How long is an unsigned shlong?

  • @BazsiDev
    @BazsiDev 4 місяці тому +5

    Just a grumpy old embedded engineer here. The question is what your job is. If your job is to make software that must work on a CPU that has less than 256 pins or operating voltage more than 1.5V, you are most probaly left with only C/C++ toolchains. Assuming you want to avoid assembly. The hardware mentioned above is basically everything your world is operated by. Want something working above 80 degC? Something that should work on a wide voltage range? If one does not want to learn new assembly for each of the targets at hand, C is the language of the cheap hardware. To my surprise, the most vocal people against C is the ones who use joe, vi, emacs or some other -vintage- exotic editors.

    • @johnbennett1465
      @johnbennett1465 3 місяці тому

      In the 80's I worked on spell checkers for typewriters and handheld devices. Even when a C compiler existed for the obscure CPUs being used, it was generally buggy and failed to even meet the loose "standard" provided by the original K&R book.
      It sounds like it is a little bit better now, but still a big pain.

    • @AntsanParcher
      @AntsanParcher 3 місяці тому

      I thought that's what Forth was for.

  • @turun_ambartanen
    @turun_ambartanen 4 місяці тому +56

    I've read their blog before/know who the author is: They have written the Rustonomicon, _the_ thing to read about unsafe rust.
    The "sounds like skill issues" by the Primagen at 6:20 and the chat at 6:23 "WTF? Even ChatGPT would do better than this article" made me once again realize that the Chat and often times The Primagen too have absolutely no idea about some part of programming.

    • @WHYUNODYLAN
      @WHYUNODYLAN 4 місяці тому +18

      She also did a ton of work getting Rust to have functional FFI with many different C compilers. She is absolutely the person to defer to on this kind of stuff.

    • @JArielALamus
      @JArielALamus 4 місяці тому +8

      Does that not confirm the so called "skill issue" then? Because She's an expert with unsafe Rust not a C expert. Nevertheless, that is still experience she got for unsafe Rust interfacing with ABIs. Judging by the other comments here, it seems the ABIs goes deeper than just C

    • @WHYUNODYLAN
      @WHYUNODYLAN 4 місяці тому +17

      @@JArielALamus for one thing, I'd wager she's more of a "C expert" than most good C programmers are, since compiler people generally need to know a lot more specifics about languages. For another, I assume "skill issue" was a joke response to the "you can't actually parse C" claim.

    • @JArielALamus
      @JArielALamus 4 місяці тому +3

      @@WHYUNODYLAN I don't know about that. I have seen the responses to this article and for the looks of it, she is indeed talking outside her area of expertise. I'm not an expert either, so I can't say for sure, I can only go by the information I'm seeing.
      Also, by those same responses, it seems working with unsafe Rust is a really challenging task.
      I'll take a deeper look into all of this, I may learn new things. Anyways, thanks for pointing out about the Rustonomicon author

    • @turun_ambartanen
      @turun_ambartanen 4 місяці тому +5

      @@JArielALamus No, she is in fact an expert on this exact topic.

  • @tinkeringengr
    @tinkeringengr 4 місяці тому +12

    Tower of Babel. I hope I still speak Python after the collapse.

  • @lMINERl
    @lMINERl 4 місяці тому +17

    Seeing people argue about tools to get job done and disregarding where this tool shine is beyond me

  • @thingsiplay
    @thingsiplay 4 місяці тому +11

    I really dislike articles which have a new paragraph for every single sentence. They probably do it, so the article looks longer.

    • @卛
      @卛 4 місяці тому +4

      no, it's for emphasis

    • @aarholodian
      @aarholodian 4 місяці тому +5

      Reddit spacing

    • @thingsiplay
      @thingsiplay 4 місяці тому

      @@卛 For people who can't read?

    • @卛
      @卛 4 місяці тому +5

      @@thingsiplay are you implying anything?
      this style of writing is popular with young people. it is styled differently than older folks might be used to, but this is right up my alley as a twenty-something years old.
      one sentence in a paragraph for the purpose of emphasis is quite common for our generation

    • @thingsiplay
      @thingsiplay 4 місяці тому +4

      @@卛 It doesn't matter what generation it is, I dislike the way how the article is structured.

  • @marc-andreservant201
    @marc-andreservant201 17 днів тому +1

    I work with DSPs and microcontrollers. I intentionally put a buffer overflow in the serial console driver to allow for firmware upgrades because I didn't have time to write a proper bootloader before release date. The shellcode both installs the bootloader and fixes the buffer overflow. I hid it from my boss by having the DMA driver, not the CPU, perform the attack, so static code analysis wouldn't catch it.
    - "Hey, how did you upgrade that without a bootloader?"
    (Proceeds to show him a very short assembly program that reads from the console FIFO and dumps it into flash)
    - "That wasn't in your code"
    - "Nope, but look, it calls the DMA driver to read until line idle without any bounds check, then we just overwrite the vector table mapping to point the reset vector to the shellcode and send the CPU reset command". For those who don't know, JEDEC compliant flash chips wrap around to address 0 when reading past the end of memory. All you need is some way to mask off the address bits that aren't used, which looks like a safety check when writing since it prevents writing past the end of memory and throwing error codes.

  • @happygofishing
    @happygofishing 4 місяці тому +53

    C is the means by which all is revealed.

  • @MrPhil1712
    @MrPhil1712 4 місяці тому +84

    C is love, c is life and also goddamn nice

  • @mattias3668
    @mattias3668 4 місяці тому +3

    30:50: How are you going to have int32_t on a 9- or 7-bit machine? And what are you going to do when you a size, a memory address expressed as an integer, or a difference between pointers? Sure, you don't need short, int, long, and long long, anymore as you have {u,}int_{fast,least}N_t nowadays, but there still are integer types where you don't want a number.

  • @phillipsusi1791
    @phillipsusi1791 4 місяці тому +8

    Yea, int was supposed to be 16 bits on 16 bit CPUs, 32 bits on 32 bit CPUs and 64 bits on 64 bit CPUs, but they kept it at 32 bit for x86_64 because "changing it would break things" ( namely badly written software ). I have worked on a CPU where int was 24 bits and long was 32. Go figure.

    • @evanrhildreth
      @evanrhildreth 4 місяці тому

      Don't forget 80 bit floats!

    • @phoneywheeze
      @phoneywheeze 4 місяці тому

      I'm not that deep, but if the authors problem is not being sure if int is 32 bits or 64 bits, why not use malloc and pointer?

    • @phillipsusi1791
      @phillipsusi1791 4 місяці тому +2

      @@phoneywheeze That doesn't really have anything to do with it.

    • @Howtheheckarehandleswit
      @Howtheheckarehandleswit 2 місяці тому

      ​@@phoneywheeze That's a completely unrelated concept. Even if you did malloc your ints, you still need to pull them into registers to actually do any math with them, and at that point you need to know how many bits the CPU will add together when you ask C to grab two ints and add them to know if your program will break in the event that, say, the user asks to make a table with more than 65535 rows.

  • @maxstevens9518
    @maxstevens9518 4 місяці тому +23

    No more netflix = no more hoodie?

    • @sutirk
      @sutirk 4 місяці тому +15

      The hoodie was company property

    • @deudz
      @deudz 4 місяці тому +1

      we need to give him a new hoodie

  • @dale116dot7
    @dale116dot7 4 місяці тому +2

    C is almost a real programming language. Assembly is the real programming language, except that assembly language is a collection of hundreds of wildly different languages. Z80 assembly is very different from PIC16 or DSP56k or S08 or S12X, ARM, IBM 370, RGP30… all different. That’s the source of the type/size issues in C. I’m lucky enough to program embedded systems but even then, C isn’t the same between different processor platforms.

  • @thingsiplay
    @thingsiplay 4 місяці тому +22

    AI = Productivity goes up, quality goes down

    • @3polygons
      @3polygons 4 місяці тому +9

      ^^This. (Not sure about the productivity, either).

    • @thingsiplay
      @thingsiplay 4 місяці тому +6

      @@3polygons "Productivity" in the sense of "Quantity". I just used that term in sarcasm manner as an alias for quantity.

    • @3polygons
      @3polygons 4 місяці тому +1

      @@thingsiplay I see.. :)

    • @Mayhzon
      @Mayhzon 4 місяці тому +4

      @@thingsiplay Does it, though?
      Can't speak for programming but what I've found with art is that you end up trying and trying so much to make it work with prompting, you'd be better off having it done professionally by someone with experience in the first place.

    • @thingsiplay
      @thingsiplay 4 місяці тому +2

      @@Mayhzon That's because you are not satisfied with the many produced content. You produce a lot, meaning high quantity, with low quality. That's why you are looking for a professional. So my statement aligns with your statement as well. :-) voila

  • @willzin-da-esfiha
    @willzin-da-esfiha 4 місяці тому +4

    You can call these functions including the binaries of the required C libraries into your compiled code by calling them in assembly or machine code. But use them as your programming lingua franca is worse than use C.

  • @johanngambolputty5351
    @johanngambolputty5351 4 місяці тому +7

    We should make whatever ABI HolyC uses the FFI standard instead.

  • @gregoryprice2984
    @gregoryprice2984 4 місяці тому +3

    The painful thing about this article is simply that systems-level programming is all about writing a generic, consumable interface to what is - essentially - an abstraction around hardware (the operating system). Being angry at C is like being angry that Rust wasn't invented immediately on top of Turing's BOMBA. It's just screaming into the void for no value.

  • @haxney
    @haxney 4 місяці тому +3

    The problem seems to be that versioning and compatibility aren't represented explicitly in C definitions, but are implied from the field order of structs or type alignment. For a universal base ABI, you'd really want something like protobuf, which has explicit field numbers, a first-class concept of "unknown fields," and a defined, platform-independent serialization. All of the clever workarounds that MS does in the minidump example should really be part of the interface specification language. Also, we got ourselves into trouble by using the same type for "an integer (of some size)," "a pointer," "an offset," "an address," and "an integer that is fast for this CPU."
    Obviously, it's about 40 years too late to do anything about any of this, but we can shake our fists at the sky.

  • @thingsiplay
    @thingsiplay 4 місяці тому +14

    C MENTIONED LETS GO

    • @jwr6796
      @jwr6796 4 місяці тому +5

      Go mentioned!

  • @sorek__
    @sorek__ 4 місяці тому +4

    In embedded we always use int32_t, uint8_t etc. Makes life much simpler, I can't stand that most codebase for PC is 99% ints, long longs and other stuff..
    Using anything else makes 0 sense and is forbidden by every dev.
    We do the same when writing embedded C++ code and we stay away from std:: and everything bloated from it.

    • @theheadpriest
      @theheadpriest 4 місяці тому

      because when you do embedded you know the architecture of the machine. PC codebases need to be able to run on different types of machines with minimal changes.

    • @sorek__
      @sorek__ 4 місяці тому +2

      @@theheadpriest on PC you have 2-3 architectures.
      In embedded you can reuse same codebase between dozens architectures and 8, 16, 32 bit processors with different endianess.

    • @kablouserful
      @kablouserful 3 місяці тому

      ​​@@theheadpriestif you need a different data for your platform (eh memory address) then you should write a new program.

  • @williamsorenson1525
    @williamsorenson1525 4 місяці тому +12

    C is turing complete. And therefore it can run any (computational) program, or any algorithm you can come up with.
    Incidentally, CSS is also turing complete. CSS is actually a programming language.

    • @AloisMahdal
      @AloisMahdal 4 місяці тому +15

      I thought it was obvious, since CSS stands for CpluSpluS. (right?)

  • @casadogaspar
    @casadogaspar 4 місяці тому +4

    "Rust make people angry that things don't looks like Rust"
    After the last 3 years coding only in swift I can relate.

  • @styleisaweapon
    @styleisaweapon 4 місяці тому +46

    Hes got it backwards. C bends to arbitrary structure layouts and whatnot. He wants every other language to do that instead of C.

    • @zeratax
      @zeratax 4 місяці тому +2

      idk where it says that?

    • @krux02
      @krux02 4 місяці тому +10

      @@zeratax It's the thing with "long". What is a "long"? How many bits does it have? What's the alignment? C does everything it can do to not give an answer to that. It all depends on the OS-cpu combination. If you work on a programming language, you want things like that to be hammered in stone.

    • @zeratax
      @zeratax 4 місяці тому +8

      @@krux02 i just don’t see where exactly the article states that every other language should do this instead of c. all i see is the author describing why c is a protocol and not a language and how insanely complicated this problem is.

    • @infastin3795
      @infastin3795 4 місяці тому +17

      ​@@krux02but you don't really want such things to be hammered down when you are writing your own os or a compiler for your own platform.

    • @digama0
      @digama0 4 місяці тому +7

      She, not he

  • @RandomGeometryDashStuff
    @RandomGeometryDashStuff 4 місяці тому +4

    31:08 is size_t supposed to be unsigned and same size as memory address?

    • @lauraprates8764
      @lauraprates8764 4 місяці тому +6

      size_t is always unsigned and it's the type returned by the sizeof operator

  • @dexterman6361
    @dexterman6361 4 місяці тому +4

    I've had to deal with this at work. We have literal meetings over ABI/API compatibility and together design a header and review it before it ships. (I'm just a junior dev tho)
    Thankfully, there are standard methods to do this well and maintain compatibility, but it comes with extreme cost. When a new feature is at potential odds with the old one, and there is a change that old and new types can mix, then oh boy.
    For example, what do you do when multiple apps load your shared object. Shared objects are typically loaded only once into memory but mapped to different virtual addresses b/w apps. The object file has both the versioned APIs - v1 and v2. One uses v1, the other uses v2. But both the apps talk to each other. You'd think everything would "compute" in v1 but the second app does not "know" about the first app. Remember that struct members are just offsets from a pointer so if you get a v2 object from the second app but was created by v1, in your library you're reading out of bounds in your library ... but it's the fault of the second app! (It should've set the version to 1 instead of 2).
    I dreamed up this scenario, but I wouldn't be surprised if it happened at some point in time. Hey hey what if apps exported their ABI info as json :D along with the binary. Then we can just use that to interop. This would also allow languages to change layouts (as in consecutive members don't need to be in the same order in the binary as they are declared)

    • @grokitall
      @grokitall 2 місяці тому

      This is just another case of the diamond dependency problem seen with objects, and should be solved the same way. Make the base abi definitions include semantic versioning info, and resolve it at link time or load time. If it cannot be resolved at that time, don't let the code run.
      C has always been defined as a source portable language, not an abi portable language, but some system and low level library developers don't help.

  • @slendi9623
    @slendi9623 4 місяці тому +6

    9:10 its actually compiler dependant for example TurboC has 16 bit ints iirc

    • @lauraprates8764
      @lauraprates8764 4 місяці тому

      at a time it was compiler dependant, but nowadays they shift to be platform dependant, but there's a reference definition for the minimum size of each integer, and the minimum size of a int is a 16bit integer

  • @johanngambolputty5351
    @johanngambolputty5351 4 місяці тому +5

    Each long should increase the number of bits by a random amount, and not by a multiple of eight, in fact, only by prime number amounts.

  • @QayLikeKay
    @QayLikeKay 4 місяці тому +7

    size_t is used in std c/++ because it's the return type of sizeof. The reason they do *that* is because anytime you're working with arrays, indices, byte sizes, etc. are all times where that value can be potentially converted to/from a pointer or used as a pointer offset. That means it needs to be able to hold any value a valid pointer could so on 64bit machines it needs to be a 64 bit int, on 32 bit it needs to be 32 bits, etc. Thus size_t avoids all of the nonsense of int vs long vs long long, etc and avoids the hardcoded sizing of int32_t and just says "whatever the size of your pointer is the size of the integer you should use for indexing, here you go". C++ mucks this up a bit because it has extra large pointers in some cases due to multiple inheritance, v-tables, etc.

  • @CrazyIvanTR
    @CrazyIvanTR 4 місяці тому +2

    Programming is like a lake, a very old untouched lake with no fish in it. The surface is all nice and clear but deep down there's mud and decaying plant matter. I like diving deep in there cuz I like rolling around in that mud but it sure feels icky every time lol.

  • @DaQatz
    @DaQatz 4 місяці тому +5

    int was supposed be 64 bit on 64 platforms. But so many people used well... very poor programming practices in the 32bit era and just assumed type sizes. Of course when you compile for a new target this breaks shit everywhere.

    • @infastin3795
      @infastin3795 4 місяці тому +7

      C didn't really have standard intX_t types back then. So I believe when you don't have a way to explicitly specify the size of an integer you start to assume sizes of int/long.

  • @VFPn96kQT
    @VFPn96kQT 4 місяці тому +2

    Fushcia is the only modern OS that doesn't rely on C lib. It uses it as shim for programs that rely on c lib but it's not required. It uses language agnostic Fuchsia Interface Definition Language (FIDL) to describe binary interface.

  • @BrunodeSouzaLino
    @BrunodeSouzaLino 4 місяці тому +12

    8:56 While the real sizes of those depend on the implementation of the data type, the minimum size for a short is 16 bits, 32 for a long and 64 for a long long. A short long would be the same as a short and a short short (half of a short) would be the same as a char.

    • @deth3021
      @deth3021 4 місяці тому +4

      Not on all systems and not by the standard.

  • @----__---
    @----__--- 4 місяці тому +2

    12:50 I dont know what zig people has told you to believe that zig is literally a fully fledged C compiler but its literally just clang with additional flags 😅

  • @josevargas686
    @josevargas686 4 місяці тому +10

    Confusing article that makes almost no sense at all, even if the author had the right ideas, clearly couldn't express them. This could be explained in less than 5 minutes by Casey :shrug:

  • @EdowythIndowyl
    @EdowythIndowyl 4 місяці тому +1

    Longs are not well-defined. That's the point. The type sizes change based upon the platform. It can be literally equal to an Int on some platforms. You must inquire using #ifdef kind of things to figure out what applies at compile time.
    The problem is not that C has no ABI, but that NO ONE clearly defined an ABI and said, "This is what we're using." In fact, if you do that, you're pushed into the world of JiT compilers. There is an easier way to do it: publishing a standard for defining interfaces that involves Linkers and Loaders doing some last-minute fixups between different binaries at load time. You'd basically assume a fixed ABI across all machines, then have the Linker/Loader inject helper transforms to the local environment. It's different from JiT only in that, once done for a given machine, it could easily be cached for the next run-time and there is (theoretically) no overhead that isn't necessary for ANY ABI abstraction to work on pre-compiled software.
    No one has written such a standard or modified a linker yet (that I'm aware).
    The alternative for fully-compiled code is this: "C is the standard OS-writing language. They must have C. Let's use C as a glue to patch together our interfaces."

  • @RillianGrant
    @RillianGrant 4 місяці тому +14

    Very interesting article but I really didn't like the tone. It felt very high-horse and dismissive even where it wasn't

    • @pavlinggeorgiev
      @pavlinggeorgiev 4 місяці тому +4

      look up the author. It will explain things 😂

    • @hardbrocklife
      @hardbrocklife 4 місяці тому +6

      The author is pretentious skynet

    • @RillianGrant
      @RillianGrant 4 місяці тому +1

      @@pavlinggeorgiev Aria Beingessner? I couldn't find anything strange with a basic google search.

  • @progste
    @progste 4 місяці тому +35

    C is not a language, it's something more!

    • @juanmacias5922
      @juanmacias5922 4 місяці тому +9

      IT'S AN EXPERIENCE!

    • @0x90h
      @0x90h 4 місяці тому

      @@juanmacias5922 IT'S A JOURNEY!

  • @mytechnotalent
    @mytechnotalent 4 місяці тому +9

    LOL C is not a programming language? I guess I have been wrong since 1974 oh well...

    • @chindianajones3742
      @chindianajones3742 4 місяці тому +6

      The title is just clickbait, but the actual content of the article is still very pertinent. C has terrible interop with other languages/interfaces compared to modern ecosystems. So i guess a better title is "C is not a modern programming language", which is quite evident.

    • @zaper2904
      @zaper2904 4 місяці тому +1

      ​@@chindianajones3742It's not just about being old though the other reason is that C runs on more architectures than all the other languages mentioned in the article put together.

    • @lauraprates8764
      @lauraprates8764 4 місяці тому +1

      @@chindianajones3742 but the problems with the article are kinda pointless, there's a well defined ABI (System V ABI in the case of Unix) that is based on assembly and it only uses C as an example, but all the specs are based on the actual assembly code, however, ppl just ignore it and just assume C is the way when in fact it isn't

    • @chindianajones3742
      @chindianajones3742 4 місяці тому

      @@lauraprates8764 yes i agree.

    • @PR-cj8pd
      @PR-cj8pd 4 місяці тому

      ​@@lauraprates8764 what's the name, where can I find the ABI definitions with assembly?

  • @Lampe2020
    @Lampe2020 4 місяці тому +1

    8:52 I call 64-bit integers "long" and Notch does so too as it seems, but in Python3's struct module a simple "long" is identical to an "int", a 32-bit integer. There you need a "long long". But I thought "long" meant "it's longer than the default"?

  • @yapdog
    @yapdog 4 місяці тому +3

    6:44 Nnnnope! I'm actually in the process of writing a C/header parser. Yeah, it's a b!tch, but you just have to put in the work. But then again, I'm old school; I'm quite used to burying my head in code for days/months/years on a single project.

    • @digama0
      @digama0 4 місяці тому

      You should check out the link given for "parsing C is basically impossible" in the article, which contains such beautiful test cases as:
      typedef long T, U;
      enum {V} (*f(T T, enum {U} y, int x[T+U]))(T t);
      // The above declares a function f of type:
      // (long, enum{U}, ptr(int)) -> ptr (long -> enum{V})
      T x[(U)V+1]; // T and U again denote types; V remains visible
      These are some absolutely hellish things which even existing compilers get wrong, and writing a correct parser from the pile of prose rules in the C standard is not at all clear, especially when there are mistakes in the standard as well (some pointed out in the same paper). The paper's title is "A Simple, Possibly Correct LR Parser for C11" - even after that in-depth investigation the authors still can't claim to have a correct parser for C11. If you think it's "just a matter of putting in the work" I think you don't understand what you are up against. Then again, if you are okay with being wrong in a bunch of edge cases then yes, it's comparatively simple, and nothing to apologize for either, even the big leagues are doing that because the actual C standard is bonkers.

  • @eightsprites
    @eightsprites 4 місяці тому +1

    C only got ”int” integers.
    Want it longer? use ”long int”, still not enough? use ”long long int”. Need an other bit? ”unsinged long long int”. Changed your mind, actually didn’t need that something shorter than an int? No problem ”short int” to your rescue. If you want values of specific byte lenght, use the standard integer types from stdint.h, here is a few examples: int8_t, int16_t, uint8_t.

    • @vitalyl1327
      @vitalyl1327 4 місяці тому

      stdint.h is a pretty recent thing, and it was a real pain before it became widely available on most (still not all) of the platforms.

    • @phoneywheeze
      @phoneywheeze 4 місяці тому

      unsigned doesn't give extra bits, it just shifts the negative, to start with 0

  • @peppy3519
    @peppy3519 4 місяці тому +43

    I think what programming language authors forget is that there are standard ABIs like the SysV and Windows ABIs (these are not C ABIs). If you use them, you could just link with any language that has a compiler for that specific ABI. No need to parse any C code, just mark the function as external and let the compiler emit code that conforms to that ABI and then let the linker link stuff together. It's a widely known functioning interface that language authors somehow forgot how to use. Yes, I get that people don't want to deal with all of the object files but how else are you gonna glue two languages together.

    • @kuhluhOG
      @kuhluhOG 4 місяці тому +20

      With the exception that the article stated that two compilers (gcc and clang) disagree on the interpretation of a part of the SysV ABI.

    • @Exilum
      @Exilum 4 місяці тому +5

      There was a mention of the SysV ABI being problematic too.

    • @sellicott
      @sellicott 4 місяці тому +1

      @@kuhluhOG IIRC I read through the AMD64 SysV abi when I read this article a while back. 128 bit integers aren't really defined in the ABI so each compiler is free to do whatever. The answer is that if you use weird types on function boundaries you are likely going to have problems, just push it to the stack.

    • @peppy3519
      @peppy3519 4 місяці тому

      @@kuhluhOG this is probably Cs fault and not the ABI, or the ABI is just badly written. But there's no use of changing it now

    • @peppy3519
      @peppy3519 4 місяці тому

      @@Exilum I don't think it's the bigger problem here. It's that languages are trying to parse C instead of linking with it. C *should* be like any other language and adhere to the ABI.

  • @khatdubell
    @khatdubell 4 місяці тому +2

    There is a reason why types that don't defined a set bit width are standard for C and C++.
    You can't guarantee that a particular platform will have a particular size.
    If you have just i8 and i16, but you need to write code for a platform that doesn't have either of those, what do you do?
    While this is EXTREMELY unlikely in a modern context, both C and C++ are obsessed with "backwards compatibility"
    Something once compiled for an DSP56000 should still be compile-able for an DSP56000 .
    I disagree with this stance, but i'm in the minority.

  • @gregorymorse8423
    @gregorymorse8423 4 місяці тому +5

    The author is confusing C ABI, a protocol with C the programming language. Maybe its just clickbait but that part of the argument was nonsense

    • @digama0
      @digama0 4 місяці тому +3

      The issue is that C ABI the protocol is written in C the programming language, so you have to understand the latter to be able to parse interface definitions using the former. This is stupid and unnecessary and causes all of C's shortcomings as a language to impact the quality of interfaces that would otherwise have nothing whatsoever to do with C.

    • @gregorymorse8423
      @gregorymorse8423 4 місяці тому

      @digama0 wrong. The ABI is a protocol. Protocols ate not language dependent. You are as foolish as the article author. He did eventually state the real culprit which wasn't the ABI. It's that "major OS" all describe the interoperability to their API and communication between shared libraries using C headers which are hard to parse. Just like the article, you are whining and not properly constructing or emphasizing the real reason. So this article mainly scrambled the minds of noobs as the main point was glossed over while he blamed the wrong thing.

    • @gregorymorse8423
      @gregorymorse8423 4 місяці тому +1

      @digama0 it has literally nothing to do with C ABI but is a protocol. The article did no justice and glossed over that "major OS" and their APIs and shared library formats are the whole source of the issue. So what you said shows lack of understanding of the entire thing. Although I think a lot of people are blindly following that article which mixed things up completely

    • @gregorymorse8423
      @gregorymorse8423 4 місяці тому

      All in all it was a whiny article about OS and shared library interfaces using C header files which are hard to parse. And it was presented as a war against C ABI which has nothing to do with it. Quite lame

    • @digama0
      @digama0 4 місяці тому +1

      @@gregorymorse8423 "All in all it was a whiny article about OS and shared library interfaces using C header files which are hard to parse." Yes. This is dumb but it's also the reality of what people (like Aria!) have to deal with in order to interface with the rest of the world. How do you expect progress to be made if we don't speak out when things are bad? I assure you this is not coming from a lack of understanding, but rather from knowing just how messed up the whole situation is and yet how little can be done to improve it short of moving all the big players in the world away from "the C ABI". Sure, it's the fault of these big players for using C, but it's also C's fault for being a bad ABI. It never really planned to be one, so that's justifiable, but it is one nonetheless and as long as people ignore its shortcomings we won't get anything better.

  • @henrykkaufman1488
    @henrykkaufman1488 4 місяці тому +7

    It is the best programming language ever, and I realized that after 15 years of programming in everything else and then revisiting C.

    • @eightsprites
      @eightsprites 4 місяці тому +3

      Welcome to the dark side of wizardry

  • @bearwolffish
    @bearwolffish 4 місяці тому +3

    Still a language, but also a protocol.

  • @obogz
    @obogz 4 місяці тому +6

    C is like Pluto, and Pluto said: "Your mama thought I was big enough"

  • @chadf99
    @chadf99 4 місяці тому +4

    Can't we all just get a long?

  • @randyriegel8553
    @randyriegel8553 4 місяці тому +1

    My first job out of college was using mainly C on an HP-UX Unix machine in early 2000's. The app controlled time clocks, sent signals to machinery in the plant, etc. It had to be real-time. My boss and I would write some assembly to pull in because the C function wasn't fast enough. Great times!!! After my boss and I left that company around the same time I went to C# and never looked back. I still to other stuff SQL, Javascript, Go, etc... now at a robotics company I'm writing C++ for micro controllers. I still do C# / SQL there to communicate to the robots.

  • @methanbreather
    @methanbreather 4 місяці тому +3

    I find it hilarious how much rust fanbois complain about C abis and apis, while rust in itself is an unstable, constantly breaking mess.

  • @ssj3gohan456
    @ssj3gohan456 4 місяці тому +1

    this article doesnt quite grasp that my day job is writing the same c code that runs on your 128-bit processor... but for a 16-bit AVR. And with slightly different typing, it is surprisingly portable

    • @phusicus_404
      @phusicus_404 4 місяці тому

      Hi, this is nice, how do you do that?

  • @mikedemchenko3513
    @mikedemchenko3513 4 місяці тому +9

    Ok, to limit misconceptions - C standard officially do not support int128 as a type - it is a “modern” compiler extensions that are not guaranteed to have a stable ABI between compilers and topic author knowingly put this exact fact to test an ABI to make a discussion feel cringey.
    This is a problem of modern C/C++ as stated that many types are required to be updated to 128 bit versions (like intmax/size) if wider integers are introduced as part of standard it will not be an ABI break as there is no guarantee about width of this types - but all code will suddenly be broken as everything works on them.
    BTW: this is the reason why we have 128 bit (and more) capable processors but no company risk to advance further as this will break C/C++.

    • @lauraprates8764
      @lauraprates8764 4 місяці тому

      c23 is supposed to have int128_t, however they will allow you to have intmax_t not capable of holding a int128_t value, but yeah , the issue in the article is not a problem

    • @predabot__6778
      @predabot__6778 4 місяці тому

      Wait... does this mean that any C-program written to take advantage of AVX-512 uses something like int128 instead of something like int512? (side-note, I see here that Unreal Engine actually has something called int512 as a type definition) But what about some of the newer existing/planned RISC-V vector-extended CPU's? The spec' goes all the way up to 4096 bits wide instructions! :O Is everyone just gonna' leave that on the table? Apologies if this post is silly, since I'm quite the beginner.

    • @lauraprates8764
      @lauraprates8764 4 місяці тому

      @@predabot__6778 in this case it does not have a stable ABI, so the programs can't have interoperability, each program has it's own definition that only suits their needs, in fact even the System V ABI for i128 in x86_64 is completely optional

    • @Kycilak
      @Kycilak 4 місяці тому +2

      @@predabot__6778 I don't think C itself knows about SIMD. It is the compiler that may for example unroll a loop to a SIMD call. An extension may also be created to explicitly call SIMD or you can use assembly.

  • @0x0404
    @0x0404 4 місяці тому +1

    The best thing objective-c and swift have are protocols from the small talk message based roots. It lets you do soft inheritance where things don’t have to conform structurally like memory mapping stuff in c

  • @Jabberwockybird
    @Jabberwockybird 4 місяці тому +12

    It's not that C isn't a language. It's the only language. All these others are just newer C compilers

  • @pyajudeme9245
    @pyajudeme9245 4 місяці тому +1

    Dennis Ritchie - the Johannes Gutenberg of the 20th century.

  • @ezemans
    @ezemans 4 місяці тому +3

    I love C in the morning.

  • @JohnnyThund3r
    @JohnnyThund3r 3 дні тому

    As someone who's studied enough C++ to know how it differs from C, the moment I heard Rust and Swift use C to talk to each other, I knew somebody, somewhere had F----d up big time and we're all paying for it now... Good to know my hunch was correct!

  • @Darth_Bateman
    @Darth_Bateman 4 місяці тому +3

    Megumi Fushiguro : "I just learned C"
    >>C is not a language anymore
    Megumi Fushiguro. :" With this treasure I summon. . . ."

  • @dorbie
    @dorbie Місяць тому

    None of this even mentioned data field padding between unaligned types in structs even when you get the size right. That's a whole other thing and is compiler dependent and adjustable in compiler options. I once had to communicate between fortran and C and the same types with compatible sizes in data blocks (structs) were padded differently by default between the Fortran and the C compilers. That was ~30 years ago. This isn't a new problem, and even C had to try to be compatible with earlier languages on occasion.

  • @nicholasbuckner5221
    @nicholasbuckner5221 4 місяці тому +3

    Terrible: that’s the long and short of it

  • @goaserer
    @goaserer 4 місяці тому +2

    Keeping memory layouts forward- and backward-compatible sounds like fun

  • @SimGunther
    @SimGunther 4 місяці тому +15

    Alt title: non-C programmer has skill issue using standard ABIs

    • @joseoncrack
      @joseoncrack 4 місяці тому +3

      Yep. Another alt title: "some people are talking, some others are doing."

  • @dieSpinnt
    @dieSpinnt 4 місяці тому +1

    Around 33:00
    Yes, there is a "triple long".
    It's called a "Long Dong Silver" and in size exactly two norm EU bananas ...

  • @sirflimflam
    @sirflimflam 4 місяці тому +8

    This is why I never understood why we're so determined to even define something like intmax_t. Every type should just have its bit count attached to it and we should declare every variable we use with that scope instead of relying on the compiler to figure it out.

    • @TurtleKwitty
      @TurtleKwitty 4 місяці тому +5

      It made sense back in the day where some machines were 16bit others were 21 others 12 and such but we definitely need a ... not c but a &c (reference c) protocol that doesnt accoutn for now entirely defunct and never gonna happen again 21bit machines and such, but for that you'd need literally everyone in the world to agree to recompile every single thing to that new but correctly stable abi with defined sizes

    • @lauraprates8764
      @lauraprates8764 4 місяці тому +1

      by definition they are different, i agree that the whole int, short int, long int, long long int is a mess and it's arguably worse for portability, but the definition for the intmax_t and uintmax_t have nothing to do with precise width integers, it's by definition the largest int that the standard defines, this only problem is with c23, because the standard defines a 128 bit precise width integer, while also allowing intmax_t to not be equal to sizeof(int128_t), the standard is not technically finished yet, so this is not a problem, specially if you cite __int128_t, that it isn't part of the standard, and this is not a compiler thing anymore (in the old days the size of any integer type was compiler dependant), nowadays this is defined by the platform so you don't need to rely on compilers to know the width of each type

  • @Squirrelies1
    @Squirrelies1 4 місяці тому +1

    Same. Whenever I am doing C stuff, I (almost) always use bit-defined types like uint64_t unless I can't such as interoping with spicy Win32 stuffs which is distressing frequently for me since a lot of the stuff I do C/C++ stuff for is game hooks (speed run tools, randomizers, etc.) where my code will be injected into the process and I'll be working with Win32 and DirectX APIs a lot of the time.

  • @Trezker
    @Trezker 4 місяці тому +6

    Last I tried, not long ago, zig wasn't able to use my favourite C library. So... nope, it's not good enough.

  • @dorbie
    @dorbie Місяць тому +1

    C is beautiful, anyone who thinks otherwise never got there through Fortran 77 and Basic before that.
    C is the lightsaber of programming languages, if you cut your leg off with it then you should have stuck to blasters.

  • @LokiScarletWasHere
    @LokiScarletWasHere 4 місяці тому +4

    TLDW: Rustacean struggles to understand a C-powered world. Half of this guy's rant is how C is bad because C is the dominant language.
    It ain't like how Windows dominates the desktop space or Chrome dominates browsers. ThePrimeTime reads and reacts to the crab's invertebrate rambling.

    • @bonerjams2k3
      @bonerjams2k3 4 місяці тому +1

      The malding Rustacean shakes in his kawaii programming socks.

  • @dimanarinull9122
    @dimanarinull9122 4 місяці тому +1

    as a C and C++ embedded SoftEng I'm in the unique position to understand size_t as an important type.
    you see, when making cross platform code that handles memory you need an (usually unsigned) integer type that is guaranteed to line up with pointer types within the system.
    this is done to reduce or avoid conversions when performing pointer arithmetic or storing pointers as address values(see how C handles ++ operator or addition with any type pointers, and why)
    when seeing how those things operate on a basic level you get to understand why those inconsistencies exist, and why for anyone above system/embedded those language types should be used either as a "I just need whatever type here" for things that are not cross platform, or not at all.
    leave it for people like me to know which type to put in the "int64_t" typedef line as we are already making and dealing with stupid system defines on a daily basis and need those system specific types for many things.
    lastly.
    even where I work, no one wants to touch "long", it's a remnant of the transition out of 16bit to 32bit and was therefore 32bit originally. "long" in contrast to "short".
    but what about int? who the fuck even knows at this point? those types were used by people back in the days where the use of typedefs was basically reserved for structs and unions, when token-pasting wasn't even a thing yet, and many more stupid limitations, they didn't know any better.