Today's Question:  What does your personal desk look like?        GIVE A SHOUT

 ALL


  JavaScript efficiency catch up

JavaScript is a very flexible language, we can write JavaScript code freely with various styles, different kinds of codes will have different execution efficiency. Here we summarize some tips we get from our development.Efficiency of JavaScript itselfJavaScript has execution context chain, closures, prototype inheritance, eval etc. It brings us some magic features, but it also introduces the performance issue, if we don't use them properly, it will affect the codes execution efficiency.1. Global variableWe may use global variables such as window,document and some custom global variables while ...

3,188 0       JAVASCRIPT EFFICIENCY EVENT DELEGATION EVAL


  40+ Techniques to enhance your php code

1. Do not use relative paths , instead define a ROOT pathIts quite common to see such lines :1require_once('../../lib/some_class.php');This approach has many drawbacks :It first searches for directories specified in the include paths of php , then looks from the current directory.So many directories are checked.When a script is included by another script in a different directory , its base directory changes to that of the including script.Another issue , is that when a script is being run from cron , it may not have its parent directory as the working directory.So its a good idea to have absol...

4,139 0       PHP EFFICIENCY QUIRK TRICK TECHNIQUES


  sorting in C++: 3 times faster than C.

If you don't know C++ well, you might be surprised how fast C++ can be sometimes. This is especially true when code involved is small, because then inlining - which is what C++ is very good at - and templating, which makes excessive inlining possible in the first place - has the most effect.The following code compares C and C++ sorting:  #include <iostream>#include <algorithm>#include <vector>#include "stop_watch.inl" // see https://gist.github.com/2057981#ifndef COUNT#define COUNT 100000000#endifint compare_int(const void* p1, const void* ...

3,873 0       C C++ EFFICIENCY FASTER SORTING


  Using C for a specialized data store

Pixenomics stores and transports 1.2 million pixels from the server to the client. During development we played with various methods to store and process this. Our ultimate goal was to send the entire board in under 1 second.During the stages of prototyping we used a MySQL database without thinking too much about performance. With a mere 2,000 pixels we quickly realised this wasn’t even usable as a demo. Changing the storage engine to memory was much better but still obviously unusable.The problem wasn’t to store the pixels but to retrieve all 1.2 million pixels quickly as well a...

2,540 0       C PERFORMANCE EFFICIENCY DATA STORE


  What's Wrong with the For Loop

Closures in Java are a hot topic of late. A few really smart people are drafting a proposal to add closures to a future version of the language. However, the proposed syntax and the linguistic addition are getting a lot of push back from many Java programmers. Today, Elliotte Rusty Harold posted his doubts about the merits of closures in Java. Specifically, he asks "Why Hate the for Loop?": I don’t know what it is some people have against for loops that they’re so eager to get rid of them. This isn’t the first or even the second time CS theorists have revolted against ...

2,242 0       JAVA EFFICIENCY PROBLEM FOR LOOP BASIC


  Python Performance Tips, Part 1

To read the Zen of Python, type import this in your Python interpreter. A sharp reader new to Python will notice the word “interpreter”, and realize that Python is another scripting language. “It must be slow!”No question about it: Python program does not run as fast or efficiently as compiled languages. Even Python advocates will tell you performance is the area that Python is not good for. However, YouTube has proven Python is capable of serving 40 million videos per hour. All you have to do is writing efficient code and seek external (C/C++) implementation for speed ...

3,102 1       TIPS PERFORMANCE PYTHON EFFICIENCY


  Introducing the for-if anti-pattern

Over the years, I've seen a bunch of coding anti-patterns.I figured maybe I'll share a few.Today, I'll introducewhat I'm calling the for-if anti-pattern,also known as"We'll sell you the whole seat, but you'll only need the edge."This is a special case of the for-case anti-pattern, whereall but one of the cases is null.for (int i = 0; i < 100; i++) { if (i == 42) { do_something(i); }}This can naturally be simplified todo_something(42);The for-if anti-pattern arises in many forms.For example:foreach (string filename in Directory.GetFiles(".")){ if (filename.Equals("desktop.ini", StringCom...

2,992 0       PROGRAMMING ANTI-PATTERN FOR-IF EFFICIENCY


  Scala Macros

This is the home page of project Kepler, an ongoing effort towards bringing compile-time metaprogramming to Scala. Our flavor of macros is reminiscent of Lisp macros, adapted to incorporate type safety and rich syntax. Unlike infamous C/C++ preprocessor macros, Scala macros: 1) are written in full-fledged Scala, 2) work with expression trees, not with raw strings, 3) cannot change syntax of Scala. You can learn more about our vision of metaprogramming from our talks. We propose to enrich Scala programming language with three flavors of type-safe compile-time macros: macro defs, macro types and...

5,282 0       SCALA EFFICIENCY MACRO MAINTAINEBILITY