Comparison of Programming Languages in Economics
Lectures will be given in English in Ancona by Riccardo (Jack) Lucchetti and in Italian in S. Benedetto del Tronto by Giulio Palomba. Students may attend whichever they prefer. However, students are expected to have a decent proficiency with both languages, since teaching material may not always be handed out in both, although we will do our.
This project contains the source code referenced in the paper A Comparison ofProgramming Languages in Economics by S. Borağan Aruoba and JesúsFernández-Villaverde.
![Riccardo ‘jack Lucchetti Riccardo ‘jack Lucchetti](/uploads/1/2/6/2/126289117/245445959.jpg)
The main fork will remain basically unchanged to allow researchers to check ourbasic results.
Abstract from the paper
We solve the stochastic neoclassical growth model, the workhorse of modernmacroeconomics, using
C++11
, Fortran 2008
, Java
, Julia
, Python
,Matlab
, Mathematica
, and R
. We implement the same algorithm, valuefunction iteration with grid search, in each of the languages. We report theexecution times of the codes in a Mac
and in a Windows
computer andcomment on the strength and weakness of each language.Files
RBC_C.c
: C code.RBC_CPP.cpp
: C++ codeRBC_CPP_2.cpp
: C++ code, more idiomatic but slightly slower.RBC_F90.f90
: Fortran code.RBC_Java.java
: Java code.RBC_Julia.jl
: Julia code, to runinclude('RBC_Julia.jl'); @time main()
.RBC_Matlab.m
: Matlab code.RBC_Matlab_Inside_Loop.m
: Matlab code with Mex file.inside_loop_mex.cpp
: Mex file for 8.RBC_Python.py
: Python code for CPython and Pypy.RBC_Python_Numba.py
: Python code for Numba.RBC_R.R
: R code.RBC_R_Compiler.R
: R code compiled.RBC_Rcpp.R
: R code with Rcpp.InsideLoop.cpp
: C++ function for Rcpp.RBC_Mathematica
: Mathematica code.RBC_Mathematica_Imperative
: Mathematica code with imperative structure.RBC_Mathematica_PartialCompilation
: Mathematica code with imperativestructure and partial compilation.RBC_CS.cs
: C# code.RBC_JS.js
: Javascrip code.RBC_Python_Cython.py
: Cython code.RBC_Swift.swift
: Swift code.
Compilation flags
- GCC compiler (Mac):
g++ -o testc -O3 RBC_CPP.cpp
- GCC compiler (Windows):
g++ -Wl,--stack,4000000, -o testc -O3 RBC_CPP.cpp
- GCC compiler (Mac):
g++ -o testc -O3 -std=gnu++11 RBC_CPP_2.cpp
- Clang compiler:
clang++ -o testclang -O3 RBC_CPP.cpp
- Intel compiler:
icpc -o testc -O3 RBC_CPP.cpp
- Visual C:
cl /F 4000000 /o testvcpp /O2 RBC_CPP.cpp
- GCC compiler:
gfortran -o testf -O3 RBC_F90.f90
- Intel compiler:
ifortran -o testf -O3 RBC_F90.f90
javac RBC_Java.java
and run asjava RBC_Java -XX:+AggressiveOpts
RBC_C.c
can be compiled in C, C++ and Objective-C:clang -o testc -x <language> -O3 RBC_C.c
with<language>
=c
,c++
orobjective-c
. Same for GCC.- Swift:
swiftc -o testswift -O RBC_Swift.swift -sdk $(xcrun --show-sdk-path --sdk macosx)
In all cases with a JIT, you may want to warm up the JIT before testing forspeed.
More about gretl
You can get the 1.10.1 version of gretl 11.49 MB from this site. This program is shared by Allin Cottrell, Riccardo 'Jack' Lucchetti completely free of charge. You can find it in the Education category, specifically Science, it supports .inp, .gdt formats. Versions 1.9 and 1.8 are still the most downloaded ones and can be run on Windows 7/8.1/10. Gretlw32.exe and gretl.exe are among the most popular installers that people use to download the software. The download link was scanned by a number of antivirus solutions and was proved to be clean.
Download