I think any modern compiler should do that by the way. In my code, rustc converted / 2 to "asr r6, r0, #1" successfully.
Re: Rust seems to bring some love to Rpi
Yes, not sure why. It's a small but real difference (0.950s c.f. 0.925s) I've not looked at the internals of the generated code.
Doing a basic prime calculation like the subject of this discussion, I get
laptop (to 100,000)
2.35s +/-0.06 C
2.31s +/-0.01 rust
RPi3 (to 50,000)
8.01s +/-0.07 C
11.4s +/-0.10 rust
So 50% slower rather than 10x slower.
Doing a basic prime calculation like the subject of this discussion, I get
laptop (to 100,000)
2.35s +/-0.06 C
2.31s +/-0.01 rust
RPi3 (to 50,000)
8.01s +/-0.07 C
11.4s +/-0.10 rust
So 50% slower rather than 10x slower.
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d
Re: Rust seems to bring some love to Rpi
Rustc uses LLVM (as Clang does) which is quite respectable, and should produce fast code.
I would certainly expect it to be in the same ball park as C.
The silly program I used did "if( n % d == 0 )" in a tight inner loop .....
the ARMv6 code produced by rustc/LLVM was:
bl __aeabi_idivmod
The much faster ARMv8 code produced by GCC was:
sdiv r1, r4, r3
mls r1, r3, r1, r4
which explains the 10x performance difference (never use trivial artificial benchmarks!)
I would certainly expect it to be in the same ball park as C.
The silly program I used did "if( n % d == 0 )" in a tight inner loop .....
the ARMv6 code produced by rustc/LLVM was:
bl __aeabi_idivmod
The much faster ARMv8 code produced by GCC was:
sdiv r1, r4, r3
mls r1, r3, r1, r4
which explains the 10x performance difference (never use trivial artificial benchmarks!)
Re: Rust seems to bring some love to Rpi
paddyg,
I do find the Rust code of conduct distasteful. Basically it says that if you ever express an opinion that someone finds "uncomfortable" then you should apologize and/or be ostracized.
Well, how could I ever use Rust? Perhaps I might want to file a bug report? It would be impossible to know if I had overstepped someones comfort zone? My disdain of Political Correctness might be detected almost immediately.
This is the kind of thinking that deposed Brendan Eich, the inventor of Javascript, from his position at a company he helped build. Simply for having a political view that others disagreed with. http://www.bbc.com/news/technology-26868536
It's the kind of thinking that got Douglas Crockford uninvited from giving a key note speech at a conference because his use of words like "promiscuous" in a technical sense made somebody feel uncomfortable. http://atom-morgan.github.io/in-defense ... -crockford
It's the kind of thinking that got James Damore fired from Google this summer: https://www.washingtonpost.com/news/mor ... 6fed795710
As a language Rust might be fine.
I find it a bit dishonest for rust-lang.org to describe Rust as a "systems programming language". As far as I can tell Rust cannot compile itself yet. You cannot build a Rust compiler using a Rust compiler. It depends on LLVM. That is to say C++.
Maybe one day.
I don't particularly have a desire to use Rust or any other programming language for "devilish antisocial purposes". Neither do I want to be unfriendly to anyone on reddit or anywhere else.Sounds like an expanded version of the Raspberry Pi forum rules "Be good to each other"... But it doesn't say you can't use rust for whatever devilish antisocial purpose you had in mind, just abide by the rules if you contribute to IRC channels, github or official rust.org forum. So you could use rust and be as unfriendly as you want on reddit (so long as you don't harass people).
I do find the Rust code of conduct distasteful. Basically it says that if you ever express an opinion that someone finds "uncomfortable" then you should apologize and/or be ostracized.
Well, how could I ever use Rust? Perhaps I might want to file a bug report? It would be impossible to know if I had overstepped someones comfort zone? My disdain of Political Correctness might be detected almost immediately.
This is the kind of thinking that deposed Brendan Eich, the inventor of Javascript, from his position at a company he helped build. Simply for having a political view that others disagreed with. http://www.bbc.com/news/technology-26868536
It's the kind of thinking that got Douglas Crockford uninvited from giving a key note speech at a conference because his use of words like "promiscuous" in a technical sense made somebody feel uncomfortable. http://atom-morgan.github.io/in-defense ... -crockford
It's the kind of thinking that got James Damore fired from Google this summer: https://www.washingtonpost.com/news/mor ... 6fed795710
As a language Rust might be fine.
I find it a bit dishonest for rust-lang.org to describe Rust as a "systems programming language". As far as I can tell Rust cannot compile itself yet. You cannot build a Rust compiler using a Rust compiler. It depends on LLVM. That is to say C++.
Maybe one day.
Memory in C++ is a leaky abstraction .
Re: Rust seems to bring some love to Rpi
Rust compiles itself since 2011.Heater wrote: ↑Tue Nov 21, 2017 6:33 pmI find it a bit dishonest for rust-lang.org to describe Rust as a "systems programming language". As far as I can tell Rust cannot compile itself yet. You cannot build a Rust compiler using a Rust compiler. It depends on LLVM. That is to say C++.
Maybe one day.
The same year, work shifted from the initial compiler (written in OCaml) to the self-hosting compiler written in Rust.[30] Known as rustc, it successfully compiled itself in 2011.
Re: Rust seems to bring some love to Rpi
That's not quite true now is it mifwoo.
Yes Rust compiles itself but it generates an intermediate representation of the code, LLVM IR.
One then needs LLVM to optimize and generate code from that intermediate representation. LLVM is written in C++.
So, if you want to build a complete Rust tool chain from scratch you need a working Rust compiler and a working C++ compiler.
https://www.quora.com/Is-Rust-a-self-hosted-language
Yes Rust compiles itself but it generates an intermediate representation of the code, LLVM IR.
One then needs LLVM to optimize and generate code from that intermediate representation. LLVM is written in C++.
So, if you want to build a complete Rust tool chain from scratch you need a working Rust compiler and a working C++ compiler.
https://www.quora.com/Is-Rust-a-self-hosted-language
Memory in C++ is a leaky abstraction .
Re: Rust seems to bring some love to Rpi
I think Rust being a systems programming language refers to the feature set which allows writing low-level code such as device drivers and memory managers which interact directly with the hardware.Heater wrote: ↑Sun Nov 26, 2017 3:07 pmThat's not quite true now is it mifwoo.
Yes Rust compiles itself but it generates an intermediate representation of the code, LLVM IR.
One then needs LLVM to optimize and generate code from that intermediate representation. LLVM is written in C++.
So, if you want to build a complete Rust tool chain from scratch you need a working Rust compiler and a working C++ compiler.
https://www.quora.com/Is-Rust-a-self-hosted-language
If you want a self-hosting system based on Rust, which is a different thing in my opinion, the easiest way might be to first write a C compiler in Rust. Use the Rust-built C compiler to compile a C++ compiler, then use the C++ compiler to compile LLVM.
Re: Rust seems to bring some love to Rpi
ejolson,
There is even an entire operating system written in Rust to prove the point: https://github.com/redox-os/redox
Although, as far as I can tell, Redox does not run on bare hardware yet.
Somebody did suggest recreating LLVM in Rust. That would do it. I don't think anyone is ever going to do that. But who knows? There are crazy people out there!
That is the way I read it as well.I think Rust being a systems programming language refers to the feature set which allows writing low-level code such as device drivers and memory managers which interact directly with the hardware.
There is even an entire operating system written in Rust to prove the point: https://github.com/redox-os/redox
Although, as far as I can tell, Redox does not run on bare hardware yet.
I think that was my point. As it stands you cannot build a Rust only self hosting system, on Redox for example. You would have to get a C++ compiler running on Redox first.If you want a self-hosting system based on Rust, which is a different thing in my opinion, ...
That all sounds far to tortuous.the easiest way might be to first write a C compiler in Rust. Use the Rust-built C compiler to compile a C++ compiler, then use the C++ compiler to compile LLVM.
Somebody did suggest recreating LLVM in Rust. That would do it. I don't think anyone is ever going to do that. But who knows? There are crazy people out there!
Memory in C++ is a leaky abstraction .
Re: Rust seems to bring some love to Rpi
The arguments for rust are that it's 'easier' to write 'safe' code. The problem is that if the switch is from old C and C++ utilities, not only is the switch from code that's already been written (so requires zero effort to write) and has a large pool of potential maintainers, but it's been very extensively tested in the real world. As you say it seems an extravagant task - but it would be very good training so maybe it will happen eventually.
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d
Re: Rust seems to bring some love to Rpi
I think, the best bet is that Rust or whatever new language the youngn's come up with next can make use of all the existing infrastructure. That is interface and link with C easily. I have no idea if Rust can do that but I presume so.
On the other hand, this last week I have found that openssl in Debian Linux, hence Raspbian, suffers from memory leaks and race conditions. Our whole foundations are rotten.
On the other hand, this last week I have found that openssl in Debian Linux, hence Raspbian, suffers from memory leaks and race conditions. Our whole foundations are rotten.
Memory in C++ is a leaky abstraction .
Re: Rust seems to bring some love to Rpi
Yes, Rust has a decent FFI so you can call C code from Rust and vice versa without too much hassle. It's quite a nice language.
She who travels light — forgot something.
Please note that my name doesn't start with the @ character so can people please stop writing it as if it does!
Please note that my name doesn't start with the @ character so can people please stop writing it as if it does!
Re: Rust seems to bring some love to Rpi
What lib does Redox use re openssh/ssl?
https://www.redox-os.org/
I am hanging out waiting to try Redox on a Pi3 in Aarch64.
I was impressed on how easy it was to get Rustc working on a Pi and the language itself is too not bad.
Probably one of the nicer ones of this new gen.
And the Servo browser has some nice tricks.
Throw everything out and run Redox on RISCV?
Redox on Pi3 with simple Servo browser, I can see myself using it.
Might have to try it on a x86 box first, yuk.
https://www.redox-os.org/
I am hanging out waiting to try Redox on a Pi3 in Aarch64.
I was impressed on how easy it was to get Rustc working on a Pi and the language itself is too not bad.
Probably one of the nicer ones of this new gen.
And the Servo browser has some nice tricks.
Throw everything out and run Redox on RISCV?
Redox on Pi3 with simple Servo browser, I can see myself using it.
Might have to try it on a x86 box first, yuk.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges
Raspberries are not Apples or Oranges
Re: Rust seems to bring some love to Rpi
Looking at the Redox cookbook we see they have a lot of recipes for making use of C libraries and programs in Redox. Like this one for openssh: https://github.com/redox-os/cookbook/pu ... 0a75884b85
Openssl for rust is here: https://github.com/sfackler/rust-openssl Which we see depends on openssl in C, OpenSSL version 1.0.1 or above, or LibreSSL.
Openssl for rust is here: https://github.com/sfackler/rust-openssl Which we see depends on openssl in C, OpenSSL version 1.0.1 or above, or LibreSSL.
Memory in C++ is a leaky abstraction .
Re: Rust seems to bring some love to Rpi
IoT not going to take off until we get secure comms.
Reusing old code with who knows what inside?
Reusing old code with who knows what inside?
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges
Raspberries are not Apples or Oranges
Re: Rust seems to bring some love to Rpi
We have secure comms, the IoT suppliers just need to use it....and some of course do.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.
Re: Rust seems to bring some love to Rpi
Gavinmc42,
https://github.com/openssl/openssl
Arguably it's better to fix what we have if need be rather than create a whole new version with a whole lot of new issues of it's own.
I was subjecting my C++ to analysis with the memory leak and thread analyzers that come the clang/llvm C++ compiler. I found a couple of memory leaks and thread race conditions in openssl. So far I'm not sure if these issues are down to openssl itself or the way it is used by the pqxx postgress database connector I'm using. We shall see.
Then again secure comms as provided by openssl is not the end of the story. An awful lot of systems get broken for many other reasons than the crypto library they are using. This security thing is hard.
We know exactly what's inside openssl. Here it is:Reusing old code with who knows what inside?
https://github.com/openssl/openssl
Arguably it's better to fix what we have if need be rather than create a whole new version with a whole lot of new issues of it's own.
I was subjecting my C++ to analysis with the memory leak and thread analyzers that come the clang/llvm C++ compiler. I found a couple of memory leaks and thread race conditions in openssl. So far I'm not sure if these issues are down to openssl itself or the way it is used by the pqxx postgress database connector I'm using. We shall see.
Then again secure comms as provided by openssl is not the end of the story. An awful lot of systems get broken for many other reasons than the crypto library they are using. This security thing is hard.
Memory in C++ is a leaky abstraction .