i think easiest way to learn how compiler works, or how the computer executes the instructions, is by writing a virtual machine that operates on stack or virtual registers. a draft vm can be written in about 130~ loc, and most topics a person learns while doing a vm, are learnt relatively smooth. also vm is a thing literally every self respecting C streamer did in a spare time
@NotMarkKnopfler5 ай бұрын
That's exactly what I did. Wrote my own Forth compiler in assembly language!
@DeclanMBrennan4 ай бұрын
Smooth? :-) CrowdStrike's VM embedded in a device driver caused an amazing amount of disruption.
@cheesed_up4 ай бұрын
@NotMarkKnopfler Did you open-source the project? :D
@marouaniAymen5 ай бұрын
Thanks for the video, but the link given in the description seems invalid, can you give a valid one ?
@EuphCat5 ай бұрын
You can google "tinyc.c" with the double quotation mark included.
@madbanana225 ай бұрын
why is your system named "fridge"
@Lonely_Wiz5 ай бұрын
to confuse hackers lol
@ThatGuyGEWP5 ай бұрын
how else will it stay cool
@jeremymcadams77434 ай бұрын
Cuz he's chill like that
@aciddev_3 ай бұрын
he liked you and left you ghosted
@WiseWeeabo4 ай бұрын
"in 191 Lines of C" The lines: if (sym == ID) { x=new_node(VAR); x->val=id_name[0]-'a'; next_sym(); }
@cheesed_up4 ай бұрын
I know, I thought the same thing - but I decided to leave the code be as the original author wrote it. I guess we could **improve** the code to make a "compiler in 1 line of C" :D
@DeclanMBrennan4 ай бұрын
Thanks for a very clear explanation. I wonder why all the "goto again" s are included rather than the usual style of using break and placing the switch in a do while loop controlled by a handled bool.
@cheesed_up4 ай бұрын
Glad that you liked the video! I wondered the same thing, but I gotta admit that even using goto's looks pretty clean. Because of this unexpected observation, I don't want to alter the code of these examples if possible. I like seeing different programming styles, even though I don't necessarily like them!
@Qstate5 ай бұрын
I liked when you compiled the compiler.
@atabac5 ай бұрын
link not working, can you put in git?
@MrDomingo555 ай бұрын
Google for a fragment of code eg. sym == WHILE_SYM. That will give you one or more hits for git... One I examined had a comment pointing to original source.
@MrDomingo555 ай бұрын
Use google to search for some possibly unique word or expression from source shown in video. I had no trouble finding multiple references to relevant file and from source file you may find, you can find reference to original author's web site. YT deleted multiple comments I posted and this hopefully stays.
@anon_y_mousse4 ай бұрын
I'm wondering if the link in the description was changed or if the people complaining about it don't know how to copy and paste. Even cell phones allow you to copy and paste from descriptions so I can only assume it was altered. That said, it'd be cool if you took the TinyC code and refactored it. Use more modern idioms and maybe add some optimizations to it. Perhaps turn it into an actual compiler that generates either assembly or a binary object file ready to link.
@cheesed_up4 ай бұрын
Regarding links: KZbin masks them if the channel is not big enough or something like that.
@anon_y_mousse4 ай бұрын
@@cheesed_up If that's what it was, then congrats on getting big enough. Hopefully that doesn't sound weird.
@enriquedelacal28145 ай бұрын
Can you provide a source for the tinyc code? Im afraid the link in the description doesnt work
@cheesed_up4 ай бұрын
Should be there now!
@enriquedelacal28144 ай бұрын
@@cheesed_upthank you so much! Im cheesed to say im subscribed
@vinayakmahajan45135 ай бұрын
How the first compiler was compiled? 🤔
@Melesio-wm9uv5 ай бұрын
The first true compliers were written by hand in assembly/machine code (0's and 1's) by people like Grace Hopper and John Backus.
@chibisuke67315 ай бұрын
thats not a compiler, but an interpreter a compiler would output assember code / binary code
@Joorin47115 ай бұрын
Typically, a compiler is separated into two parts: the front end and the back end. The front end parses the input data, the source code, and generates the abstract syntax tree (and does optional optimizations) and that intermediate representation is handed off to the the back end that generates whatever output is desired. It does not matter if the compiler generates assembly (take gcc for example), bytecode (Java, C# or WebASM) or directly outputs machine code, it still compiled the source code translating it from source code to something that is either directly executable or that can be further worked on to generate something that can be executed. In the case of tinyc, the compiler comes bundled with a virtual machine (like Java, C# and WebASM) that can execute the output from the compiler. So, no, tinyc is not an interpreter, it is a compiler since it performs the work of a compiler.
@nothappyz5 ай бұрын
@@chibisuke6731 they literally talked about this in the first few minutes
@AschKris5 ай бұрын
This is like saying that clang is not a compiler
@antonpieper5 ай бұрын
@@Joorin4711by that logic, all interpreters would be a compiler, bevause all of them use Tokenizers and Parsers
@NotMarkKnopfler5 ай бұрын
Not necessarily. A compiler might output byte code like Java or C#.
@narrowbtw39705 ай бұрын
bel video frate :D
@nothappyz5 ай бұрын
This was awesome
@suou79385 ай бұрын
which font is this? for a second I thought it was comic sands😂
@lankin92175 ай бұрын
It's monospace comic sans...
@imsuck125 ай бұрын
maybe it's comic mono
@suou79385 ай бұрын
@@lankin9217 didn't know such a thing existed...
@BlueSheep955 ай бұрын
It's called Comic Mono
@sean_r5 ай бұрын
from undertable
@NicolasVycasNery5 ай бұрын
The source link is broken, can you fix it?
@ji10465 ай бұрын
Link broken :(
@polarnight-no5 ай бұрын
Very interesting! I found some source code which seems similar here
@ycemilk5 ай бұрын
Where do you find these codes?
@maximkovalkov13345 ай бұрын
FELLOW COMIC CODE ENJOYER 🎉
@cheesed_up5 ай бұрын
Ayy
@CyprianBergonia5 ай бұрын
video looks good, but sound is not clear
@cheesed_up4 ай бұрын
Thanks for the feedback, I'm working on this :D
@gaeshows19385 ай бұрын
What accent is this guy speaking?
@bunny.bunbob5 ай бұрын
russ/slav
@brentpappas40555 ай бұрын
Concise though I think this would be a bit terse for a beginner. Good for a KZbin video though. Also the amount of code on each line is way too much for me, I’m too used to clang format haha
@cheesed_up4 ай бұрын
Yeah, I also think there is too much stuff on one line a lot of times. I wanted to format the example using clang, but then I decided to leave it as is. I think it's sometimes interesting to see how other people organize their code :D. BTW - regarding formatters - if I saw code formatted like this on a project I'm working on, I'd probably snap!
@clojurediary5 ай бұрын
Wow!
@Paxsali5 ай бұрын
I don't understand why there is no LISP like low-level programming language. If the syntax was a LISP, then the compiler would not have to worry about converting tokens into an AST, because who cares about that anyway? The job of the compiler is to produce portable or optimized code, not do re-invent wheels. Imagine a C like low-level systems programming language that forces their users to write in a LISP like syntax, so that the context of any number of operations and functions is crystal clear for the compiler (and unambiguous). The compilers would have a lot less complexity that way and can focus on stuff that makes them "magic" (all the implicit re-writes and transformations that makes code faster). Just my thoughts that were spontaneously popping in my head as I was listening to this video...
@DeclanMBrennan4 ай бұрын
Crystal clear to the compiler but hard on the human with *L* ots of *I* rritating *S* uperfluous *P* arentheses. 🙂 (A very old joke).
@0LoneTech3 ай бұрын
Lisp is low level on the Lisp machines. Otherwise have a look at RPL; sysRPL is the assembly language for the machines that run it, and it's inspired by Forth and Lisp. Forth has an extremely simple compiler that doesn't use any AST, and colorForth is the assembly language for GreenArray computers. Open Firmware also runs Forth, though it uses a bytecode interpreter (allowing it to be CPU architecture independent).
@TopchetoEU4 ай бұрын
for the love of christ never show your code publicly again