woensdag 23 september 2015

Programming languages compared, and why I'm sticking with Python until Julia grows up

Comparisons of programming languages abound, especially with regard to running speed. This paper in the Journal of Economic Dynamics and Control by Boragan Aruoba of the University of Maryland and Jesús Fernández-Villaverde of the University of Pennsylvania is yet another one, albeit in a peer-reviewed journal and with a procedure (value function iteration) that is common in my field. Main observations:
  • When it comes to speed nothing beats C++ and FORTRAN.
  • Julia performs really well: only 2.37 times the running time of C++.
  • Python and R are slowpokes, at about 45 (Python with the Pypy interpreter) to 491 times (R without its Compiler package) times the running time of C++.
  • Matlab is somewhat inbetween the slowpokes and the frontrunners, with about 9 times the running time of C++.
  • R, Matlab and Python can get a boost from just-in-time-compilers and C compilers (like Rcpp for R; or Numba or Cython for Python) that make their running time comparable to that of Julia (although Rcpp is still a bit disappointing: 5.4 times the C++ running time).
Adding my own considerations:
  • I tried C++ and gave up very quickly. I bloody hate it with a passion.
  • I find R not much better: even though it is a scripted language it is clumsy, illogical, and makes for horrible code. Rcpp worked fine until I found out that it cannot handle matrices with more than 2 dimensions. Speeding up your R code with bigger matrices requires the use of full-blown C++. In other words, two languages that I bloody hate.
  • I value my independence, so I prefer to work on my own laptop with my own licenses. That makes Matlab, with its steep license fee, a no-go.
  • I've experimented with Cython and it seems to work quite well. I love the accessibility and clear layout of Python; moreover, my university teaches Python twice a year in an undergrad course. The only real problem with Python is that it is reputedly difficult to parallellize.
  • One day I'll start using Julia. It's fast, accessible, and (so they say) easy to parallellize. But not until there is a stable version and a decent IDE.

zaterdag 19 september 2015

On interdisciplinarity

Check out the really cool cover of Nature's special feature on interdisciplinarity!

Of course, as an economist I especially like their inclusion of "Invisible Hand" as the sole superhero representing the social sciences in their scientific team of Avengers. But it is also symbolic for the fact that economists have, in my view, gone the furthest in integrating their discipline with the natural sciences. This holds particularly for environmental and resource economists, who by definition deal with problems of the natural environment like pollution and overfishing. The reason is pretty geeky: most economic research is quantitative, and quite a lot involves the development of mathematical models. And whaddayaknow: so do climate science, population biology, hydrology, and a host of other natural sciences. Give me your equations and I'll plug them into my CGE model.

It is actually much, much harder to truly integrate qualitative social sciences like sociology or anthropology with quantitative sciences - even with a social science like economics. Models like IMAGE and DICE describe the global climate as well as the economy; the Gordon-Schaefer fisheries model and Colin Clark's work on renewable resource use, which use basic models from population biology like logistic growth, are part of the standard canon of resource economics since decades; when Daniel Pauly criticizes the limited impact of the "social sciences" on fisheries research, he lumps together economics with biology, not sociology. Meanwhile, it has taken until 2009 that the Nobel committee finally recognized anthropologist Elinor Ostrom for her contributions to the economics of common pool resources, and economists and sociologists share little but contempt for each others' fields. The Indian economist Jagdish Bhagwati is said to have joked that good economists reincarnate as physicists; wicked economists reincarnate as sociologists. But Ostrom's Nobel also shows that things are changing, especially in the field of institutional economics. Let's have more of that in the future.