9 ms·
Why scientists are turning to Rust
- triska 6y agoRust is a very compelling environment for many kinds of scientific computing, also due to the features noted in the article: “Unlike the many compilers and ancillary utilities that programmers use to build C code, Rustaceans can use a single tool, called Cargo, to compile Rust code, run tests, auto-generate documentation, upload a package to a repository and more. It also downloads and installs third-party packages automatically.” Fetching required packages in this way is very convenient, something one notices rather soon when writing Rust applications. There are already many dedicated packages also for highly specialized applications, and with cargo it is easy to use them immediately.
- Junk_Collector 6y agoIt's really better than that. Cargo lets you specify the version of the package that you are using/used. This is a huge deal for getting something to run later and for reproducibility.
- steveklabnik 6y agoLot of discussion over on /r/rust https://www.reddit.com/r/rust/comments/k4jdvw/why_scientists_are_turning_to_rust_nature/ https://www.reddit.com/r/rust/comments/k4jdvw/why_scientists...
- okareaman 6y agoI bought your book and it's been helpful. Thanks!
- steveklabnik 6y agoGlad to hear it!
- okareaman 6y agoI've been learning Rust and find it not hard to learn, I think because I already know C/C++ and understand the concepts of pointers, references, stack and heap allocations.
- etimberg 6y agoAgreed, I've seen lots of posts about the learning curve so I went in expecting a lot of pain. I've been pleasantly surprised so far.
- cassepipe 6y agoI can confirm. I started learning Rust as a second language right after Python and it was hard to make sense of anything. Why the hell some values have the Copy trait and others don't? Then I learned C and now I have good mental model of how memory is allocated and Rust feels okay. I just don't like that it hides away the complexity because when it does not work, you don't have the means to understand why, you just know did not follow the rules that you never remember anyways because they don't make sense to you. C has quirks too and the learning can also be steep, but it forces you to understand how things are working under the hood. Will continue to learn Rust but I have high hopes for the Zig language which seems more approachable with C in mind (rather than C++ which Rust is said to be a replacement for).
- kgarten 6y agoI work in hci research and have never played with/ heard of Rust being used. Was quickly checking for visualisation libraries and found https://lib.rs/visualization https://lib.rs/visualization Loved the Color scheme and font ... lol. Anyways, will be using Rust for a small side project (short paper for augmented Humans ( https://augmented-humans.org/ https://augmented-humans.org/ deadline in 2 weeks :) let’s see how quickly I can learn it). Any tutorial recommendations go using Rust for statistics/data plotting? https://lib.rs/crates/plotlib https://lib.rs/crates/plotlib Or the gnuplot Wrapper looks up for the task for me.
- tormeh 6y ago> deadline in 2 weeks That's.. ambitious. Rust is a nice language, but the borrow checker, for all its awesomeness, has a fairly steep learning curve. Unless you're a C++ programmer, in which case this level of thinking won't be totally alien to you at least.
- kgarten 6y agoThanks for the warning. I have the weekend, I will probably just do 1-2 Plots. I program C, C++, matlab, Python and Ruby. Just looked a bit into Julia and Haskell. Language Lover ... also trying not so common languages (my favourite is still OpenDylan).
- dystroy 6y agoIt really depends on the problems you work on. For my first program (task scheduling, regexes, redis, rest), everything was simple and obvious, it was made in about 3 days. My second program was dealing with several kinds of graphs, optimal sub string addressing, and then I hit the painful points and it took me several weeks of this side project to get my head around the complex concepts of Rust, and several months to really feel at ease. There's a subset of problems for which Rust is "easy" and it's probably possible, with some guidance and occasional help, to organize one's work around those.
- DiabloD3 6y agoYou know why I like Rust as a programmer? It's community feels a lot like how the Perl community did at the height of Perl's popularity. This is in contrast to Python's (has a friendly community, but tends to have bikeshedding), Node's (outright toxic npm-based warfare), or Java's (corporations shit out awful code when they're done with it, ie, everything donated to Eclipse or Apache, or all the dumpster fire code Google has released, and its up to you to judge how awful it really is). Perl's CPAN? Lots of really nice code that follows a pretty good UNIX "does one thing, and does it well" philosophy, with lots of friendly folks. As long as Rust doesn't have a Perl 6 moment, we're good.
- Ericson2314 6y agoMaybe Rust is the true Perl 6 :O
- lizmat 6y agoWell, Rust does share its first letter with the Raku Programming Language, the new name of Perl 6 (https://raku.org https://raku.org using the #rakulang tag on social media).
- proverbialbunny 6y agoI'm a researcher and I loved prototyping in Perl once upon a time ago. It was so fast and easy to get an idea out. I've played with Rust too, and have done a project in it. I like it too, but as a necessity, not out of a strong love. I do love the package manager Rust has though. It's so nice to not have to worry about that kind of thing. Once Raku has dataframes, and it is stable, I'll definitely be checking it out.
- lizmat 6y agoInteresting. I assume the R flavour of data frames would be most used?
- proverbialbunny 6y ago
- bluenose69 6y agoI've started learning Julia lately, and it also has an appeal, especially for fortran-ish computations. (Yup, I said fortran ... it is still used in lots of scientific computations e.g. fluid-mechanical models.)
- ur-whale 6y ago"used" as in "using existing libraries" or do you mean there are folks still writing fortran in 2020?
- mattkrause 6y agoI have a collaborator who was writing Fortran this summer (and not even in physics!). Oddly, it didn't seem like he was particularly locked in by a vast pile of legacy code; he just found it a good match for his mental model of the project.
- bluenose69 6y agoYes, people still write fortran in 2020. It's not just for legacy products (as, I think, Cobol is). Fortran is a very expressive and efficient language for high-performance computation. When you start a calculation that may take weeks to complete, you want to use a tool that you can trust. Fortran is a great language for legacy products, with code written 50 years ago still working fine. But it has also gained new features over the years, keeping it ahead of competitors in terms of its ability to harvest all a machine can deliver. This is all for technical work like numerical modelling. Scientists are a very practical lot, switching from Fortran to C (usually C++) when that makes sense, then to python, R, etc when that makes sense, and so forth. The original article was about scientists switching to rust. I don't know anyone who has done that. I do know many who are exploring Julia, though. Bear in mind that scientists tend to be quite good at technical work. Learning a new language is not a significant problem for them. But scientific programming is about much, much more than programming. The essence of scientific programming is in the underlying mathematics and science, and Fortran just happens to be pretty good at those things.
- amelius 6y agoI thought scientists were turning to Julia.
- tclancy 6y agoNo, this is exposure to Oxygen.
- ku-man 6y agoMany were but many turned back to whatever they were coming from. Julia it's an interesting language with rather odd design choices though. In my opinion, the major hurdle to a wider adoption is that it was/is oversold. They claim c-like processing speeds, and in many cases they can be reached, but not off the bat. You need lots of hacks to get to those speeds.
- st1x7 6y agoThis seems like a stretch, or it seems very limited to the specific people mentioned in the article. I find it hard to believe that scientists who have specialised very narrowly in their domain will also want to be full-time software engineers too and choose one of the most complex languages on top of that. This just doesn't scale beyond the few people who are really into it. > Köster, now at the University of Duisburg-Essen in Germany, was looking for a language that offered the “expressiveness” of Python but the speed of languages such as C and C++. Rust doesn't have the expressiveness of Python (even when you put expressiveness in quotes), it's not even close. What you're looking for is probably Julia (and Julia is already quite a bit more difficult than Python even if the syntax looks superficially similar).
- adamnemecek 6y agoScientists will write whatever makes most sense. Julia is comparably easy as python it’s just that it has more advanced features.
- st1x7 6y agoIt's considerably more difficult than Python, people just get misled by the similar syntax. The advanced features that you're mentioning aren't optional in Julia, especially if you care about performance.
- dnautics 6y agoBut you don't care about performance with Julia. You just write your thing. Then you complain to the community that it's slow, and they optimize it for you! Only half kidding.
- adamnemecek 6y agoWhich part of Julia is difficult?
- xiphias2 6y agoFor me it was understanding the type unification rules. After a long time I read the original dissertation papers, and only that was the time when I finally understood what method is being called why at what point. While method dispatch is the most interesting part of Julia, it's the most complex as well.
- as_keyof_typeof 6y agoI first thought of Rustlang when I saw the title, then I saw the nature.com domain and corrected thinking "oh interesting, what are scientists studying in iron oxide?"
- throwaway201103 6y agoI work in an academic computer science/big data/ML research environment. Nobody is using Rust. They use Python or Java.
- willis936 6y agoThe computationalists I know are maintain large sets of fortran code. When they’re not doing that, they’re porting fortran codes to julia or python or writing new codes in julia or python.
- proverbialbunny 6y agoUsually these types are writing Python libraries, porting them to C and C++, not writing direct Python.
- proverbialbunny 6y agoYah, you're not going to need Rust, but some kinds of research could benefit and does use Rust. Eg, anything financial, where floating point is a no go, Python falls on its face. Anything physics like NASA type research can benefit from strict types. Robotics, and so on.. ymmv. Rust shouldn't take away from Python or Java, but it may take away from research that uses Fortran, C, or C++.
- ageofwant 6y agoScientist are not turning to rust. Scientist, if they are turning, are turning to the scientific standard compute language and its plethora of platforms and libraries: Python. Rust is fine, but it will never catch up or replace Python. Python is just good enough at what it does and will only become better.
- Ericson2314 6y ago> Python is just good enough at what it does Perhaps? > and will only become better. Very unlikely
- torgian 6y agoYeah, I agree. All the scientists that I know who are using a programming language, are using Python because it’s easy enough to learn how to use and it’s powerful for their needs. I really don’t see Rust being used for anything other than very specific cases.
- stolen_biscuit 6y agoI can't help but feel that given the requirements laid out in the article Nim would be a more suitable fit for their goals over Rust. I do think Nim really nails great performance with a very clean and straightforward syntax, certainly easier for someone who only works in Python to pick up over Rust.
- chairmanwow1 6y agoNim would be a nice option if the ecosystem were even half as developed as the Rust package ecosystem.
- stolen_biscuit 6y agoKind of a chicken and egg scenario there really. A few early adopters will need to branch out and start using it to get that momentum building, which is probably a great opportunity for scientists who are looking for an alternative
- chairmanwow1 6y agoI think this is exactly the point I was making. There isn’t a real reason to use Nim, so no one but language enthusiasts will.
- planetis 6y agoReason for using Nim is its simplicity, anyone writing Python can switch to Nim, fast compile times and it's speed which is on par with C/C++
- planetis 6y agoNim has plotting, dataframe, matrix libs and even a fully featured machine learning library, I don't see the reason why it can't be used, especially by scientists. https://github.com/Vindaar/ggplotnim https://github.com/Vindaar/ggplotnim https://github.com/unicredit/neo https://github.com/unicredit/neo https://github.com/mratsim/Arraymancer https://github.com/mratsim/Arraymancer
- gnusty_gnurc 6y agoI don't think scientists should worry themselves with the cognitive burden of Rust. It's hard enough to figure out how to do things in any language as a full-time software developer, never mind someone that just needs a program for their research, etc.
- ironmagma 6y agoScientists are currently writing their code in C++ in many cases. If you have needs that require the performance benefits of C++, why not do it in a language that has a cohesive design (and is actually intuitive) instead of learning the pile of layers of decades-old debt that is C++?
- gnusty_gnurc 6y agoI question if scientists ever should have to tackle the ins and outs of software architecture and performance optimization. Never mind the daunting task of running software. I don’t really see Rust being altogether different to someone outside the software industry. It’s yet another complex knowledge domain that can be abused and intractable like any other.
- ironmagma 6y agoI suspect the lines are not as cleanly drawn as anyone would like them to be, no more making programming unnecessary for scientists than they make cooking unnecessary for <insert non-chef profession here>.
- dystroy 6y agoHard to answer this question but I worked with scientists who were wasting an incredible amount of time debugging their badly designed fortran or c++ programs, or just hitting walls when they shouldn't. So yes you can easily start hacking something in fortran or c++, and the cognitive load is probably much smaller, but then you have the risk of being eaten by your bugs, or of not working on some problems just because the tool you make is so badly designed you give up doing the necessary changes.
- jimbob45 6y agoDoes anyone know why scientists aren’t just using Excel? Nothing against Python/Julia but Excel seems like it would be my first choice (paired with some CSV files).
- ur-whale 6y agoExcel is far too slow for large scale datasets.
- jimbob45 6y agoIs that true? Python is pretty slow too. I can’t imagine many scientists would really mind leaving their work running overnight.
- proverbialbunny 6y agoIt's true. Fun and relevant fact: The job title data scientist was invented at LinkedIn when they saw data analysts that needed to know R or Python skills. These skills seemed different enough from the traditional Excel and SAS data analyst jobs at the time to warrant a new job title. So did Excel not cut it, or was it a preference to use Python? Back then Excel supported up to 65,535 rows, and would typically crash with over 8,000 rows. I worked in that era in Excel. One model once was split across three spreadsheets. Only one spreadsheet could be open at a time, they would take 20 minutes each to load, and there was about a 50% chance they would crash while loading. So what do you do if you need over 65,000 instances of labeled data? For a neural network it's nice to have a million instances, yes a million. R and Python have in them what is called a dataframe. It's a spreadsheet, but in another programming language. We tend to load our data into those, which is just like Excel, but without the hardware limitations. So in many ways, today it's just like it once was, but we get to choose which programming language to use while working in a spreadsheet, and let's be fair, the Excel programming language isn't exactly great.
- mattkrause 6y agoI think you are...dramatically underestimating the size of many "modern" datasets and what most scientists want to do with them. We record (electrical) neural activity from behaving animals. The raw data is about 1 Gb/minute, and we collect hours of it per day, 5-7 days/week. The lab next door has microscopes that produce image sets that are in the Gb to Tb range (big swathes of human brains, imaged at micron resolution). An RNAseq experiment is ~20 Gb range; other genomic things are similar, maybe a bit smaller. All of this would be intractable in Excel, even over a long weekend :-) On top of that, Excel often doesn't do much of what you would need: there's basically no support for signal processing or image analysis or genomic work.
- rudolph9 6y agoRust may or may not be a good choice for research scientist needs but the biggest missing piece in my opinion is reproducibility. I haven’t worked with it extensively (I use nix on my workstation) but I’m a big fan of what the Guix folks are doing targeting the scientific community https://hpc.guix.info/blog/2019/05/gnu-guix-1.0-foundation-for-hpc-reproducible-science/ https://hpc.guix.info/blog/2019/05/gnu-guix-1.0-foundation-f...
- bigger_cheese 6y agoHas someone attempted to write something like Numerical Recipes Textbook or the GSL Scientific Library using Rust a lot of people in my org use those two resources - especially the NR textbook all the time. I've found a lot of people bash NR online as outdated but it has really clear explanation of how certain algorithms are written as well as clean to read code examples. Very helpful to follow along with an explanation of the algorithm and see it all laid out in front of you with code. So maybe a modern version written in a newer language could be a hit.
- dystroy 6y agoI loved Numerical Recipes but it's the product of an old time. It was terribly useful but also in some complex parts very buggy and badly optimized. Nowadays, a similar effort would have to be community driven, and open-source, and include the deep discussions for domain specializations.
- eigenspace 6y agoI'm a physicist who knows many physicists who write a lot of code. I don't know any physicists who use or even want to use Rust.
- LordHeini 6y agoYep, with the exception of the computery fields of pyhsics, they cold not care less about programming languages. I have seen physicists write entire non trivial image processing pipelines in Matlab. Where they happily processed gigabytes of images made by some weird microscope costing stupid amounts of €. It (mostly and somehow) works but it is slow as hell (porting to c++ cut the time to run a process from 1 day to a few seconds). They never even bothered with a "real" language because the "computer guys" can port that stuff if need be. If you have a hammer...
- WhoCaresLies 6y agoThis seems very suspicious All these pro rust/mozilla journalists are all related to Mozilla in some ways Few google search and you start to see how all these people are connected Hmm What about CSS developpers, they are also turning to Rust? We'll need the Markdown writters to turn to rust too!
- planetis 6y agoAll in all another unfounded, Rust evangelist "rust can fix your clogged toilet" article. Aren't you tired of these?