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

  Рет қаралды 29,660

Tsoding Daily

Tsoding Daily

Күн бұрын

Пікірлер: 131
@merthyr1831
@merthyr1831 Жыл бұрын
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 Жыл бұрын
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 11 ай бұрын
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 7 ай бұрын
​@@robmorgan1214then how do rust and zig manage to do it? Zig can even build C
@fiona9891
@fiona9891 5 ай бұрын
​@@robmorgan1214 there is no reason a c build script would not be able to do that
@Vulto166
@Vulto166 Жыл бұрын
This is my favorite project on your repo. I hope it receive more love in future.
@danidotexe_
@danidotexe_ Жыл бұрын
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 Жыл бұрын
Are ypu high brother?
@zahash1045
@zahash1045 Жыл бұрын
Holy C
@badstep495
@badstep495 Жыл бұрын
C only fans
@phitc4242
@phitc4242 Жыл бұрын
C gang
@fedang
@fedang Жыл бұрын
Real
@bfitzger2
@bfitzger2 Жыл бұрын
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).
@Vulto166
@Vulto166 Жыл бұрын
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.
@sebc521
@sebc521 Жыл бұрын
Another amazing video, bravo.
@L4oo.
@L4oo. 2 ай бұрын
in case anyone was wondering, thorn was used in Old English, and I think Old Norse, but I'm not entirely sure. It's still used in Icelandic (and maybe Faroese, but I'm also not sure about that)
@8Trails50
@8Trails50 Жыл бұрын
This dude is the goat
@blastygamez
@blastygamez Жыл бұрын
Ur one of my favorite programmers on yt, keep it up!!
@MouldySoul
@MouldySoul Жыл бұрын
out of interest who are your others? I don't have plural, this dude's like Jimi Hendrix when I was 16 to me.
@legendrags
@legendrags 10 ай бұрын
This single man made me learn C and make my own build system. What a chad
@xdman2956
@xdman2956 Жыл бұрын
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
@JonnyDeRico
@JonnyDeRico Жыл бұрын
Smells like your work will introduce the end of java. You are my hero D:
@RenderDragon
@RenderDragon Жыл бұрын
People program in java not because of complexity of existing build systems for C
@JonnyDeRico
@JonnyDeRico Жыл бұрын
@@RenderDragon so it is, because they don't understand pointers?
@sandworm9528
@sandworm9528 Жыл бұрын
​@@JonnyDeRicoliterally yes 😅
@Marco-pz5dx
@Marco-pz5dx Жыл бұрын
Love the "Buy more RAM lol!!" to handle out-of-memory by the way ahaha (around 09:00)
@simonl1938
@simonl1938 Жыл бұрын
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 Жыл бұрын
// 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 Жыл бұрын
Don't
@theevilcottonball
@theevilcottonball Жыл бұрын
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 Жыл бұрын
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_ Жыл бұрын
@@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.
@monad_tcp
@monad_tcp Жыл бұрын
7:44 this is really good, I hate shell scripts, I would totally use C directly
@cenntraru
@cenntraru Жыл бұрын
23:18 reminds me the saying: Every sage writes the same book.
@maxsilvester1327
@maxsilvester1327 Жыл бұрын
What does this saying mean? Google doesn't show any results.
@satchelfrost6531
@satchelfrost6531 Жыл бұрын
I really love this idea.
@killianperlin8276
@killianperlin8276 Жыл бұрын
Your framework idea reminds me a lot of Cello (libcello), very interesting project imo.
@Vulto166
@Vulto166 Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
It's because it use more keys. But
@VincentLAnderson
@VincentLAnderson Жыл бұрын
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 Жыл бұрын
@@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 Жыл бұрын
@@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.
@D_VAULTZ
@D_VAULTZ Жыл бұрын
You did it again son! King Tso Ding brap brap
@kwyrky
@kwyrky Жыл бұрын
Just leaving this military grade comment here: Good stuff!!!
@kibels894
@kibels894 Жыл бұрын
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
@bassguitarbill
@bassguitarbill Жыл бұрын
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
@NeZversSounds
@NeZversSounds Жыл бұрын
Omg! It is mindblowing! I hate C/C++ build ecosystem because of stupid unique build environment requirements when just trying projects.
@xdman2956
@xdman2956 Жыл бұрын
C is king of programming like lion is king of jungle
@drdca8263
@drdca8263 Жыл бұрын
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 Жыл бұрын
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.
@Kapendev
@Kapendev Жыл бұрын
The actual king of programing is BetterC and C is the jester. True.
@bbq1423
@bbq1423 Жыл бұрын
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)
@Je3f0o
@Je3f0o Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
@@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 Жыл бұрын
@@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 Жыл бұрын
@@Je3f0o haha yes that would help :D
@dwightk.schrute8696
@dwightk.schrute8696 Жыл бұрын
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.
@lievenpetersen
@lievenpetersen Жыл бұрын
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.
@robmorgan1214
@robmorgan1214 11 ай бұрын
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.
@r2com641
@r2com641 Жыл бұрын
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++
@0netom
@0netom Жыл бұрын
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...
@replikvltyoutube3727
@replikvltyoutube3727 Жыл бұрын
Tsoding about to develop Tsai, a jai-like package/framework for C
@replikvltyoutube3727
@replikvltyoutube3727 Жыл бұрын
If yes, pls connect a package manager to it and/or libraries linked through http(s)
@ilikegeorgiabutiveonlybeen6705
@ilikegeorgiabutiveonlybeen6705 Жыл бұрын
lol thats a good name
@TheDamisBlaine
@TheDamisBlaine Жыл бұрын
In one of Tsoding' latest videos he talked about how programming is self-destructive, does anyone rememer where that was? I cannot find it
@stbessonov
@stbessonov Жыл бұрын
Hi Tsoding. How about raycasting (wolfenstein) with textures using C/Raylib? Would be super nice
@Olegach21
@Olegach21 Жыл бұрын
probably too easy for his gigabrain, he did software renderer recently
@D-V-O-R-A-K
@D-V-O-R-A-K Жыл бұрын
Build systems existing is just a sign that the compiler frontend sucks, isn't it?
@nocodenoblunder6672
@nocodenoblunder6672 Жыл бұрын
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.
@chri-k
@chri-k Жыл бұрын
the library has a function for checking if a file is older than another file
@nocodenoblunder6672
@nocodenoblunder6672 Жыл бұрын
@@chri-k 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.
@chri-k
@chri-k Жыл бұрын
@@nocodenoblunder6672 well, then use it for the project you are building. Nothing’s stopping you from doing that.
@Momoyon
@Momoyon Жыл бұрын
The question is can nob automatically rebuild your tea? 🤔
@SourabhBhat
@SourabhBhat Жыл бұрын
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 Жыл бұрын
By checking the modified time for the file.
@SourabhBhat
@SourabhBhat Жыл бұрын
@@anon_y_mousseYeah! Looks like I wrote the comment a bit too soon. :)
@gala_vs
@gala_vs Жыл бұрын
Can u bump the Audio a bit before uploading to YT 🙂
@Argletrough
@Argletrough Жыл бұрын
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 Жыл бұрын
Man! That sucks! 🫂
@VincentLAnderson
@VincentLAnderson Жыл бұрын
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 Жыл бұрын
Ok, im a little confused. Isnt make and cmake written in c?
@mauricioParaquedas
@mauricioParaquedas Жыл бұрын
you look a lot like skylab
@mayuinc
@mayuinc Жыл бұрын
Is C your favorite language?
@monad_tcp
@monad_tcp Жыл бұрын
30:21 hey, I have a PDP11 clone that I made myself
@ezpz4akash
@ezpz4akash Жыл бұрын
❤❤❤❤
@mouhamedbourouba3637
@mouhamedbourouba3637 Жыл бұрын
1:15:40 it fking worked
@DanelonNicolas
@DanelonNicolas Жыл бұрын
military grade hahaahahaha I love it! what is this? a VPN? an encrypted email service?? haha tsoding is live tsoding is love
@herkulessi
@herkulessi Жыл бұрын
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
@cheebadigga4092
@cheebadigga4092 Жыл бұрын
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 Жыл бұрын
Go build not enough?
@cheebadigga4092
@cheebadigga4092 Жыл бұрын
a build system for C/C++ written in Go
@east_wood
@east_wood Жыл бұрын
@@cheebadigga4092 ahh icic
@StevenMartinGuitar
@StevenMartinGuitar Жыл бұрын
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" 😂
@tusharmaurya1668
@tusharmaurya1668 Жыл бұрын
Who disliked this video... like why?
@MouldySoul
@MouldySoul Жыл бұрын
I thought mingw rhymed with pingu.
@puncherinokripperino2500
@puncherinokripperino2500 8 ай бұрын
append sister
@ilikegeorgiabutiveonlybeen6705
@ilikegeorgiabutiveonlybeen6705 Жыл бұрын
military??????????????? bro
@chri-k
@chri-k Жыл бұрын
military-grade software is a fitting description for this
@abiiranathan
@abiiranathan Жыл бұрын
First comment
@heyyouhere
@heyyouhere Жыл бұрын
voidf
@Randy_McShandy
@Randy_McShandy Жыл бұрын
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
@kokokoshka-s7c
@kokokoshka-s7c Жыл бұрын
Actually, this "build system" can be written in a few lines of bash. Very useful for small C snippets.
@maxsilvester1327
@maxsilvester1327 Жыл бұрын
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.
Building Raylib using Only C Compiler (No CMake or Zig) (Nob Ep.03)
1:45:14
I regret doing this...
1:20:07
Tsoding Daily
Рет қаралды 82 М.
World’s strongest WOMAN vs regular GIRLS
00:56
A4
Рет қаралды 16 МЛН
小丑揭穿坏人的阴谋 #小丑 #天使 #shorts
00:35
好人小丑
Рет қаралды 37 МЛН
I tried Swift and came out a different person
1:56:59
Tsoding Daily
Рет қаралды 110 М.
Will Ada Replace C/C++?
44:57
Tsoding
Рет қаралды 95 М.
ZIG | Ep1 | Introduction
20:18
Code Guild
Рет қаралды 8 М.
Hash Table in C
2:11:31
Tsoding Daily
Рет қаралды 68 М.
I tried React and it Ruined My Life
1:19:10
Tsoding Daily
Рет қаралды 146 М.
Making Minecraft from scratch in 48 hours (NO GAME ENGINE)
16:38
Harder Drive: Hard drives we didn't want or need
36:47
suckerpinch
Рет қаралды 1,7 МЛН
Nix explained from the ground up
23:39
Surma
Рет қаралды 55 М.
Stress Testing WebSocket Implementation
2:36:44
Tsoding Daily
Рет қаралды 18 М.
Why Isn't Functional Programming the Norm? - Richard Feldman
46:09