Julia vs. Python: Which is best for data science?

Python has turned into a data science and machine learning mainstay, while Julia was built from the ground up to do the job.

What is the Julia language?

Created in 2009 by a four-person team and unveiled to the public in 2012, Julia is meant to address the shortcomings in Python and other languages and applications used for scientific computing and data processing. “We are greedy,” they wrote. They wanted more:

We want a language that’s open source, with a liberal license. We want the speed of C with the dynamism of Ruby. We want a language that’s homoiconic, with true macros like Lisp, but with obvious, familiar mathematical notation like Matlab. We want something as usable for general programming as Python, as easy for statistics as R, as natural for string processing as Perl, as powerful for linear algebra as Matlab, as good at gluing programs together as the shell. Something that is dirt simple to learn, yet keeps the most serious hackers happy. We want it interactive and we want it compiled. (Did we mention it should be as fast as C?)

some advantages of Julia over comparable systems include:

  • Free and open source (MIT licensed)
  • User-defined types are as fast and compact as built-ins
  • No need to vectorize code for performance; devectorized code is fast
  • Designed for parallelism and distributed computation
  • Lightweight "green" threading (coroutines)
  • Unobtrusive yet powerful type system
  • Elegant and extensible conversions and promotions for numeric and other types
  • Efficient support for Unicode, including but not limited to UTF-8
  • Call C functions directly (no wrappers or special APIs needed)
  • Powerful shell-like capabilities for managing other processesLisp-like macros and other metaprogramming facilities.
  • Julia can call Python, C, and Fortran libraries. Julia can interface directly with external libraries written in C and Fortran. It’s also possible to interface with Python code by way of the PyCall library, and even share data between Python and Julia.
  • Julia supports metaprogramming. Julia programs can generate other Julia programs, and even modify their own code, in a way that is reminiscent of of languages like Lisp.

Julia vs. Python: Advantages of Python

Although Julia is purpose-built for data science, whereas Python has more or less evolved into the role, Python offers some compelling advantages to the data scientist. Some of the reasons “general purpose” Python may be the better choice for data science work:

  • Julia arrays are 1-indexed. This might seem like an obscure issue, but it’s a potentially jarring one. In most languages, Python and C included, the first element of an array is accessed with a zero—e.g., string[0] in Python for the first character in a string. Julia uses 1 for the first element in an array. This isn’t an arbitrary decision; many other math and science applications, like Mathematica, use 1-indexing, and Julia is intended to appeal to that audience. It’s possible to support zero-indexing in Julia with an experimental feature, but 1-indexing by default may stand in the way of adoption by a more general-use audience with ingrained programming habits.
  • Python has far more third-party packages. The breadth and usefulness of Python’s culture of third-party packages remains one of the language’s biggest attractions. Again, Julia’s relative newness means the culture of software around it is still small. Some of that is offset by the ability to use existing C and Python libraries, but Julia needs libraries of its own to thrive.
  • Python is getting faster. Aside from gaining improvements to the Python interpreter (including improvements to multi-core and parallel processing), Python has become easier to speed up. The mypyc project translates type-annotated Python into native C, far less clunkily than Cython. It typically yields four-fold performance improvements, and often much more for pure mathematical operations.
  • Python has millions of users. A language is nothing without a large, devoted, and active community around it. The community around Julia is enthusiastic and growing, but it is still only a fraction of the size of the Python community. Python’s huge community is a huge advantage.

Sources:

https://docs.julialang.org/en/v1/

Developer and part time tech blogger