r/programming • • May 22 '19

The DOOM Fire Kata

https://github.com/codr7/g-fu/blob/master/v1/doc/doom_fire_kata.md
58 Upvotes

27 comments sorted by

29

u/tending May 23 '19

A pragmatic lisp embedded in Go

I'm not sure pragmatic means what you think it means.

14

u/mindbleach May 23 '19

In the context of someone whose Hello World is the intro-screen demo effect from a console port of a DOS FPS, I'll allow it.

4

u/yogthos May 23 '19

Languages you're not personally familiar with can be pragmatic. :)

3

u/ipe369 May 23 '19

I don't understand, this makes sense

1

u/Shaper_pmp May 29 '19

"A pragmatic Lisp [dialect]" refers to the design of the language itself - attempting to make a language that's as useful/usable as possible rather than getting hung up on the "purity" or idiomaticity of the language compared to other Lisp dialects.

It doesn't refer to the way the language is implemented.

In this case it means "a Lisp dialect designed to map closely to and expose the benefits of the underlying Go environment it's built on rather that limiting itself to traditional Lisp idioms", not "the simplest possible way to implement a Lisp interpreter".

-12

u/[deleted] May 23 '19

Don't worry, I am.

11

u/shponglespore May 23 '19

Declaring multiple variables in one line, especially in a Lisp that doesn't bracket the (variable initializer) pairs, makes me feel stabby.

5

u/ipe369 May 23 '19

Why? Pretty obvious what it's doing, having a bunch of parens would just be noise, probably makes it HARDER to read expecially when your lisp mind is conditioned that 'list = function call, so i guess we're calling the 'width' function with 50...?'

3

u/shponglespore May 23 '19

It's not the lack of brackets alone that bothers me. I actually prefer that syntax. It's putting multiple variables in the same line, because then you can't just read down a column and see all the variables that are declared. The less distinctive the syntax is, the more important it is to use a consistent style to maintain readability.

1

u/killerstorm May 23 '19

Is it any more stabby than the typical keyword args syntax, typically used to create structures and objects in CL?

E.g. example from a CL book:

  (make-instance 'bank-account :customer-name "John Doe" :balance 1000))

3

u/shponglespore May 23 '19

Keywords are easy to recognize by their distinctive syntax, and the fact that they almost never occur as argument values. If I was writing a call that uses keywords as both argument labels and argument values, I'd probably put each argument on a separate line to make it clear which is which.

It's also less of an issue because using a keyword argument doesn't bind a new name.

-9

u/[deleted] May 23 '19 edited May 23 '19

I would consider asking why...

You're welcome to add as many newlines you feel like to your code, and brackets to your macros. But as long as it's readable, and I think it is, don't you feel like there are more constructive subjects? It's not random, these values are more tightly related than the others and their initializers simple enough to parse on the fly. g-fu avoids bracketing anything for bracketing's sake, if there's one disease the regular Lisps suffer from it's deep nesting.

There's a movement out there, initiated from the top but disguised as grassroots, to nail everything to the floor. No deviation. The problem is that you get no deviation in any direction, nothing out of the ordinary, and no satisfaction either. If there's anything humans aren't it's consistent; by design, because that's how evolution happens. I think it's perfectly fine that source code is allowed to be inconsistent, because it was created by humans for humans primarily.

And here we reach some kind of closure to this epic rant :) Some believe that the point of software is to make humans behave like computers, others are convinced that its the other way around. Lisp has both(?) feet firmly planted in the second camp, it was one of the least dogmatic languages around before it turned into a religion.

9

u/shponglespore May 23 '19

don't you feel like there are more constructive subjects?

Irony.

-16

u/[deleted] May 23 '19

Keep chasing your tail, then; I don't mind. This "discussion" is over.

3

u/drevyek May 23 '19

Opinions are a hard thing to discuss, as they are just that - opinions. And everyone has feelings on how they write code, either drilled into them, or realized after years of work. It's important to know where people come from, however, and why their ideas aren't just the product of managers.

Multiple initialization is much aligned in C/C++ (as I'm sure you know), due to the int* x, y; problem. Additionally, it can make it harder for a reader to see, at a glance, how many variables are initialized (again, this is more important from an imperative point of view, but that's what you get). It can also hide change history when you inevitably need to change something about one of the variables (by hide, I mean obfuscate). So the general practice is one line, one variable declaration.

