5 ms·
The repo says "An exercise in minimalism." – Looking at the code, there is nothing minimalistic about it. Perhaps in terms of C it can be called that, but in te
by zelphirkalt 7y ago
The repo says "An exercise in minimalism." – Looking at the code, there is nothing minimalistic about it. Perhaps in terms of C it can be called that, but in terms of programming languages in general, this cannot be called "minimal" at all.
The code quality is terrible. Few explaining comments (actually mos of those are only 1 or 2 words, so not explaining anything at all) and almost all variable names consist of 1 or 2 characters, which do not say what the thing actually is. Then to achieve this arbitrary goal of doing it "in 4 functions" (actually procedures) loads of stuff was apparently stuffed into 4 those 4 functions, so much so, that they are longer than a whole page of code. Most of it looks like gigantic switch statements. It's horribly written code. It looks like what I think of as a C nightmare.
I will admit, I could not write such a thing myself. I lack the knowledge for writing such a low level stuff, do not use C, and if I had that knowledge to do it, my inner drive to do a cleaner job than anything remotely looking like that code, would prevent me from ever sharing such a thing with anyone in public. At least group cases into procedures as it makes sense. Even people writing this low level type of code should be aware of how unreadable that code is, right?
- jabbequbs 7y agoI've only skimmed the code but it seems to me that the repo is an art piece just as much or more than it is a software project. The medium is code but that doesn't mean that it needs to adhere to professional standards anymore than someone's woodworking project needs to adhere to building codes.
- jfkebwjsbx 7y agoThe code is obviously not intended for production, but it is straightforward nevertheless for anyone with C experience.
- joppy 7y agoGigantic switch statements are pretty much the best way to do a parsing style thing in a straightforward basic manner, and it is after all, “an _exercise_ in minimalism”. There are short variable names but again there are not many variables used in the whole program. This was not code written to be approachable by any other random team member without further context, it was written for a different purpose entirely. Perhaps people would be less reluctant to show their code in public if it were not so often criticised for falling short of some criteria that the author was never intending to meet?
- zelphirkalt 7y ago> This was not code written to be approachable by any other random team member without further context, it was written for a different purpose entirely. Ah, let me quote: "Programs must be written for people to read, and only incidentally for machines to execute." – Hal Abelson And I believe he is right. If you don't write your programs for other people to read, then they not worth being written in that way. Always consider that next person, who needs to read and understand your code. If you don't, then you are not much of a great team player at all. It's great you can do some brain acrobatics, but not much use, if the only one on team being able to understand your code is yourself. I don't know how many 1 person software developer jobs there are still out there, but I guess the number is vanishingly small, compared to team jobs. I would not want someone in my team, who does not pay attention to keeping things very readable. > Perhaps people would be less reluctant to show their code in public if it were not so often criticised for falling short of some criteria that the author was never intending to meet? True, you got a point here. But do we want this display of code? However, personally, I'd probably not miss reading such code and maybe it would even be good for the entire profession of software development, if such code was not displayed as something to be achieved but rather something to be shunned.
- joppy 7y agoIt’s not a piece of software worked on by a team though. It’s a personal project, written to by one person to be understood by that person, and incidentally I think some effort has been made to make the code easier to read for random passers-by on the internet. Not every piece of code has to be written to meet the same goals, there is a large spectrum. I write both terse notes to myself, and longer more well-thought out sets of notes to distribute to undergraduates in classes I teach. I wouldn’t give the undergraduates my personal notes - they are simply too unpolished and terse - but my colleagues find them very helpful on occasion. Is it wrong to have two different ways of writing? I would say this C implementation leans somewhere between “note to self” and “arty exploration”. Is it worth being written? I don’t think you or I could be the judge of that, but the author obviously thought so. Live and let live.
- userbinator 7y ago
- jackewiehose 7y ago> I lack the knowledge And yet you have a strong opinion about how terrible it is. It is very minimal and it is very readable. It is actually a joy to read. You have no idea what a C-nightmare really is.
- zelphirkalt 7y agoYep, I can have a "strong" (what is strong?) opinion about it, because I know what readable code in other programming languages looks like and it certainly does not look like that. I did use C a few times in assignments and still my code had more comments and better readable names for basically everything than the code present in the repository. Wait, you are telling me, that people write even less readable code in C? Perhaps you are right. Perhaps people can really be that much without care. It still does not make this code "very readable". If it was very readable, I would have a vague idea about what each of the "functions" does from reading its name or its docstring. Oh wait, there is no docstring at the beginning of each of the "functions" and the name consists of one word, sometimes abbreviated word. And the variable names don't give me hints either. I think our definitions of readable code simply differ quite a lot. When I write code myself, I am unwilling to accept code on that readability level, but we probably have different standards. Perhaps for entertainment purposes only, you could show me a real C nightmare. I do honestly believe you, that there is worse ;)
- saagarjha 7y agoI agree with you, the code isn’t as readable as it could be. But that’s precisely the point here: it’s an exercise in artistic license, so its conciseness is a feature, not a bug. Think of it like poetry.
- psychoslave 7y agoI can recognize why it will generates a feeling of elegance, as some say with short mathematical concise formula. However this is more like of esoteric practices: it's meaningful for the selected few that went through the initiation, and has only the charming/frustrating taste of mystery for other. But, at least to me, it's nothing like poetry. Anyone, without any specific formation, can read poetry and understand something of it. In poetry, artistic license is the exception, not the general rule. The deep meanings, intertwines between form and content, the attention to metre, the use of allegories, and so on, will not be consciously grabbed by every reader. But still anyone that has the base language knowledge required can read it and find some sense to it.
- hibbelig 7y agoIt's a C compiler in 500 lines. I guess there are C compilers in 500,000 lines.