198 points · by jakobnissen · 3y ago · 179 comments
Python is the de facto but it's so slow for anything that can't be well represented as vectorized NumPy operations. There are ways around that like Numba, Jax, Cython, etc. but their use cases are pretty limited, and they don't work well with other Python packages.
There is, of course, C and C++ which are commonly used to speed up Python or as standalone packages. However, C++ is such a complicated beast that writing performant and correct code takes forever. C is much more manageable, but I find that there are not a lot of scientific packages written in pure C. This isn't even touching on the horrendous build system that is CMake.
Fortran is a pretty simple looking language and would probably be the closest to Julia in terms of speed and expressiveness, but the writing is on the wall and Fortran's days are numbered. I am not aware of many new packages being developed using it.
Other than that, there's languages like Rust and Go but those have ecosystems that are so small, they make Julia's ecosystem look like Python's. I really don't want to spend my time as a grad student writing basic numerical libraries from scratch.
Nothing could be further from the truth. Fortran, both the language itself and the packages in the ecosystem, is continually developed. There are a few peer-reviewed studies that quantitatively tracked Fortran usages and concluded that Fortran is not just for legacy code -- people actually continue to write new packages precisely for the reasons you mentioned (expressivity, performance)
"Modern Fortran" book would be one way of doing it,
Same goes with Perl - probably more Perl developers than at its heyday in the 90s but a smaller chunk of the overall picture. Measure by noise levels and anything that doesn't explode seems to be dying.
I'm sure people will become more critical of Julia if it successfully becomes the de facto for those things but there's a big difference in that Julia is very focused on those things whereas Python is trying to be as general purpose as possible
I really don't see a place for Python
ml --> Julia, C++, R
dataviz --> R, JS/TS
beginner-friendly --> JS
web --> JS
want a backend framework but wanna choose a language that's easy to hire for --> TS, Ruby
huge, stable community --> JS/TS
quick scripts --> Deno
systems --> Rust, C++, Java, Go
I'd say it still dominates in scripting/webscraping and creating shareable work (e.g. Jupyter), but I'm just pointing out that at this point it's replaceable in those areasI see that as more of a point in Python's favour than Julia's. IME languages that are designed as general-purpose languages tend to be better than languages that are designed for niche purposes, even within those niches. The things that make a language good require consistent, general thinking.
They've been saying this since the late 1980s. Not that I think it's particularly lively, mind.
From "The Handbook of Computers and Computing", by Arthur H. Seidman and Ivan Flores, 1984, https://archive.org/details/handbookofcomput00seid/page/342/... :
> For many years, it has been popular to predict that FORTRAN soon will be a dead language, to be replaced by a "better" language. Despite the undeniable fact that there are more eloquent, rich and powerful languages available, FORTRAN continues to be used widely and, indeed, is still the most popular programming language for scientific and engineering applications.
From NASA Conference Publication 2055, Engineering and Scientific Data Management, 1978,https://archive.org/details/NASA_NTRS_Archive_19780025833/pa...
> Margaret White: ... I know FORTRAN is essentially a dead language, but there is a lot of FORTRAN around. Would you care to respond?
> Jim Browne: Is there anyone from IBM who would care to respond? The microphone is yours. Who is it? How many times has FORTRAN been buried?
I am mostly indifferent to the language (love the Jupyter equivalent tool Pluto, dislike Pkg, love the simplicity of matrix operations, dislike being pushed towards the REPL...) - I am increasingly irked by the observation that in topics like this the Julia community comes out in force to downvote anyone who expresses a negative opinion.
I’ve always found Matlab the language to be small and simple, with just a few oddities. The library is where most of the warts accumulated, but I’ve used it long enough to learn them. Performance is much better than python - very fast matrix operations and Java-like speeds for everything else, with comparable startup times.
Main argument against that is probably that it's possible to get the same sort of codegen out of C++ and fortran native programmers are somewhat scarce, though I'd bet on it being easier to teach to domain people than julia or c++.
(disclaimer: I've used neither of them)
I see what you did there.
If Julia had evolved into a community-managed language in the same way that Python has, I would have a positive outlook on it - but I am nervous about the efforts to commercialise it (which mostly just seems to be a case of skimming value off of financial institutions). It is totally understandable why the creators went down this route, but I just wish they had been more idealistic rather than getting on the "everything is a VC-backed company" bandwagon. While I hope Julia continues to grow, I don't trust its longevity enough to put serious effort into using it for myself.
Google owning Go is a big downside, but I think people know that going in - also, Google makes no attempt to monetize the language.
If you think that picking any language and any library combination with a semi-high requirement for the number of features you want to be already implemented will be able to fulfill the "this has to be completely correct or I won't use it for my research"-requirement you will have a hard time.
The last part of the post seems to be about OffSetArrays.jl. Many people who have implemented libraries and who care about composability and generic input also agree that the Base AbstractArray interface is not perfect or complete and sometimes the issue is that the interface that does exist is not followed well enough for composability to work. A more complete, agreed upon, and generally adhered to interface for an "AbstractArray" would be nice and has been+is being worked on and discussed by many people in the community.
Hamming distance was one, if I recall correctly, that wasn't correct, as well as a few others in its parent module.
I still use the package, of course, because its great. But given the disconnect I saw I'm still careful when documenting as to what method is used (and use a comment to clarify). Most of the time it isn't a huge deal.
If you need correct results, the trick is to not trust anything. Any results that come out need to be validated. This can be done by running the equations backwards to see if the initial conditions and/or boundary conditions hold. For example, when I wrote matrix inversion routines long ago, I'd check that multiplying the original by its inverse produced the identity matrix.
I.e. do not trust. Verify.
Julia's authors get credit for trying to rewrite many core compute/LA libraries from scratch in a composable manner rather than using ancient fortran code nobody dares touch. That said, the article was a good wake up call to the community that tests and correctness is vital for trust.
Edit: First paragraph removed as the person I referred to disagrees with me and asked me to make an edit.
You can go even further than that. OpenBLAS, the BLAS linear algebra library that things like Julia and NumPy use by default now, was an MIT Julia Lab project. The developer was a research software engineer in CSAIL under Alan Edelman! And then the openlibm open source math library? Also made by the Julia developers. Julia developers like Steven Johnson and Doug Bates are also the ones behind some of the ancient classic codes like FFTW and nlopt. So in many cases they aren't just rewrites but rewrites by authors of the some (but not all of course) of the ancient codes!
(And many of these are C)
In what sense? The only "official" link that I can find is that one of the developers spent part of 2016 as a postdoc at MIT.
openlibm is just (yet another) msun repackage, isn't it?
Only the BLAS/LAPACK reference implementation are in F77. Intel MKL, OpenBLAS, ATLAS and other are all in a mix of C and ASM.
And yet this is an anticipated reaction:
> Whenever a post critiquing Julia makes the rounds, people from the community are often quick to respond that, while there have historically been some legitimate issues, things have improved substantially and most of the issues are now fixed.
> For example:
> [...]
> These responses often look reasonable in their narrow contexts, but the net effect is that people’s legitimate experiences feel diminished or downplayed, and the deeper issues go unacknowledged and unaddressed.
> My experience with the language and community over the past ten years strongly suggests that, at least in terms of basic correctness, Julia is not currently reliable or on the path to becoming reliable. For the majority of use cases the Julia team wants to service, the risks are simply not worth the rewards.
Julia's library compatibility is still an issue, but hardly related to the language itself. Unlike many languages, Julia has regression testing for its graphical plotting output. This means it can and usually does check that a given output matches a previously known function(s) output across each release iteration. This means that unlike many languages that fix/ignore various external library versions, Julia actually checks that data gives the exact same results every time.
The caveat is that people must report issues to the project, or add regression tests to ensure correctness persists throughout the ecosystem. =)
Now, there are of course much more mature options if that makes you comfortable, which is totally respectable, but saying there are bugs in the programming language borders spreading FUD.
Coming from C two of them were expected for me (products of Int8) and aliasing of arrays on sum! But I suppose that's debatable
How do you feel about bugs in the number system because let me tell you IEE-754 doesn't give correct results.
Hate to say this but checking for correctness is your job. There is no programming system that will be 100% correct. Yes, it sucks when a language might break your mental model of how it works (and I'm not speaking for Julia, I don't use it anymore, it's possible the correctness bugs are egregious) but you should be writing extensive tests if you're truly worried about having to retract a paper. If you, say, use python, you better triple check that no dict is getting mutated under the hood when you pass it into a function, etc.
That's a bug in your code, not in Python.
The Julia correctness issues are things like basic math functions, called in simple normal ways, returning wrong numbers.
If you have an example of this, I'd be interested in tracking it down. I didn't see this in Yuri's blog post, nor am I aware of any egregious examples of this right now.
Yes. But also No.
The "No" case being if you run your data through a well established program or library already known in academia to have been scrutinized to give accurate results to the 20th decimal place of precision.
julia having bugs is very different from other languages being fundamentally conceptually flawed (like perl ruby c?)...
some of those bugs were already fixed
Note a few things here. One, this is some user deciding to turn off the safeguards, not necessarily Julia being unsafe but instead Julia being flexible and some users abusing that without checking it well. Two, you can run Julia in a way where this feature is disabled: just running `julia --check-bounds=yes` and all `@inbounds` markings are ignored. So in theory this entire blog post could've just been "please run Julia via `julia --check-bounds=yes` and you get better error messages". Note this isn't something that's obscure: literally every time you run `]test` or use package CI it puts things into this mode, so it's used daily by almost all developers. Third, you say you do scientific computing but this post was about statistics libraries.
Look, it's not perfect. What I'm hoping for is that Julia's compiler soon improves its tracking of certain effects like size and uses that to emit code without bounds checking when it proves the code stays inbounds. If that's the case, then `@inbounds` wouldn't be necessary, and this would go away completely. But for now, we have a system when when you need to, you can opt out, and users can explicitly turn off all opt outs with just a single command line argument. I think that's at least a better solution than say MATLAB where indexing out of bounds resizes the array without an error, or indexing out of bounds in Python or R can just wrap around and give you a value without erroring. At least Julia chooses safety by default, and we need to bonk a few people on the head to stop turning off the defaults before checking correctness (in the name of "maor performance", which could soon be replaced by the compiler simply doing this as an optimization and thus further reducing the need for people to do it).
And another change that can be done to Julia here is that all of the features that can be unsafe, like `@inbounds` and `@fastmath`, can be moved to an Unsafe.jl standard library, so that packages have to explicitly import Unsafe.jl and you can check the Project.toml to see if a package uses it. That paired with command line overrides to disable any of these features would give very clear warnings and workarounds for users. What you'll find with this is that there is a very small set of packages using it. And unlike some other languages, Julia makes these unsafe triggers local, so hopefully we can further localize and cage any usage of this to be a very small surface area. To me, that seems like something that is at least solvable, in comparison to other language designs where such unsafe behavior is global to the whole language (I'm looking at you Python, https://moyix.blogspot.com/2022/09/someones-been-messing-wit... bites so hard every time I try something...)
If you are building a tool you expect other people to use, "correctness" needs to be priority number one. After that you can think about speed and aesthetics.
I mean, the end result is the same. In all cases it's debuggable - the language itself is also just a large piece of software. And if these things are practically the same, and 90% of your bugs come from your own code, and 90% of the remaining ones from third-party libraries, how much do the last 1% bugs really matter?
The panda's bug tracker stressed me out on a daily basis. I've also found bugs that effected results due to missing instructions between processor architectures, erasure coding in wire protocols for storage systems, and even a kernel bug.
But by far the most common was by the author of the model themselves.
Software has bugs, no exceptions.
That being said, I do agree that Pkg.jl is much more sleek and modern than Conda/Mamba.
[0] https://docs.conda.io/projects/conda/en/latest/user-guide/co...
julia> open("exam<TAB>
will give you:
julia> open("example.log"
Any Python user who’d be interested in using Julia is or should be familiar with ipython. (If you’re not, it’s a better REPL originally made to make iterative scientific like programming easier in Python, made by the same person/people behind jupyter, which was originally called the ipython notebook.)
Yes Python prides itself on its standard library and it’s be nice to have a better standard REPL. If this were the point being made I’d appreciate the post more.
But, Python is a large and diverse ecosystem, so having different tools coming out of different domains all sharing the same language is part of the value, so it’s not the most hard hitting critique of Python.
That the author made such a point of this, in my eyes, make them seem a little too keen to dunk in Julia’s major “big-brother” competitor rather than being as fair and accurate as they can. Though, I haven’t read their previous Julia-critical post, so I may very well be overreacting. Still, use ipython.
I would have assumed so too, but the number of (reasonably competent) Python programmers who are shocked to know there are alternate REPL interfaces would suggest otherwise. I was lucky enough to get into Python when these thing were still new and shiny, so I came across ipython/bpython pretty early on. But nowadays the very fact that ipython is well-established means that people don't talk about it as much, assuming everyone knows about it, so it's very much possible that someone comes across news about Julia (which is still "new and shiny" enough to be in the news) and doesn't know about ipython.
Defaults matter, and are the only thing used by a large segment of users, even in today's information-rich and one-tap-install world.
Julia's numerical syntax is unbeaten. I wish other languages would adopt it.
Rust has the most beautiful runtime/toolchain but a doubtful syntax.
When you want to use it for the type of number crunching programs that Julia is made for.
Rust is made for making programs that currently C and C++ are used for: every tick counts, close to the metal kind of code (kernels, drivers, hi-perf, soft-realtime, etc). Julia is not even considered in that space.
The latency of Julia does really suck though. I would wait it out if I were you and check in in two-three years and are if it's better (which it very much should be!)
It looks really promising, like “the way things were always supposed to be”, but I haven’t yet developed a full and intuitive understanding of what it means.
In my mind it also removes a lot of cases where I need major restructuring and and refactoring in typical OOP languages. Getting type hierarchies and code organization wrong is so much easier with OOP and much harder to de-tangle.
Not always easy to explain with examples. Once you used MD for a while and try SD again you really start noticing how clunky SD makes code writing.
If you're coming from a functional language, the main difference is that Julia will compile specialized versions of functions for your types, and makes it a lot easier to write runtime efficient and generic code.
For a simple example of this in action, consider the following
julia> a = 1//3 # a is the rational number 1/3
1//3
julia> b = 2+3im # b is a gausian integer (complex number with integer coefficients)
2 + 3im
julia> a+b # even though these types don't know about each other, appropriate methods get called to get a complex rational result.
7//3 + 3//1*im
This might seem really basic, but you'll be hard pressed to make a system like this in another language without hard coding a list of dispatches manually.
If I wanted to use eg Euler angles or modified Rodriguez vectors or some other representation of rotation, the identical code pattern would work.
Any language with semi-decent support for generic programming (via traits, type classes, overloading, what have you) should be able to do the above.
Well, Julia has better than semi decent support for generics, since every function is by definition a generic.
It does so many things very right and always from first principles, not ad hoc (ad hacks).
some random examples that I love
sum(xs...) = reduce(+, xs)
julia > (6ft + 1km) * 1km/s 1002 m s⁻¹
julia> 'a' in "abc" true
180° + π == 2π
map(x -> 2x, [2,4,6,8]) == [2,4,6,8].*2
julia> ⊕(x, y) = x+y
julia> 1⊕2
3
∑(xs...)=fold(xs,+)
julia> ∑(2,4,6,8) 20
∑(xs)=fold(xs,+)
julia> ∑([2 4 6 8]) 20
Firstly I like the aesthetic and implications of f(x, y, z) over x.f(y, z). I like that f is its own thing and not a property of x.
Secondly, it's really nice to be able to reach however far down the callstack you need to go to patch some function "owned" by someone else to act correctly or more efficiently with whatever your type is. You can get correct code most of the time with single dispatch and well-thought-out interfaces, but getting interfaces right in advance is really tricky and requires coordination with other users of the interface whereas multiple dispatch can often work well without much coordination and can also handle cases where you want the implementation to vary dramatically based on the type (the OneHotVector in Karpinski's "Unreasonable effectiveness of multiple dispatch" talk is an example of this).
For new programming language XXX I look for a book like the "K&R for XXX". I see some older ones from Packt, but nothing like the official Rust Book, for example. There is "Think Julia" (OReilly) but its older.
0. Watching this [0] Fireship video to get the “big picture” on the language.
1. Reading the “Noteworthy Differences from other Languages” [1] section of the manual, if your language is on the list.
2. Then, if you're hurried, read Learn Julia in Y Minutes [2], or otherwise read the official manual [3] in order, skipping sections you're not interested in.
In case you're interested in scientific computing specifically, you can start from Chris Rackauckas' course on Parallel Computing and Scientific Machine Learning [4]. And if you don't have a straightforward application to test Julia on while learning, I would recommend doing the exercises available in Exercism [5], which are well-made and provide access to awesome mentors.
As for books, Think Julia is pretty good imho, even if it's a little bit outdated.
[0]: https://www.youtube.com/watch?v=JYs_94znYy0
[1]: https://docs.julialang.org/en/v1/manual/noteworthy-differenc...
[2]: https://learnxinyminutes.com/docs/julia/
[3]: https://docs.julialang.org/en/v1/manual/getting-started/
[4]: https://www.youtube.com/watch?v=-lJK92bEKow&list=PLCAl7tjCwW...
Though if someone wants to dive deep into the language, I'd plug my own SciML course notes: https://book.sciml.ai/, which again is not for general usage but scientific computing but does show a lot about good programming styles (see https://book.sciml.ai/notes/02-Optimizing_Serial_Code/).
It is not exactly a K&R style book but I did write it to appeal more to regular programmers than academics. The Julia world is very dominated by researchers which is reflected in how it is often presented.
It isn’t meant to show directly applicable code examples but focus more on things which could be fun and interesting to implement: such as simulate rockets.
1. Look at example 'Hello world' code
2. Attempt a problem on Project Euler
3. Look at docs/source code to get what I'm missing
4. Repeat
Julia docs are good for step 3. I don't think there are many super technical books like the one you're looking for, since Julia doesn't really have an industry that would produce them, and since the core is still being developed and all that.
Julia is the language that spares me from reaching for Python. I appreciate that.
It doesn't replace all the other languages in my quiver but nor does it have to.
(If I compare Julia with Lisp or R/tidyverse/ggplot2 then frustrations emerge but "doctor doctor it hurts when I do this.")
1. Rather than use something like reStructuredText or Texinfo they used Markdown, and then of course had to define a bunch of custom additional stuff to make it work for documentation, plus a custom program to publish the documentation to a limited number of formats. Unlike the two documentation languages I mentioned, the Juila "customized Markdown" isn't publishable to Info, so it can't be used in Emacs: rather, it's basically just a bunch of web pages.
2. Julia is completely dependent on LLVM. Even Rust (which was initially like that) now has a GCC-based implementation.
Why do you care about LLVM?
I think it's strange for a language to absolutely rely on the architecture of one compiler. Ideally it should have at least two that are both under FLO (free/libre/open) licenses.
Regarding LLVM specifically, see here: https://gcc.gnu.org/legacy-ml/gcc/2014-01/msg00247.html
I'd rather just learn one thing and use it for many different projects.
So I think most of the blog post has already been addressed?
The one thing we haven't done is improved type printing. I am with you on that one, and actually opened a Base Julia issue about it way before your blog post: https://github.com/JuliaLang/julia/issues/36517 . It requires a Base Julia fix though, so that's a bit out of my hands. Also, I think it would be good for Base Julia to do a bit of the error message interpreting that SciML has done, specifically for broadcast (https://github.com/JuliaLang/julia/issues/45086). So there are some more improvements to be done, but I don't think the blog post is up-to-date given the overhauls that were done in the summer of 2022 (thanks to your feedback).
It would be nice to hear updated thoughts when you have a chance to try all of these improvements (especially when v1.9 comes out with the cached binaries)!
> It would be nice to hear updated thoughts when you have a chance to try all of these improvements (especially when v1.9 comes out with the cached binaries)!
I finished my Master in physics. Now, I'm working in IT, and even tough physics will always have a special place in my heart, I probably will not return to physics.
If I will find myself doing Numerics, I might give Julia a second try, but I don't think I will find myself doing numerics anytime soon.
Maybe if I buy a SDR and have some fun with it, I might use Julia.
Threading may be easy but the approach they are taking is not very performant for various hardware-related reasons.
I tried Ruby first but it was just a bit too long.
Julia fit the ticket. I could write a simple simulation that was understandable inside the Tweet.
people ask instead: whom will I be able to communicate with. what kind of cultural repository (wealth) do I get access to. how will I benefit to justify spending the limited opportunities I have to reprogram my brain.
the programmer-to-programmer aspect of computer languages is not appreciated enough, especially not in the modern, highly networked and open source way of developing software. yes, the primary purpose is to marshal ones and zeros in silicon chips and it does matter if the language helps you do that in a sane way but this is just one of the many factors people consider.
I think, unfortunately for Julia and other aspiring challengers, right now the primary social network dynamics among developers is "winner takes all". e.g., its not a deep secret that the meteoric rize of python is because it enabled countless people to aspire to be part of the perceived AI/ML/FAANG gold rush. Over time programmer eyeballs motivate investment in ecosystem evolution and a benign spiral is set in motion.
I don't have a crystal ball as to when/if/how the current pyfever might cool down. You can't predict those things, they are an emergent property of our very complex networks. Maybe some killer feature or julia or rust or go or dart or kotlin will trigger some regime change, but unless it does, any discussions of alternate greatness have a distinct detached feeling to them.
Choosing the lowest common denominator language to be able to communicate with the “most number of people” is a specific bias (nothing wrong with it). People pick languages with many different motivations — something might sound/read elegant, or there’s a specific group of people they want to engage with (Eg: anime enthusiasts, kernel developers, statisticians, etc.)
> I think, unfortunately for Julia and other aspiring challengers, right now the primary social network dynamics among developers is "winner takes all".
Only for certain use cases. Between Python and Julia, there’s exactly one language I want to program in, and will strongly prefer every time I can get away with it.
I don’t want to diss on Python — its ecosystem/workflow is a substantial improvement over the previous era, but it has so many warts (for certain fundamental needs, Eg generic programming) that you can never fix the problem “additively” by extending the ecosystem instead of radically redesigning the language ground up.
thats definitely true, but my observation is that collective behaviors in the adoption of a communication channel have a network dynamic that can dominate rational factors. In previous eras people would learn German or French to get access to scientific/technical literature. At some point English simply became the de-facto language for sharing such knowledge irrespective of whether it might have been the most adapted for this. This does not mean that other languages go extinct, it just creates an allocation that does not seem to correspond to "objective" features.
> you can never fix the problem “additively” by extending the ecosystem instead of radically redesigning the language ground up.
thats an interesting view but there are important counterexamples :-). you can see, e.g., the rapid developments in the last few years in the C++ space. essentially what can happen in response to pressure (from other ecosystems) is the development of dialects and multi-paradigm languages (abandoning full backward compatibility and/or simplicity). similarly one would think that if python continues benefiting from lavish attention at some point there will be a python 4 etc. you might argue that this not really "fixing the problem" but in the context of delivering useful products here and now this becomes a bit academic
Yes, but only if they are all equally expressive, or if you only care about the lowest common denominator. In a situation with an expressiveness gradient, the distinction will always survive. I think this insight is articulated well in PG's essay on the blub paradox.
Eg: English is a pathetic solution if you want precise/expressive communication for the purpose of engineering -- so no amount of network effect will enable English to trump equations even if it were some new idea (language) like calculus competing with a thousand year old language.
> similarly one would think that if python continues benefiting from lavish attention at some point there will be a python 4 etc. you might argue that this not really "fixing the problem" but in the context of delivering useful products here and now this becomes a bit academic
Probably the most fundamental tenet (self-professed) of Python is its "simplicity". Whatever that might mean, it seems highly incompatible with growing the language in the manner of C++, and even more so if the changes were backwards-incompatible (as the 2->3 transition demonstrated). The dynamics of language evolution might still bias towards that outcome as the needs of large corporate codebases dominate the beginner's need for simplicity, but at that point Python would have lost most of its soul.
But, regardless of all that, (as a concrete example of the kind of limitation I'm talking about) it seems impossible to support generic programming in Python without giving up on OOP / single dispatch. <Lipstick, pig, etc.>
> in the context of delivering useful products here and now this becomes a bit academic
I disagree, vehemently :-) When there is an impedance mismatch between the problem domain and the abstractions fundamentally embedded into a language/system, you are setting yourself up for a world of pain -- needing an exponential amount of engineering effort to overcome the barrier, and the solution will still forever be doomed to mediocre quality (at best).
Calling Python (or pretty much anything) "general purpose" in an absolute sense is a bit of a misnomer -- it just means one is blind to the limitations/biases embedded in the technology, or is implicitly focusing on a limited set of problems.
Famous last words.
What I meant was that, when multithreading is hard in Julia, it's not Julia that makes it hard. Julia gives you exactly all the tools you need, easily available. It's that the problem is hard, i.e. you fuck it up even with good tools available.
In my work though, problems tend to be simple to parallelize.
Man, Jakob just has a way of writing that gets right to the point. Nice post.
My only complaint about the post is that in Python you have many different REPL options. For example, both ipython and bpython are miles ahead of the Julia REPL. I agree though that the Julia default REPL is better than the Python default REPL. I particularly like the shell mode in Julia. You can also make your own modes, like a sql mode or any custom DSL mode.
I have been very critical about Julia in the past, so I'll say some positive things before I complain more :)
- The package management in Julia is god-like. Specifically, there's a whole subset of packages that are just binaries and libraries cross compiled on VMs for Windows / Mac / Linux + x86 / x64 / ARM, and it just works. There's no more trying to compile code on a users computer when trying to install a package, it's beautiful. It is truly a phenomenal piece of engineering, and I cannot praise it enough. Hats off to the core team responsible for this.
- Multithreading is such a joy to use. Compared to any other dynamic GC language, Julia and Go are pretty much up there in terms of usability + features. So much better than Python or R. But while I prefer Julia over Go, I do prefer Rust over Julia.
Now for some of my grievances. I'm a nobody in the Julia community so take my word for what it is worth.
- Optimizing Julia code is a joy. However, learning how to optimize Julia code not straightforward. If you are coming from Python and/or don't have experience thinking about memory, cache lines, references, mutability etc, you have your work cut out for you in terms of learning how to optimize Julia code. In addition to that, there are Julia specific things you need to learn to know how to optimize your code. Do you know what the function barrier paradigm is? No? Too bad, now your codebase is 10x slower and refactoring could take weeks. And that's just the theory of everything you need to learn. There's SO many subtle ways your Julia code can be slow because the compiler wasn't able to "see through your code". And the tooling here is getting better but still has a LOONNNGGG way to go. Statically being able to check and assert for problematic inferences will improve this for me a la JET.jl but right now JET.jl is too slow to run on a large codebase.
- Thinking with Multiple Dispatch (MD) is much like Thinking with Portals. Once you get it, you have this ah-ha moment. But the type system is overloaded in my opinion. You HAVE to use the type system for MD but people also use it for interfaces (AbstractArray for example). I think adding inheritance in the abstract type system was a mistake, and a trait or interface like approach would be way better for this. Maybe something like concrete types for dispatch and abstract types for interfaces? I don't think this will EVER change though, not in Julia 2.0 or 3.0 or later, because it is SO ingrained into the Julia community. I'm not explaining this well here but I've complained about it before in previous comments on HN and am too lazy to go find it and copy paste :)
- There's a number of minor syntax / usability gripes I have that I don't think will ever be fixed as well. I generally think a programming language should incentivize you to "do the right thing", often my making it easier to type. In Julia this framework of thinking exists but isn't applied consistently. It is easier to create a immutable struct than a mutable struct
struct Immutable
x::Int
y::Int
end
# vs
mutable struct Mutable
x::Int
y::Int
end
However, if you want to use it to store user data, if you choose immutable structs, your interface for users is EXTREMELY annoying. For example, if they want to update `x` from `1` to be `2`. im = Immutable(1, 3)
im = Immutable(2, im.y)
With mutable structs: m = Mutable(1, 3)
m.x = 2
There's third party packages that make this easier but this should ABSOLUTELY be in Base.There's similar complaints I have about type names in Julia. I'm incentivized to write `::String` instead of `::AbstractString`, `::Int` instead of `::Integer`. In Julia using `AbstractString` is almost always preferred. The naming is also quite annoying. Why does `AbstractString` have `Abstract` in the name but `Integer` not, when both of them are abstract types?
I've said this before and I'll say it again. I think Julia core devs should have a usability expert come in and review their whole codebase and workflows and make suggestions. I have no idea how Rust has nailed this so well. In Rust, so many things are just consistent. You can guess what the names or behavior of what you want so often, it's awesome.
TLDR:
If you are thinking of using Julia for a large production codebase, wait 5 more years. I've learnt that the hard way. For personal projects it is amazing though.
That's the whole point of immutability that you can't "just update". I fail to see how obscure magical updates on immutable (?) structs like advertised in [1] or [2] e.g.
using Accessors
@set obj.a.b.c = d
are beneficial. Note that there is _zero_ explanation on the front page of what the above snippet does, how to use it and what actually happens under the hood. One example of why I personally don't have much trust in JuliaLand.Scala has `x.copy(field=newval)` for its (immutable) case classes. Note how clear it is that one is making a copy. Lenses are also outside of the stdlib (e.g. [3]).
[1] https://github.com/JuliaObjects/Accessors.jl
> It is easier to create a immutable struct than a mutable struct
This is exactly an implementation of that principle - since very often one of the goals when using Julia is performance, it makes sense to incentivize the more performant option. [1]
> I'm incentivized to write `::String` instead of `::AbstractString`, `::Int` instead of `::Integer`. In Julia using `AbstractString` is almost always preferred.
I'm on the fence about this one. I used to think this way, but now I think just slapping Abstract types everywhere in code leads only to fake-genericity. It's the sort of trap that leads to the kind of problems Yuri complained about in his (in)famous blog post.
I'd rather someone type ::String and be artificially limited in what they accept (at least for now, until someone complains), rather than be incentivized to say they accept an abstract type and then end up not actually supporting all of the abstract type interface's flexibility.
[1] https://docs.julialang.org/en/v1/manual/types/#Mutable-Compo...
It also means the libraries are short and easy to understand, instead of having tens of thousands of lines implementing said primitives etc.
Welp. Im out.
This is surprising, because the Julia devs have been very careful to maintain backwards compatibility since version 1.0 released in 2018.
In Julia, all open source packages that pass tests on the latest release are confirmed to also pass on a release candidate before that candidate can become the next release.
A major package being incompatible with a new Julia version just doesn't happen.
Julia takes its stability guarantees seriously.
Julia doesn't have a good support for OOP. I don't think FP is the optimal way to solve all possible programming tasks. Usually a mix of both approaches leads to the most simple, maintainable and readable code.
And I'm really not sold on multiple dispatch. In Swift, I would simply implement the join function by adding an extension on `Array<String>`. And the + function would just be, for example, `static func + (left: Vector2D, right: Vector2D) -> Vector2D`. I've never come across a situation where I wished Swift would support multiple dispatch. On the other hand, the fact that Julia doesn't use the object.method() has 2 very clear drawbacks: lack of completion in an IDE and poor readability (example: `object.doSomething(a, b, c).doSomethingElse(a, b, c)` - imagine how would this look in Julia).
1. We are talking about a function that takes two values and spits out a third. In what sense are we talking about calling a method (or passing a message) to an object (the first string) to mutate its state? How do we enable a compiler to reason about the side-effects (or lack) of this code?
2. In mathematics "+" is almost always used for a commutative operation on values, so defining it the way you have breaks an (implicit) interface that is not explicitly codified (in part because current languages do not give us a way to codify this). The ability to reason about such properties is crucial if you want the runtime to be able to automatically reorder/parallellize/etc without breaking correctness.
3. While these details are minor annoyances in the case of string concatenation (fairly benign problem), they can become really painful when you are trying to leverage the power of generic programming to compose sophisticated algorithms. A classic poster example for this is when you want to add units or uncertainties/error-bars to your numbers and have all your numerical & plotting code generalize seamlessly -- Julia (for example) performs beautifully, while I don't see how any single dispatch (OOP) language can handle this challenge. More examples in this spirit: complex numbers, autodiff with dual numbers, etc.
2. I don't get this. What's the difference from Julia? Whether the operation is commutative is defined by the implementation of +, like in Julia, AFAIK.
3. Multiple dispatch seems useful in these cases, although it's a fairly niche area. I don't know how doable would this be just with generic programming / protocols without MD, didn't think too much about it. I vaguely remember that I didn't like that extending code with MD in a way relies on implicit, undefined interfaces.
Not that bad is it? I think I like it better actually, especially if a b and c had variable names that were longer
The dot version exactly matches my thinking - take this object and transform it with parameters a, b, c and then transform the result again.
When you have an object that you apply a series of transformations to, it's natural to describe the process in chronological order.