Military Grade Build Tool for C (Nob Ep.02)

  Рет қаралды 27,866

Tsoding Daily

Tsoding Daily

Күн бұрын

Previous Episodes: • Music Visualizer
Chapters
- 0:00:00 - Announcement
- 0:00:56 - Intro
- 0:15:10 - Adding Build Configuration
- 0:40:44 - Generating Build Config File
- 1:18:31 - Parsing Build Config File
- 2:00:24 - Testing on Windows
- 2:06:09 - Outro
References:
- Tsoding - musializer - github.com/tsoding/musializer
- Tsoding - nobuild - github.com/tsoding/nobuild
- mstorsjo - msvc-wine - github.com/mstorsjo/msvc-wine
Socials:
- Twitch: / tsoding
- Twitter: / tsoding
Support:
- BTC: bc1qj820dmeazpeq5pjn89mlh9lhws7ghs9v34x9v9

Пікірлер: 131
@danidotexe_
@danidotexe_ 8 ай бұрын
If C has a million fans, then I am one of them. If C has ten fans, then I am one of them. If C has only one fan then that is me. If C has no fans, then that means I am no longer on earth. If the world is against C, then I am against the world.
@sinamobasheri
@sinamobasheri 8 ай бұрын
Are ypu high brother?
@zahash1045
@zahash1045 8 ай бұрын
Holy C
@badstep495
@badstep495 8 ай бұрын
C only fans
@phitc4242
@phitc4242 8 ай бұрын
C gang
@fedang
@fedang 8 ай бұрын
Real
@merthyr1831
@merthyr1831 8 ай бұрын
nobuild is unironicallly a very cool tool. I wish more c/c++ devs didn't make you learn cmake or ninja or whatever to get a project running
@monad_tcp
@monad_tcp 7 ай бұрын
I know too much about the inner workings of CMake for my own sanity. I had enough the other day, so I made another build system Now I have this insanity: Lua -> CMake -> Ninja -> Clang -> CMake -> MSBuild -> Clang/CC (*4) -> Bazel/Buck (*1) -> Ninja -> Clang -> Bazel/Buck (*1) -> CMake (*3) -> Ninja -> Clang -> Bazel/Buck (*1) -> CMake (*3) -> MsBuild -> Clang/CC -> GN (*2) -> Bazel (*1) I have my own custom python builder that can work with both (*2) Sometime I hate people from Google (*3) yes, don't ask why (*4) of course I also use Clang with MSBuild, why not All of that because I use both OpenCV and Tensorflow and I need whole-program optimization, so I need to compile everything.
@robmorgan1214
@robmorgan1214 6 ай бұрын
It sucks but is necessary. When you touch C, you touch metal. This means you need tools regardless of which OS you're compiling it for. Different HW but portable code means different linking and different compiler macros. It is a limitation of the physical world vs. an interpreter on an abstract machine.
@julians.2597
@julians.2597 2 ай бұрын
​@@robmorgan1214then how do rust and zig manage to do it? Zig can even build C
@fiona9891
@fiona9891 28 күн бұрын
​@@robmorgan1214 there is no reason a c build script would not be able to do that
@Vulto166
@Vulto166 8 ай бұрын
This is my favorite project on your repo. I hope it receive more love in future.
@Vulto166
@Vulto166 8 ай бұрын
It would be good imo if you make a list of benefits of using nob as build system. Most people never realize how important and versatile it is until someone says that.
@bfitzger2
@bfitzger2 8 ай бұрын
I love it. It looks like nobuild is trying to reproduce what Zig and Swift have - completely integrate build systems that are for all intents and purposes built into the compiler. A Zig build script is a Zig source file, a Swift build script is a Swift source file (and I think Jai also does this). I think this is the best way to do a build system for a language, and someday I'll figure out how to do this for multi-language projects (Zig is inching towards this, but with Zig as the primary, I think all the languages should be on equal footing).
@sebc521
@sebc521 8 ай бұрын
Another amazing video, bravo.
@xdman2956
@xdman2956 8 ай бұрын
the entropy thing is interesting. In an assignment to create radio sender and radio receiver programs (to have radio stations "transmitting" over the network) the sender was the 100x easier part. The receiver had to worry about packet ordering, deviations from protocol and missing packets. Looks like the same principle
@legendrags
@legendrags 5 ай бұрын
This single man made me learn C and make my own build system. What a chad
@blastygamez
@blastygamez 8 ай бұрын
Ur one of my favorite programmers on yt, keep it up!!
@MouldySoul
@MouldySoul 8 ай бұрын
out of interest who are your others? I don't have plural, this dude's like Jimi Hendrix when I was 16 to me.
@alh-xj6gt
@alh-xj6gt 5 ай бұрын
Like the philosophical take on increasing or decreasing entropy 1:34:00 as in it takes only seconds to vomit yet it take several minutes - or depending on the fabric involved several hours - to thoroughly clean it all up.
@satchelfrost6531
@satchelfrost6531 8 ай бұрын
I really love this idea.
@cenntraru
@cenntraru 8 ай бұрын
23:18 reminds me the saying: Every sage writes the same book.
@maxsilvester1327
@maxsilvester1327 8 ай бұрын
What does this saying mean? Google doesn't show any results.
@killianperlin8276
@killianperlin8276 8 ай бұрын
Your framework idea reminds me a lot of Cello (libcello), very interesting project imo.
@kibels894
@kibels894 8 ай бұрын
Use nob to bundle your utility headers into the nob.h header. So like mongoose web server your repo has checked in both the build artifact nob.h, but also nob.c as the build script, and src/ folder with all your header libraries. Then when you run nob.c, it rebuilds nob.h from src/, and you commit that along with changed sources. You can replace shitty glibc and make in one repo
@Marco-pz5dx
@Marco-pz5dx 8 ай бұрын
Love the "Buy more RAM lol!!" to handle out-of-memory by the way ahaha (around 09:00)
@8Trails50
@8Trails50 8 ай бұрын
This dude is the goat
@D_VAULTZ
@D_VAULTZ 8 ай бұрын
You did it again son! King Tso Ding brap brap
@simonl1938
@simonl1938 8 ай бұрын
I'd love to see something like an extension of C with namespaces and maybe some other minimal but useful things that would fit well with C. Maybe call it C+ :^).
@theevilcottonball
@theevilcottonball 8 ай бұрын
// Cursed namespaces // main.c #define prefix(name) np##name #include "numpy.h" ... // numpy.h #ifndef prefix #define prefix(name) name #endif typedef struct { size_t nlength; char* data; } prefix(arra1dy); prefix(array1d) prefix(zeroes)() { ... }
@theevilcottonball
@theevilcottonball 8 ай бұрын
Don't
@theevilcottonball
@theevilcottonball 8 ай бұрын
yeah. It's funny that few C killers do not take the superset approach: Zig, Odin, Hare, Jai, V, Vale, Val, Beef, C2, C3, ... all make their own language
@RobinHood-yk8og
@RobinHood-yk8og 8 ай бұрын
C More vs Lega C "build it and they will come." The standard for C came after the language was developed, but people seem to think "we cant just build something new, we have to accept how it is." This guy is proving that you can do whatever you want. If enough people did the same thing, and built tools for C, with C, then the standard has already changed and it's just waiting for the ANSI & ISO folks to catch up. "Just" (yeah, I know) needs a compiler to be built and/or modified to accept the new features.
@JoStro_
@JoStro_ 8 ай бұрын
@@theevilcottonball Odin actually started from the creator of it trying to make an improved C, it lead him to come to the conclusion that he'd be better off making his own language instead, hence Odin was born.
@JonnyDeRico
@JonnyDeRico 8 ай бұрын
Smells like your work will introduce the end of java. You are my hero D:
@RenderDragon
@RenderDragon 8 ай бұрын
People program in java not because of complexity of existing build systems for C
@JonnyDeRico
@JonnyDeRico 8 ай бұрын
@@RenderDragon so it is, because they don't understand pointers?
@sandworm9528
@sandworm9528 8 ай бұрын
​@@JonnyDeRicoliterally yes 😅
@bbq1423
@bbq1423 8 ай бұрын
Think you'll a lot of the benefits from unit caches just using ccache. Otherwise you'll need to generate a dep file (-MD flag I think) and store it somewhere, then check if any of the dependencies changed too. (say for example foo.h changed but not foo.c)
@monad_tcp
@monad_tcp 7 ай бұрын
7:44 this is really good, I hate shell scripts, I would totally use C directly
@lievenpetersen
@lievenpetersen 8 ай бұрын
I still think, the return value of your run command async function should be bool (if it isn't already), just to keep in line with the rest of the library.
@kwyrky
@kwyrky 8 ай бұрын
Just leaving this military grade comment here: Good stuff!!!
@drdca8263
@drdca8263 8 ай бұрын
1:34:33 : this bit about how parsing a format taking more work than producing it, I think makes sense, to the degree that I think it should maybe be possible to express as a theorem, but, I’m not sure how to formulate it. Hmm... Well, what if you just like, take your struct or whatever, like, whatever region of memory you have, and just, write those bytes to a file? I suppose an issue with that is that if your data structure isn’t a fixed-size struct on the stack somewhere, and is instead something which contains pointers to things of varying size on the heap, (or more generally, if it contains any pointers at all), then you can’t really just directly load it from the file and expect it to work. Hm, I suppose in that case, you *could* like, when writing it to the file, concatenate all the regions of memory together, and like, replace all the pointers in it with pointers relative to the start of the resulting blob of data... and then, when loading it, if you just loaded the file into memory, that would *almost* work, except you would need to have to add the base-point to all the pointers before dereferencing them. Well, I suppose, if it also had like, at the start of the blob, a number indicating the number of pointers to fix (by adding the address of the start of the region of memory), followed by a list of the (relative) locations of these relative-pointers, the loading from the file could consist of: 1) reading the file into memory 2) looping through the list of relative-pointers and converting them to actual pointers 3) casting the location of the next byte after this list, to the type for the head object of what was loaded And this seems like it would be pretty short, independent of the details of the structure, and, probably substantially simpler than creating the file? However: it would have absolutely no error handling! Perhaps *this* (the need to handle the possibility of invalid data) is what is responsible for the extra effort needed when parsing some encoded data? Or, it could instead be the mismatch between human-readable format and in-memory format? Edit: actually, I think probably for many kinds of data, if one cared not at all for error-handling, the parsing of the representation could exactly mirror the production of the representation? Write-string, read-string. Write-Int, Read-Int. Really, the processes involved in expressing some data in a file, if the file content is represented by just another region of memory, should be entirely reversible. If you wrote it in a reversible programming language like Janus (iirc?) you could probably write the “convert this data to encoding for a file” and “take this data as encoded for a file, and obtain the data it represents”, and have them be the same function, just run in different directions? That is, assuming you didn’t care about error handling. ... though, I guess you would need to make the file such that it can be read backwards? (Because, writing it forwards, would entail reading it backwards) which could be problematic? I guess the approach would probably be (outside the function) to copy the data structure, and then express every part of the data structure in the file, and then then using only what is in the file, subtract (or xor, or whatever) off all the parts in the copy, and then once it is all zeroes, de-allocate it. Though I guess maybe would have to do the zeroing-out and de-allocating recursively. Hm. How do you handle malloc in reversible computing, actually? I suppose something like: When you call malloc, you obtain a pointer to a region of memory which is all zeros, and in order to be able to de-allocate it, you are obligated to first zero it out (in a reversible way, of course). But, also, I guess it would be forbidden to use the pointer in ways other than as a pointer? E.g. it would be forbidden to malloc two regions of memory, and then have a switch statement on whether the difference between the pointers to those regions of memory is divisible by 3, and then de-allocate those two regions, because the details of how malloc behaves (what particular blocks of memory it hands out) shouldn’t be something that normal code should need to care about? Like, if I have two functions that have disjoint combinations of inputs and outputs, doing one function, then doing the other, then undoing the first function, then undoing the second one, should result in no overall effect. (Essentially , calling functions should be applying elements of a groupoid, and, where applicable, elements with disjoint support should commute... Actually, not sure if “groupoid element” is precisely the right idea?) At least, in situations where no error occurs.
@blackbeard3449
@blackbeard3449 8 ай бұрын
My intuition for that is that a raw text file does not have a "structure", the "structure" contains extra information. When you write a file you lose the structure, when you are parsing the file you are recreating the structure which needs extra work.
@bassguitarbill
@bassguitarbill 8 ай бұрын
I've been ignoring your nobuild videos because on the surface it doesn't seem as interesting as some other stuff you've done. That's a mistake on my part; I'm learning so much from this video. Edit: lmao yep "military-grade" got me, I have no idea how but it got me to click
@Kapendev
@Kapendev 8 ай бұрын
The actual king of programing is BetterC and C is the jester. True.
@xdman2956
@xdman2956 8 ай бұрын
C is king of programming like lion is king of jungle
@TheDamisBlaine
@TheDamisBlaine 8 ай бұрын
In one of Tsoding' latest videos he talked about how programming is self-destructive, does anyone rememer where that was? I cannot find it
@Vulto166
@Vulto166 8 ай бұрын
I'd like to add another comment about touch and file creation in Linux. I usually create files with "> file.txt" and if i want to create files and start to edit it imediately i do cat > "file.txt" When i finish editing and hit ctrl+c it created and has content. Very useful imo.
@anon_y_mousse
@anon_y_mousse 8 ай бұрын
If you're not going to use a proper editor, fine, bu why not use here-strings so you don't have to hit ctrl-c at the end?
@Vulto166
@Vulto166 8 ай бұрын
It's because it use more keys. But
@VincentLAnderson
@VincentLAnderson 8 ай бұрын
What do you do to work around the text you are entering into the file being parsed as a command by accident? Also, I attempted this in my terminal and shell and it just produced an empty file.txt and didn't require ctrl+c. I've also seen the use of cat /dev/stdin, but can't manage to get it to work and I am wondering if it's the shell and terminal emulator combination that is the issue. here-doc works fine though.
@anon_y_mousse
@anon_y_mousse 8 ай бұрын
@@VincentLAnderson The terminal really shouldn't matter, and I'd wager most shells would work the same as bash, but I'll ask anyway, what are you using?
@Vulto166
@Vulto166 8 ай бұрын
@@VincentLAnderson Problably is something in your environment. The expected behaviour of cat > file.txt should be stdin wait for text input, you can do new lines, but not backspaces. Mistakes can't be fixed and you should do ctrl+c in an new empty line, because ctrl+c don't let current line be passed to the file.txt. This command is only useful for quick notes and stuff, i never intended to replace standards text notes programs.
@r2com641
@r2com641 8 ай бұрын
would be more interresting to see same thing with modern c++, with modules as well. no header files.. something like.. inherent c++ build system for c++
@dwightk.schrute8696
@dwightk.schrute8696 8 ай бұрын
40:34 Butchered the joke Mr Streamer. The 3 most difficult things in computer science are 1) naming things 2) off by one errors. Add we list also should parallelism ccuonrenrcy adn.
@stbessonov
@stbessonov 8 ай бұрын
Hi Tsoding. How about raycasting (wolfenstein) with textures using C/Raylib? Would be super nice
@Olegach21
@Olegach21 8 ай бұрын
probably too easy for his gigabrain, he did software renderer recently
@robmorgan1214
@robmorgan1214 6 ай бұрын
Is static linking possible with nob? Why not make it detect the default rt environment target. You don't need a configuration file your computer already knows and hence nob already knows... assuming you got nob already installed on your system.
@Je3f0o
@Je3f0o 8 ай бұрын
When I make build system hardest and most annoying thing is some header file included multiple c files and modified. Because of that i need to recompile c files which depends on that header file. Sometimes some c files didn't recompile and creates seg fault. In that case I need some sort of AST index database like IDEs. I don't use IDE. I like to code in my vim. So usually I do `make clean && make`...
@rosen8757
@rosen8757 8 ай бұрын
Make can read dependency files that at least gcc can create with the -M(variant) flags. Solves the problem you are describing.
@anon_y_mousse
@anon_y_mousse 8 ай бұрын
That's a fair point, but you could always create an interface module and segregate its compilation to that module. Then just use the interface that's generated in every other module.
@Je3f0o
@Je3f0o 8 ай бұрын
@@rosen8757 Sometimes it didn't. I compile with ` -MP -MD` flags every single c files and it creates lots of *.d files too. And still doesn't recompile some files...
@Je3f0o
@Je3f0o 8 ай бұрын
@@rosen8757 Oh I forget to `-include $(OBJ_FILES:.o=.d)` in my some Makefiles. That is why sometimes some C files didn't recompile. Never forget include *.d files in Makefile. :P
@rosen8757
@rosen8757 8 ай бұрын
@@Je3f0o haha yes that would help :D
@SourabhBhat
@SourabhBhat 8 ай бұрын
Does this build system ignore already compiled files? Like in case of `make` a target is not build again if the sources have not changed.
@anon_y_mousse
@anon_y_mousse 8 ай бұрын
By checking the modified time for the file.
@SourabhBhat
@SourabhBhat 8 ай бұрын
@@anon_y_mousseYeah! Looks like I wrote the comment a bit too soon. :)
@0netom
@0netom 8 ай бұрын
why not use env variables instead of command line flags? it might be more suitable for this specific use case. then the parsing would be already handled by your shell and your application wouldn't need to be concerned with the extra state management issues which having config files introduce...
@NeZversSounds
@NeZversSounds 8 ай бұрын
Omg! It is mindblowing! I hate C/C++ build ecosystem because of stupid unique build environment requirements when just trying projects.
@gala_vs
@gala_vs 8 ай бұрын
Can u bump the Audio a bit before uploading to YT 🙂
@ezpz4akash
@ezpz4akash 8 ай бұрын
❤❤❤❤
@Argletrough
@Argletrough 8 ай бұрын
unit caching made me fail a uni assignment: I added a syntax error in a header but the only .c file that included it had a newer cached .o, so I didn't see a problem when I ran make... but the assessor couldn't compile the code
@TsodingDaily
@TsodingDaily 8 ай бұрын
Man! That sucks! 🫂
@nocodenoblunder6672
@nocodenoblunder6672 8 ай бұрын
Very very cool stuff especially the self rebuilding. Correct me If but only nob is not recompiled in case nothing has changed. In other words the project that we are building with nob is always building from scratch at least with the current implementation of nob.c I think it would be cool if that was not the case like it is in Make where only the touched files would be recompiled. Although I am not sure whether it would make sense for nob.h to handle this at all or If it would make more sense for this to just be handled by nob.c on an individual project level.
@U20E0
@U20E0 8 ай бұрын
the library has a function for checking if a file is older than another file
@nocodenoblunder6672
@nocodenoblunder6672 8 ай бұрын
@@U20E0 I know that but is is only used for Nob.c itself not the project it is building. In the next video nob.c gets modified such that raylib is not rebuild from scratch every time.
@U20E0
@U20E0 8 ай бұрын
@@nocodenoblunder6672 well, then use it for the project you are building. Nothing’s stopping you from doing that.
@Momoyon
@Momoyon 8 ай бұрын
The question is can nob automatically rebuild your tea? 🤔
@replikvltyoutube3727
@replikvltyoutube3727 8 ай бұрын
Tsoding about to develop Tsai, a jai-like package/framework for C
@replikvltyoutube3727
@replikvltyoutube3727 8 ай бұрын
If yes, pls connect a package manager to it and/or libraries linked through http(s)
@ilikegeorgiabutiveonlybeen6705
@ilikegeorgiabutiveonlybeen6705 8 ай бұрын
lol thats a good name
@VincentLAnderson
@VincentLAnderson 8 ай бұрын
This is cool but I am disappointed that there isn't a mature build tool that was literally recognized by the military as standard.
@zahash1045
@zahash1045 8 ай бұрын
Ok, im a little confused. Isnt make and cmake written in c?
@TurtleKwitty
@TurtleKwitty 8 ай бұрын
The base program, but the way you use it is mostly shell script in the case of make or entirely custom and bullshit to learn in the case of cmake
@mauricioParaquedas
@mauricioParaquedas 8 ай бұрын
you look a lot like skylab
@mouhamedbourouba3637
@mouhamedbourouba3637 8 ай бұрын
1:15:40 it fking worked
@D-V-O-R-A-K
@D-V-O-R-A-K 8 ай бұрын
Build systems existing is just a sign that the compiler frontend sucks, isn't it?
@mayuinc
@mayuinc 8 ай бұрын
Is C your favorite language?
@monad_tcp
@monad_tcp 7 ай бұрын
30:21 hey, I have a PDP11 clone that I made myself
@cheebadigga4092
@cheebadigga4092 8 ай бұрын
You just inspired me to write something similar in Go, primarily to learn. Maybe it will grow to become something, maybe not lol
@east_wood
@east_wood 8 ай бұрын
Go build not enough?
@cheebadigga4092
@cheebadigga4092 8 ай бұрын
a build system for C/C++ written in Go
@east_wood
@east_wood 8 ай бұрын
@@cheebadigga4092 ahh icic
@DanelonNicolas
@DanelonNicolas 8 ай бұрын
military grade hahaahahaha I love it! what is this? a VPN? an encrypted email service?? haha tsoding is live tsoding is love
@StevenMartinGuitar
@StevenMartinGuitar 8 ай бұрын
So are you telling me that if someone tries to build from a build cache and encounters an error, and we need to tell the user to re-bootstrap the build system that the error message will read "NOB_ERROR - Please touch nob to continue" 😂
@puncherinokripperino2500
@puncherinokripperino2500 3 ай бұрын
append sister
@aabansen
@aabansen 5 ай бұрын
macos works i checked
@herkulessi
@herkulessi 8 ай бұрын
glibc is a mess. If I recall correctly, glibc talks to systemd out of band to resolve DNS things... I would just compile statically against musl or dietlibc or some other libc that doesn't need itself dynamically in static builds
@MouldySoul
@MouldySoul 8 ай бұрын
I thought mingw rhymed with pingu.
@heyyouhere
@heyyouhere 8 ай бұрын
voidf
@tusharmaurya1668
@tusharmaurya1668 8 ай бұрын
Who disliked this video... like why?
@ilikegeorgiabutiveonlybeen6705
@ilikegeorgiabutiveonlybeen6705 8 ай бұрын
military??????????????? bro
@U20E0
@U20E0 8 ай бұрын
military-grade software is a fitting description for this
@abiiranathan
@abiiranathan 8 ай бұрын
First comment
@Randy_McShandy
@Randy_McShandy 8 ай бұрын
Stupid idea: build system that can be used from #!/usr/bin... as a first line in a main.c, so you can just run ./main.c as a plain executable. No more build system to bootstrap
@ilyacheladin1
@ilyacheladin1 8 ай бұрын
Actually, this "build system" can be written in a few lines of bash. Very useful for small C snippets.
@maxsilvester1327
@maxsilvester1327 8 ай бұрын
tcc (Tiny C Compiler) has a similar feature. You can just do use "#!/usr/bin/tcc -run" as a first line, make the file executable and use lit like a shell script.
Reverse Engineering Data Files
1:59:16
Tsoding Daily
Рет қаралды 38 М.
Web in Native Assembly (Linux x86_64)
2:03:41
Tsoding Daily
Рет қаралды 54 М.
When Steve And His Dog Don'T Give Away To Each Other 😂️
00:21
BigSchool
Рет қаралды 11 МЛН
I Need Your Help..
00:33
Stokes Twins
Рет қаралды 158 МЛН
Универ. 13 лет спустя - ВСЕ СЕРИИ ПОДРЯД
9:07:11
Комедии 2023
Рет қаралды 693 М.
Drag and Drop in C (Yes, it is possible! Let me show you how...)
1:18:02
Making Minecraft from scratch in 48 hours (NO GAME ENGINE)
16:38
Custom Hot Reloading in Jai
2:05:35
Tsoding Daily
Рет қаралды 11 М.
How I Stopped Caring and Just Improved My Project (Nob Ep.01)
1:48:36
Tsoding Daily
Рет қаралды 43 М.
Hash Table in C
2:11:31
Tsoding Daily
Рет қаралды 56 М.
How does an OS boot? //Source Dive// 001
50:22
Low Byte Productions
Рет қаралды 375 М.
Hot Code Reloading in C
2:16:18
Tsoding Daily
Рет қаралды 60 М.
You don't need Generics in C
1:37:38
Tsoding Daily
Рет қаралды 56 М.
wireless switch without wires part 6
0:49
DailyTech
Рет қаралды 1,3 МЛН
Выложил СВОЙ АЙФОН НА АВИТО #shorts
0:42
Дмитрий Левандовский
Рет қаралды 1,8 МЛН
С ноутбуком придется попрощаться
0:18
Up Your Brains
Рет қаралды 328 М.
😱НОУТБУК СОСЕДКИ😱
0:30
OMG DEN
Рет қаралды 3,2 МЛН
Очень странные дела PS 4 Pro
1:00
ТЕХНОБЛОГ ГУБАРЕВ СЕРГЕЙ
Рет қаралды 425 М.