Thursday, December 20, 2012

IE Fail Story



Chrome: http://chrome.google.com
Firefox: http://getfirefox.com
IE: http://windows.microsoft.com/en-US/internet-explorer/downloads/ie-9/worldwide-languages

Tuesday, December 18, 2012

Python vs Bash

For some reason I liked the idea of language comparison.
Today's topic is "Python vs Bash". 

From internets: "Generally, bash works better than python only in those environments where python is not available."

Bash is great for one-liners, maybe 10-liners tops. For the rest tasks - Python is the clear choice. 
I've used both bash and python a lot. Bash maybe even two times more than python. And the main reason for choosing python over bash for scripting is that python works with read-data, while bash works with "stderr/stdout". In other words:

bash = "raw stdout/stderr text + script logic"
python = "down/upstream data + script logic (+ exceptions control, + multi-threading, + libraries)"

Monday, December 17, 2012

.... and one more for Python vs. Perl


Python:

def command_wrapper(args):
    <some logic>

pool = multiprocessing.Pool(pool_size)
try:
  pool.map_async(command_wrapper, commands).get(run_timeout)
except SomeTimeOutException:
  <some timeout handler>


Perl:

while ($children < $max_children) {
  if (my $pid = fork) {
    $children++;
  } else {
    $SIG{'ALRM'} = sub {
     <some sig_alrm handler>
    }
    alarm(run_timeout);
    <some logic>
    $SIG{'ALRM'} = 'DEFAULT';
  }
}

CoffeeScript > JavaScript

There is one thing that is missing in coffeescript vs javascript comparison on coffeescript.org. In coffee almost all the braces are optional and therefore it's "easy-on-the-eye", but (!) there's also a huge benefit of omitting braces - you don't have to match them.

Like this:

abc = (function() {
  $.ajax({
    url: "/cgi-bin/someapp/someurl.php",
    data: ({
      someparam: "somevalue",
      anotherparam: "anothervalue"
    }),
    success: function(data) {
      somehandler = function() {
        alert("bl");
      };
      for(var i=0; i < 10; i++) {
        somehandler(i);
// WTF below this line
      }
    }
  })
})()

And... last four lines are easily understood in this short piece of code or if the code was written two minutes ago. It will be not, however, 3 months after that.