Julia gets mentioned in an article about FORTRAN

A different perspective.

I think “Python but fast” is a good way to explain Julia to programmers who have never heard of it. The main differences are

  • speed - fast enough that it doesn’t need C extensions. CPython is notoriously slow on many tasks. I think speed is the biggest difference between CPython and Julia, because it avoids needing C extensions in many cases. The original “Python but fast” is PyPy, whose speed has been hampered by maintaining compatibility with the old CPython C-API; recently the Hpy project has started work on replacing that API. I suspect (without evidence) that if PyPy had been available when the scientific Python stack was being written (around 2000), then Python’s scientific libraries wouldn’t need so many C extensions either, and that stack could’ve been implemented with much more Python and much less C.

  • multiple dispatch - has some ecosystem effects like encouraging more array types. I don’t think this has as much impact yet as it could, mostly because Julia lacks interfaces. Without an interface definition system, APIs are inconsistent, unreliable, and have unclear semantic relationships. I don’t think “automatic interoperability” is scalable in practice under an informal manual model. This is why Clojure has Spec and why Python has protocols/zope interfaces/ABCs.

  • macros - Allow more concise syntax in some cases. Python might get these soon though they often do more harm than good. Julia’s hygiene is complicated.

  • uniform packaging story - Having a single declarative packaging tool makes it easier to statically analyze and manipulate packaging metadata. Python has good packaging systems now with Poetry and Conda, but there’s a ton of existing code that doesn’t use systems like these.

Python and Javascript are maybe the most-used languages in the world, so it makes sense to compare to them when possible. But the comparison is also pretty natural.

On the similarities. I’ll pick some features and compare Julia and Python to alternative choices other languages have made.

  • Easy to start. print("hello") just works. Compare to Java which needs public static void main(String[] args) which can overwhelm a beginner before they even start.

  • Significant focus on scientific applications. Contrast with Common Lisp, a fast lisp with a smaller scientific user focus.

  • Syntax. Mostly M-expressions but with some reserved keywords like continue and while. Contrast with Scheme, which uses S-expressions only.

  • Built-in repl. Contrast with C++, which is often used in scientific applications but doesn’t have a repl.

  • Dynamic typing. Values are tagged with their class at runtime. Contrast with C++ again.

  • Static type annotations. Both have a system for optionally declaring types which helps with reliability and documentation when used. Contrast with C++ which has required static annotations and Clojure which doesn’t have any.

  • Mutability. In both languages, mutable state is widely used. Contrast with Haskell which mostly disallows this.

  • Ability to evaluate code as data. Julia has syntax sugar :(a + b) which can be written in Python as ast.parse("a + b"). Since the distinction between compile time and run time is fuzzy under JIT compilation, these are more similar than they look. Python also has builtins compile() and eval(). Contrast with Go which doesn’t have this.

  • Program distribution. Run under the preinstalled runtime executable. Contrast with Go which makes static executable binaries.

  • Strings. Strings are sequences of code points. Contrast to Swift which uses extended grapheme clusters.

  • Partial extensibility. Users can define the value of the booleanized version of their expression, but can’t control the behavior of if or overload dispatch. Contrast to CLOS which lets users control dispatch.

  • Garbage collection. Allocated space is collected automatically by a garbage collector. Contrast to C and Rust which don’t have this.

  • Batch garbage collection. Latency can be inconsistent under this model, which is relevant in some applications. Contrast to Go, which considers GC latency an “existential threat” and designed its garbage collector to minimize latency.

  • Hard to control low-level performance-sensitive properties. For example, there is currently no way to disallow allocations in either language. Contrast to C, which makes allocations more explicit.

  • Unrestricted use of foreign objects. You can access private data on any object. Contrast to Java which disallows this.

All in all, I don’t think Julia in 2021 is as different from Python as some users might – except for tuned speed – but that’s not necessarily a bad thing: Python is popular for good reason. Julia is immature in comparison and hasn’t yet figured out its story on a lot of things, such as traits and interfaces, which are promising future directions (among many others). Julia’s capabilities are likely to mature over time in ways we haven’t seen yet.

18 Likes