Code Review: Holy C Lexer

Поділитися
Вставка
  • Опубліковано 21 лис 2024

КОМЕНТАРІ •

  • @tedchirvasiu
    @tedchirvasiu Рік тому +802

    "I'm a white man, I write my own compiler"

  • @larryluck7305
    @larryluck7305 Рік тому +502

    RIP Terry A Davis 🙏

    • @DarkerCry
      @DarkerCry Рік тому +39

      Such a tragic story, the guy was truly amazing

    • @shojauddin2509
      @shojauddin2509 Рік тому +4

      @@DarkerCry he was genius but he wasn't that amazing as a person, he said lots of racist stuff in his times

    • @DarkerCry
      @DarkerCry Рік тому +36

      @@shojauddin2509 lol

    • @leaveleague3491
      @leaveleague3491 Рік тому +17

      @@shojauddin2509 still a genius

    • @mr.billthrower7392
      @mr.billthrower7392 Рік тому +1

      @@shojauddin2509 You do know that the nigga had schizophrenia right...

  • @simonfarre4907
    @simonfarre4907 Рік тому +209

    2:05 - you guys say "the way its laid out now is bad". How so? I think you probably didn't think this through. A pointer to U8 is not byte sized. It is, 32 or 64 bits depending on the platform. Its kinda funny that you both say "it's categorically bad". Codefluencers do what codefluencers do 😊

    • @orbital1337
      @orbital1337 Рік тому +16

      They didn't see the pointer - that shitty C syntax of putting the pointer on the identifier instead of on the type is to blame. The variable declaration syntax in C is such a horribly messed up disaster.

    • @simonfarre4907
      @simonfarre4907 Рік тому +3

      @@orbital1337 it is on the type though; but I think I get what you mean. You want *u8 instead of u8*.

    • @orbital1337
      @orbital1337 Рік тому +16

      @@simonfarre4907 No, in C and C++ (and presumably Holy C) the * does not go on the type. For example, you can write "int *x, y, *z;" and this declares an int pointer x, an int y (!) and another int pointer z. This is a very useful feature of C if you hate your colleagues and/or want to increase your job security by making your code less readable. Like seriously, who thought that was a good idea?
      Anyways, in the code in the example, this style is used so the first variable is declared as "U8 *input" instead of "U8* input". With the way the text is aligned, that makes it look like the types are U8, U64, U64, U64, U8 if you're just skimming over the code.

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

      @@orbital1337 Yes it does. It depends on how you read them. int a* would have been "not on the type". But following the type, means it's part of the type sequence.
      The rest I certainly agree with. But they did not get it until later in the video.

    • @nameq
      @nameq Рік тому +15

      not the only mistake they made

  • @johanngambolputty5351
    @johanngambolputty5351 Рік тому +268

    In unholy c, you have to tip your fedora to get any memory... m'alloc

    • @wchen2340
      @wchen2340 11 місяців тому

      #define NULL ((void *)0x666)

    • @JasonMitchellofcompsci
      @JasonMitchellofcompsci 9 місяців тому +23

      That is the most un-temple os thing I've ever heard.

    • @catlolis
      @catlolis 6 місяців тому

      shut up

    • @soothsayerslunk1
      @soothsayerslunk1 6 місяців тому +12

      You been comprised by the glow in the darks

  • @angelcaru
    @angelcaru 6 місяців тому +56

    The title for this is kinda confusing. When I read "Holy C Lexer" I think "the lexer for Holy C", not "some random lexer that happens to be written in HolyC"

  • @tomkayak9752
    @tomkayak9752 Рік тому +43

    Wow, Terry Davis. I did just go down that rabbit hole.

  • @Endelin
    @Endelin Рік тому +87

    I'm going to name my next videogame character Malloc Numerick.

    • @themannyzaur
      @themannyzaur Рік тому +9

      Me seeing this some time in the future and just laughing my ass off because I know where it's from 😆

  • @slendi9623
    @slendi9623 Рік тому +150

    I love how people got confused by U0, yes HolyC has both I0 and U0. Idk the difference really other than its different types. Also, classes can have at most 1 level of inheritance

    • @RotatingBuffalo
      @RotatingBuffalo Рік тому +15

      i'm fairly sure it doesn't have I0, as it would be the same as U0. also I looked it up and have not seen any evidence to the existence of an I0 type.
      regardless, the purpose of the type is the same as "void" in standard C, although sizeof(U0) is 0, and sizeof(void) is 1.

    • @yjlom
      @yjlom Рік тому +7

      @@RotatingBuffalo sizeof (void) is implementation defined I'm pretty sure
      edit: actually it must be undefined since pointer arythmetics on void *is illegal outside of GNU extensions

    • @8ightfold
      @8ightfold Рік тому +1

      @@yjlom sizeof(void) is nonstandard, not imp defined. It's ill formed, don't use it :P

    • @slendi9623
      @slendi9623 Рік тому +9

      @@RotatingBuffalo Both I0 and U0 exist, execute CDoc *doc = DocNew("::/Dump.DD"); Who("m",,,doc); DocWrite(doc); then Ed("::/Dump.DD"); this dumps the hash table and you can then search for I0.

    • @slendi9623
      @slendi9623 Рік тому +5

      @@yjlom sizeof(U0) and sizeof(I0) are both 0, sizeof(U64) is 8.

  • @SimGunther
    @SimGunther Рік тому +89

    That case range in the switch statement is one of the MANY things that make it truly "holy" ❤

  • @minciNashu
    @minciNashu Рік тому +49

    Why the hate for u64 as length? It's equivalent to size_t on 64-bit targets, which is what's used for container size.

    • @mattymerr701
      @mattymerr701 Рік тому

      Or uint64_t right?

    • @YourMom-rg5jk
      @YourMom-rg5jk Рік тому +27

      people like to over-complicate things. modern software is a god damn clusterfuck

    • @maksymiliank5135
      @maksymiliank5135 10 місяців тому +16

      @@YourMom-rg5jkSounds like something Terry Davis would say

  • @aichrist
    @aichrist Рік тому +53

    Rest in Peace Terry! I've been working on a tutorial series. Hopefully more apps in HolyC soon :)

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

      I see you followed through. Good job.

  • @ghostbusterz
    @ghostbusterz Рік тому +51

    2:10 - TempleOS is 64-bit, meaning addresses (pointers) are 8 bytes. Thus, the Lexer class is laid out correctly if the concern is optimal packing.
    8 bytes
    8 bytes
    8 bytes
    8 bytes
    1 byte

  • @kurt7020
    @kurt7020 Рік тому +56

    Reminds me of "clang" being pronounced "C-lang". It's called "clang" (like the sound) by the project deveopers.

    • @aasquared8191
      @aasquared8191 Рік тому +6

      dude, it's not a holeyck. its definitely holy c.

    • @thego-dev
      @thego-dev Рік тому +8

      @@aasquared8191 i think they're talking about the "MAlloc" situation, but okay

    • @astroid-ws4py
      @astroid-ws4py Рік тому

      We also have flang.

    • @JafacaksWasTaken
      @JafacaksWasTaken Рік тому +3

      its holy c like holy see, the jurisdiciton of the pope

    • @sqlexp
      @sqlexp Рік тому

      It should be pronounced as Holy Shee or Holy Chez💩

  • @Endelin
    @Endelin Рік тому +59

    As a kid I thought the word "prevent" meant "to start". So Smokey the Bear's PSA of "Only YOU can prevent forest fires" was super confusing.

  • @pubwinner7867
    @pubwinner7867 10 місяців тому +59

    Pseudo intellectuals mocking holy c vibe. i cant keep watching

    • @TheVimeagen
      @TheVimeagen  10 місяців тому +31

      i think calling me a pseudo intellectual is an insult to pseudo intellectuals

    • @LanceWillMakeIt
      @LanceWillMakeIt 10 місяців тому +6

      wasn't ready for that 😂@@TheVimeagen

  • @almighty1984
    @almighty1984 Рік тому +13

    I remember making Quake maps and not knowing what "nonsolid" meant

  • @alkeryn1700
    @alkeryn1700 Рік тому +19

    actually you can use the "..." range when using clang, many compiler implement it but it isn't part of the standard !

    • @BanakaiGames
      @BanakaiGames Рік тому +7

      It's from gcc, the flag for it in clang is even gnu-case-range

  • @onioncontrol
    @onioncontrol 10 місяців тому +8

    RIP Terry. I hope I'll get to meet you when I leave this earth. God Bless everyone. If you're schizophrenic please don't let yourself degrade as bad as Terry was twords the end.

  • @u9vata
    @u9vata Рік тому +8

    HolyC also have other trickeries that are handy actually...

  • @anispinner
    @anispinner Рік тому +11

    Case range in the switch statement? Holy C... Why the F C didn't have that

    • @JasonMitchellofcompsci
      @JasonMitchellofcompsci 9 місяців тому +2

      That's what Holy C is. C++ threw the kitchen sink at C. Holy C just added the obvious stuff. Also it can be repl'd.

  • @JasonMitchellofcompsci
    @JasonMitchellofcompsci 9 місяців тому +13

    As for the reason for the U64 instead of U32. Basically the since HolyC is newer than 64 bit processors and it's a fresh start with no historic unix code the idea is there is never a reason for 32 bit anything.
    The whole point of TempleOS is to come in with no standards and start new. This is one of the reasons it doesn't do networking. Then it would have to accept insert random list of RFCs. Nope. It is forbidden to code RFC or ISO anything in TempleOS. Unless you can personally invent it you shouldn't code it.

  • @plagiator19
    @plagiator19 5 днів тому +1

    I think these guys glow in the dark

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

    Doesn’t that dude on the right believe he is a “god” programmer (at least how he talks on his streams) and he didn’t even fcking know malloc was “memory allocation”?😂

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

      the only god programmer is terry imo

  • @therealsunnyk
    @therealsunnyk Рік тому +7

    "It looks like Go"... err... it looks like C?

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

    Chat blew up about U0 being used in place of void and they didn’t even notice

  • @MACAYCZ
    @MACAYCZ Рік тому +6

    5:50 In fact gnu extension added support for that.

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

    terry himself referred to it as "malloc" og terminology

  • @asdfasdf9477
    @asdfasdf9477 Рік тому +24

    Let’s just pray that MAlloc never fails.

  • @cadetsparklez3300
    @cadetsparklez3300 8 місяців тому +2

    get the word rust off my holy c

  • @zenedge7599
    @zenedge7599 Рік тому +5

    R.I.P. Terry A Davis

  • @TeH.j0keR
    @TeH.j0keR 2 місяці тому

    I can imagine Lex Fridman writing his own compiler, like a machine.

  • @KadenCartwright
    @KadenCartwright Рік тому +6

    Is that TPope in the background 😂💀

  • @deleted-test
    @deleted-test Рік тому +9

    i want to make a linux window manager in holyC. i know nothing about holyC. I barely know anything about C.
    i will come back to this comment once i reach my goal, be it months or years.

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

      are you there yet

    • @deleted-test
      @deleted-test Рік тому

      @@leehaswell4206 bruh i commented 3 days ago and you responded yesterday :skull: no way im that quick

    • @paulmccartney2327
      @paulmccartney2327 Рік тому +2

      It's been a long goal of mine to write an interrupt routine in Haskell. Wish me luck guys !!!!!!!!!!!!!!!!!!

    • @LanceWillMakeIt
      @LanceWillMakeIt 10 місяців тому +1

      are you there yet

    • @deleted-test
      @deleted-test 10 місяців тому

      @@LanceWillMakeIt not yet. :>

  • @nameq
    @nameq Рік тому +37

    honestly impressive how little you know for what and how youre doing

    • @szymoniak75
      @szymoniak75 Рік тому +8

      exactly

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

      ​@@szymoniak75 peak dunning-kruger codefluencers
      theyre probably not too dumb but the confidence is repulsive

    • @AKA-077
      @AKA-077 10 місяців тому

      what do you mean

    • @The_Conspiracy_Analyst
      @The_Conspiracy_Analyst 10 місяців тому +7

      Yeah this is what stood out for me as well

  • @steveg1961
    @steveg1961 Рік тому +6

    I've always pronounced it "MAL-loc." That just seems the right pronunciation. Knowing, of course, it is a memory allocation.

  • @moosethemucha
    @moosethemucha Рік тому +5

    I've seen several of these now - whats the context ? What is this code for - is it a coding golf challenge thing ? Who's writing this code for the review ? It took me so long to work who Tom was - he'd know though as he's a genius.

    • @joraquest2306
      @joraquest2306 Рік тому +2

      lmao I dont know why they are doing it but the codes are written by viewers

    • @replikvltyoutube3727
      @replikvltyoutube3727 Рік тому +9

      I think it's following a book about making parser. It's a thing Primeagen wants to make programming language speed competition with in 'real-ish world' scenario.

    • @reo101
      @reo101 Рік тому

      ua-cam.com/video/gsrNrlA-dog/v-deo.html

    • @InvidiousIgnoramus
      @InvidiousIgnoramus 10 місяців тому

      @@joraquest2306 I highly doubt Terry A Davis came back from the grave to send his code to these literally whos.

  • @scrawnydaghost
    @scrawnydaghost Рік тому +4

    I have no idea what any of this means but my faith in God has only grown watching it

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

    The monkey lexer is a module in the Elixer lib? Which distro are you running?
    Nice feature talkie-talk. Was it about ~100 LoC? A bit tóó bounded for Terry's multi-decade project.
    Looking forward to the next feature. Tokenization compared to TS-Rust-Zig-deez?

  • @FastRomanianGypsies
    @FastRomanianGypsies Рік тому +2

    maya hee, maya hoo, maya ho, maya haha! numa numa eric

  • @meowrbius
    @meowrbius Рік тому +5

    Legend ‎Terry and his legendary language

  • @osamaaj
    @osamaaj Рік тому +6

    3:33 always make sure malloc returns a valid pointer before proceeding to use it.

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

      Actually, in Holy C we use a faith-based system. If you're not a sinner you always get a valid pointer back!

    • @osamaaj
      @osamaaj Рік тому +6

      @@TonKcedua my bad. Guess I need to work on my faith 🛐

    • @slendi9623
      @slendi9623 Рік тому +3

      templeos is so lightweight, malloc never fails, also throws 'OutMem' if fails

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

    When are you going to review the Jai code?
    I might try to quickly get it done before you review it.

  • @DNA912
    @DNA912 Рік тому +2

    have to come clean. I also didn't realise malloc was MAlloc

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

    Hey is there a place where I can see all these submissions? I think they would be a really great source for referring any new language

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

    tsar + coding = tsoding lol

  • @GerbenWijnja
    @GerbenWijnja 6 місяців тому

    TempleOS supports images inside text files. Like, you can have an animated gif in your source code file.

  • @NikolaNevenov86
    @NikolaNevenov86 Рік тому +7

    wtf....first time I saw `malloc` I was..."Oh it's - memory allocate". Still malloc sounds better than M-Alloc. Like some people will pronounce char as "car" or "khar"... it's char, short from "character".

    • @illyias
      @illyias 11 місяців тому

      Let's be real, the entirety of C's naming convention is a disaster from start to finish. There's nothing redeemable here either way.

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

    *FACT: The Pope is also known as the "Holy See"*

  • @anon-fz2bo
    @anon-fz2bo Рік тому +1

    suppose the func StrNewN took in a buffer of 3 characters and the size arguement was the length of this buffer.
    that implies that the first line in this function is an array of 4 bytes right? malloc(sz + 1) == malloc(3 + 1) which means allocate 4 bytes in this case from my understanding.
    then copy the contents of the input buffer into the newly created output buffer & null out the final index of that character array effectively making a c string ie a string that ends will a null byte then simply return this string.
    what i dont get is why alloc 4 bytes instead of 3? im assuming the extra byte is used to assign the null byte.
    if output now has a length that is == input and input was an array of the chars "abc" then out[sz] is actually out[3] which hes setting to be equal to '\0'. you would get an indexing error in most languages coz the compiler would say something like index out of bounds in this case but im assuming thats why he allocated 4 bytes instead of 3 for the out buffer?

    • @NoodleFlame
      @NoodleFlame Рік тому

      So possibly zero indexing and length variables are causing some confusion here? Following your example:
      If StrNewN took in a buffer of 3 characters and the size argument was the length of this buffer 3 then....
      Yes that does allocate an array that can occupy 4 chars, 3 from the buffer passed in and an additonal char '\0' for the delim. The valid index range being 0..3 inclusive (4 in total).
      If the input was "abc" then after the MemCpy the output would look like this:
      out[0] = 'a'
      out[1] = 'b'
      out[2] = 'c'
      And then it terminates the c string at index sz which we passed in as 3 and because we have extended the array by 1, we know that the previous length is now the maximum valid index.
      out[3] = '\0'
      Hopefully that clears things up a little

    • @maksymiliank5135
      @maksymiliank5135 10 місяців тому

      C represents the string with a zero byte (0x00, '\0') at the end to indicate that it is the last byte of the string (that's why it's called "zero-terminated string"). So If you want to get the length of a string, you have to count the number of bytes until you find zero byte. Usually the zero byte is not counted to the length, but you have to allocate one additional byte in a buffer and set it to 0, because a lot of functions in c expect a zero-terminated string.

  • @livingfreely
    @livingfreely 5 місяців тому

    Regarding the spread operator in the switch case:
    Terry Davis was explaining this and said roughly that this is the hardest question in programming to decide if things like these are either "divine intellect or n-word-licious."

  • @distant6606
    @distant6606 Рік тому +6

    wheres go 🧐

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

    Bro looks like Sirius Black

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

    I am so sad i missed the stream i wouldve flexed holyc's switches and running holyc in the preprocessor being able to streamprint into the compiler input

  • @etzerdlasgaudistuben5300
    @etzerdlasgaudistuben5300 9 місяців тому +2

    you are normies that didnt understand the holy c

  • @georgecop9538
    @georgecop9538 Рік тому +6

    Then why is not MemAlloc, to align with MemCpy?

    • @themannyzaur
      @themannyzaur Рік тому +4

      To make it easier for C programmers to know which functions to use and such I guess
      So malloc = MAlloc and MemCpy = memcpy

    • @SimonBuchanNz
      @SimonBuchanNz Рік тому +4

      Because the original C only looked at the first 6 characters of the name. You could make it longer, but it would ignore anything past that silently.
      Another fun detail is that struct fields were unscoped, so if you had two "name" fields the compiler just picked one of the offsets and used it for any ".name" in the source.
      They *really* believed in "Worse is better" back in the 70s!

    • @aahnecroth
      @aahnecroth 11 місяців тому

      because god said "no!"

  • @ultraderek
    @ultraderek 7 місяців тому

    Holy Malloc Vim-man.

  • @timokreuzer381
    @timokreuzer381 6 днів тому

    Every US developer I know would pronounce every acronym as if it was a legit word. Be it "malloc" or "URB" and "IRP" (which sound exactly the same). And people made fun of me, when I pronounced "GUID" as "Gee-U-I-D", and since I'm German my manager couldn't resist making bad jokes about "Jew-ID". Especially when jewsh devs were present. Man, that were the good ol' times 😅 Good thing I'm retired though.

  • @h4ndle_yt
    @h4ndle_yt 5 місяців тому

    What do you think the King would say while watching these two monkeying around while reading his code hmmmm

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

    only God can criticise Terry's code

  • @aasquared8191
    @aasquared8191 Рік тому +11

    BASIC when's't

  • @RandomGeometryDashStuff
    @RandomGeometryDashStuff Рік тому +2

    05:39 it's c gnu extension

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

    Classes are from the lord😂😂

  • @sixthsurge
    @sixthsurge 6 місяців тому +1

    everyone knows malloc is short for mallocate

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

    goto is only problematic if you write your whole application within a single function. you can't goto across functions as far as i know. that's setjmp/longjmp. if you follow good programming practices goto is a great statement for simplifying messy control flows.

  •  10 місяців тому

    ALL HAIL THE GREAT M'ALLOC

  • @tru2thastyle
    @tru2thastyle 5 місяців тому

    Terry was a genius.

  • @albuquerquehotspot7835
    @albuquerquehotspot7835 Рік тому +2

    Terry had the … spreading operator decades before ES6 JS 😯

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

    There is calloc and realloc as well

  • @gnuemacs1166
    @gnuemacs1166 6 місяців тому

    What Git did u pull from ?

  • @mattiapalmese2971
    @mattiapalmese2971 Рік тому +3

    3:45 it's called "malloc" in real C (or holy) and not "mfree" because "mfree" would be calloc.

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

    straight from god himself, isnt it weird how no one uses holyc in prod?

  • @rnrbishop
    @rnrbishop 24 дні тому

    I mean terry was right, linux types are confused by anything not pretending to be a 70s mainframe.

  • @LukeNewcomb
    @LukeNewcomb Рік тому

    malloc is a word.

  • @lowlevelcodingch
    @lowlevelcodingch 6 місяців тому

    did he say Tsoding?

  • @plato4ek
    @plato4ek Рік тому

    Can anyone explain me the joke about nUmeric vs numEric? Is there a different meaning for the former? (Not a native speaker.)

    • @justinwinch6275
      @justinwinch6275 Рік тому +3

      They don't mean different things, it's just that the typical pronunciation is the latter (emphasis on the "er" syllable, not "num") so it sounds weird saying the former. Since he'd only seen "numeric" written in code and not said out loud, he never learned the correct pronunciation for several years until he finally said it out loud and someone corrected him.

    • @illyias
      @illyias 11 місяців тому

      ​@@justinwinch6275 The joke is more than that. He'd only ever seen it spelled out, so he thought it was some special programmer lingo - a "numeric". Only afterwards, he realized it's a totally normal word.

  • @szymoniak75
    @szymoniak75 Рік тому

    what did i just watch?

  • @adityathapa2187
    @adityathapa2187 9 місяців тому

    How to learn holy c

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

    I bet you can't even see them glow in the dark smh tbh

  • @whoopsimsorry2546
    @whoopsimsorry2546 11 місяців тому

    U8 * has 8 bytes size

  • @mosomiliardaru
    @mosomiliardaru Рік тому

    tom is a genius, his language is better than this

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

    Ameno/10

  • @julianranieri6014
    @julianranieri6014 Рік тому

    It's absolutely malloc idgaf

  • @rust5427
    @rust5427 6 місяців тому

    these guys are so hot

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

    If you are this dumb about Terry Davis, then you should not be covering his language.

  • @bullpup1337
    @bullpup1337 10 місяців тому

    why does he think holyc is from the 80s? and why does he say “they” pretty sure terrys preferred pronouns was he him lol

  • @fahadali1372
    @fahadali1372 5 місяців тому

    read about islam

    • @ahhfdhxhdj5312
      @ahhfdhxhdj5312 5 місяців тому +1

      why would he want to read about a demon possesed pedophile

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

    Holy C has no class inheritance.

  • @ІлляМіхневич
    @ІлляМіхневич 4 місяці тому

    @tsoding mentioned

  • @julienc.8562
    @julienc.8562 Рік тому +2

    ThePrimeagen referencing @ts0ding ❤