The previous post glossed about why I now prefer Python to write code, including for a module like logopt. This post explains in more details some specific differences where I prefer one of these two languages:
- 0-based indexing in python versus 1-based indexing in R. This may seem a small difference but for me, 0-based indexing is more natural and results in less off by one errors. No less than Dijkstra opines with me on 0-based indexing.
- = versus <- for assignment. I like R approach here, and I would like to see more languages doing the same. I still sometimes end up using = where I wanted ==. If only R would allow <- in call arguments.
- CRAN versus pypi
- CRAN is much better for the user, the CRAN Task Views is a gold mine, and in general CRAN is a better repository, with higher quality packages.
- But publishing one CRAN is simply daunting, and the reason logopt remained in R-Forge only. The manual explaining how to write extensions is 178 pages long.
- Python has better data structures, especially the Python dictionary is something I miss whenever I write in R. Python has no native dataframe, but this is easily taken care of by importing pandas.
- Object orientation is conceptually clean and almost easy to use in Python, less so in R.
- Plotting is better in R. There are some effort to make Python better in that area, especially for ease of use. Matplotlib is powerful but difficult to master.
- lm is a gem in R, the simplicity with which you can express the expressions you want to model is incredible
All in all, I prefer coding in Python. This is a personal opinion of course, and R remains important because of some packages, but for more general purpose tasks, Python is simpler to use, and that translates in being more productive.