Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Beautiful code


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
15 replies to this topic

#1 Mussi   Crossbones+   -  Reputation: 2095

Posted 15 October 2011 - 05:22 AM

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?

Sponsor:

#2 Radikalizm   Crossbones+   -  Reputation: 2974

Posted 15 October 2011 - 06:40 AM

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!


#3 Antheus   Members   -  Reputation: 2397

Posted 15 October 2011 - 08:47 AM

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.

Posted Image

It's similar with elegant code.

#4 Cornstalks   Crossbones+   -  Reputation: 6991

Posted 15 October 2011 - 08:56 AM

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.

Posted Image

It's similar with elegant code.

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


But in all seriousness, yeah, I agree.
[ 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 ]

#5 way2lazy2care   Members   -  Reputation: 782

Posted 15 October 2011 - 09:31 AM

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.

#6 SteveDeFacto   Banned   -  Reputation: 109

Posted 15 October 2011 - 07:57 PM

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 Posted Image

#7 Mussi   Crossbones+   -  Reputation: 2095

Posted 16 October 2011 - 07:17 AM

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.

Posted Image

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.

#8 markr   Crossbones+   -  Reputation: 1653

Posted 16 October 2011 - 04:14 PM

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).

#9 ApochPiQ   Moderators   -  Reputation: 16387

Posted 16 October 2011 - 04:32 PM

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!

#10 szecs   Members   -  Reputation: 2185

Posted 17 October 2011 - 02:05 AM

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).

#11 gavco98   Members   -  Reputation: 372

Posted 18 October 2011 - 02:02 AM

Only entomologists find my code beautiful :(
Gavin Coates
IT Engineer / Web Developer / Aviation Consultant
[ Taxiway Alpha ] [ Personal Home Page ]

#12 Lode   Members   -  Reputation: 982

Posted 18 October 2011 - 02:24 AM

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.

Posted Image

It's similar with elegant code.


The integral does not have enough information. f, a and b are not given.

I know this is just an example, but, this is what I disliked about courses and love about programming code:

Programming code requires you to give the value, operators, etc... of everything you need. Only then it compiles and works. Every mathematical problem can be formulated as programming code.

Mathematical formulas can be sloppy, and often are in course books, with you having to guess the values or sometimes even meanings of some of the symbols based on vague slides. Plus, variable names in math formulas are 1 letter names, that's not very readable code :).

#13 Eelco   Members   -  Reputation: 301

Posted 18 October 2011 - 02:54 AM


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.

Posted Image

It's similar with elegant code.


The integral does not have enough information. f, a and b are not given.

I know this is just an example, but, this is what I disliked about courses and love about programming code:

Programming code requires you to give the value, operators, etc... of everything you need. Only then it compiles and works. Every mathematical problem can be formulated as programming code.

Mathematical formulas can be sloppy, and often are in course books, with you having to guess the values or sometimes even meanings of some of the symbols based on vague slides. Plus, variable names in math formulas are 1 letter names, that's not very readable code :).


Truth.

Conciseness and brevity are not the same thing; mathematicians and some functional language designers have a habit of confusing the two.

A concise statement of a solution to a problem is awesome. Zipping the equivalent text string will not make it a better solution, just harder to work with.

#14 Hodgman   Moderators   -  Reputation: 31786

Posted 18 October 2011 - 03:20 AM

Zipping the equivalent text string will not make it a better solution, just harder to work with.

hahaha nice analogy!


Some things that come to mind for me when considering the beauty of code are:
How long does it take me to understand?
How connected/dependent is it to/on other code?
How deliberate is it with it's usage of resources?
How far does it stray from the scope of it's problem?
How easily can I change it?

#15 Telgin   Members   -  Reputation: 200

Posted 18 October 2011 - 09:40 AM


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!


I'd like to think this means my code is actually not as bad as I think it is. But I know better, my code is hideous because it's usually tossed together without a large amount of thought. It does work most of the time, but I feel bad for whoever has to maintain this stuff if I leave my current position.

I do feel a certain amount of pleasure in actually producing elegant code that is maintainable and scalable, but it just doesn't happen often. My code usually looks clean up until it's about 50 lines long. It's all downhill from there.
Success requires no explanation. Failure allows none.

#16 RivieraKid   Members   -  Reputation: 375

Posted 18 October 2011 - 01:11 PM

code that looks like the problem being solved is beautiful because anyone can understand it and its easy to maintain.

Layers of abstraction for abstractions sake are the devil.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS