GitHub Repo: github.com/orosmatthew/hydrog... Keyboard: Keychron V6, Gateron G Pro V2 Brown Switches
Пікірлер: 182
@zokalyx9 ай бұрын
After watching so much "clean code" and "good standards" and "being production ready" in youtube, this feels refreshing. A down to earth coding session for a fun project.
@rodrigoqteixeira7 ай бұрын
nice profile foto 🤣
@5cover6 ай бұрын
props to him for writing code that actually does something. So-called "clean" code is often sparse in terms of actual things being done.
@Time4Technology7 ай бұрын
2:35 This does work, however `&&` in bash will only execute the second command (your echo) if the exit code of the first program is `0`. In your case the exist code is `2`. For this use case, you want to use a semicolon (`;`) instead of `&&` to chain the commands, to have your `echo` run regardless of the first programs exit code.
@kvbc54259 ай бұрын
this is peek content
@grawssАй бұрын
Glad it peeked my interest.
@dhanushg52549 ай бұрын
I think the function peak has to be renamed peek at both files, since peak means the top and peek means to look ahead.
@RED40HOURS9 ай бұрын
I was confused why he named it that way!!
@pixeled-yt9 ай бұрын
u right
@henrikholst74909 ай бұрын
I miss the peek and poke intrinsics from C64 basic! 😅
@RED40HOURS9 ай бұрын
@@henrikholst7490 that is OLD! I wasn't born in those years of Commodore 64 and old computers but I'm fascinated by them!!
@ThsHunt9 ай бұрын
@@pixeled-yt how r u using ubuntu on windows
@zokalyx9 ай бұрын
19:18 Bjarne once said: "There are only two kinds of languages: the ones people complain about and the ones nobody uses"
@henrikholst74909 ай бұрын
To be honest this is a great video. I have a ton of experience from software development but I never tried to make my own compiler. This guy just goes at it. "it's just another program" love the mentality that nothing is too hard to do.
@Rubyboat9 ай бұрын
I really hope you continue this series! its been so fun to stumble along with you
@logixthedev9 ай бұрын
In your Peek() functions, you're not using the 'ahead' value when retrieving the character/token using the .at() function. This could lead to some problems down the road, if it isn't already. Also, afaik from previous attempts at doing this sort of thing, it's a good practice to make sure there's a new-line at the end of the file when you load it (or just add one to the loaded text) so your tokenizer doesn't miss the final token. Could be worth looking into. Loving these videos though!
@minamagdy41266 ай бұрын
Also, the ahead value should default to 0, to coreect behaviour to what is currently expected with regards to the return value if not none. Also, the > should be a >= when comparing the index+ahead with the length, again to preserve correct behaviour.
@Swedishnbkongu5 ай бұрын
Yeah, I was surprised this flew under the radar but I'm guessing trying to keep a train of thought while talking is making it harder for him
@NickMaxwell6 ай бұрын
This is one of the most interesting series I've seen on KZfaq. Just perfectly paced, understandable, great presentation. Thank you.
@nibrobb9 ай бұрын
This is *peak* () entertainment
@nikkehtine8 ай бұрын
This series is so much fun and so interesting. It makes me feel so smart
@dimabelya83389 ай бұрын
I love these vid. i just finished the last one. it was the perfect video to watch after taking the final to computer system and architecture. biggest part of our final project was writing an assebler, so your vid felt perfect to watch next
@tedlasso28879 ай бұрын
This Video series is a great source of learning. Thanks for making. Keep Uploading More Videos like this
@rz23749 ай бұрын
this is a great series, i just finished the last video, excited to watch this one
@ccz82_9 ай бұрын
loving this series so far
@SimGunther9 ай бұрын
The fun to come in parsing is that infix/prefix expressions (why would anyone do postfix in current year?) is done via pratt parsing while statements are parsed via recursive descent or GLR. Wish you good luck and don't let the modern C++ features bring you down!
@angelcaru8 ай бұрын
kzfaq.info/get/bejne/breAZcl1p6_cmoE.html
@unthinkabilities9 ай бұрын
yo this series is awesome. i love programming
@humaneBicycle9 ай бұрын
finally a youtuber that listens. ggs
@1Lobby9 ай бұрын
Such a well done series, looking forward to the upcoming parts. Will you ever use the ahead parameter or your peak (peek) functions?
@_VeljkoMiletic_9 ай бұрын
Again, good video. This can be such a good series!
@MrAndrewtux9 ай бұрын
Such a great series ! ❤
@abrudner9 ай бұрын
9k views with
@lborate35439 ай бұрын
This guy makes my adderall sleepy
@lborate35439 ай бұрын
Maybe the "exit" check should have a space? To be "exit " example of issue String brexit13; Would cause a crash.
@simonzprahy92709 ай бұрын
2:40 possibly the main issue why it did nothing is that && operator executes the next command when the left command ends successfuly (exit code 0) but you are using all sorts of numbers to test it, which however results in basically error as far as the shell is concerned so it does not call echo at all.
@akmalraj1219 ай бұрын
really loving this series ! 🔥
@old_cd_rom95189 ай бұрын
Hey! Nice explanation dude! This vids should become more rated!
@nepp95749 ай бұрын
Nice video:) never tried doing something like this but might just try myself sometime. Some small things I noticed; Modern C++ prefers stringviews over passing const string references. This prevents any copies being made. And since this is a video about writing a compiler… splitting your header files and impementation (CLion can do that quickly for you) can speed up your compilation of your compiler dramatically 😛
@eldyj9 ай бұрын
commenting second part lessgo didn't found any other sussy timecodes 44:20 malloc & free 29:40 lisp langs looks like perfect AST example, they even don't need much explanation: (display (+ 1 (* 69 (- 10 2)))) 11:50 void type exists for no return 10:43 yay my sugesstion from part 1 was mentioned 8:40 you can return '\0' char
@certidailyfacts9 ай бұрын
Loving these videos, as someone who enjoys tinkering and making their own strange languages it's fun! I would say, do you not think for the nodes instead of prefixing with Node it would look better post-fixed with Node? Such as ExitNode, ExprNode. Also, exit in C is defined in cstdlib and is a function (that the compiler does funny things to when it is using due to there being no way to actually express an exit). Maybe lexing and parsing a function call would be better in the long run here. FnCallNode could contain a vector and then it scales a bit. Then you can just hardcode checks for the function name for now to mess. Anyway, good video bro keep em coming
@SimGunther9 ай бұрын
What do you mean "then it scales a bit"? No doubt that having a type for bulletin functions that take in a vararg of "values" and returns a single "value" result makes so much more sense than these raw keywords pointing to an ExitNode or SysCallNode.
@certidailyfacts9 ай бұрын
@@SimGunther Well because they have just begun, I thought that having baseline functionality for functions would make life easier in the long run. Just a simple construct that takes arguments and optionally contains a return value. Then it scales because they can implement more functions without much boilerplate.
@SimGunther9 ай бұрын
@@certidailyfacts That's a similar train of thought I had for that construct. There's a call expression I evaluate to see if the function name belongs to a builtin/intrinsic before calling it as a regular function and not an evaluation of the vector of statements with an environment localized to the non builtin function.
@danielpina70139 ай бұрын
Hey, great series of videos, looking forward for this compiler series. What's your CLION theme? Keep up the great work, and informative series!!!😀
@danielpina70139 ай бұрын
And what font do u use btw?
@pixeled-yt9 ай бұрын
Font: Iosevka Theme: One Dark
@MatthewPurnell8 ай бұрын
46:08 in VSCode it's Alt+Shift+up/down arrows to move lines and Ctrl+L to select multiple lines before moving. Not sure if it's the same in CLion.
@torarinvik49209 ай бұрын
Lol "an abstract syntax snake". Great video, but If one is serious about wanting to learn to write programming languages I recommend learning to compile to C or LLVM. Both of those are cross platform and will generate fast code. Assembly is cool, but really niche at this point and creates countless platform headaches. Btw for those who are scared of C++ one can still write a compiler in python or javascript, and when that is done one can make the compiler self-compile. The best languages IMO for doing this is F# or Rust both have advanced pattern matching and great debugging and testing frameworks.
@toby99996 ай бұрын
I find Rust scary. C++ looks more scary than it need be due to the feature bloat added in recent years.
@torarinvik49206 ай бұрын
@@toby9999 I agree. Rust is really nice, but it takes some time to get used to.
@aloluk8 ай бұрын
I'm seriously sure you get bounds checking with array lookup of an stl vector, ie using []. Its the same thing.
@luis10barbo6 ай бұрын
Great video, Tsoding!
@elkvisАй бұрын
I had the same is never used when I used CLion. It was always annoying, and there doesn't seem to be a way to fix it.
@Dynamic-Productions9 ай бұрын
Had a project to make a language in Java while in school, so this is going to be interesting to follow to see what choices you make! btw, "./out ; echo $?" should work for a one-liner. it'll run the first command before the second rather than together.
@Kiwi-tq2fy9 ай бұрын
&& will only run the second command, if the first one ran successfully (returned 0). Because his program returned 20, the && didn't run the echo.
@Dynamic-Productions9 ай бұрын
@@Kiwi-tq2fy Accurate, better than my late night explanation :)
@starshipx12829 ай бұрын
Great one. Pls keep up thnx 🥰
@idlewise7 ай бұрын
@Pixeled When you edit the test.hy file, why did you need to recompile?
@minimumt3n2049 ай бұрын
this is peek content (bah dum tss)
@mehmetgulcudeveloper4 ай бұрын
What exactly will be the product that will emerge at the end of these videos?
@css21659 ай бұрын
just finished watching pt1. lol
@solomax20119 ай бұрын
Dumb question, but what's that font for code called? I see it sometimes but forget it
@pixeled-yt9 ай бұрын
Iosevka
@weeb32778 ай бұрын
28:40 when you got to this point shouldn't you have written tests to make sure your compiler stays in a working condition?
@divided_by_dia4468 ай бұрын
Do all high level languages generate Parse Trees? I once was in a group project writing a compiler for Prolog in Haskell and we also had to implement sld-resolution, so thats why i wonder?
@pixeled-yt8 ай бұрын
Not necessarily, most c-style languages do. Might not be 100% necessary depending on the syntax of the language like a functional or stack-based one
@divided_by_dia4468 ай бұрын
@@pixeled-yt Thanks :)
@Khanasad_9 ай бұрын
Awesome ❤
@Gibon3459 ай бұрын
Cant you just include everything in a precompiled header and include the pch everywhere (ofc while keeping pragma once)?
@teprox76908 ай бұрын
Wonderful! 👍
@theboydaily2 ай бұрын
12:00 A "const" method could have side effects such as modifying a "mutable" member.
@monad_tcp7 ай бұрын
55:34 another compiler of course
@Draugo5 ай бұрын
Why has no one pointed out that the off by one in peek was because you're checking one ahead for end of string/vector while actually peeking the current character/token. The amount to peek should default to 0 and you should return the character/token of index+amount. Now the amount does nothing and your peek is only accidentally complete when you check if peek+amount is larger than length/size.
@insert91244 ай бұрын
FYI, if you want to do ./out and echo $? on the same line. Use a semicolon insead of && as this: ./out; echo $?
@m4rt_9 ай бұрын
./out $$ echo $? fails because the return code of ./out is non zero. (It doesn't execute following commands if the command fails) What I tend to do is to put them in a bash script and just run the bash script.
@JackieSL99 ай бұрын
You can define the functions without inline. all inline does is tell the compiler to inline the functions contents directly into the place where you call it.
@henrikholst74909 ай бұрын
The only problem will appear if you compile separate object files that has the same thing defined. Use a single cpp or include them like this. You could even error out if the same cpp file is included twice. Avoid header files as they are there just for the problems we want to avoid - multiple compilation units that share code. 😅 A better more suitable keyword would be "static" which makes the function local to the compile unit. I think. It has been ages since I touched C/C++
@Swedishnbkongu5 ай бұрын
inline keyword actually has very little to no affect on the compilers decision to inline for the major compilers. It's more for allowing multiple definitions without violating ODR, therefore allowing implementations of non-template functions in headers. It also has novel uses in static variable initialization
@SGSP3Ай бұрын
@@henrikholst7490 Tbh everything you said here tells me you never knew how to write C/C++ propperly in the first place.
@_slier9 ай бұрын
part 3 when?
@rubycart1239 ай бұрын
every time there is a big change in the code i get about 30 errors and i never know what it wants cuz my compiler is broken
@emdeetee83638 ай бұрын
This is great
@TheRealMangoDev5 ай бұрын
when you use [] if the item in the vector/array/list doesnt exist, itll add it to the vector/array/list. So .at is just a lot better.
@wedarobi9 ай бұрын
2:37 Using && only runs the right hand side if the left hand side was 0. You can run both on one line the way you want by using a semicolon instead, like this: ./out; echo $? 1:03:42 i feel like not inlining everything in headers could've avoided this :^) you'd only need to include the bare minimum in the headers themselves, and then can include everything you need in just the .cpp files
@monad_tcp7 ай бұрын
33:10 yeah, and we though C++ was bad, its just a mini-boss.
@DDlol019 ай бұрын
so... I have been refreshing the channel page every 20 mins on average since i watched this video. just for pt. 3 I have pt. 1 & 2 done before and the explanation was good. JUST the last step is missing for me. How I get the tree to do stuff... EDIT: I do not need _optimized_ code, i need _explained_ code. This is well explained (with some very minor hiccups, : D so cute). [+ minor edits on the phrasing]
@pixeled-yt9 ай бұрын
Check tomorrow morning ;)
@DDlol019 ай бұрын
@@pixeled-yt : O °(^_^)°
@hobrin42429 ай бұрын
I am pretty sure that peak in your context, is actually spelled peek btw
@pixeled-yt9 ай бұрын
Lol, you're right
@hobrin42429 ай бұрын
@@TigranK115 lmao
@aloluk8 ай бұрын
Why do you else after a continue at 1:05?
@MrKomalarn9 ай бұрын
Making a snake from a pe*is made my day
@idlewise7 ай бұрын
@12:05 "Hey it's C++, you know how it works!" - nope
@simonwillover41756 ай бұрын
I would write my compiler in JavaScript, since then no one would have to bother with C-Make and all that other stuff. There are a lot of drawbacks to using JS, but at least it is a lot simpler to run.
@toby99996 ай бұрын
Been doing C++ application development on Windows for 25 years. I never use CMake. Must be a Linux thing?
@theitatit9 ай бұрын
let's gooooo
@henrikholst74909 ай бұрын
I think this stream would be 2x if he did this with pair programming. Feel free to steal my ideas.
@catgirlQueer9 ай бұрын
hey your compiler playlist is backwards
@pixeled-yt9 ай бұрын
Fixed, thanks for letting me know
@barakap23729 ай бұрын
What clion theme?
@pixeled-yt9 ай бұрын
One Dark theme
@Tramontano_T9 ай бұрын
You missed the joke about the ASS - Abstract Syntax Snake
@sigstackfault9 ай бұрын
2:38 ./out; echo $?
@Pritam2527 ай бұрын
He is I guess the first person I ever watched that uses #pragma once, clean code standards are truly something for him..
@monad_tcp7 ай бұрын
17:40 petition the rename unpeek to regurgitate.
@dilipisharaytАй бұрын
Do you heard about two programs called "yacc" and "lex" ? :|
@ruiuniver49 ай бұрын
wonder what is ur keyboard setup?
@SimGunther9 ай бұрын
I think it's QWERTY
@pixeled-yt9 ай бұрын
Keychron V6, Gateron G Pro V2 brown switches
@ruiuniver49 ай бұрын
got u thx a lot!@@pixeled-yt
@ruiuniver49 ай бұрын
lol
@fkeyzuwu5 ай бұрын
tsoding from wish kinda goes hard ngl.
@mateus449 ай бұрын
you shouldnt need any of the inlines, methods defined directly in the class body are implictly inline and shouldnt cause any ODR violations
@Unstableslab479 ай бұрын
21:31 Same
@Unstableslab479 ай бұрын
* 29:31
@sigstackfault9 ай бұрын
I would make way more utility functions, like `consumeWord` or `consumeDigits`
@bitw1se8 ай бұрын
Yeah the code is really dirty
@lakshaydhiman40562 ай бұрын
Bro i think i am too noob. Still i will make my own compiler
@Grynjolf8 ай бұрын
By the way, that's not what the inline keyword means in c++.
@canada66189 ай бұрын
Do you have any plans of making your programming language self compiled?
@pixeled-yt9 ай бұрын
If I can get that far, then sure, that would be cool
@mapron19 ай бұрын
@@pixeled-yt I see no realistic way of doing that if you stick with C++. And not utilize LLVM/binutils and existing STL libraries like libc++. For C compiler it's possible, but for C++, one person, not external dependencies and reasonable time? Yeah, it would not 'be cool' it would be freaking achievement of the century. (well, you can be ambitious ofc!)
@pixeled-yt9 ай бұрын
Well I'm not writing a c++ compiler, I'm writing a compiler for my own custom language which I am bootstrapping with c++
@mapron19 ай бұрын
@@pixeled-yt That is current situation, so for self-compilation you need either 1) change your whole source of compiler to 'new lang'. 2) make your language at least subset of C++. I was discussing the latter.
@bitw1se8 ай бұрын
@@mapron1bootstrapping is just a lot of work. that’s how it is. If you write a minimal compiler first, that compiles a language similar in features to C then you can bootstrap pretty early in development.
@kklowd9 ай бұрын
Ur so cute
@pierwszywolnynick9 ай бұрын
it's "peek" not "peak"
@meomweowКүн бұрын
liked and subbed for the pp
@surgeon239 ай бұрын
28:13 almost fixed it 🙃
@valizeth40738 ай бұрын
Making your member functions inline when you define them directly in the class is redundant, they're already inline. And inline is not a performance related specifier, it's not about inlining, it's about making something avoid the ODR.
@toby99996 ай бұрын
Inlining is also about performance if it eliminates the function call overheads.
@Swedishnbkongu5 ай бұрын
@@toby9999their point is that 'inline' has little to no affect on compiler inlining intrinsics for the major compilers. It's all about ODR (one definition rule - allowing multiple definitions i.e. definitions in header). And the OP is right that member functions should be implicitly 'inline' already IIRC
@vsctutorials83559 ай бұрын
Hi
@air_ballonАй бұрын
9:05
@fraenkiboii7 ай бұрын
wrt pragma once please read cpp core guidelines SF.8!
@LimeLiquide8 ай бұрын
Nice video, but You messed up!
@mike64_t9 ай бұрын
Great video, but if you really want to bridge the gap to the metal, why not directly emit x86 opcodes/operand bytes with a InstructionBuilder abstraction or something and construct an ELF file around that? That removes the last bit of magic imo. Also whenever your compiler stringbuilds instead of going to an IR (or in the final step machine code), you are probably doing something wrong. The only people who have a license to construct compilers THAT horible are the ML compiler people writing everything in python 🙃🙃🙃🙃
@rodrigoqteixeira7 ай бұрын
when I see him using c++ I reallize that java would be perfect if it compiled to an executable... 😅
@toby99996 ай бұрын
I hate java. It's not the best at anything in my opinion.
@rodrigoqteixeira6 ай бұрын
@@toby9999 ar least you came know what the "FileInputStream" class does
@zvch887 күн бұрын
32:48 “…and we’re talking about a formal grammar here, not just your, you know, your simple English grammar like what even is that; English is all confusing. Are there even rules to it at this point there are so many exceptions…” I LAMO’ed when I heard this cause I’ve thought about how terrible English is as well (sometimes I text using parenthesis to group the words to prevent confusion or include sub-notes like what I’m doing now). Lol
@pyyrr9 ай бұрын
create a makefile to make things easier
@nibrobb9 ай бұрын
That is what CMake is for 🥰
@pyyrr9 ай бұрын
makefile is still much easier
@DarkPortall9 ай бұрын
for a guy who's using c++ he seems to really hate c++
@destinydonut8 ай бұрын
that’s just anybody who uses c++
@benebene95258 ай бұрын
Great Video, but i noticed how you moved values AFTER already passing them by copy, which obviously defeats the pprpose of moving
@matthewmurrian95847 ай бұрын
No, it doesn't. You're exactly wrong on this.
@Swedishnbkongu5 ай бұрын
Haven't watched the whole thing, as long as he moves into the constructor, and in the constructor body, then both are moves and no copy
@MrNickolay19864 ай бұрын
consoome()
@Diamonddrake9 ай бұрын
“This will be inline too just because I don’t like writing things in separate files” I don’t think that keyword means what you are implying it means 🤔
@pixeled-yt9 ай бұрын
It allows me to not have to put the declaration in a header file and implementation in a cpp file. The inline keyword allows you to include the header file (with function implementations) in multiple cpp files without the compiler complaining about a "multiple definition" error
@bitw1se8 ай бұрын
@@pixeled-ytYou don’t need to use the inline keyword if you implement methods in a header file. It will be inline implicitly, tho if it’s actually inlined is still up to the compiler.
@SuperDarkBoss8 ай бұрын
Nice series but code is sluggish at best and painful to watch, hope this improves cause the subject is really complex..