Advertisement

Beautiful code

Started by October 15, 2011 11:22 AM
14 comments, last by RivieraKid 13 years ago
Sometimes when I write a complex piece of code that's easy to reuse and loose coupled or something along those lines I can't help but think it looks beautiful :lol:. How many of you occasionally think their code looks absolutely beautiful?
For me it's not the code itself that is beatiful, but the implementation behind it

I've had a number of occasions where I had an idea for a feature or an improvement in some of my projects which seemed to work out great on paper, but which I was unsure of while fleshing it out and implementing it (is this going to be fast enough? am I making this overly complex? etc.)

To see such an implementation working nicely and often even better than expected while written in a clean coding style is pure beauty to me, and the sense of accomplishment you get from implementing something you designed completely by yourself and which is working perfectly is just awesome

I gets all your texture budgets!

Advertisement
Compare:
Volume of sphere = 4.13 * r^3
Volume of cube = a^3
Volume of cylinder = 3 * r^2 h
Volume of tea pot = "measure with cylindrical cups the volume of water it holds"
Volume of a mine = ...
Volume of a ... = ???


vs.

1845918e723ad0b5874fa2fb77870925.png

It's similar with elegant code.

Compare:
Volume of sphere = 4.13 * r^3
Volume of cube = a^3
Volume of cylinder = 3 * r^2 h
Volume of tea pot = "measure with cylindrical cups the volume of water it holds"
Volume of a mine = ...
Volume of a ... = ???


vs.

1845918e723ad0b5874fa2fb77870925.png

It's similar with elegant code.

Exactly. The code is waaaay more elegant than the stupid integral.


But in all seriousness, yeah, I agree.
[size=2][ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]

For me it's not the code itself that is beatiful, but the implementation behind it

I'm the opposite. I find the algorithm more beautiful than the actual implementation of it.

Sometimes when I write a complex piece of code that's easy to reuse and loose coupled or something along those lines I can't help but think it looks beautiful :lol:. How many of you occasionally think their code looks absolutely beautiful?


All of my code is beautiful! jk tongue.gif
Advertisement

Compare:
Volume of sphere = 4.13 * r^3
Volume of cube = a^3
Volume of cylinder = 3 * r^2 h
Volume of tea pot = "measure with cylindrical cups the volume of water it holds"
Volume of a mine = ...
Volume of a ... = ???


vs.

1845918e723ad0b5874fa2fb77870925.png

It's similar with elegant code.


This is sort of how I shoot myself in the foot sometimes. When I only need the volume of one or two items for example, I still try to implement the general and more elegant solution, which takes more time and adds unnecessary complexity.
Code can look beautiful, but the proof of the pudding is in the eating.

Code which does useful stuff, mostly does not look beautiful. Aesthetics is not its primary concern.

While there are some things which look ugly, and are very bad, in practice, a lot of uglyness is about making it *sodding well work*. Code looks ugly, because it contains countless small bugfixes which accumulate over time, to make it look like a mess, but it *works*.

I see programmers (not software engineers!) refactor code because they think it is ugly. They may make it look nicer, but inevitably introduce countless bugs. Software engineers never refactor code because it is ugly.

Unit tests might detect the really big stupid bugs, but the small, sneaky bugs get through, into production, and break stuff for customers (err, players in the games industry, I guess).

Code which does useful stuff, mostly does not look beautiful. Aesthetics is not its primary concern.


This.

Most production-level code is actually pretty hideous. Of course, it can be hideous because it's truly bad, or because it's full of tiny considerations for really obscure cases.


Hmm, I smell a journal entry :-)


[edit] As threatened!

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

Hmm, if I were at my own computer, I could do some mass killing by showing some of my code I saw beautiful.
They weren't good or anything, but sometimes I spent hours just looking at those beautiful code (with appropriate music of course).

This topic is closed to new replies.

Advertisement