• 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
tom_mai78101

Optimization, Code Improvements, Code improvising... Questions, Questions, Questions...

11 posts in this topic

Do we learn all of these things when we are coding and nothing but coding? Just making a small example, being as humble as possible.

I was thinking of a imaginary book on Amazon.com that teaches a learner how to optimize a program, in a way that it's easy to do these things. And probably thinking that it's a intermediate level programming book. Or another imaginary book that guides a person who has finished an introductory book of a specific programming language, towards a more appropriately difficult level of programming.

You know, a book that's in the middle between Beginner and Advanced. If we have read this imaginary book, do we learn optimizations and/or code improving skills? Or, suggested by some people, we should continue to program/code, until we get tons of Eureka! moments while doing it, and learn from those experiences?

I know there are no shortcuts, knowingly that it takes about some X number of years to get it right, even I have read an article on being a good programmer in 6 really hard steps and felt it's a responsibility as a programmer to achieve it (well, sort of...).

I'm in a mood where I wanted to blurt out questions, and just wanted to kill time reading people's opinion on topics I'm interested in, such as this. I'm back to having a programmer's block, in a good way, as I've completed a hurdle (however large or small it seems...) in Java. Oh yeah, loved this new block.

And there's a rumor I've heard while Googling. If you're programming while doing a commentary, you'll sort of learn how to think in accelerated mode, meaning that ideas/thoughts/words keeps popping into your brain, and forcefully causes you to think faster while trying not to pause or go silent. Is that "code improvising"? Would it be in the same league as "optimization"?
0

Share this post


Link to post
Share on other sites
Meh. Reading said book could be beneficial or harmful. There's nothing wrong with learning optimizations and things like that. In fact, learning some of them can give you an Aha! moment, where you understand better what the computer is doing and why it does things in ways you first thought were weird, helping you to understand what's happening with your code and, hopefully, helping you to become a better programmer. However, the danger is getting into the Optimize This! Optimize Everything! mode of thinking. And then you start prematurely optimizing, and then you do two things to yourself. You stop creating and developing projects as well as you used to, so your development time goes up while your output goes down. And you also get into some bad habits of various hacks/workarounds just to save a cycle or two in an area of the program that it really, really doesn't matter.

tl;dr Its ok to read and learn, but just make sure you are aware of the dangers and pitfalls and are vigilant in protecting yourself from the traps.
0

Share this post


Link to post
Share on other sites
"Code improvising"

...

I code this way [b]if I already know the results I'm looking for and how to get them[/b], without laying out an outline or writing 5000 lines of comments that explain my logic and reasoning.

If I'm coding this way, I will do either one of two things:
*Realize the instant I write something that it can be written better, in less lines, or more efficiently, then re-write it.
OR
*Finish the snippet of code at hand, weather it's a class, a set of functions or an entire module, then scour through it and see where changes are necessary, then make them.

I don't focus on optimizing the crap out of something when I first write it, but I try to keep things as simple as possible, which brings me to this guideline I was taught when I started programming 7 months ago: The simplest solution, though not always the most straightforward, is usually the best. I'd rather see results NOW and worry about making those results less taxing later on. As long as things are abstracted to an appropriate level which allows you to do this, IMO this is the best way to do things.
0

Share this post


Link to post
Share on other sites
Hi Tom,



As others have mentioned, just worry about making an actual playable game first. And as I'm sure someone would / will point out; the compilers these days can optimize vastly better than most people can (even if they can write assembly themself). Make your layout, program your game, once it's playable run it through a profiler which will show you where the "bottlenecks" are. This way you can focus on and optimize areas that actually need it. Thus saving time, you actually stay motivated longer as you see results faster, and you avoid the foresaid pitfall above, "optimizing this, optimize that, optimize everything!"


Good luck :)
0

Share this post


Link to post
Share on other sites
Write code. Get it to work. Note anything that gave you trouble or gave you an eureka moment. Then show us and we can show you how to tweak it. Believe me. Code Review is a beautiful thing.
1

Share this post


Link to post
Share on other sites
Understand algorithms, data-oriented design, caching, and the memory hierarchy -- those are the optimization that are valid in the early-and-mid-game today. Optimization in the traditional sense, that is to say micro-optimization or non-algorithmic optimization, are highly dependent on machine architecture, and even on the structure of surrounding code (calling code, called code, or code that may have recently run), so there is absolutely no point in such optimization until the code is largely complete (at least by sub-system, not necessarily the entire body of code). Once you reach that level of completeness, intuition is unreliable and only profiling will tell you the truth about performance. Any optimization in a "cold" code path is wasted effort and unnecessary confusion.


