News for hackers. Stuff that matters.
Re:Rust for Python Programmers by bitL on Wednesday May 27, 2015 @07:54AM (#9610685)
A quick question from a Rust noob: if I knew Python, why should I try Rust? What is in there that would make my life better? At first glance I see a lot of unimportant syntactic sugar or concepts I am not sure would make my life any easier (ownership tracking vs garbage collection).
Re:Rust for Python Programmers by untothebreach on Wednesday May 27, 2015 @08:03AM (#9610723)
As a current python & rust user, I can say that I picked up rust because I liked the idea of a systems language that could give me c-like performance, without having to use C. Rust seems, to me, like a combination of the best parts of python (traits as pseudo-duck-typing), haskell (type inference, functional concepts), and C(++) (speed, no GC).

As @mitsuhiko says in the article, it is very easy to export symbols from a Rust library so that they can be used via CFFI, so the possibility of "dropping down to Rust" instead of "dropping down to C" is very attractive to me.

Re:Rust for Python Programmers by Cyph0n on Wednesday May 27, 2015 @08:56AM (#9610977)
I have my eyes on Rust, mainly for no GC and its ownership system, and Nim for its clean, Python-like syntax but with C performance.

I also have Julia in my mind for my next scientific computing (image processing, DSP) project.

Re:Rust for Python Programmers by untothebreach on Wednesday May 27, 2015 @09:15AM (#9611073)
I keep on messing around with Julia, but I never stick with it. I have nothing in particular against the language, but I don't do a lot of scientific computing, so my motivations to use it are not that great.
Re:Rust for Python Programmers by juliangregorian on Wednesday May 27, 2015 @10:03AM (#9611369)
I think Julia gets unfairly pigeonholed. It's got a great concurrency story, for example. I know what you mean though, it always seems to be the language I'll write my "next" project in.
Re:Rust for Python Programmers by Lofkin on Wednesday May 27, 2015 @11:28AM (#9612044)
Why can't it be used for general computing?
Re:Rust for Python Programmers by Fede_V on Wednesday May 27, 2015 @11:47AM (#9612177)
It can. However, Julia made a very strong push to target the scientific computing niche (very strong array support, ease of writing tight loops in native code, etc) - and such it has a very quickly growing ecosystem of high quality scientific packages.

In comparison, Julia has relatively few web frameworks, GUI toolkits, etc..

Re:Rust for Python Programmers by untothebreach on Wednesday May 27, 2015 @12:59PM (#9612727)
Sure it can. But why would I pick it up over, say, rust? Rust gives me the productivity of a dynamic language, and the speed of a systems language. Julia gives the same. So, given similar pros/cons, the choice comes down to aethsetics, and Julia just didn't give me a compelling enough reason to switch.
Re:Rust for Python Programmers by the_mitsuhiko on Wednesday May 27, 2015 @09:59AM (#9611347)
The main problem with nim is that you can't really pair it with Python whereas you can have Rust and Python call each other if you want.
Re:Rust for Python Programmers by chrisheller on Wednesday May 27, 2015 @12:03PM (#9612309)
Have you played around with Nimborg? That allows embedding Python in Nim fairly easily.

https://github.com/micklat/NimBorg

I've been able to call into the Nim side from Python by treating the Nim code as C functions to call. That works, but it would be interesting to come up with a more Pythonic way of doing that.

Re:Rust for Python Programmers by Siecje on Wednesday May 27, 2015 @10:16AM (#9611458)
Can you expand on why that is?
Re:Rust for Python Programmers by the_mitsuhiko on Wednesday May 27, 2015 @10:57AM (#9611802)
Nim requires a runtime to operate. Figuring out how to safely share the runtime between different Python extensions requires the cooperation of all of those extensions. You probably also need to move all nim code into a thread.
Re:Rust for Python Programmers by untothebreach on Wednesday May 27, 2015 @10:26AM (#9611529)
Just a guess, but it is probably because they each have their own GCs, and that makes it harder* to ensure that objects created in language A, from language B, haven't been collected when language B needs them again.

* harder, but not impossible

Re:Rust for Python Programmers by apendleton on Wednesday May 27, 2015 @01:38PM (#9613010)
So there probably aren't many circumstances where you would be choosing between one and the other, but one reason you might want to keep your eye on Rust is for extension-writing. The traditional approach to dealing with stuff that needs to be fast in Python is to get it working in pure Python first, optimize as best you can, and if it's still not fast enough, profile to identify your hot loops and rewrite those bits in C as an extension. This is somewhat less necessary in the era of PyPy, but still a common way to think about things.

To me, at least, Rust provides a compelling alternative to C in the Python+C combination. Coming from Python, writing C is pretty unergonomic; it's super-easy to shoot yourself in the foot and have your program die with an inexplicable segfault, which feels pretty alien for someone used to nice pretty stack traces. Rust promises to make that a lot more pleasant by being memory-safe, while still making good performance promises.

Re:Rust for Python Programmers by joliv on Wednesday May 27, 2015 @08:28AM (#9610841)
I actually came for the robust type system. Not sure if that falls into your "unimportant concepts" category, though :)
Re:Rust for Python Programmers by olavk on Wednesday May 27, 2015 @10:19AM (#9611480)
I don't think you would ever have a project were you could choose between Rust and Python. Their domains are quite distinct.

Rust is for performance critical applications where you cant afford garbage collection. You would choose Rust as an alternative to C or C++.

Using Rust will certainly not make your life easier compared to Python. But you could use Rust on some projects where Python is not possible.

Re:Rust for Python Programmers by okasaki on Wednesday May 27, 2015 @08:02AM (#9610718)
Rust has much better performance.