Live data from Hacker News

A comparison of programming languages in economics

marginalrevolution.com

11–20 of 83 posts

Re: A comparison of programming languages in economics

#11

Earlier quoted context omitted.

It is unfortunate that the authors of this paper didn't reach out to experts in each programming language in order to write high-quality code against which they could have run the analysis. This seems like the perfect use-case for open-source: academic study, subject-matter experts in one area who are stepping outside their areas of expertise and an interesting subject matter. They should have crowd-sourced the code…

I don't know about other languages, but the authors did reach out to us to sort out performance issues with the Julia code.

That is very good to know. That reassures me a little.

I was really impressed with the speed difference they noted between Python and R and the fact that Numba wasn't too much slower than C++ implementations. However, given the state of the R code I became wary of accepting the benchmarks at face value.

I haven't made the jump from R to Python for statistical applications yet. So, this article gave me something to think about. In terms of programmer happiness, I'm willing to live with a little slower performance in Python and not have to spend hours in C++.

Re: A comparison of programming languages in economics

#12
post #9

Earlier quoted context omitted.

It is unfortunate that the authors of this paper didn't reach out to experts in each programming language in order to write high-quality code against which they could have run the analysis. This seems like the perfect use-case for open-source: academic study, subject-matter experts in one area who are stepping outside their areas of expertise and an interesting subject matter. They should have crowd-sourced the code…

From the paper... Second, to make the comparison as unbiased as possible, we coded the same algorithm in each language without adapting it to the peculiarities of each language (which could reflect more about our knowledge of each language than of its objective virtues). They have invited others to fork the code on github and write the fastest possible for each language.

Thank you for the note. I hadn't visited the github yet.

I will be interested to see whether people can whittle down the respective benchmarks.

Re: A comparison of programming languages in economics

#13
In case anyone missed the Java results, I do think it is worth mentioning that it is very competitive:

"Our fourth result is that Java imposes a speed penalty of 110 to 169 percent. Given the similarity between Java and C++ syntax, there does not seem to be an obvious advantage for choosing Java unless portability across platforms or the wide availability of Java programmers is an important factor."

Re: A comparison of programming languages in economics

#14
post #4

I used to be gung-ho about convincing economists to use Python (started econpy.org in the 1st year of my PhD in economics, stopped updating it after 2 years). But now I just don't care. The vast majority of economists are horrible programmers, however most know how to script in at least 1 language, and a small number of them are actually really good at scripting. An extremely small number of economists know they're w…

Hey, that's really neat. I'm doing a post-masters right now in energy economics and have been transitioning into using python for everything (from previously using Matlab or whatever was available), but I'm eyeing an economics PhD down the line.

You have any advice/opinions on economics PhDs?

Re: A comparison of programming languages in economics

#15

In case anyone missed the Java results, I do think it is worth mentioning that it is very competitive: "Our fourth result is that Java imposes a speed penalty of 110 to 169 percent. Given the similarity between Java and C++ syntax, there does not seem to be an obvious advantage for choosing Java unless portability across platforms or the wide availability of Java programmers is an important factor."

In my professional life I have rarely (if ever?) seen a language chosen on the basis of it's syntax.

Re: A comparison of programming languages in economics

#16
post #3

Their code is on github [1]. I am a C++ programmer so I'm happy that C++ came out on top, but the comparison is obviously flawed (as these sorts of comparisons always are). The problem is that the implementers don't have the same level of skill in each language and who knows how much time they spent analyzing and refining each version. See Russ Cox's response [2] to a Google paper [3] of a similar nature comparing C+…

I almost gasped when I saw that their R code[1] does the bulk of its computations inside a while(...for(...for(...for(...if(...){...}else{...})))) block, instead of using functionals like apply and 'vectorized' operations like ifelse.

If this criticism seems harsh, compare the authors' R code to Hadley Wickham's advice at http://adv-r.had.co.nz/Profiling.html -- or just search Google for "speed-up loops in R".

--

[1] https://github.com/jesusfv/Comparison-Programming-Languages-...

Re: A comparison of programming languages in economics

#17
Economic is a large, diverse field and it would be reasonable to assume, for instance, that R is used in very different ways than C++, so this study is already of limited use. Furthermore, they claim to be comparing the "strength and weakness of each language" yet only analyze the performance of naively-written, unoptimized code.

Re: A comparison of programming languages in economics

#19
post #15

In case anyone missed the Java results, I do think it is worth mentioning that it is very competitive: "Our fourth result is that Java imposes a speed penalty of 110 to 169 percent. Given the similarity between Java and C++ syntax, there does not seem to be an obvious advantage for choosing Java unless portability across platforms or the wide availability of Java programmers is an important factor."

In my professional life I have rarely (if ever?) seen a language chosen on the basis of it's syntax.

I get what you mean, but lots of languages have seen limited popularity due to their unfamiliar or odd syntax (e.g. lisp).

Re: A comparison of programming languages in economics

#20

Economic is a large, diverse field and it would be reasonable to assume, for instance, that R is used in very different ways than C++, so this study is already of limited use. Furthermore, they claim to be comparing the "strength and weakness of each language" yet only analyze the performance of naively-written, unoptimized code.

You bring up a good point in that the use cases for each language varies. R is a good example because one of the main reasons it is chosen is due to the fact that it already has the largest set of drop in econometrics operations for tons of extremely specific situations. In any other language, you'd often have to code a bunch of complex linear algebra by hand, which would totally negate any marginal benefits due to computation time.

In terms of econometrics, Python is going to surpass closed source software packages like SPSS, SAS, eViews, etc soon simply because the rate at which econometric procedures are being implemented in Python is growing steadily (e.g. via a statsmodels/pandas/numpy/scipy based stack). I don't think Python will ever pass R in this respect though as R has a large share of the statisticians helping add the implementations relative to Python.

Post reply on HN