

Ask YC: What Does "Taste and Style in Programming" Mean to You? - watmough

I like to look at code and be able to say that it has been written with 'taste and style'. Taste and style means different things to different people.<p>What does it mean to you? What do you like to see in code or design?
======
gizmo
Code has style when you can't describe why the code is so good. Because when
you try to describe it, you know you're selling it short - the code is more
than simply its specification. The only way to convey the quality of the code
is by reading the code itself. Code has style when you'd rather read the code
than an explanation of what it does.

For me, it's always a matter of simplicity. When a problem is hard to describe
in English, you naturally assume the code will be a bit complex as well. And
yet, sometimes, the problem can be decomposed so neatly that the parts are
trivial and fit together effortlessly. For me a requirement is that after
carefully reading the code you are absolutely certain there is no room left
for bugs. You almost know for certain that the code didn't have any bugs when
it was written down for the first time, because it captures intent so well. If
you need to refactor it's probably too late already.

So I think books like "Beautiful code" got it entirely wrong. I especially
don't agree with icey's opinion that refactoring can make code tasteful or
that linebreaks can make or break greatness. It's about bringing human
thoughts to computer code. And when that mapping is perfect, the code is
great.

~~~
Agathos
Some of the essays in Beautiful Code argue more or less what you said here, or
at least they do to me. What do you think they got wrong?

------
pavelludiq
Look at the two pieces of poetry:

"Did you hear about the rose that grew

from a crack in the concrete?

Proving nature's law is wrong

it learned to walk with out having feet.

Funny it seems, but by keeping it's dreams,

it learned to breathe fresh air.

Long live the rose that grew from concrete

when no one else ever cared."

and

"I see no changes all I see is racist faces

misplaced hate makes disgrace to races

We under I wonder what it takes to make this

one better place, let's erase the wasted

Take the evil out the people they'll be acting right

'cause both black and white is smokin' crack tonight

and only time we chill is when we kill each other

it takes skill to be real, time to heal each other"

there both from Tupac Shakur, but the first one is from the poem " the rose
that grew from concrete" and the second one is from the song "Changes" The
difference is that in the first one its just words put together with a
meaning, they say something. But the second one i like more, because of the
rime and the rhythm. The first one is written on paper and published to be
read, but the second one is from a song, it has to conform to the rhythm of
the song, the words are structured to fit with the music and the flow, the
second one has structure and architecture and it has to be simple enough to
fit with the music and the beat. Making the second one is harder and its more
beautiful. When i see good code, for me that means that it follows the flow of
the readers mind, the code just fits and does its job, no fancy magic stuff,
just simplicity and beauty. It has to be easy to understand too.

~~~
Agathos
I like the first one a lot better.

You may have unintentionally supported the null hypothesis, that there's just
no accounting for taste.

~~~
pavelludiq
The first one is good of course, but the idea is that i liked the structure
and rhythm of the second one. If i was looking for poetic expressiveness i
might rethink my choice. The idea of taste is that you look for something, and
if you find it in an object, you like that object. If you are looking for
strange symbolist metaphors in poetry, you don't look at realism poetry, you
look at symbolism. And in PG's essay about taste he said that people just have
a lot in common, so they are generally looking for the same stuff.

------
icey
I know exactly what you're talking about! To me, you can look at a piece of
code, and know if it has a certain Feng Shui to it... Code that is only dense
when it has to be, and is commented when it is. Artful use of white space.
Code that has obviously been refactored once or twice.

Other than that, it's sometimes hard to describe. But it is very easy to tell
if you're looking at code from someone who loves to code versus code written
by someone who just does it for a paycheck.

------
ratsbane
I like to see code that my mind can parse as easily as the machine can.
Tasteful code likely is short, efficient, and readable... but perhaps there
are exceptions to that? Good taste is like obscenity - hard to define but you
know it when you see it.

<http://www-cs-faculty.stanford.edu/~knuth/lp.html>

------
donw
This is the same as asking why certain pieces of art or music are beautiful.
Any two random people would likely disagree over their interpretations of
beauty, but as a whole, many works would likely receive a drastically high
'beautiful' vote, like Pachelbel's Canon.

That said, with code, I think there are a few properties which are considered
'beautiful' or 'tasteful', not in and of themselves, but combined with that
impalpable aesthetic we call 'beauty'.

Of all of these, I think the only one most programmers would agree on is that
truly incredible code is nominally quite brief.

~~~
gizmo
> truly incredible code is nominally quite brie

That's probably true. But that makes me wonder...

People have a hard time appreciating poetry in their second or third language,
because you need to have such vast knowledge to get the subtleties of the
poet's intentions.

I suspect the same holds for code. The more skilled and more experienced the
programmer, the more complexity he can handle. And he'll find beauty where
mortals like us are simply confused.

I can't appreciate Shakespeare, but I suspect it is as great as many claim it
is. I would probably dismiss Shakespeare as unnecessarily complex and verbose
if I didn't know better.

Worth thinking about the next time you're annoyed at a piece of complex code,
and really want to refactor it so everybody can read it. You may be destroying
something beautiful.

------
neilk
I don't know if it can be boiled down to one thing. One likes to see mastery
at every level, from the high-level design down to strict adherence to coding
conventions.

The software has to have a strong opinion about what it's doing. It's modelled
the problem in a way which leads to a straightforward solution, using a
minimum number of concepts.

According to the conventions of the language in which it was written, the
visible structure must reveal the underlying concepts. To a reasonably
experienced practitioner, the code documents itself and comments are
infrequent.

------
baha_man
It's much easier to see what's bad about code written by other people. I
suggest you look at some really bad code, and then try and imagine what a
superior programmer would find offensive about your code.

You can always visit thedailywtf.com if you're lucky enough not to be exposed
to bad code on a daily basis. My personal pet hates are copy-and-paste code,
inconsistent formatting, excessively long lines, bad or non-existent naming
conventions, Hungarian notation, and spelling mistakes - pretty basic stuff.

------
iron_ball
I'd like to add a subquestion: I'm always told to check out other people's
code and study it, but I'm also well aware that popular software doesn't
necessarily mean good code. What source-available projects would you recommend
I look at if I want to see some quality examples of the craft?

~~~
culley
I recommend finding a mentor. Someone who writes code that you respect (be it
for quality, clarity or efficiency). Start reading their code and asking
questions.

The open source community is a good place to start looking if you don't have
someone you respect in your own community.

~~~
Agathos
And so the question comes full circle: did you have any particular open source
projects in mind? It's a big community.

------
richcollins
Usually simplicity with correctness

------
pg
Getting the essential things right.

~~~
simplegeek
essential things, please explain this a bit?

~~~
andreyf
If you're programming in Lisp, this probably means writing the right macros -
the right DSL - to express the rest of your code in.

------
almost
Five pounds of flax

