News for hackers. Stuff that matters.
Re:Poop: Performance Optimizer Observation Platform by warent on Saturday June 17, 2023 @01:28AM (#36367575)
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

Re:Poop: Performance Optimizer Observation Platform by brosciencecode on Saturday June 17, 2023 @01:48AM (#36367645)
Out of curiosity, what makes it unreadable to you?
Re:Poop: Performance Optimizer Observation Platform by slekker on Saturday June 17, 2023 @02:04AM (#36367721)
Not OP but to me it is a bit difficult to read due to the syntax highlighting colours (mainly red and brown)
Re:Poop: Performance Optimizer Observation Platform by dinglejungle on Saturday June 17, 2023 @01:50AM (#36367661)
This might be more of an indictment on 'readable' being a meaningful concept (beyond simple personal preference) than it is of Zig's syntax.
Re:Poop: Performance Optimizer Observation Platform by proto_lambda on Saturday June 17, 2023 @01:57AM (#36367687)
I'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?
Re:Poop: Performance Optimizer Observation Platform by LanternLight83 on Saturday June 17, 2023 @02:10AM (#36367745)
I'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)?

Re:Poop: Performance Optimizer Observation Platform by lionkor on Saturday June 17, 2023 @05:32AM (#36368667)
Youre 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.
Re:Poop: Performance Optimizer Observation Platform by TeMPOraL on Saturday June 17, 2023 @02:55AM (#36367960)
Looks 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.

Re:Poop: Performance Optimizer Observation Platform by wiseowise on Saturday June 17, 2023 @03:55AM (#36368219)
> 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.

Re:Poop: Performance Optimizer Observation Platform by voakbasda on Saturday June 17, 2023 @10:44AM (#36370618)
Many 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

Re:Poop: Performance Optimizer Observation Platform by wiseowise on Saturday June 17, 2023 @11:23AM (#36371017)
> 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?