Typically there are a few kinds of books relevent to programming -- beginner/introductory language/technology books, advanced language/technology books, references, algorithm books, patterns and practices books, reference books and hardware books.

If you've moved beyond the beginner's books (and you should be totally honest about whether you have), I would recommend to move on to algorithm, patterns and practices, and hardware books as a next step, and get lots of practical experience by writing *real* programs. As you complete these real programs, reflect on what went well or did not, and either carry that experience to the next program, or re-tackle the old one and try to do it better (though don't get stuck in that pattern too long, a new problem is always more challenging than a known quantity).
1

Share this post


Link to post
Share on other sites
Last few posts are pretty much spot on. I got few warnings though.

Don't set the goal too far, you will fail and lose motivation. Failing a project you have spent a lot of time will take the fun out of programming. Sometimes it's better to drop failed project than try to repair it. Maybe even do the project again from scratch, but better.

To learn to optimize, you should first write a working program. Then run profiler for it, measure where most time is spent, and only then start the research why is it slow and can it be improved.
0

Share this post


Link to post
Share on other sites
Most of what I would say has been said.

Now I am going to contradict all of that and mention a book that taught me so friggin much about optimization it was scary...

[url="http://www.amazon.com/Zen-Graphics-Programming-2nd-Applications/dp/1883577896"]Michael Abrashes Zen of Graphic Programming.[/url]

This book is old, very old, but damned if it didn't rewire the way I looked at code. Abrash just had this nack for explaining how to optimize code. I haven't read it in years, but it was about the only book that directly taught me optimization techniques.

I'm not recommending you pick it up... the subject matter just ins't relevant for the most part these days ( that book did the equivalent of writing Open GL or Direct X! ) as we don't work at the low of a level anymore, but it was a very profound read from an amazingly talented guy.



That said, even with that book, nothing taught me optimization like experience. Also, coming to the realization that 90% of code doesn't actually have to be optimized and benefits greatly from being readable... that one took a while to sink in.
0

Share this post


Link to post
Share on other sites
If you haven't come across it yet one of our moderators ([url="http://www.gamedev.net/index.php?showuser=33873"]ApochPiQ[/url]) recently posted a journal entry that I think might be relevant: [url="http://www.gamedev.net/blog/355/entry-2250592-become-a-good-programmer-in-six-really-hard-steps/"]Become a Good Programmer in Six Really Hard Steps[/url].

[size="1"][b]EDIT: [/b]Just realised you actually mentioned this article in the original post -- my apologies, but I'll leave the link here for the benefit of anyone else reading the topic.[/size]
[size="1"]
[/size]
[size="2"]Don't let the article scare you off however; the steps listed generally take a long time, and they're not easy to achieve, but it's not all rough-going with no reward along the way -- as you learn you'll experience a lot of rewarding moments where you manage to solve problems, where things click and you understand things you didn't before, and you'll probably make at least one or two pieces of software that you're really proud of and/or which help you out a lot in your day-to-day life.[/size]
[size="2"]
[/size]
[size="2"]
[/size]
[size="2"]If you feel you're getting beyond beginner books I'll second the recommendation of finding some more advanced books covering algorithms and/or data structures, or you could consider looking for a book which takes a more in-depth look at a particular subject (AI, graphics programming, whatever) which interests you. Don't be afraid to go back to your beginner books if you find you've bitten off more than you can chew, and don't be afraid to use reference materials. The important thing is to continue writing code and not to get too hung up on trying to do everything correctly the first time around -- just work towards making things work, and you'll find that the mistakes you make along the way will be your most valuable learning experience; you'll also get a feel for what works well, what doesn't work so well, and when/where it's worth putting in the effort to optimise.[/size]
[size="2"]
[/size]
[size="2"]
[/size]
[size="2"][b]You should also put in the time to learn how to use your tools properly. [/b][/size]
[size="2"]Get really familiar with your debugger and the various functionality it provides; if you're new to using the debugger get some relatively simple (but bigger than "Hello World" -- you'll need enough to play with!) that you're familiar with and mess it up on purpose -- cause compile errors and learn how to efficiently look up the error messages -- cause logical errors and learn how to step through your code and examine the contents of your variables and track down where things are going wrong.[/size]
[size="2"]Find a profiler and learn how to use it -- until you're working with real code this probably won't click with you, but it's worth trying to start early so you can get familiar with the tools and get into the habit of checking which parts of the program could really benefit from optimisation.[/size]
[size="2"]Learn how to use some sort of source control -- get some different advice (there should be plenty of posts and articles on the topic) on different ways to use source control and try them out with your small projects so that you can learn different work-flows and figure out what works for you.[/size]
[size="2"]
[/size]
[size="2"]Hope some of the helps![/size]
0

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