• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Mussi

Beautiful code

15 posts in this topic

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?
1

Share this post


Link to post
Share on other sites
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
0

Share this post


Link to post
Share on other sites
Compare:[code]
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 ... = ???[/code]

vs.

[img]http://upload.wikimedia.org/wikipedia/en/math/1/8/4/1845918e723ad0b5874fa2fb77870925.png[/img]

It's similar with elegant code.
2

Share this post


Link to post
Share on other sites
[quote name='Antheus' timestamp='1318690047' post='4872857']
Compare:[code]
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 ... = ???[/code]

vs.

[img]http://upload.wikimedia.org/wikipedia/en/math/1/8/4/1845918e723ad0b5874fa2fb77870925.png[/img]

It's similar with elegant code.
[/quote]
Exactly. The code is waaaay more elegant than the stupid integral.


But in all seriousness, yeah, I agree.
0

Share this post


Link to post
Share on other sites
[quote name='Radikalizm' timestamp='1318682411' post='4872817']
For me it's not the code itself that is beatiful, but the implementation behind it
[/quote]
I'm the opposite. I find the algorithm more beautiful than the actual implementation of it.
0

Share this post


Link to post
Share on other sites
[quote name='Mussi' timestamp='1318677745' post='4872793']
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?
[/quote]

All of my code is beautiful! jk [img]http://public.gamedev.net/public/style_emoticons/default/tongue.gif[/img]
0

Share this post


Link to post
Share on other sites
[quote name='Antheus' timestamp='1318690047' post='4872857']
Compare:[code]
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 ... = ???[/code]

vs.

[img]http://upload.wikimedia.org/wikipedia/en/math/1/8/4/1845918e723ad0b5874fa2fb77870925.png[/img]

It's similar with elegant code.
[/quote]

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

Share this post


Link to post
Share on other sites
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).
0

Share this post


Link to post
Share on other sites
[quote name='markr' timestamp='1318803254' post='4873231']
Code which does useful stuff, mostly does not look beautiful. Aesthetics is not its primary concern.
[/quote]

This.

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


Hmm, I smell a journal entry :-)


[edit] [url="http://www.gamedev.net/blog/355/entry-2250790-there-are-many-kinds-of-ugly/"]As threatened![/url]
2

Share this post


Link to post
Share on other sites
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).
1

Share this post


Link to post
Share on other sites
[quote name='Antheus' timestamp='1318690047' post='4872857']
Compare:[code]
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 ... = ???[/code]

vs.

[img]http://upload.wikimedia.org/wikipedia/en/math/1/8/4/1845918e723ad0b5874fa2fb77870925.png[/img]

It's similar with elegant code.
[/quote]

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

Share this post


Link to post
Share on other sites
[quote name='Lode' timestamp='1318926253' post='4873805']
[quote name='Antheus' timestamp='1318690047' post='4872857']
Compare:[code]
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 ... = ???[/code]

vs.

[img]http://upload.wikimedia.org/wikipedia/en/math/1/8/4/1845918e723ad0b5874fa2fb77870925.png[/img]

It's similar with elegant code.
[/quote]

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 :).
[/quote]

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

Share this post


Link to post
Share on other sites
[quote name='Eelco' timestamp='1318928048' post='4873816']Zipping the equivalent text string will not make it a better solution, just harder to work with.[/quote]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?
0

Share this post


Link to post
Share on other sites
[quote name='ApochPiQ' timestamp='1318804324' post='4873241']
[quote name='markr' timestamp='1318803254' post='4873231']
Code which does useful stuff, mostly does not look beautiful. Aesthetics is not its primary concern.
[/quote]

This.

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


Hmm, I smell a journal entry :-)


[edit] [url="http://www.gamedev.net/blog/355/entry-2250790-there-are-many-kinds-of-ugly/"]As threatened![/url]
[/quote]

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

Share this post


Link to post
Share on other sites
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.
1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0