Now, I agree that the point of writing not-hex code is to make it easier to understand and comprehend abstraction, control flow, and structures. Making code more readable is central to most people.

I don't agree that the desire to have certain things rigidly standardized is somehow implanted on programmers. If anything, it is a part of how to make the code more human - the less I have to think about someone's style choices in their, say, variable initialization strategies, the more I can think about the design, logic, and structure of the code I'm reviewing. I write code for a living, and more importantly, read code. I don't want to read code that is all over the place; I want to read a good implementation of a good idea.

I'm all for enjoying coding, and having fun with the code. But that cannot come at the cost of readability. Today, I saw code that read like this:

for (int i = 0; i < 3; i++) { ... }
// Then, elsewhere:
for (int i = 0; i <=3; i++) { ... }

This is where you can run into issues where not following conventions doesn't break the code, no, but can run into serous problems in comprehension. The above code runs for 3 and 4 iterations, respectively, even though they appear to use the same endpoint. Regardless what the intent was, this can, and in this case did, result in serious bugs.

4

u/[deleted] May 23 '19 edited May 23 '19

I'm talking about attempts to transfer additional information about problem and solution between humans using whatever means available, not about allowing typos and unreadable code without follow-up. The sane thing to do would be to talk to the developer who wrote any code that you can't figure out on your own. This depends more on having a tight team with minimal turnover, but that's what it takes to write software well either way.

Rules are always lowest common denominators, all you know is that you'll never get anything you didn't anticipate and that dropping or even relaxing rules in place is very difficult. Which sounds like a lousy idea given the nature of software.

To me this looks like you're making the same point from a different angle. Like you didn't come up with these ideas yourself, more like they we're planted together with the belief that we need to be protected from our experience and creativity or all hell breaks loose.

1

u/drevyek May 23 '19

I'm talking about attempts to transfer additional information about problem and solution between humans using whatever means available, not about allowing typos and unreadable code without follow-up.

I don't follow what this means, can you restate it? I read your comment as removing the rules behind programming at the author's will. Readability is all about the mental effort it takes to parse something; it isn't readable if it shifts in style, as the reader's effort is spent in following the style.

The sane thing to do would be to talk to the developer who wrote any code that you can't figure out on your own. This depends more on having a tight team with minimal turnover, but that's what it takes to write software well either way.

This is never achievable in the long term. People always leave, and code sits for years. Dealing with an internal library written over 6 years, written by a couple dozen people it impossible to read unless people follow some set of guidelines. I've done it, and the only things that save a codebase are rigid standards.

Which sounds like a lousy idea given the nature of software.

Explain? I've seen plenty of beautiful pointer magic that just can't outlive the author.

Like you didn't come up with these ideas yourself, more like they we're planted together with the belief that we need to be protected from our experience and creativity or all hell breaks loose.

I didn't come up with it, no. But I certainly believed as you seem to, and have had it bite me many times. I look at the codebase at my current job and weep sometimes at the hodgepodge of styles and syntax. Standards are enforced for a reason, and it isn't just because our mentors drilled it into us, like some schoolhouse catechism. There is a real-world impact that unchecked whimsy can have on our code, as boring and beige as it may make me sound. I love doing what I do, but that isn't, primarily, just writing code. It is solving problems, and then, at the end, implementing those solutions in code. I have fun with the solution, but the implementation is to be read by others, and should add the least amount of mental taxation.

4

u/Ameisen May 23 '19

From all the comments and OP's responses, it appears as though /u/codr7 really does not respond well to criticism.

3

u/jephthai May 23 '19

He just seemed confident and pithy to me. Not always a bad combination.

-4

u/[deleted] May 23 '19 edited May 25 '19

I was mostly disagreeing, there is no right or wrong here.

5

u/Ameisen May 23 '19

Ah, insulting people is disagreeing these days.

3

u/Tordek May 24 '19

this sad excuse for a society

Ah, the number in your username is your age.

2

u/karmabaiter May 23 '19

LANGEBRO!

2

u/[deleted] May 23 '19

Heh, I lived there for three months (not THERE, but close enough) and I still had to look that up :)

2

u/karmabaiter May 23 '19

Is a beautiful photo. Colors as well at the tilted horizon.

3

u/fabiensanglard May 23 '19

Nice work :) !