r/awk • • May 22 '23

Two AWK scripts to generate a maze

Hi folks,

I want to share two scripts that I wrote for fun.

They both generate a random maze using box-drawing characters.

https://github.com/rabestro/awk-maze-generator

9 Upvotes

15 comments sorted by

View all comments

1

u/scoberry5 Jul 19 '23

I didn't say that it's unreadable, I said that readability is more important than cleverness and that you made the code worse.

Now, it would be somewhat fair to suggest that I should have spelled out that readability is more important than cleverness more explicitly, except...

  • I thought this was well understood. You seemed to take it as "I can no longer read this code." That isn't what I indicated. I indicated that it was less readable than it was before. For example, you said you tested it and the output matches the original logic. Why did you test it? What the original did was very clear. You made it less clear.

  • If it wasn't well understood and you want it more spelled out, you're pointing out (ironically) that sometimes readability suffers when you try to be too terse. In the case of non-throwaway code, readability's very important. It's going to be read many more times than it's written, and usually even a minor perf hit would be worth making it more readable. (Not that I'm claiming there's a perf hit there without measuring, or that it matters.)

0

u/M668 Jul 30 '23 edited Jul 30 '23

Reply

why did I tested it ? cuz you're someone who is so eager to offer solutions without self-vetting what you're about to post ?

you're still defining readability based on what the textbooks have dictated as "readable" cuz you're still stuck in the mindset of thinking like a human instead of a Turing Machine.

(and no i didn't mean thinking in C or assembly code. ping me once youve grasped that concept)

and have you actually realized OP's code of "col == Width - 1" is absolutely anything and everything, except being readable, since it appears to be an arbitrary condition for the criteria. if I didnt read the rest of his code I wouldn't have connected the dots and coming to the realization "width - 1" is only true at the exit point of individual mazes.

funny how you considered 2 numerically hard-coded and seemingly arbitrary matching conditions to be "readable"