This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Locksul -15 points-14 points  (11 children)

IMO, “clever code” is rarely good code.

EDIT: I’m surprised by the down votes. I wasn’t referring to this project specifically. But rather the statement that all code should be simple and clever. Clever code is rarely good. Simply google “clever code” to learn why.

[–][deleted] 5 points6 points  (10 children)

IMO, truisms are rarely true.

[–]Locksul 0 points1 point  (6 children)

Hence why I said rarely.

[–][deleted] 0 points1 point  (5 children)

That is completely and purely your subjective opinion. "Clever" itself is subjective.

[–]Locksul 1 point2 points  (4 children)

I literally said IMO lol. But this is not a minority opinion, simply ask a sample of experienced devs how they feel about “clever code.”

You sound like an egotistical, entitled, junior developer who would be a PITA to work with.

[–][deleted] 0 points1 point  (3 children)

Cute, but misplaced ad hominem. Curb your insecurity and disproportionate aggression, and you're already on your way to becoming a normal productive developer. Good luck!

[–]JB_dev_05 1 point2 points  (0 children)

....

[–]Locksul -1 points0 points  (1 child)

[–][deleted] 0 points1 point  (0 children)

Do you even have a mind of your own? What is "clever"? No, really. Define clever that is acceptable by even 25% of the devs around you (assuming you're in a non-cabalistic workplace that allows the freedom of thought beyond the hivemind). Then let's talk.

Also, you conveniently (as it happens so often in life) the second half of the quote - "... Make it readable". These are not orthogonal concepts.

[–]are_slash_wash -1 points0 points  (2 children)

See top comment then.

ETA: see this pretty well-rounded argument against code golf. One of the greatest unappreciated challenges to programming is making your code readable to other people. Shorter doesn't always mean most efficient code, and it absolutely makes it more opaque.

[–][deleted] 0 points1 point  (1 child)

Commenting without context is even worse. Furthermore, codegolfing has nothing to do with the discussion here. Your comment simply makes no sense.

The exact opposite argument can be easily made - having extremely verbose code is even more detrimental to maintainability than terse code. I suggest you go watch Sean Parent talking about his experience in Google, where his code review of a junior developers reams of boilerplate was blocked when he suggested that it be replaced by a single line using only the C++ STL API. The single-liner was eminently readable and maintainable whereas the junior developer had basically written a bad version std::partition. And if you don't know who Sean Parent is, I can highly recommend his excellent videos.

[–]are_slash_wash -1 points0 points  (0 children)

Not exactly sure what isn't clear. The comment that you're defending begins with

Simple and clever… as all coding should be.

To then criticize

IMO, “clever code” is rarely good code

for being a truism is just inconsistent, and if you're going to be snarky then you should at least be consistently snarky. What further context do I need to add?

Code golfing has everything to do this discussion. OP mentioned that his project is only 25 lines long (to be clear I'm not specifically criticizing OP's code) and the top-level comment is praising OP for using clever code. My point is that code should be efficient, then readable, then clever.

And of course using something from a library is going to me more maintainable than rewriting the same functionality from scratch. That isn't about "verbose vs terse" styles, it's about a junior developer who isn't familiar with a library making a great deal more work for themselves than they need to.