20 ms·
From Julia to Rust
- hexane360 5y agoAs someone who dabbles in both Rust and Julia, I agree there's a lot Julia can learn from Rust. Rust has made a lot of good technical decisions, and I think many of these decisions came from having a team of experienced systems programmers. In comparison, Julia's decision making process seems much more informal, and snap decisions are sometimes made from the narrow perspective of academic programming rather than carefully considering the goals of the language, future uses, and forwards compatibility.
- xianwen 5y agoI'm very interested in Rust. However, it seems that Rust is not yet able to do symbolic math.
- hexane360 5y agoI'm sure there are some crates out there, but probably nothing very stable. If there's one thing Rust is not, it's a good "glue" language. It seems to do best in large, densely coupled projects. This is where there's the least cost to defining all your own types, and also where a strong type system provides the most benefit. I think there will always be a place for more dynamic languages that tend to do better at interfaces.
- miguelraz 5y agoAuthor here: I specifically mentioned the `egg` crate because of it's capabilities for symbolic math. You can check a minimal application of arithmetic differentiation and some simplification rules in their repo here: https://github.com/egraphs-good/egg/blob/main/tests/math.rs https://github.com/egraphs-good/egg/blob/main/tests/math.rs
- xianwen 5y agoThanks. I'll give it a try!
- ForHackernews 5y agoI like both languages, but they seem to have extremely different goals and target users to me. Julia aims to be better than R and Python at statistics and data analysis. It's not there yet, but I could easily see it replacing a great deal of academic use of Numpy and Python in Jupyter notebooks (the 'ju' is Julia). On the other hand, Rust seems like it's aiming at being a safer alternative to C for low-level systems programming. I'm sure there's things Julia could learn from Rust, but the design decisions are going to differ wildly because they just aren't trying to do similar things.
- awaythrowact 5y agoFair. But to play devils advocate: one stated goal of Julia is to solve the “two languages” problem where developers prototype in {scripting language} and then reimplement in {system language}. So while Julia is meant to be as easy as Python, it also needs to be as powerful and flexible as Rust (or C or whatever). It’s supposed to be the “best of both worlds” and Rust lives in one of those worlds. If developers are better off prototyping in Python jupyter notebooks and then reimplementing in Rust than they are implementing in Julia, then I’d say the comparison is relevant. Maybe it’s an unfair standard and Julia can be a “better Python” without needing to be a full replacement of a systems language, but then Julia isn’t fully solving the two language problem, right?
- duped 5y agoThe two language problem exists for a bunch of reasons, some good and some not. The biggest reason is because some function of the high level language is incompatible with the application domain. Like garbage collection in hot or real-time code or proprietary compilers for processors. Julia does not solve these problems. Other reasons are practical, like portable executables in Go or Rust (portable in the sense they do not require dependencies on their target systems, usually). Julia does not solve this problem. Then there are the reasons to use scripting languages over the system languages, like expressive syntax with low cognitive overhead. Julia definitely helps here. But this comes at the cost of execution and startup time. Julia only kind of solves this problem. So if Julia is trying to make a more performance scripting language then that is admirable. But for most of the projects where I have needed to prototype in a script and implement in a systems language, Julia would not have worked. Even today I don't have a good reason to use it over MATLAB for day to day work, since I already have the license and their ecosystem is more mature.
- deleted 5y ago[deleted]
- iamcreasy 5y agoAgree with this sentiment. Its especially evident when you look at their package manage. Here is a nice talk from the guy who wrote it 3 times: https://www.youtube.com/watch?v=HgFmiT5p0zU https://www.youtube.com/watch?v=HgFmiT5p0zU
- adgjlsfhk1 5y agoIt might be worth noting that the current one (the third that he wrote) is probably one of the best package managers of any language. It supports environments, multiple package servers, installing packages from url, easy local development, is completely immutable, and reasonably fast.
- noobermin 5y agoKinda betrays your bias by uplifting "experienced systems programmers" and shitting on the "narrow perspective of academic programming". God, calling it a "betrayal" softens how explicit your disposition is actually. On the other hand, Rust will probably in its current form not be used for anything seriously academic (well, may be cs academic which is different) because honestly the memory paradigm is difficult to understand for people in the field. May be one day, assuming the rust mentality becomes more mainstream but computational science has always been its own thing that doesn't really follow cs trends (both good and bad in its own respects) and it certainly isn't moving in the direction of more intelligent memory management.
- neolog 5y agoI agree with GP. It's not just about the differing goals of the projects. Julia is developed by numerical computing people. Imho the community really needs help from some PL and systems people.
- noobermin 5y agoWhy? EDIT: Expounding on "why": On what aspects specifically does the Julia community need help from system programmers and programming language experts?
- deleted 5y ago[deleted]
- deleted 5y ago[deleted]
- BadInformatics 5y agoThe biggest group outside of numerical computing in Julia land are the PL and systems people though? This includes type theorists [1], database folks [2], distributed systems people ([3] to name just one). There are also a fair number of compiler nuts, hence the existence of multiple projects [4][5] in this space. And this is before getting into things that bridge more than one of the domains above, e.g. [7] or [8]. FTR, I think it's fair to question whether numerical computing should have an outsized influence on the direction of the language. I also think it's a pretty fair comparison to point out how standardized and consistent the Rust governance process is compared to Julia's (the Rust RFC system is an exemplar here). That doesn't mean there is a dearth of PL and systems knowledge in the Julia community though. [1] https://github.com/AlgebraicJulia/Catlab.jl https://github.com/AlgebraicJulia/Catlab.jl [2] https://www.youtube.com/watch?v=tRBl-6uEJJE https://www.youtube.com/watch?v=tRBl-6uEJJE [3] https://github.com/JuliaParallel/Dagger.jl/ https://github.com/JuliaParallel/Dagger.jl/ [4] https://github.com/FluxML/IRTools.jl https://github.com/FluxML/IRTools.jl, https://github.com/FluxML/MacroTools.jl https://github.com/FluxML/MacroTools.jl [5] https://github.com/JuliaCompilerPlugins https://github.com/JuliaCompilerPlugins [6] https://github.com/0x0f0f0f/Metatheory.jl https://github.com/0x0f0f0f/Metatheory.jl [7] https://2020.splashcon.org/details/splash-2020-rebase/13/Non-local-compiler-transformations-in-the-presence-of-dynamic-dispatch https://2020.splashcon.org/details/splash-2020-rebase/13/Non... [8] https://github.com/JuliaSymbolics/Symbolics.jl https://github.com/JuliaSymbolics/Symbolics.jl
- beforeolives 5y agoThe most fascinating thing about this is that the author's first two programming languages are Julia and Rust.
- miguelraz 5y agoIt is infrequent! Author here: I knew enough C and Fortran to turn in small assignments for my physics courses, but Julia was the first one where I started developing code.
- zamalek 5y ago> Julia was the first one where I started developing code. This is fantastic! I think that Julia really has unseen potential for the scientific community, and even more unseen potential beyond that (most of Julia conf is scientific). FP also comprises of some really great habits to pick up early on, I'm still trying to unlearn dumb OOP idioms (which is why I'm targeting Julia as my next language).
- dnautics 5y agoI feel like you are a kindred spirit! Although Julia is far for my first language, Julia is the first language I ever did a coding interview in (at Apple; it was the language I was doing the most work on and I took their "use whatever language you're comfortable with" to heart. It went poorly).
- O_H_E 5y ago> It went poorly Just the interview? Or anything language related?
- Diggsey 5y ago> Rust people keep saying they have no Garbage Collector, when they have a Region Based Garbage Collector. Rust does not have a region based garbage collector. Memory management in Rust works exactly the same as in does in C++ (ie. destructors are automatically called when variables go out of scope, and those destructors may deallocate memory). The borrow checker is purely a check: not only does it operate entirely at compile-time, it does not even influence code generation. The only thing the borrow checker can do is prevent code from compiling.
- zamalek 5y agoCorrectly/academically speaking, a GC emulates infinite memory[1]. It's a misnomer (because the fact/name predated the theory). In the event that you actually have infinite memory, NOOP could be classified as a GC. Academically speaking, Rust is a managed language. The GC has simply been lifted to compile-time (or runtime in the case of Rc). You never call `alloc` and you never call `free`. [1]: https://devblogs.microsoft.com/oldnewthing/20100809-00/?p=13203 https://devblogs.microsoft.com/oldnewthing/20100809-00/?p=13...
- miguelraz 5y agoFair enough, thanks for the pointer, I've amended the most recent version of the post and given you credit.
- Ar-Curunir 5y ago> You never call `alloc` and you never call `free`. That’s not a property of the language, only of the standard library. You could design APIs that do require you to manually call alloc and free; it’s just less ergonomic to do that
- Diggsey 5y agoBy that definition C++ is also garbage collected and managed. Given that C++ is oft cited as the canonical unmanaged non-GCed language, this seems like a not very useful definition. (And you can call `alloc` and `free` from Rust, https://doc.rust-lang.org/std/alloc/fn.alloc.html https://doc.rust-lang.org/std/alloc/fn.alloc.html) It's also weird that you call out `Rc` specifically. `Box` also allocates and free memory, as does `Vec` and other types from the `alloc` crate.
- philzook 5y agoHybrid physicist and weirdo programming language aficionado: a man after my own heart! Great summary! Keep up the good blogging!
- miguelraz 5y agoThanks Phil! I've been meaning to get to your Z3 tutorials soon, they rock too! See ya around! Also, I think you can totally tell that this is part of my brain-dump that's been pouring out to the #formal-methods channel on the Julia Zulip.
- jp0d 5y agoControversial opinion here! I don't think people who use languages like Julia/R/Python etc worry about most of the computer science side of things. Most of them are data scientists/analysts, statisticians and from pure sciences. Primarily because the availability of wide range of libraries that makes their lives a lot easier. Also many aren't too concerned about performance of the language either. It's indeed fascinating that the author's first language was Julia. It'd be interesting to know why the author chose Julia as the first language.
- miguelraz 5y agoBecause I heard the good word of our Lord and Savior David Sanders [1] in my computational physics class and I've renounced the devious ways of Fortran since. [1]: https://www.youtube.com/watch?v=gQ1y5NUD_RI https://www.youtube.com/watch?v=gQ1y5NUD_RI Concretely, I joined the Julia slack and ran into a very welcoming community of people who helped me learn. Julia's like that so far. Yes, I agree many data science people don't dive into internals - but for some reason these low-level details keep fascinating me so I don't mind some of the pain.
- socialdemocrat 5y agoI don’t find that to be true with Julia. Keep in mind that Julia is intended to not only replace python and R but also C++ in a science setting. The academic programmers who write the high performance code parts usually do this in C/C++ and Fortran and thus tend to be quite familiar with a lot of low level computer science stuff. Looking at generated assembly code for a Julia function is a pretty normal thing to do. I am an old C/C++ developer and find myself very much at home with Julia. Sure I have used Python and Ruby before but those always make decisions around memory layout and code generation inaccessible. Thinking about Julia as yet another Python, R, Ruby or a JavaScript is just wrong. It doesn’t really fit existing categories well.
- krapht 5y agoI mean, the best way to think about it is as a replacement for MATLAB, except with better support for general purpose computing. MATLAB the language syntax is optimized for double precision matrix math - but MATLAB is interpreted with a JIT and extremely productive IDE, so actually really easy to use, except for the part where it costs $2000 per toolbox per year. It also interops fairly seamlessly with Java since it runs on the JVM. Mathworks: the company that I wouldn't pay paying money to, if it wasn't such a ridiculously large sum. I don't have any issue paying for Jetbrains IDEs, but it's an order of magnitude smaller than Mathwork's yearly take.
- noobermin 5y agoSo this is interesting but I mean imagine a post comparing R to perl. Julia I think has the potential to be a general programming language but it is primarily geared towards data scientists and (more importantly) computational scientists who are stuck writing f77 (and f90 would literally be an upgrade for them). Julia has its use case at least from my vantage point as a computational person while Rust has no applicability (yet) in that domain. For example, the lack of ability to use fortran style loops mentioned in this article kinda says to anyone looking for something new, "yeah I'll stick with fortan then." It's fun to compare things in general but the two languange concern very different areas of computing so much so that the "differences" will actually be the differences in the domains rather than the languages actually.
- 7thaccount 5y agoYep. I think of computational languages for stats or numerical work like (R, Python, Matlab, Mathematica, Fortran...etc), and systems languages like (C, C++, D, Rust). I don't see a lot of crossover there. One is expected to be very interactive for analysis and the other not interactive at all and for building infrastructure more or less. C++ and C (somewhat of an exception here) have some good numerical libraries for things like sparse matrices, but Rust did not have mature libraries for that last time I checked, but I suppose you could do some FFI stuff.
- Certhas 5y agoIt's weird to me to see Fortran and Mathematica grouped together. :) The reality in Python, Mathematica, etc... is that you don't write your libraries in them. You delegate the ahrd work to libraries written in Fortran/C/Rust... so as soon as your research touches on new algorithms (or even just new combinations of algorithms) you are not doing pure Python anymore but will be touching systems languages. Julia is less interactive than Python (mostly due to the just ahead of time compilation model), but can match the speed of Fortran/C/Rust etc... so in this domain it has a strong overlap with what you use the systems languages for. Before I transitioned my group to Julia I was looking very heavily into going to Python/Rust (and Python/Numba which I spent the most time prototyping and investigating). And I can imagine that for some groups a Python/Rust hybrid would be a better fit than Julia. For doing some data wrangling I still prefer Python for it's smooth interactivity. But, for example, Julia now has by far the most complete, flexible and all around amazing differential equations solver library in existence. This library also wraps the Fortran stalwarts like Sundials, but it's implemented entirely in Julia. There is no C/C++/etc... backend doing the heavy lifting in the background (well if you don't count LLVM at least), and the pure Julia solvers are now beating the Fortran/C++/etc... solvers pretty much across the field.
- Shadonototro 5y ago2 orthogonal languages, i'm not sure it worth comparing.. each has their pros/cons for specific use cases
- miguelraz 5y agoEven if there was no technical knowledge to be learned from (which there is), the social governance model is good to keep an eye out for. Some innovations come from social relations and rethinkings - I'm glad the Rust community is pushing the envelope in the way that they are and I wish for their experiment to keep on growing.
- miguelraz 5y agoAdded this great quote by Uncle Iroh as a TLDR to the article. https://www.youtube.com/watch?v=drvAftwsTlU https://www.youtube.com/watch?v=drvAftwsTlU
- Shadonototro 5y agoit sounds more like a sect than anything
- flakiness 5y ago"My first real programming language was Julia" Such a 2021 moment! Kind of envious. The first programming language follows you through your career. Mine (C++) has been a curse and a blessing at the same time. Wish you luck, sincerely. People like you define the next decades.
- miguelraz 5y agoWell, my book on Learn LLVM 12 by Kai Nacke should have arrived today, so I'm not out of the C++ woods just yet. Thanks, cheers to you too!
- mhh__ 5y agoI wouldn't learn C++ by learning LLVM if that's what you mean, or at least have one of (say) Stroustrup's books on the shelf.
- miguelraz 5y agoThat's fair, but I'm only interested in learning C++ insofar as it helps me understand Julia's internals. I think I did Stroustrup's "Principles and Practice Using C++" for about 12 chapters a while ago; I might revisit it later thanks to your comment.
- pjmlp 5y agoSpeaking as someone that does C++ since 1993, and as compiler geek, the OP is right. I advise you to at least read Tour of C++ 2nd edition. Projects like LLVM are one of the reasons C++ will stay around for decades to come, and they make use of many features that you won't find explained how they work on a book describing LLVM APIs.
- miguelraz 5y agoThe book arrived today! But yeah I might skim the Tour of C++ - thanks for the *ptr!
- tastyminerals2 5y agoStrange jump from one new language to another which is intended to solve different set of problems. Why not Nim (which actually has some data libs to compare against)? Performance wise Julia and Rust are not a fair comparison either once you’ve out of Julia’s comfort zone. So, the actual reason of why the author decided to try one over another and not looking at anything else is the exposure? Julia can also learn a lot from Ada about safety. It can learn tons from APL on how to manage multidimensionality in a concise manner. And even though I believe Julia and Rust are great languages everyone should learn about, this kind of choice between one new shiny thing and another new shiny thing feels rushed and therefore amateurish.
- miguelraz 5y agono u
- DreamScatter 5y agoI was a big fan of Julia for a long time, but when i realized that Stefan Krapinski and his Julia Stewards are a gang of assholes, it ended my interest in being involved. They banned me from all their discussion websites and repositories after i questioned them about their "wokeness". I hate to use that term, but everyone's using that word now, so there. Basically, they were trying to convince people that there are a lack of women using Julia because women feel uncomfortable for an unspecified reason. They were specifically unwilling to survey women about why they don't use Julia. Since they were unwilling to do a survey, i had to call them out for being delusional, as it is not even pseudoscience but straight up delusional to make claims like this with out any survey information at all. After that, they said they would continue the discussion after banning me. Since then, I have been unable to contribute to the Julia open source / free software. I'm a developer of several well known Julia packages, and I am not allowed to help other people solve their problems and fix issues with my code. It's been over 6 months, and they extended my ban another 6 months. It's ridiculous, and I will never respect Stefan Krapinski and his gang of Julia Stewards again. I think Julia is a good language, but with that kind of leadership, they are bound to destroy the language forever. Wolfram language is actually a lot more inclusive towards me, and they are encouraging me to get involved due to my math research, while the Julia people are actively trying to discourage me and prevent me from doing work. Rust is also a nice alternative to Julia. Stefan Krapinski and his gang have written some kind of blackmail against me, they threatened me with spreading some kind of internet gossip about me if i don't stop complaining about them. Haha, as if they can blackmail me with their stupid gossip. I recommend staying away from the toxic community created by the Julia Stewards, who are a gang of assholes led by Stefan Krapinski. The language is alright, but the people behind it are not respectable. Stefan Krapinski is also responsible for introducing telemetry to the Julia language, so that's another reason not to use Julia.