A Julia-Python-R Rosetta Stone

I’d like to share this cheatsheet illustrating common patterns side by side in Julia, Python, and R. I find it useful as a reference when switching languages, and perhaps others might also find it helpful. Here’s a preview of the first page:

16 Likes

it would be perfect if matlab is also included

1 Like

There seems to be a typo in Julia’s Boolean category: true && false == false.

Increase the font size please?

Nice effort! Assuming you accept bug reports here, here’s another small issue: 1:10 in Julia/R gives you 1 through 10 included, whereas range(10) in Python yields 0 through 9 included.

The nice thing about the current version is that you show the most idiomatic loops in all three. So I guess you’d want to decide whether it’s a Rosetta Stone for the spirit of the language or for the precise behaviour :slight_smile:

Thanks for the typo reports. These have been fixed. (I agree that changing to range(1, 11) is a good idea, to highlight the different indexing behavior.)

I agree it would be nice to have MATLAB/Octave for comparison too. For those who might not have seen it previously, this cheatsheet does include MATLAB.

The font size could be increased, but it would require reformatting the document (a disadvantage of PDF). My thought is that most folks would be using the PDF anyway, and then you can zoom in as needed. Could be worth supporting a large-font-size version, though, for those who want to print it out and have trouble reading smaller type.

1 Like

This is nice thanks. I wish we also had one for plotting. I mainly use ggplot as I am most comfortable with it, but

  1. this means I have to save Julia output and read into R.
  2. ggplot dosn’t support 3d plotting.

I’ve just downloaded PyPlot and am trying to work with it, but a cheat sheet for ggplot and equivalent PyPlot commands would be ideal. In fact, I don’t even know if PyPlot can work with “melted” data as I am so used to that.

There’s this one for Plots.jl.

It’s Julia-only though; I agree it would be nice to have a similar dictionary between Julia, Python, and R. I actually did start on something like that at one point, but I found it to be much trickier than the general purpose one linked in the OP here. The problem is that the mapping involves some translation of the way you think about building graphics (as opposed to mostly superficial syntactic differences), and I found it difficult to capture that. Still could be helpful even if that part isn’t done especially well, though.

4 Likes