ciplogic.com
Live with grace. Write superb software.

I just took for a test the native promises implementation (that is available since node v0.12), the bluebird implementation, and core-promise, my own TypeScript implementation.

The tests are here for the native, bluebird or core-promise. Note that all the implementations pass the full Promises/A+ test spectrum of 872 tests.

I ran each test file 11 times, using:

1
for f in `seq 0 10`; do time mocha test-core-promise.js > /dev/null 2>&1; done

Obviously, I changed the file name between iterations.

I removed 11.9 seconds, because these are setTimeouts in the actual tests, remaining with actual execution of promises time, and these are the final results (in seconds):

 

Native Bluebird Core-Promise

1.616 1.760 1.564

1.567 1.626 1.520

1.568 1.669 1.548

1.539 1.657 1.573

1.574 1.595 1.557

1.583 1.604 1.580

1.543 1.582 1.540

1.529 1.622 1.567

1.600 1.605 1.567

1.407 1.661 1.544

1.467 1.640 1.587

 

Conclusion

Unsurprisingly the native implementation won performance wise, but only less than 1% compared to the core-promise, but ~5% compared to bluebird. Also core-promise defaults to the native promises implementation if it's available, if you would use the exported Promise class (for tests I accessed the CorePromise implementation on purpose).

1
var Promise = require("core-promise").Promise;

Not to mention readability of code: core-promise's Promise vs bluebird's Promise.

*Disclaimer* I am the creator of the core-promise, and yes I feel pretty good getting better performance than the "unmatched performance" of bluebird. :)

Do you want to live reload the browser as you edit and save using VIM?

Well wait no more, you can install the application by simply running:

1
2
npm install -g fast-live-reload
fast-live-reload

Afterwards whenever saving, the page is automatically reloaded. Without any browser plugins.

fast-live-reload in action

Start with:

1
sudo visudo

(Press `ESC` followed by `:wq<ENTER>` to write the file, press `i` to start typing. When unsure press `ESC`.)

Add a line after all the Defaults with the following content:

1
Defaults    insults

For example on my system that would be:

1
2
3
4
Defaults    env_reset
Defaults    mail_badpass
Defaults    secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
Defaults    insults

Try to sudo with a wrong password and see what happens:

1
2
3
4
5
6
7
8
raptor:~$ sudo ls
[sudo] password for raptor: 
No soap, honkie-lips.
[sudo] password for raptor: 
Do you think like you type?
[sudo] password for raptor: 
stty: unknown mode: doofus
sudo: 3 incorrect password attempts

Yes, they change randomly.

When creating web applications, a lot of time is consumed switching back and forth between the code and the application itself. What if there would be an application that would refresh your browsers automatically?

Did your mind needs to stop to read (taken from ckeditor source):

1
2
if ( !dontRemove )
    removeNoAttribsElement( element );

Well you're not alone.

Stop using double negations, even if your code looks "cleaner", and refactor them to be single negations.

A simpler rule is never use negation variable names, so you don't run into issues like this. So don't use names such as: "noElementPresent", "dontRemove" or "notExisting".

For the previous example instead of "don't remove" go with "keep element", "keep", or something along those lines. Just search a thesaurus if you can't find a word.

1
2
if ( !keepElement )
    removeNoAttribsElement( element );

Notice how readability is just so much better.

Disqus Comments

comments powered by Disqus

Germanium

The one to rule them all. The browsers that is.

SharpKnight

SharpKnight is an Android chess game.

MagicGroup

MagicGroup is an eclipse plugin.