Is good code easy to read/understand, or clever and concise?

Is good code easy to read/understand, or clever and concise?

Other urls found in this thread:

blogs.janestreet.com/category/ocaml/
twitter.com/NSFWRedditVideo

#1

>Is good code easy to read/understand

Yes

Both

Both

Depends.

If you're working in enterprise, they probably follow OOP principles, in which case you want to follow the SOLID OOP principles.

If you're writing a personal short term project, then clever and concise is fine. If you're working on a project to share with other ppl that isn't too serious, then readable.

Neither because it's should be in assembly without any comments

In fintech I wrote algorithmic trades in OCaml and had to use induction to prove my functions had no side effects. A guy checked my programs and would reject them if they weren't so clear an idiot could understand them. All my clever hacks were rejected too since if it wasn't proven to work nobody would touch it.

>algorithmic trades in OCaml
Nope.

Always go with clever one-liners. If the human doesn't understand it, you just need smarter humans.

Thanks for the comments. Just finished my first major bit of code for my coop job and was wondering where to go from there. I wrote concise code compared to what my coworkers were doing, but what I made is also less obvious than what they had. Thinking now that I'll more or less just copy their style of programming for the time being and wait some months (when I really know what I'm doing) before I try out the fancy faggot approach again.

Depends on the project.

If its something you just need to get done for a contract or whatever, good code is whatever works, meets specifications and gets the job done.

If it's something you intend to go back and reuse time and time again, and you have other people using/interacting with it at the source code level, good code is something that's easy to read and understand.

If you're evil and you want to have leverage over your boss but be hated by your coworkers, good code is clever and concise, always works, is well documented, but the code itself is *purposefully* hard to read and full of things like ternary operations, functions you've made yourself which are integral to the code successfully working, and just totally spaghettified within each block.

If you need to write incomprehensible code to show off your ego, then you're just insecure.

always ALWAYS easy to read/understand. even for personal projects, when you get back to it in 5 years, you'll want to understand it

anyone who says otherwise doesn't have programming experience or is a retard

>clever code
Could mean that you're using obscure features and things people normally don't think about. That's bad. Unless its helping achieve some goal.
>easy to read
Not always possible to achieve. Some systems aren't easy to understand because they're solving complex problems. That said complexity is to be fought where it can be afforded.
>concise
This is usually good in the true meaning of the word. But far too often people think writing a python oneliner is the only concise code. If you have a hundred lines of code that's trivial to understand sequentially it's often much better than one line of less comprehensible code. The one liner ruins your pattern recognition. If you write the hundred line version you can get the gist of the code quicker a lot of the time.

It manages to combine both.

Honestly, it's more complex than all that. Carmac's fast inverse square root function is God tier code even tho it's incomprehensible.

It's fast, optimizes a bottle neck, does a discrete job, and more importantly, it can be verified to work by unit testing it thoroughly.

It's also stood the test of time.

Good code should have the ugly bits separate from other functions. Hard to read and hard to verify are separate problems.

the best code has zero comments

>the best code has zero comments
>the worst code also has zero comments

blogs.janestreet.com/category/ocaml/

git. gud.

at my job i write obscure lovecraftian black voodoo magic code that only i can maintain so the company cant fire me unless they want to rewrite all of the software

on my personal projects i like to write clean and concise code

code that is -truly- concise is necessarily easy to understand

That's a nice way to make unmaintainable code and shit on your future self or your coworkers

Both, but obviously being easy to read is far more important because eventually other people are going to have to understand it so they can work on it.

if both have the same performance, then obviously easy to read.

you dont want to dig through 2000 lines of 'clever' code everyday.

"clver and concise" code is for stuff code artisans don't mess around, like really low level shit.