Take the 2-minute tour ×

While this may be a very subjective question I was wondering if there's a place (or many places) on the web where one can read up about good coding and performance tips for different languages and how they may compare with others?

For example in AS3 it's faster to multiply rather than to divide, is this the same for JS? What other tips are there to really make our code run lightening fast? And where are these tips?

share|improve this question

closed as not constructive by Mark Trapp Nov 21 '11 at 21:20


Good coding practices can be subjective, but performance definitely isn't. –  Steven Jeuris Nov 8 '11 at 13:37
Please don't get offended, but your question sounds too much like "what is the zen of all good software engineering?" or in the lines. It is good to discuss good coding practices and performance. However,I would suggest you should rather be little more concrete about your question. –  Dipan Mehta Nov 8 '11 at 16:26
I'm not offended, I think you misunderstood the question. It's about writing the best optimised code depending on tips and tricks for different langages, eg loops and what not. –  Ahmed Nuaman Nov 8 '11 at 16:47
If a "one stop shop" actually existed, then sites like this or stack overflow would not. –  whatsisname Nov 8 '11 at 17:55
While this might've been a way to generate a canonical answer to this type of question, it instead became a discussion topic. If a question like this is going to work, it's better off reasked with more specificity. –  user8 Nov 21 '11 at 21:21
add comment

4 Answers

I think this website i.e Programmers.StackExchange is basically aimed at this types of problems and question only. Here is an excerpt from the FAQ page :-


  • algorithm and data structure concepts
  • design patterns
  • developer testing
  • development methodologies
  • freelancing and business concerns
  • quality assurance
  • software architecture
  • software engineering
  • software licensing
share|improve this answer
Technically if the question is "which of these two operations will run faster in X language" isn't that a StackOverflow question? –  Ben Brocka Nov 8 '11 at 13:13
No, I think it will belong here. Rather than being directed at a particular coding problem, it concerns the language feature which should be sought here. For example, In this question , I asked which has a better performance b/w ICollection<T> and List<T> –  Pankaj Upadhyay Nov 8 '11 at 13:18
@BenBrocka: And if the question is formulated as, "can this piece of code be made more performant?" it can also be a Code Review question. :) –  Steven Jeuris Nov 8 '11 at 13:39
@PankajUpadhyay I was under the impression language stuff only belongs here at a fairly high level-fundamentals of OOP and their support in languages, recursion, not stuff like nitpicky "++x vs x++" which I seem to see fairly often on SO. It's a language feature but I feel it's too "close to the code" for here, I may be misjudging though. –  Ben Brocka Nov 8 '11 at 14:05
Of course stackexchange is always a place to turn to in times of need but when it's just little things like recursion, loops (what BenBrocka mentions) I would've thought that there's somewhere to read up on this. –  Ahmed Nuaman Nov 8 '11 at 14:19
add comment

The real question you should ask yourself first is: "Should I already be thinking about performance?"

Usually you should only be concerned about performance once you run into performance issues. Here is one of my favorite quotes:

It is easier to optimize correct code than to correct optimized code. - Bill Harlan

For performance problems caused by inefficient algorithms (or hobbyist discussions irrelevant to an actual project) you are best off here at Programmers. For language specific performance problems you are better off at Stack Overflow.

And to answer your actual question: If a site which lists performance statistics for every language (comparing features) existed, how would you use it? Would you choose one language over the other because it does faster virtual calls?

share|improve this answer
I do understand your point of view and yes you're right but optimised code can be correct code too, for example casting int instead of Number in AS3 is quicker and what not. It's just these little things that one ought to get into a habit of doing when writing code. Regarding your last part, I wouldn't use it to choose language X over Y, it's just nice to have a comparison and to see how tasks perform differently in different languages. –  Ahmed Nuaman Nov 8 '11 at 14:20
@AhmedNuaman: Funny that you should mention that (Number vs int). I did a quick google check for it and found this interesting observation. –  Steven Jeuris Nov 8 '11 at 14:28
Hahaha, see! There's so much conflicting stuff. I guess it probably makes sense to start discussions on SE and then use that as a reference! And RE numbers, I got my refer from Mr Skinner: gskinner.com/talks/quick/#10 –  Ahmed Nuaman Nov 8 '11 at 15:23
That's what I'm trying to find out, any resources where one would say "Flash @25fps Number is easier/faster/better than int" and why. –  Ahmed Nuaman Nov 8 '11 at 16:46
In the database world if you aren't thinking performance during design you are incompetent. There are known performance killers that anyone should avoid using as a first choice. Performance is critical to database systems. It is not simple to refactor badly performing databases that have 100,000,000 records in the tables. It is not premature optimization to learn performant design and code and to use that as the first choice. –  HLGEM Nov 8 '11 at 20:31
show 3 more comments

You're getting really good answers here. The stack* forums are an excellent source of information.

While each language has performance tricks, the key to good performance is simplicity of design. Then, after the software is running (not when you're coding) deal with performance. It's unproductive to go eyeballing code and guessing if you should use trick X in location Y. Let the actual running program tell you what to fix. (Everybody knows that, but they still use the ready-fire-aim method.) If you learn this technique for performance diagnosis, you will find it useful, as have many others.

Basically, you interrupt the program at random several times, and each time understand in detail what it's doing. Don't skim. Understand what it's doing and why.

If you see it doing something twice, no matter how you describe it, that activity is taking significant time. The sooner you see it, the more significant it is.

Technically, if some activity is consuming fraction p of time, the average number of samples you need before you see it twice is 2/p. So if p is 20%, on average it will take 10 samples to see it twice. (Technically, this comes from the negative binomial distribution, where if a coin has fairness p, the number of tails you will get before x heads is, on average, x(1-p)/p.)

The point of this approach is that, rather than measuring various things and hoping to narrow in on some problem code, it shows you the problem in crystal-clear detail, even if it's not localized to a particular piece of code. It can find problems you can't find any other way.

share|improve this answer
add comment

Based on the lack of actual answers, you might want to build the site you were looking for. It's fairly easy to make the simple performance comparisons you described and put them into a blog. If you want others to be able to provide input, you could encourage Stack Exchange to add a performance.StackExchange.com site, or you could build a similar site yourself.

share|improve this answer
I really don't think this post should qualify as an "answer". It tells the asker that his question doesn't have an answer, and that he should answer it himself. It would be much better to attempt to answer the question, then provide the kind of guidance that this "answer" attempted to give. ... see what I did there? ;p –  Steven Jeuris Nov 9 '11 at 8:36
add comment
