Earlier quoted context omitted.
Agreed, this would be very beneficial to students and people learning C.
I have used the source code for Plan 9's core utilities as a teaching aid for students learning the basics of C and operating systems to great effect. I have found GNU's tools to contain a lot of "cruft" to make them run fast, which is not necessarily conducive for those who are not familiar to why they work.
Decoded: GNU Coreutils
51–56 of 56 posts
Re: Decoded: GNU Coreutils
#52Nice project. Just looked for the source code of "yes" ( https://github.com/coreutils/coreutils/blob/master/src/yes.c ), cause it seems to be the easiest code to understand. I didn't get it. Damn. Looks still complicated.
Re: Decoded: GNU Coreutils
#53Earlier quoted context omitted.
I have used the source code for Plan 9's core utilities as a teaching aid for students learning the basics of C and operating systems to great effect. I have found GNU's tools to contain a lot of "cruft" to make them run fast, which is not necessarily conducive for those who are not familiar to why they work.
Busybox and Toybox also contain pretty simple and easy to follow implementations.
OTOH, I shouldn't because I think my current router has more CPU / Memory than my first mainframe.
Re: Decoded: GNU Coreutils
#54I know, I know, the classic "goto Considered Harmful". And, yes, it can be abused just like every other programming construct.
I see 2 generally good use cases for goto: 1) error handling to cleanup in failure in C (in C++ RIAA constructs ahould be used instead) 2) exitting nested loops, instead of a flag and a break.
I've also seen C++ code use do while loops with while(false) so that they could use "break" to exit the non loop. Its very confusing and non obvious, because you see the do, and thus expect a loop. Meanwhile (the absurdly long function) has the while(false) on a separate screen, not making it clear that the code doesn't actually loop. Just use the goto. It's clearer and omits the abuse of a looping primitive (that doesn't actually loop).
Yes, goto can be abused, so can many other statements.
Sorry, /rant
Re: Decoded: GNU Coreutils
#55Earlier quoted context omitted.
I have used the source code for Plan 9's core utilities as a teaching aid for students learning the basics of C and operating systems to great effect. I have found GNU's tools to contain a lot of "cruft" to make them run fast, which is not necessarily conducive for those who are not familiar to why they work.
Yeah, plan 9 was my second thought when I saw this. The first one was suckless' core.