5 ms·
Not to be rude but this source code... makes me wonder if I ever want to use Zig. It looks barely readable https://github.com/andrewrk/poop/blob/main/src/main.
by warent 3y ago
Not to be rude but this source code... makes me wonder if I ever want to use Zig. It looks barely readable
https://github.com/andrewrk/poop/blob/main/src/main.zig https://github.com/andrewrk/poop/blob/main/src/main.zig
- brosciencecode 3y agoOut of curiosity, what makes it unreadable to you?
- slekker 3y agoNot OP but to me it is a bit difficult to read due to the syntax highlighting colours (mainly red and brown)
- dinglejungle 3y agoThis might be more of an indictment on 'readable' being a meaningful concept (beyond simple personal preference) than it is of Zig's syntax.
- proto_lambda 3y agoI've never touched zig and know next to nothing about it, but that all looks reasonable to me at a glance. What exaxtly do you find so bad?
- LanternLight83 3y agoI've never used Zig or C++, mostly Bash, Python, and Lisps, but have recently began learning C. I see C++ in search results, and it looks like C with higher level features in a register that reminds me of Java. I see this, and it looks similer: C with higher level features that remind me more of Python. I'm sure it's got other important features and priorities that set it apart (oft' discussed here), but that's what I see, and I dig it. To be clear there are definitely a few ideoms I'd need to learn before considering this readable (it ain't psudocode), but I generally see all the building blocks and recognize what they're achiving. Maybe I'd have put them together slightly differently, but that could be equally true in Python. I'd rather learn this next than C++. The density of how it's been written reminds me of some lisp code I've read, some implementations of state machines can be hard to follow too (in the classic "but where does it do the thing?" sense). I attribute a lot of the stuff that I don't follow to the lower-level C influence; I'm working for the first time with memory managment, structs, static types, pointers, bitwise opperations, etc. Think I made my point in there somewhere >z> Would love to know where you're coming at it from, I'd imagine that the C or 'kinda functional control flow' aspects might explain what looks most forign to you too (unless you have broader experience with low level languages)?
- lionkor 3y agoYoure mostly right, but Zig is not higher level than C. In some ways, its lower level, as in C the allocator you use is mostly abstracted away, while in zig its usually required to be specified.
- TeMPOraL 3y agoLooks fine to me. Syntax is the run-of-the-mill post-Java style currently favored, as exemplified by e.g. Haskell or Rust. Not a fan personally, but this is what is popular now, so that's what we have to live with ¯\_(ツ)_/¯. Style-wise, looks fine. Code split up into functions where it makes sense, inlined where it doesn't. I've seen worse - for example, code that takes the equivalent of that, and splits it into 100 functions across 10+ files.
- wiseowise 3y ago> I've seen worse - for example, code that takes the equivalent of that, and splits it into 100 functions across 10+ files. This so many times. Will never understand why people are so afraid of multi thousand lines of properly structured code but will happily giggle when the same structure is split across 10-20 files. And no, it’s not for reuse sake.
- voakbasda 3y agoMany thousand lines of structured code that does not get broken into logical modules ends up an unnavigable and unmaintainable mess. I would not hesitate to split up such code. Encapsulation and modularity are good engineering practices. Personally, I will not contribute to any project that opposes such things
- wiseowise 3y ago> Many thousand lines of structured code that does not get broken into logical modules ends up an unnavigable and unmaintainable mess. Where did I say anything about that?