Live data from Hacker News

Decoded: GNU Coreutils

maizure.org

51–56 of 56 posts

Re: Decoded: GNU Coreutils

#51

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.

Busybox and Toybox also contain pretty simple and easy to follow implementations.

Re: Decoded: GNU Coreutils

#52
post #23

Nice 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.

Yeah, `yes` ended up complex in order to get better performance; if you want something simpler, maybe try https://www.maizure.org/projects/decoded-gnu-coreutils/env.h... ?

Re: Decoded: GNU Coreutils

#53

Earlier 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.

Busybox is a fun read on how they got all that functionality into such a small space. It always amazes me that my home router has all those functions because of Busybox being loaded.

OTOH, I shouldn't because I think my current router has more CPU / Memory than my first mainframe.

Re: Decoded: GNU Coreutils

#54
This is probably going to be an unpopular opinion, I dont agree with the criticism of the use of goto.

I 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

#55
post #43

Earlier 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.

suckless seems like a spiritual successor to Plan 9 (albeit POSIX), to the point that it uses some of the same constructs, so I’m not surprised that you thought of it.
Post reply on HN