Subscribe to DSC Newsletter

Interesting picture that went viral on Facebook. We've had plenty of discussions about Python versus R on DSC. This picture is trying to convince us that Python is superior to Java. It is about a tiny piece of code to draw a pyramid.

This raises several questions:

  • Is Java faster than Python? If yes, under what circumstances? And by how much? 
  • Does the speed of an algorithm depend more on the design (quick sort versus naive sort) or on the architecture (Map-Reduce) than on the programming language used to code it?
  • For data science, does Python offer better libraries (including for visualization), easier to install, than Java? What about the learning curve?
  • Is Java more popular than Python for data science, mathematics, string processing, or NLP?
  • Is it better to write simple code (like the Java example above) or compact, hard to read code (like the Python example). You can write Python code that is much longer for this pyramid  project (like the Java example) but far easier to read, yet executes just as fast. The converse is also true. What are the advantages of writing the compact, hard-to-read code?

Related article:

DSC Resources

Additional Reading

Follow us on Twitter: @DataScienceCtrl | @AnalyticBridge

Views: 59831

Reply to This

Replies to This Discussion

One R approach:

pyramid = function(n, x = list()) {

for(i in seq(n)) {x[[i]] = rep('*', i)}


# for 1000 rows:


user system elapsed
0.00 0.00 0.02

I feel this is not the way it can be compared.. I know both and found effective in their respective fields.



  • Add Videos
  • View All

© 2020   Data Science Central ®   Powered by

Badges  |  Report an Issue  |  Privacy Policy  |  Terms of Service