r/programminghorror • u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo "You live" • Dec 25 '25
one file is better than cmake
https://youtube.com/watch?v=j3BvierE2hM&si=CD7z-a2o-PF7QwJnI came across this and thought it was pretty horrifying. Definitely not advocating for this.
47
Upvotes
51
u/lor_louis Dec 25 '25
Cmake is so bad I buy it.
14
u/ironykarl Dec 25 '25
It's not a bad approach for personal projects or modestly-sized codebases, at all
3
u/reinhart-py Dec 28 '25
I don't understand shi but tell me more about that cursor, like how
52
u/shizzy0 Dec 26 '25
Incremental compilation gone. I get dumping cmake but a makefile is fine and you can have incremental builds.
7
u/questron64 Dec 27 '25
This is referred to as a unity build, and they're pretty good. This is not horrifying at all. Before compilers had good link-time optimization this also produced better executables.
You lose incremental builds, but you don't need that with modern machines on small to medium C projects. C compiles really fast, this is not C++. But unity builds are overall faster, as the compiler only needs to be invoked once and there is no link phase. You do lose parallelization in builds, though. Overall they're slower, but not as slow as you'd think.
You lose static scope. C doesn't give you much in the way of encapsulation features and static scoping (which limits the scope of an identifier to a single translation unit) is your primary language feature for encapsulation. You do stuff with static variables and functions and provide an interface with functions. You don't have that anymore because there is only one translation unit now, everything has the same scope.
6
u/B1ggBoss Dec 25 '25
Oh god
2
u/RevengerWizard Dec 27 '25
His other videos are fairly nice, but this…
Please, please, please, use header files.
4
u/Brixjeff-5 Dec 26 '25
Cmake sucks. But if you know a few debugging tricks you can get it to automate just about any task. And then it really starts to shine. Cmake is great actually
1
u/reddituser91200 Dec 27 '25
Scott the Woz
0
u/pileofplushies Dec 26 '25
This'll work up to some level of complexity. not really so much lines of code, more just how much work the compiler actually has to do to build the code. And funnily enough, it allows for better optimized builds since you never cross compilation unit boundaries. But if you ever need to actually share this code with another human being, a batch script is not a valid build system and you should feel shame if you pretend otherwise
9
u/v_maria Dec 26 '25 edited Dec 26 '25
this is bad but it seems like a cool channel.
diving in, making your hands dirty and learning is much more fun (and useful!) than accepting best practice just because its best practice
1
u/[deleted] Dec 26 '25
[removed] — view removed comment