News for hackers. Stuff that matters.
Re:Rust 1.24 by talson on Thursday February 15, 2018 @03:24PM (#16387282)
Can someone sell me on using rust over python? I am just gernerally curious as to the advantage beyond rust being compiled.
Re:Rust 1.24 by kzrdude on Thursday February 15, 2018 @04:05PM (#16387621)
When I use Python I miss Rust's enums, the pattern matching of those enums, and the static types that help refactoring (the compiler spots where one change has knock-on effects in the rest of the project..).

Especially how Rust enums and structs make it easy to define new types to guide your programs are a highlight for me.

I don't think Rust is better than Python for every task. Python is a lot simpler if you can get something done with its built in types (dicts, sets and lists). Python's dynamic types are also a great benefit for some tasks, where Rust's dynamic dispatch support is very limiting.

Crazily, handling dependencies and building a project is way easier in pure-Rust than pure-Python since it's standardized.

Re:Rust 1.24 by akmittal on Friday February 16, 2018 @12:59AM (#16390252)
Go is good middle ground between simplicity and being fast/dynamic.
Re:Rust 1.24 by kod on Friday February 16, 2018 @09:00AM (#16392326)
Walk middle, sooner or later get the squish just like grape.
Re:Rust 1.24 by SanFranManDan on Friday February 16, 2018 @10:11AM (#16392841)
> Avoiding both these extremes, the Tathagata (the Perfect One) has realized the Middle Path; it gives vision, gives knowledge, and leads to calm, to insight, to enlightenment and to Nibbana.
Re:Rust 1.24 by kod on Saturday February 17, 2018 @07:35AM (#16400416)
But I bet Mr. Miyagi could beat up your Tathagata in a coding contest.
Re:Rust 1.24 by Rotareti on Thursday February 15, 2018 @04:25PM (#16387772)
> Especially how Rust enums and structs make it easy to define new types to guide your programs are a highlight for me.

In recent versions Python got some nice improvements in this area, with the new way of creating NamedTuples, Data Classes and the typing module. I wrote a stackoverflow answer recently that sums it up, if anyone is interested:

https://stackoverflow.com/a/45426493/1612318

Re:Rust 1.24 by sidlls on Thursday February 15, 2018 @05:01PM (#16388144)
Those artifacts in Python don't really compare with what the parent laments. Rust's sum types are one of my top reasons for preferring the language.
Re:Rust 1.24 by whyever on Thursday February 15, 2018 @05:07PM (#16388198)
There are not sum types though.
Re:Rust 1.24 by aidenn0 on Thursday February 15, 2018 @03:33PM (#16387358)
While there is overlap between problems that might be sanely solved using python and problems that might be sanely solved using rust, the languages target very different problems.

You could write parts of a network server or parts of an OS kernel in python. You could write nearly the entirety of it in rust.

I would say that you need not use rust if python works well for you, but rust is probably better than C for implementing libraries that might be called from python.

Re:Rust 1.24 by pas on Thursday February 15, 2018 @07:10PM (#16388921)
Python is great, and getting better.

Just religiously use mypy. (Gradual typing!)

And profiling, and when something is reallly slow, bring out the Cython.

And when something is still not fast enough, well ...

Release the Rustacean!

Re:Rust 1.24 by IshKebab on Thursday February 15, 2018 @03:49PM (#16387486)
They really very different but...

+ Static typing (extra safety, robust refactoring, code completion etc.)

+ Much much faster and less memory use

+ Compiles to a relatively standalone binary (not as good as Go though)

+ No Python 2/3 nonsense to deal with

- Much more complicated. You have to deal with lifetimes and borrowing and so on. It's really very difficult and we still don't know how to write some types of programs nicely (e.g. GUIs)

- Slow compilation times

- Can get pretty verbose and full of type boilerplate

Honestly if I was coming from Python I think I would switch to Go first. It is still way faster than Python, has a very nice "batteries included" standard library, static typing, very fast compilation and makes nice static binaries. The downside compared to Python is that it isn't very expressive at all - you'll find yourself writing out loops where you might have used a one-line list comprehension or something in Python.

Re:Rust 1.24 by Spiritus on Friday February 16, 2018 @02:24AM (#16390579)
> No Python 2/3 nonsense to deal with

Instead you have the stable/nightly nonsense to deal with, like Clippy and Rocket only working on nightly for example.

Re:Rust 1.24 by MrBuddyCasino on Thursday February 15, 2018 @04:03PM (#16387604)
> Compiles to a relatively standalone binary (not as good as Go though)

Whats the difference?

Re:Rust 1.24 by steveklabnik on Thursday February 15, 2018 @04:05PM (#16387620)
We use glibc by default, so while Rust statically links all Rust code by default, that's still dynamically linked. You can use MUSL to remove that, where appropriate, but it's not the deafult.
Re:Rust 1.24 by burntsushi on Thursday February 15, 2018 @05:02PM (#16388159)
To add an additional clarification here for others (I know Steve knows this :P), by default, at least on Linux, whether Go produces a dynamic executable or not depends on which things you import. For example, a simple hello world program will produce a static executable:

    $ cat main.go
    package main
    
    import "fmt"
    
    func main() {
            fmt.Println("Hello, world!")
    }
    $ go build
    $ ldd scratch
            not a dynamic executable
But anything using the network, like a simple HTTP server, will cause the Go tool to build a dynamic executable:

    $ cat main.go
    package main
    
    import (
            "log"
            "net/http"
    )
    
    func main() {
            // Simple static webserver:
            log.Fatal(http.ListenAndServe(":8080", http.FileServer(http.Dir("/usr/share/doc"))))
    }
    $ go build
    $ ldd scratch
            linux-vdso.so.1 (0x00007fff161f0000)
            libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f796b0e8000)
            libc.so.6 => /usr/lib/libc.so.6 (0x00007f796ad31000)
            /lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x00007f796b306000)

Now of course, you can set flags to force Go to always produce a static executable, but the difference here isn't too much different with Rust. With Rust, you do need to install MUSL, add the target and then rebuild with an extra flag, but it's all very simple.

(To be clear, I am not criticizing Go here! There are good reasons why they link to libc by default when network stuff comes into the picture.)

Re:Rust 1.24 by jhasse on Thursday February 15, 2018 @05:07PM (#16388196)
What's the problem with that? Do you use any of glibc's private API?
Re:Rust 1.24 by steveklabnik on Thursday February 15, 2018 @05:13PM (#16388248)
The problem is that you have to think about it at all. If you compile on a machine with a new libc, and then try to run it on a machine with an old libc, it won't work. So you end up doing what most people do, even outside of Rust, which is take the oldest CentOS box you can stand and do builds on that.
Re:Rust 1.24 by jhasse on Friday February 16, 2018 @03:20AM (#16390768)
The Autopackage project had a solution for this problem years ago called apbuild. It would search for the versions of glibc symbols and use the oldest possible ones, which resulted in portable binaries. With some quick googling I found the code here: https://github.com/DeaDBeeF-Player/deadbeef-plugin-builder/t... Probably doesn't work anymore though :/

It's a bit sad that this is still unsolved, probably due to the GNU people's hatred for closed-source distribution.

Re:Rust 1.24 by IshKebab on Friday February 16, 2018 @12:20PM (#16393891)
It's the GNU way:

1. Refuse to do something properly because it will make it too easy... or something.

2. Wait until someone else gets fed up enough and makes a better version.

3. Fade into irrelevance.

See: GCC/Clang, glibc/musl, Bash/??? (someone please make something sane)

Re:Rust 1.24 by jhasse on Friday February 16, 2018 @12:26PM (#16393945)
Re:Rust 1.24 by dorfsmay on Thursday February 15, 2018 @04:00PM (#16387581)
Python:

Think about your domain problem, don't worry about CS and perf

Use the REPL to "touch data with your own hands"

Rustlang:

Fast, fast, fast

Everything bundled inside a single binary that you can just ship - no dependency hell for your users

Re:Rust 1.24 by carlmr on Friday February 16, 2018 @08:41AM (#16392210)
Rust can give you speed and safety in one package. But you sacrifice ease of coding, especially as the IDE ecosystem is not there yet in terms of ease of use.

I've taken a few apps from Python to C#/F# and seen speed increases around 50x. With Rust I could increase the speed from C#/F# by around a factor of 10x for string heavy applications processing large files. So the speed difference might be 500x between a Python and Rust application (depends HEAVILY on the problem you're solving though, a lot of the problems that can be vectorized easily work pretty fast in Python).

I'd say I'm faster at writing F# than at Python, because the type system helps me build more easily maintainable code, and the functional style is better for the way I think (I grew up with structural, learned OO in uni and thought most of it is bananas and more obfuscation than helping, and I'm happy the world is now slowly getting to something sensible again). It takes me a bit longer to write Rust programs though.

Cargo is the best build system of the 3 languages though, you can easily add crates (imports) and the build system handles everything, even unit testing. I gotta say on the project setup front Rust with Cargo is much better than any other language I know.

And I think once we get good IDEs with robust code completion and error detection, I can become quite fast at Rust as well.

Re:Rust 1.24 by pjmlp on Friday February 16, 2018 @10:10AM (#16392831)
My Rust dream IDE would visually display lifetimes and how they relate to each other. :)
Re:Rust 1.24 by carlmr on Friday February 16, 2018 @10:58AM (#16393220)
That would be a really cool feature.
Re:Rust 1.24 by qarioz on Friday February 16, 2018 @10:20AM (#16392902)
RLS works just fine on my Linux box, error detection and completion and formatting. Debugging is so so, not very good. But on my Mac box, it's always crashing.
Re:Rust 1.24 by carlmr on Friday February 16, 2018 @10:58AM (#16393219)
For me it's a) crashing quite often on Windows and Linux and b) doesn't really autocomplete anything beyond really simple cases where I don't need it like "Vec::<String>::" will give me new. But on most things it's just really awful.

Error detection, at least in VSCode is only displayed after compiling, that might be the plugin though.

Re:Rust 1.24 by carlmr on Monday February 19, 2018 @06:17AM (#16412204)
I have to make a correction, the Rust (rls) plugin now works much better. I updated my rust distribution.
Re:Rust 1.24 by oconnor663 on Thursday February 15, 2018 @09:19PM (#16389412)
Just my favorite single reason: I love ownership. I love knowing what a function is going to do with the HashMap/dictionary I pass into it. I love knowing when I'm the only piece of code that can touch something. Sure, there are benefits in terms of not needing a GC too, but I just love how clear it makes everything.
Re:Rust 1.24 by chrismorgan on Friday February 16, 2018 @09:21AM (#16392471)
Yeah, I vacillate between judging algebraic data types and ownership as the thing I like most about Rust over other languages (formerly Python, but I do much more JavaScript now), but I think ownership wins most of the time. Strong ownership protects from vast swathes of really annoying bugs that are unpleasantly easy to unknowingly inject and particularly hard to track down. Certainly I believe that Rust’s strong ownership model is the defining feature of the language—most of the language’s features come about as a consequence of it (though this dominance has slowly been diminishing since 1.0).
Re:Rust 1.24 by michaelchisari on Thursday February 15, 2018 @03:29PM (#16387316)
Performance is quite a bit higher for rust. And it's a much safer language by design (and forces the programmer to be as such).

That said, development time in Python is much faster.

Honestly, it depends on what you're building.

Re:Rust 1.24 by andrewflnr on Thursday February 15, 2018 @07:51PM (#16389105)
Rust is not safer than Python in Rust's own terminology. It takes more work than in C, but you can write memory bugs in Rust, by design. Python will catch those damn near every time, and if it doesn't you file a bug. Sure, there's less serious classes of bugs that Rust is likely to catch, but that's not really safety except in a definition loosened to near uselessness.
Re:Rust 1.24 by roblabla on Thursday February 15, 2018 @11:01PM (#16389759)
> you can write memory bugs in Rust, by design

Unless you're talking about unsafe rust, that's wrong. And if you ARE talking about unsafe rust, well you can do the same in Python.

I do agree that python and rust are both "memory-safe" languages. I'm not sure about the other kind of safety rust provides though: thread-safety. That's really where Rust shines: you can write concurrent program and be statically guaranteed to have no data-races. I'm not sure how this transposes in python.

Re:Rust 1.24 by vvanders on Thursday February 15, 2018 @08:25PM (#16389231)
You can describe "safe" along different axes and python is not completely immune to memory issues. I guarantee that if you start using ctypes you'll manage it at some point.
Re:Rust 1.24 by Etzos on Thursday February 15, 2018 @03:53PM (#16387530)
I'm curious what parts of Rust you think are safer than Python.

Edit: The only big thing I can think of is the safety of compile-time type checking to ensure you won't end up with some kind of runtime error from mismatched types. Is there something I'm missing?

Re:Rust 1.24 by estebank on Thursday February 15, 2018 @04:50PM (#16388023)
Immutability by default, exhaustiveness checks (make sure that you match over all variants of an enum or cover all valid values in an integer), return flow validation (did you forget a return somewhere? Is it the right type?), and, as you mentioned, type checking being mandatory, all libraries define their accepted types. Not only that, being types "cheap", it is customary to wrap base types in explicit types that won't be compiled:

    type Point(u32);
    fn foo(p: Point) {...}
    foo(0u32);
        ^^^^ expected Point, found u32
Re:Rust 1.24 by lmm on Thursday February 15, 2018 @04:19PM (#16387720)
When you work with the type system it checks a lot more than you check in Python. In Python you pass around untyped tuples and maps because defining classes won't gain you anything (and is surprisingly cumbersome and unpythonic), whereas in an ML-family language like Rust you use lightweight, fine-grained types to check that every function call is correct and you can refactor fearlessly.

(I'd recommend using a language with garbage collection unless you really need to not though; OCaml is quite Rust-like but means you won't have to worry about the borrow checker)

Re:Rust 1.24 by saghm on Thursday February 15, 2018 @04:55PM (#16388076)
> I'd recommend using a language with garbage collection unless you really need to not though; OCaml is quite Rust-like but means you won't have to worry about the borrow checker

OTOH, Rust arguably has a better story for tooling (build system, dependency management, etc.), a more full-featured standard library, and better concurrency support. Depending on your priorities, some or all of these might be worth having to learn the borrow checker.

Re:Rust 1.24 by FullyFunctional on Thursday February 15, 2018 @04:52PM (#16388045)
Well, O'Caml and Haskell predates Rust by decades. I was delighted to see Sum-Product types in Rust when I played with it. They go a long way to cleanly model the problem domain. Obviously you can simulate them, but it's much easier to get wrong or "cheat" (say having a bunch of fields, only some of which are valid depending on a tag).
Re:Rust 1.24 by lmm on Friday February 16, 2018 @04:37AM (#16391090)
> I was delighted to see Sum-Product types in Rust when I played with it. They go a long way to cleanly model the problem domain.

Umm yeah, they've been a part of every ML-family language since the '70s, OCaml, Haskell and Rust included.

Re:Rust 1.24 by tome on Friday February 16, 2018 @06:05AM (#16391512)
(FullyFunctional seems to understand this, as far as I can tell)
Re:Rust 1.24 by FullyFunctional on Sunday February 25, 2018 @08:23PM (#16462335)
I do, but I wasn't aware that Rust was considered in the ML family (ML as Meta Language, like SML/NJ). I'm somewhat skeptical of that.

What I see from Rust is a lot of the really great things from functional languages (esp. strong typing) and beyond, but applying them to a language aiming as low as C. That's certainly interesting.

Re:Rust 1.24 by smaddox on Thursday February 15, 2018 @04:13PM (#16387688)
Rust also enforces deep immutability by default, which makes resource sharing bugs much less common.
Re:Rust 1.24 by currymj on Thursday February 15, 2018 @05:29PM (#16388359)
the type-checking catches lots of memory errors (irrelevant in a GC language like Python, but wouldn't be caught by the compiler in C or C++), but it also catches data races when writing concurrent code, which is definitely something that could happen in Python.
Re:Rust 1.24 by grayrest on Thursday February 15, 2018 @06:12PM (#16388614)
> The only big thing I can think of is the safety of compile-time type checking to ensure you won't end up with some kind of runtime error from mismatched types. Is there something I'm missing?

It's this but designs in statically typed languages with more expressive type systems tend to push a lot of the logic into the type system so you can't use APIs incorrectly. This isn't exclusive to Rust but I do have a few examples:

The Glium OpenGL wrapper puts a lot of effort into moving errors to compile time. The overview[1] explains a bunch of them.

[1] https://github.com/glium/glium#why-should-i-use-glium-instea...

The Servo project uses the type system to tie rust code into the spidermonkey garbage collector so it can't be misused[2].

[2] https://research.mozilla.org/2014/08/26/javascript-servos-on...

More abstractly, one of the more unique features of Rust's type system (linear types) is the ability to be sure a reference is destroyed. This makes Rust particularly good at describing state machines that are compile-time checked. Using standard OOP terms, each state is a class and its methods are the valid transitions. You can't take an invalid transition because the method is missing. You can do this in any language, though it tends to be only done in statically typed languages and it's awkward in Python. What makes Rust unique is that calling the method will consume the instance so you can't accidentally make a transition twice. Trying to call the method again is a compile error. A concrete example of this is state_machine_future[3], which generates an asynchronous state machine using macros.

[3] https://github.com/fitzgen/state_machine_future#example

In a slightly different use of the type system, the Rocket framework has a concept called Request Guards that allow you to map from something in the Request to a parameter in the request handler function. The overview[4] has a simple example on the "Dynamic Params" tab that maps url pieces to a string and an int. This mapping, however, is extensible and you can map to anything. If your handler needs an AdminUser, you can have the request guard pull the user id off the request, connect to the db, retrieve the user, verify the user as an admin, and only enter the handler if all that is successful. This means you can move all the logic and error handling around this into a single place that can be reused just by putting an AdminUser parameter on a handler. I've seen this done with middleware in other frameworks but in Rocket it's on-demand per-handler. As a result, the handlers only have to implement the happy path, which keeps them more compact than I've seen in dynamic language frameworks.

[4] https://rocket.rs/overview/

So the general idea is to use the type system to help you use stuff right. As with anything, it's possible to overdo it and get crazy boilerplate heavy code where you have to convert/cast all over the place and unanticipated use cases can't be done but it tends to be helpful, particularly with autocomplete.

Re:Rust 1.24 by michaelchisari on Thursday February 15, 2018 @04:10PM (#16387655)
That's a big one.
Re:Rust 1.24 by shpongled on Thursday February 15, 2018 @06:20PM (#16388653)
I pretty much can't stand to write python after learning and using Rust. The static type system in Rust is just so great, and easy to use once you get the hang of it.

This especially shines through if you have to use code someone else wrote.

Re:Rust 1.24 by carlmr on Friday February 16, 2018 @08:43AM (#16392227)
I'm happy there are others seeing the benefits of strong static type systems (strong is important, the C type system which is rather weak in many instances is not as helpful).
Re:Rust 1.24 by narimiran on Friday February 16, 2018 @08:12AM (#16392063)
> Can someone sell me on using rust over python?

I can't. But I can try to sell you Nim [0] as a compiled/faster addition to your Python, from my own experience of using it in last few months and coming from Python.

It uses significant whitespace and the syntax will surely look familiar to any Pythonista, and the entry barrier is much lower (i.e. learning curve is much shallower) than Rust.

Speed improvements I experienced are in the range of 10-100x, while the code doesn't look that much different than Python. I have solved Advent of Code in both Nim and Python in parallel [1] so you can compare the solutions/syntax yourself.

[0] https://nim-lang.org/

[1] https://github.com/narimiran/AdventOfCode2017

Re:Rust 1.24 by walkingolof on Thursday February 15, 2018 @03:27PM (#16387301)
Re:Rust 1.24 by pvg on Thursday February 15, 2018 @04:41PM (#16387939)
That's a bit like asking someone to sell you on using a plasma cutter over a dremel tool. It can be done but it's not particularly useful or sensible.
Re:Rust 1.24 by ZenoArrow on Thursday February 15, 2018 @06:22PM (#16388658)
Everything you can write in Python you can write in Rust, and everything you can write in Rust you can write in Python.

The main differences are found in tooling, library ecosystems, development speed and runtime overhead.

Re:Rust 1.24 by pvg on Thursday February 15, 2018 @06:48PM (#16388819)
Everything you can write in Python you can write in Rust, and everything you can write in Rust you can write in Python.

That really isn't true in any practically meaningful sense. 'The main difference is everything is different' is not a very strong counter-argument.

Re:Rust 1.24 by ZenoArrow on Friday February 16, 2018 @02:25AM (#16390583)
> "'The main difference is everything is different' is not a very strong counter-argument."

That wasn't my counter argument, and I can't work out what you misinterpreted about what I said to get that impression.

My point was, unlike a Dremel and a plasma cutter, Rust and Python can be used for the same tasks. As they're both Turing-complete, anything you write in one can be written in another. The differences I suggested were to highlight the relative strengths, or in other words how much work you'd need to put in to get the desired result.

To be clear, if you hadn't tried to dismiss the GP who requested information about how Python and Rust compared to each other, I wouldn't have replied.

Re:Rust 1.24 by pvg on Friday February 16, 2018 @02:49AM (#16390671)
As they're both Turing-complete

The moment you trot that out, you lose your 'but your analogy is terrible' privileges by default, however terrible my analogy is.

Re:Rust 1.24 by ZenoArrow on Friday February 16, 2018 @03:09AM (#16390733)
How so?
Re:Rust 1.24 by pvg on Friday February 16, 2018 @03:27AM (#16390790)
Because more or less everything is Turing-complete. Your mom is probably Turing-complete. 'Your mom' is a pithy but lousy argument.
Re:Rust 1.24 by ZenoArrow on Friday February 16, 2018 @03:47AM (#16390879)
> "Because more or less everything is Turing-complete."

If you understand what it means, then you'd know that it means that all programming languages are comparable, from assembly to Haskell, in the sense they can all be used to do the same job. Therefore, requesting a comparison of the strengths and weaknesses of two programming languages is not a foolish request. The point of such a request is to find out where it makes sense to use a particular language. To give another example, let's say someone asks if it's a good idea to write a web server in assembly or in Go. It's certainly possible in either, but in order to explore what the best choice is then further discussion is required. Comparing a Dremel to a plasma cutter is an attempt to shut down this discussion, which doesn't help in furthering the knowledge of the participants.

Re:Rust 1.24 by pvg on Friday February 16, 2018 @04:30AM (#16391061)
If you understand what it means, then you'd know that it means that all programming languages are comparable

I think this is where we strongly diverge and I resent, a bit, your implication that because I don't buy into this I somehow 'don't understand what it means'. I understand what it means. I just think it's plainly ridiculous.

Re:Rust 1.24 by ZenoArrow on Friday February 16, 2018 @07:10AM (#16391744)
> "I just think it's plainly ridiculous."

You compared a Dremel to a plasma cutter as a way to explain the differences between Python and Rust, how is that any less ridiculous?

Re:Rust 1.24 by pvg on Friday February 16, 2018 @05:30PM (#16397099)
It’s an analogy and like most analogies it’s imperfect. My point was and remains that a really bad argument (“everything is Turing-complete!”) is not much of a critique of that or really any analogy. Because it’s so obviously shallow and bad.
Re:Rust 1.24 by ZenoArrow on Friday February 16, 2018 @08:44PM (#16398333)
> "My point was and remains that a really bad argument (“everything is Turing-complete!”) is not much of a critique of that or really any analogy. Because it’s so obviously shallow and bad."

You're getting hung up on a minor detail. My main point was not about Turing completeness. My main point was that requesting a comparison of programming languages is a legitimate request. Turing completeness is just one angle by which to see this. As you seem to object to that suggestion, there are plenty of other ways to explain it.

For example, one way to compare languages is to look at the key libraries and frameworks that have been built up around them. So for example, Rocket vs Django, Diesel vs SQLAlchemy, etc... If we're comparing languages, we should compare what the languages makes it easy for us to do, and libraries are a big part of that.

Another way to look at this suggestion is that "writing performant code" is something that's easier in some languages than others, and the libraries built using those languages are likely to reflect that. However, performance is just one metric by which to compare languages/libraries/frameworks, which is another reason why these comparisons can help in building an understanding in when a language is likely to be the best one for the job.

Lastly, to make this as clear as possible, I'm not advocating for Python or for Rust, I am only advocating for language comparison as a helpful approach when building familiarity with programming language strengths and weaknesses. Both Python and Rust have niches they excel in, but there's also a large amount of overlap. As an example, game frameworks exist for both Python and Rust, and discussion can help others find what's best for them.

Re:Rust 1.24 by laxd on Thursday February 15, 2018 @06:45PM (#16388800)
Python does'nt give you the low level control needed for.. low level stuff. And even if it can be implemented does'nt mean it will be fast enough.
Re:Rust 1.24 by ZenoArrow on Friday February 16, 2018 @02:30AM (#16390602)
If that's your impression, then I'd suggest Python is used for more than you're currently aware of. Here are two examples of Python being used for "low level stuff":

https://micropython.org/

http://www.myhdl.org/

Re:Rust 1.24 by sp0ck on Friday February 16, 2018 @02:53AM (#16390685)
Nothing against Python (I'm using it) , but those solutions have huge performance impact comparing C/Rust on bare-metal. Interrupt handling, GPIO operations are orders of magnitude slower in python. Take such simple board and run basic bit-banged gpio PWM. You need "beefy" Cortex-M family to get similar performance that you can get with 8/16-uC with C. Nice for hacking stuff but I would't trust my AC conditioner firmware running months without power cycle on interpreted language :) C/Rust gives you static analysis of memory usage so you can predict sw memory usage. With Python VM single bug in it can shutdown your code or eat all heap. Maybe now maybe after six months running your code. Nice hacking tools thou.
Re:Rust 1.24 by ZenoArrow on Friday February 16, 2018 @03:21AM (#16390769)
> "those solutions have huge performance impact comparing C/Rust on bare-metal"

I didn't suggest Python is the optimal solution for low level coding, I just suggested it is an option.

> "You need "beefy" Cortex-M family to get similar performance that you can get with 8/16-uC with C."

In the case of MicroPython, people find it usable on platforms like the ESP8266, which is less powerful than a "beefy" Cortex-M. As before, I don't deny that there is a performance overhead compared to C, but it clearly has some traction in the embedded space.

Re:Rust 1.24 by laxd on Friday February 16, 2018 @08:27AM (#16392136)
Uh, your examples of low level python are full of C.
Re:Rust 1.24 by ZenoArrow on Friday February 16, 2018 @12:51PM (#16394184)
If you understood what MyHDL is doing, you'd know that doesn't matter.

Furthermore, most Python implementations are built using C, including the canonical one (CPython). It is possible to have performant Python implementations without using C, if that's what you're getting at.

Re:Rust 1.24 by laxd on Friday February 16, 2018 @03:37PM (#16395908)
No I am not simply talking about performance. I see you keep refering to Turing completeness in other replies, even condescendingly implying that your HN peers does not understand it, when you are clearly the one whose understanding needs to mature. A turing complete system is one where the rules are powerfull enough that you are able to implement "anything" INSIDE of them. Does'nt mean you are able to break out the system and manipulate the underlying environment, or even infer anything about how it's implemented. Just to bring my point to the extreme: Minecraft is turing complete. Does'nt mean you can bootstrap your cpu with. You can in theory emulate your cpu on top of it though.

Actually you seem to suggest that not even performance is of any hindrance to python. In which case I'm lost for words. You win.

Re:Rust 1.24 by ZenoArrow on Friday February 16, 2018 @09:11PM (#16398467)
> "Does'nt mean you are able to break out the system and manipulate the underlying environment"

I didn't think I'd have to spell things out so excessively, but... let's extend the description then... Any Turing complete language where you can write files to storage. To give an example of why the storage is relevant, let's look at Java. Java's sandboxed in the JVM right? However, if you think about it more broadly, as long as you can freely write files to disk you can write machine code to disk. In other words, as you can write a compiler in Java, you can break out of the sandbox.

As for Minecraft, I don't know enough about it, but if it's possible to write a compiler in Minecraft then that would have the same escape hatch too. It might not be a tool you choose to code a BIOS, but we're not looking at whether something is optimal, we're looking at whether something is possible.

> "I see you keep refering to Turing completeness in other replies"

> "Actually you seem to suggest that not even performance is of any hindrance to python. In which case I'm lost for words. You win."

Perhaps you overlooked the following quote as it didn't fit with what you decided you wanted to say...

"I didn't suggest Python is the optimal solution for low level coding, I just suggested it is an option."

Re:Rust 1.24 by seanmcdirmid on Thursday February 15, 2018 @05:51PM (#16388498)
Python and Rust exist in very application domains, so I don’t think they are very interchangeable with each other. Now if you are writing C++ code...
Re:Rust 1.24 by smt88 on Thursday February 15, 2018 @03:43PM (#16387442)
What do you use Python for?
Re:Rust 1.24 by todd_wanna_code on Thursday February 15, 2018 @11:16PM (#16389817)
I would say types. I think types have been really a lot of help to me, coming from mostly dynamic languages. It forces you to think about your problem more than just throwing some code together. Another thing I enjoyed is easier concurrency. But apart from that, I feel like its a matter of choosing the right tool for the right task.
Re:Rust 1.24 by dingo_bat on Friday February 16, 2018 @08:19AM (#16392104)
Instead of learning weird new stuff like rust or go, I find that c/c++ and python cover the entire range of problems you will ever need to solve. It takes a lot of time to start being productive in rust/go, and the benefits are vague. Instead I'd rather learn to use C++ and python better.
Re:Rust 1.24 by dthul on Friday February 16, 2018 @09:20AM (#16392463)
Learning weird new stuff can have a positive impact even though you don't end up using it as your workhorse though.

After coding in Rust for several weeks I went back to C++ for my day-to-day work since I'm still more productive with it and the code I produce has no safety/security implications. The knowledge gained in those few weeks of Rust readily translated into C++ skill improvements, even though I already considered myself a solid C++ programmer before. Being forced to think about ownership, borrowing, move semantics, etc. constantly gets you into a mindset that is very helpful also outside of Rust.

Re:Rust 1.24 by e12e on Friday February 16, 2018 @12:52PM (#16394194)
Re:Rust 1.24 by fafhrd91 on Thursday February 15, 2018 @08:14PM (#16389191)
you can always try rust in parallel with python code with libraries like pyo3