dimanche 22 mai 2016

Why Javascript in 2016 ?

Many of my friends express their surprise when I say I chose to learn JavaScript in 2016.

With so many cool languages to learn, why using a "toy language" of the past instead of, let's say Haskell, Go, Nimrod, Rust (just to name some)?

First and foremost, for me it's not as much as learning JavaScript in 2016 as learning a new language in 2016. But whatever your reasons : not become fossilized, improve your efficiency with new tricks/paradigms/tools or just plain fun you'll probably feel the urge to learn a new language sooner or later.
This bring us back to the question why JavaScript in 2016?

Reason to choose JavaScript


It could be handy to be able to do everything in one unique language (from command line tools, front-end Web dev,  server coding, phone applications to robots programming) and JavaScript now allows that. That wasn't the case before but with node/express/commander/ionic/cylon.js (to name few) you'll have all your needs covered.
Data mining, 3D display, efficient network agents, whatever the task, you can do it efficiently in JavaScript.


Every study will tell the same story: Javascript developers are on high demand, and the demand is growing.
  • CodingDojo list Javascript as the 3rd top requested language.
  • Bloc.io give interesting figures on the growth.
  • ...
This makes JavaScript an excellent skill to possess.


When learning, the community is as much important as the technology studied.
I find in the Javascript community the same things I've learnt to love in the Perl community : efficient tools, diversity, an unorthodox/innovative/open/somewhat messy but pragmatic approach.
This community is easily reachable through the numerous quality blog and sites :


You could evaluate a language ecosystem by many ways but let's consider the JavaScript ecosystem by it's users base and by its language central repository.

The site modulecounts lists NPM as the first module repository whatever the language (be it for total modules count or average growth) and even if some things are to be improved, npm offer a really easy way to manage/reuse the impressive JavaScript's modules list.

Concerning the users base, a github study on languages (2015)  place Javascript as the top language.

That is just numbers of course, but whatever the criterion you choose, chances are that the Javascript's community will score well against all the other languages.


Although not as disruptive for your coding habits as another language (like Haskell) could be.
JavaScript brings many things to play with and extend your confort zone.
Want to play with asynchronicity (would be a good Idea if you still haven't done so in 2016 ;-) )? What about trying promises?
Want to try functionnal programming? Check Ramda or Immutable.
Love to explore new Web paradigm? I suppose things like React / Flux or Koa might interest you.
With the language itself being in constant improvement and the use of transpilers, even the syntax evolves regularly.


That's another area where JavaScript shines. As a developer, having  many configurable linters (JSHint, ESLint...), transpilers (Babel), test libraries/frameworks (Jasmine, Mocha, Chai, PhantomJS...), task runners (Grunt, Gulp) enable you to enforce good practices, better code quality/consistency and globally speed up langage learning.


For some the abundance of choice and constant change may be daunting.
But if you're not among them, be prepared, with JavaScript, to explore a world where there are always plenty of new options and no consensus on the "best" tools to use.
New tools/projects pop up faster than you can list them and issues tend to be solved in no time.


If you're embracing change, 2016 could be the perfect time to learn JavaScript.
I hope this article gave you enough information to convince you. In all cases, don't hesitate to comment and give your feedback.

mercredi 18 mai 2016

Migration dans la simplicité.

Après une mise à jour de mon système je me suis retrouvé avec un postgresql 9.5 flambant neuf (et vide) ! et une version 9.3 encore en place avec toutes mes bases dedans.

Mais moi je veux toutes mes bases dans la 9.5 et pas de 9.3.

Modification du Port à 5433 dans /etc/postgresql/9.3/main/postgresql.conf et 5432 dans /etc/postgresql/9.5/main/postgresql.conf

Un petit redémarrage en tant que root

root@vault:~# pg_ctlcluster 9.3 main restart
Redirecting restart request to systemctl
root@vault:~# pg_ctlcluster 9.5 main restart
Redirecting restart request to systemctl

Une copie simplissime en tant qu'utilisateur 'postgres' :

postgres@vault:~$ pg_dumpall -p 5433 | psql -d postgres -p 5432

Un peu de nettoyage

root@vault:~# pg_ctlcluster 9.3 main stop
Redirecting stop request to systemctl
root@vault:~# pg_dropcluster 9.3 main

Et voila toutes mes bases migrées...

J'adore PostgreSQL !

mercredi 27 avril 2016

Yeoman : Passing data from generator to sub generator

I won't present Yeoman here. If you like to use scaffolding tool and use JavaScript, you already have heard about this great tool.

Maybe you've even tried to write your own generator. If you did, sooner or later you'll want to structure your code using sub generators and pass data from your (main) generator to your sub generators.

This simple task took me more time than needed, mainly because I was unable to find the right documentation.
The official documentation on the topic suggest using composeWith() with the options parameter to pass data to the called generator, but doesn't show how to get the data in the called generator.

So in hope the following could help others, you'll find below an example of how to do it.

In the generator you call the sub-generators this way :
//in generator-arhuman/generators/app/index.js 
this.composeWith('arhuman:express', { options: { my_opt: 'anystring' } }, { local: require.resolve('../express') });

Note the second parameter, the options object described in the documentation.
Now in the called sub-generator you get the data in the constructor by defining an option:

//in generator-arhuman/generators/app/express/index.js
module.exports = yeoman.generators.Base.extend({ 
  constructor: function () { 
      yeoman.generators.Base.apply(this, arguments); 
      // This option will get the value passed by the caller generator
      this.option('my_opt', { 
            type: String, 
            required: true, 
            desc: 'My option' 
  // Writing Logic here 
  writing: { 
    // Copy the configuration files 
    config: function() { 
        this.destinationPath('package.json'), { 
          name: this.options.my_opt
     // ...

  install: function () {

By giving it the same name as the key in the options object used in the composeWith() call you will get the value from the caller generator and use it later through this.options.my_opt