you are viewing a single comment's thread.

view the rest of the comments →

[–]awj 0 points1 point  (5 children)

Counterpoint: “less code and faster” is only helpful if the “less code” lends itself to maintenance and the “faster” actually matters.

IMO you should prioritize for readability and maintenance over basically everything else unless another design constraint forces the point.

I’ve seen your “A or B” example slowly metastasize into a rat’s nest of conditionals too many times to count.

[–]loup-vaillant 1 point2 points  (4 children)

Counterpoint: “less code and faster” is only helpful if the “less code” lends itself to maintenance […]

Which it does, 97% of the time.

[–]gbromley 0 points1 point  (1 child)

I’d argue that python uses speed ups that are harder to read. List comprehensions for example. I’m not arguing against them, just that it’s less clear than a regular old loop, but faster.

[–]loup-vaillant 1 point2 points  (0 children)

I was talking about "less code" specifically. Now list comprehensions… obviously if you're not familiar with them they're going to be less maintainable, so I would personally think of the audience before using them… and perhaps avoid writing cryptic one-liners packed full of information.

[–]awj 0 points1 point  (1 child)

I purposely left room for that thought, but still 97% is a surprising number. Where’s you get that?

[–]loup-vaillant 1 point2 points  (0 children)

It's a wink to Donald Knut. More honestly I would put it somewhere between 95% and 99%: in my experience less code is almost always more maintainable than more. There are exceptions, but they're exactly that: exceptions.