User avatar
PeterO
Posts: 5974
Joined: Sun Jul 22, 2012 4:14 pm

Anyone using Rust on a PI ?

Mon Feb 18, 2019 11:46 am

Is anyone here using Rust on their PIs ?

If so, are there any "gotchas" to lookout for ?

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

jacko.jackonelli
Posts: 2
Joined: Mon Feb 25, 2019 11:55 am

Re: Anyone using Rust on a PI ?

Mon Feb 25, 2019 12:01 pm

I am! Or rather, I am just starting.

My goal is to build a control software for my beer brewery. The plan is to setup a minimal webapp using Rocket (https://rocket.rs/) for monitoring the brewing process.

With cargo support for ARM cross compilation works like a charm, the only difference from developing on an ordinary computer is the hardware communication, which for me is quite simple. I only need basic GPIO, PWM and one-wire.

My two main concerns is if this char dev (https://docs.rs/gpio-cdev/0.1.0/gpio_cdev/) library is mature enough , it seems quasi-official (written by a rustembedded guy but is somewhat inactive). The other is to solve the one-wire interface.

What about you?

Jacko

User avatar
PeterO
Posts: 5974
Joined: Sun Jul 22, 2012 4:14 pm

Re: Anyone using Rust on a PI ?

Mon Feb 25, 2019 1:31 pm

Sadly their Gtk+ bindings are really rather incomplete so I'm rapidly loosing interest :-(

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

jacko.jackonelli
Posts: 2
Joined: Mon Feb 25, 2019 11:55 am

Re: Anyone using Rust on a PI ?

Mon Feb 25, 2019 2:11 pm

Well, I always use the pi headless so I wouldn't know about any graphics.

User avatar
paddyg
Posts: 2591
Joined: Sat Jan 28, 2012 11:57 am
Location: UK

Re: Anyone using Rust on a PI ?

Tue Mar 05, 2019 8:59 am

Rust is hard to start with but it's worth sticking it out (imo). To make myself fight my way through it I started the process of converting the pi3d python module to Rust. see here https://github.com/paddywwoof/rust_pi3d

I also did a test compiling an image processing thing for python access here https://github.com/paddywwoof/atkinson which compares cython, C, C in python module structure and rust.

I think the pure rust GUI side is still in a bit of limbo with at least three different different projects. But there are Qt and gtk wrappers. And SDL2 seems to work fine.

Paddy
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

User avatar
PeterO
Posts: 5974
Joined: Sun Jul 22, 2012 4:14 pm

Re: Anyone using Rust on a PI ?

Tue Mar 05, 2019 9:40 am

What worried me was the Gtk+ examples seemed to be in a state of flux, with recent changes on git including changes like this.

Code: Select all

        window.connect_delete_event(clone!(window => move |_, _| {
            window.destroy();
changing to

Code: Select all

        window.connect_delete_event(move |win, _| {
            win.destroy();
            Inhibit(false)
This makes it seem like event the authours haven't made up their minds how things are supposed to work.


I have to say that to me the rust syntax is impenetrable. Far too much "Not invented here" and ignoring of well established conventions. While it might be fine once you understand it, to the beginner it is just randomly jumbled up symbols.

And it annoys me that their central argument for the language is that programmers are incapable of writing correct code in any other language !

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

User avatar
jahboater
Posts: 6306
Joined: Wed Feb 04, 2015 6:38 pm
Location: Wonderful West Dorset

Re: Anyone using Rust on a PI ?

Tue Mar 05, 2019 10:07 am

Having spent time restoring old cars, the name does not appeal!

There is no ISO standard for Rust yet, so things may randomly change - it is a young language.
PeterO wrote:
Tue Mar 05, 2019 9:40 am
And it annoys me that their central argument for the language is that programmers are incapable of writing correct code in any other language!
That's quite common sadly, despite obvious evidence to the contrary.
Or it is "as fast as C", which it never is.

There is now a good choice of interesting new languages to investigate:

For a start .... D, go, swift, Fortran 2018
even C++17 but that's pretty impenetrable too!

See also
https://www.tiobe.com/tiobe-index/

User avatar
Gavinmc42
Posts: 4863
Joined: Wed Aug 28, 2013 3:31 am

Re: Anyone using Rust on a PI ?

Tue Mar 05, 2019 10:48 am

I found it easy to get on Raspbian and that was years ago?

Been tinkering with it, but I have done no projects in Rust.
I love how fast it compiles compared to that C/C++ GCC stuff ;)
Go, Rust and Pony are the top need to learn languages on my list, D recently got added.

I prefer any of these over C++ :lol:
These all work in Gentoo64 which is my main Pi dev OS for these languages.
Sakaki has newer versions on Gentoo64 than those on current Raspbian.

Firefox is Rust, Neddy Seagoon wrote up that saga for Gentoo64 on the Gentoo pages.
I would call that a pretty serious project.

There is also a baremetal version somewhere.
https://github.com/rust-embedded/rust-r ... -tutorials
Is it currently just a one man band effort?
Rust embedded works for smaller Arm's so should work on the single core Pi's.

I am hoping that Redox makes it to Pi perhaps this year?

Accelerated graphics in baremetal has been done by a few people now so that could be made Rusty.
So far I have found OpenVG relatively easy but how far it can be pushed I have no idea yet.
Simple OpenVG GUI OS yep, full on Windowing OS outside my skill set, ditto for 3D.
AJ Starks is the place to go for OpenVG, he has done it in Go, Rust is a similar level.

Due to where Rust is coming from I expect most support will be more relatable to the 64bit 3B's.
Rust can talk to C libs so those can be used for GPIO stuff?
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

Heater
Posts: 16870
Joined: Tue Jul 17, 2012 3:02 pm

Re: Anyone using Rust on a PI ?

Wed Mar 06, 2019 6:04 am

Gavinmc42,

Wow, how old do you have to be to remember Neddy Seagoon?
https://en.wikipedia.org/wiki/Neddie_Seagoon

Who fittingly gave us "The Raspberry Song" in 1978:
https://www.youtube.com/watch?v=b_As2ao3Ga8

@PeterO,
And it annoys me that their central argument for the language is that programmers are incapable of writing correct code in any other language !
Sadly, history shows us that is true.

Mind you, that statement does not exclude the possibility that programmers cannot write correct code in Rust either!
Memory in C++ is a leaky abstraction .

User avatar
Gavinmc42
Posts: 4863
Joined: Wed Aug 28, 2013 3:31 am

Re: Anyone using Rust on a PI ?

Wed Mar 06, 2019 7:49 am

Wow, how old do you have to be to remember Neddy Seagoon?
My age.

Saw an interview with two of the Monty Python guys, they talked about their influences.
Can remember those old radio, black and white TV shows.
The Goon show, Cook and Moore etc, then Monty Python came along and TV got very weird.
How old do you need to be, to know that Python the computer langauge was named after Monty Python?

My programming is a bit Rusty along with my memory? :lol:
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

Lokathor
Posts: 3
Joined: Wed Mar 06, 2019 8:38 am

Re: Anyone using Rust on a PI ?

Wed Mar 06, 2019 8:42 am

jahboater wrote:
Tue Mar 05, 2019 10:07 am
There is no ISO standard for Rust yet, so things may randomly change - it is a young language.
This is not what I would characterize as accurate.

Rust comes in two main flavors: Stable and Nightly. If you stick to Stable then your code today (rustc-1.33.0) can generally be expected to work very far into the future. They take stability extremely seriously.

User avatar
PeterO
Posts: 5974
Joined: Sun Jul 22, 2012 4:14 pm

Re: Anyone using Rust on a PI ?

Wed Mar 06, 2019 8:55 am

Gavinmc42 wrote:
Tue Mar 05, 2019 10:48 am
I found it easy to get on Raspbian and that was years ago?

Been tinkering with it, but I have done no projects in Rust.
I love how fast it compiles compared to that C/C++ GCC stuff ;)
Go, Rust and Pony are the top need to learn languages on my list, D recently got added.

I prefer any of these over C++ :lol:
These all work in Gentoo64 which is my main Pi dev OS for these languages.
Sakaki has newer versions on Gentoo64 than those on current Raspbian.

Firefox is Rust, Neddy Seagoon wrote up that saga for Gentoo64 on the Gentoo pages.
I would call that a pretty serious project.

There is also a baremetal version somewhere.
https://github.com/rust-embedded/rust-r ... -tutorials
Is it currently just a one man band effort?
Rust embedded works for smaller Arm's so should work on the single core Pi's.

I am hoping that Redox makes it to Pi perhaps this year?

Accelerated graphics in baremetal has been done by a few people now so that could be made Rusty.
So far I have found OpenVG relatively easy but how far it can be pushed I have no idea yet.
Simple OpenVG GUI OS yep, full on Windowing OS outside my skill set, ditto for 3D.
AJ Starks is the place to go for OpenVG, he has done it in Go, Rust is a similar level.

Due to where Rust is coming from I expect most support will be more relatable to the 64bit 3B's.
Rust can talk to C libs so those can be used for GPIO stuff?
And the point of this ramble is ?

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

User avatar
PeterO
Posts: 5974
Joined: Sun Jul 22, 2012 4:14 pm

Re: Anyone using Rust on a PI ?

Wed Mar 06, 2019 8:58 am

Gavinmc42 wrote:
Tue Mar 05, 2019 10:48 am
I love how fast it compiles compared to that C/C++ GCC stuff ;)
I miss the old days when typing "make" would always give you time to make a fresh mug of tea !

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

User avatar
Gavinmc42
Posts: 4863
Joined: Wed Aug 28, 2013 3:31 am

Re: Anyone using Rust on a PI ?

Wed Mar 06, 2019 10:34 am

I miss the old days when typing "make" would always give you time to make a fresh mug of tea !
Plus lunch and a short nap, before that it was start compiling then go home and hope it was ok in the morning.
Now with Rust and these speedy Pi's I might get one sip of coffee, if I have my hand on the handle..

That's why I need stronger typed languages.
We coded better C back then because it was so painful and gave us time to think of what could go wrong.
So when it did go wrong we already had a good idea of how to fix it.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

Heater
Posts: 16870
Joined: Tue Jul 17, 2012 3:02 pm

Re: Anyone using Rust on a PI ?

Thu Mar 07, 2019 8:21 am

So what you are saying is that to improve software quality we can forget about strict type checking, static analysis, formal methods, testing and all that, what we need much slower compilers.

At least with slower build systems programmers will create less bugs per day!
Memory in C++ is a leaky abstraction .

User avatar
paddyg
Posts: 2591
Joined: Sat Jan 28, 2012 11:57 am
Location: UK

Re: Anyone using Rust on a PI ?

Thu Mar 07, 2019 9:01 am

For further clarification (of the "drinking more tea produces better code" variety), despite @gavin's assertion, I found rust build times universally longer than gcc... but not long enough to put the kettle on.
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

User avatar
jahboater
Posts: 6306
Joined: Wed Feb 04, 2015 6:38 pm
Location: Wonderful West Dorset

Re: Anyone using Rust on a PI ?

Thu Mar 07, 2019 9:26 am

Heater wrote:
Thu Mar 07, 2019 8:21 am
At least with slower build systems programmers will create less bugs per day!
More thinking time between builds.

Just use C++ instead of C for long compile times!

User avatar
PeterO
Posts: 5974
Joined: Sun Jul 22, 2012 4:14 pm

Re: Anyone using Rust on a PI ?

Thu Mar 07, 2019 9:40 am

Gavinmc42 wrote:
Wed Mar 06, 2019 10:34 am
We coded better C back then because it was so painful and gave us time to think of what could go wrong.
So when it did go wrong we already had a good idea of how to fix it.
Some time ago I made a comment in a lecture I was giving on old computer emulation and a member of the audience stopped me and said...

"There are some of us in the audience who were glad to get one compiler run a day!"

That puts it all into perspective !

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

User avatar
Gavinmc42
Posts: 4863
Joined: Wed Aug 28, 2013 3:31 am

Re: Anyone using Rust on a PI ?

Thu Mar 07, 2019 10:46 am

I found rust build times universally longer than gcc... but not long enough to put the kettle on.
Second coffee gets made while Windows boots.

I have not done enough Rusting but building C compilers overnight has happened a few times.
I found it a good way to destroy expensive SD cards.
strict type checking, static analysis, formal methods, testing and all that,
Sounds horrible, why would I do all that?

I am a recent convert to stronger typed languages and object programming.
Most of my object programming is just hacking someone's example code into something else.
But as Steve Ciarcia once said " I program with a soldering iron" I too am mostly a hardware guy.

Julia just made it to my list of languages to learn, compiled stats stuff.
But R and Octave, Wolfram etc do similar stuff.
I tend to prefer newer languages just on Basic principle, newer is better ;)

If I can learn enough perhaps I will make my own language one day.
If an OS can be made in Rust that's good enough to learn it, my own OS is on that very long list too.
Sort of Sudoku for an old tech guy's brain.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

Heater
Posts: 16870
Joined: Tue Jul 17, 2012 3:02 pm

Re: Anyone using Rust on a PI ?

Fri Mar 08, 2019 6:57 am

Gavinmc42,
Sounds horrible, why would I do all that?
Good question. You might actually like it...

Your suggestion was that we created better code when compile times were longer as we had more time to think.

Well, the other way to achieve the same effect is: Don't compile the code!

On various safety critical projects I have worked on it could take a week to get one character in one line of code changed to fix some bug or other.

Here is how it goes:

1) Edit the code changing the single character.

3) Check code in and raise a change request.

2) Get two other engineers to review the change and sign off on it.

3) A test engineer creates or modifies a unit test for the change.

4) He get's two other test engineers to review and sign off on the change to the test.

5) Another test engineer runs the test against your new code.

6) At least he and another will check the test results and sign off on it.

7) As 2) to 6) above but for integration tests.

8) Documentation may need updating as well. Design spec, detail design spec, test procedure etc. Which will need review and sign off of course.

9) At some point take a look to see all the above has happened. Although there will be a quality control leader who should have signed off that all of the above procedure happened correctly.

There we have it, one week and 10 engineers to make a one character change. Best part is you never actually had to compile anything, the other guys did all that.
Memory in C++ is a leaky abstraction .

User avatar
Gavinmc42
Posts: 4863
Joined: Wed Aug 28, 2013 3:31 am

Re: Anyone using Rust on a PI ?

Fri Mar 08, 2019 8:50 am

Well, the other way to achieve the same effect is: Don't compile the code!
I agree, shell script does not need compiling.
I found bash, awk, sed all work fine even editing while still running and from 100km away.
Micropython also seems ok.
Probably even a good justification to use Basic? :lol:

Your solution does require 10 engineers, I'm just one code hacker in a basement.
Tell the boss I need another 9 guys? Yep told him we need 25, but I'm still it.

Even single core 1GHz cpu's can do a lot with just scripting.
Is there a Rust interpreter?
What is the fastest script language that runs on Pi's, V8? NodeJS?

Hmm, would a scripting/interpreted language be best for IoT?
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

Heater
Posts: 16870
Joined: Tue Jul 17, 2012 3:02 pm

Re: Anyone using Rust on a PI ?

Fri Mar 08, 2019 1:27 pm

I thought the idea was to slow things down and make time for thinking...and coffee.

Shells and interpreted languages are far to quick and interactive. They keep you busy all the time. That's no good.
...would a scripting/interpreted language be best for IoT?
Plenty of people are building IoT gizmos with interpreted languages:

MicroPython: https://store.micropython.org

Javascript: https://www.espruino.com/

Lua: https://www.nodemcu.com/index_en.html

Are they best? Depends what you want.

Such languages are slow so if you need serious processing in your device then no.

Being interpreted they take more energy to get the job done. If you need a really frugal battery powered IoT device, as is common, then no.

They require quite a bit of RAM/ROM so that adds to size, cost, power consumption.
Memory in C++ is a leaky abstraction .

User avatar
Gavinmc42
Posts: 4863
Joined: Wed Aug 28, 2013 3:31 am

Re: Anyone using Rust on a PI ?

Sat Mar 09, 2019 2:11 am

I did my first Mesh network in 2011, it used Python scripting, low power RF, worked fine, still is. ;)
It was not quick to do, far to much time was spent on learning the tools.
What took 6 months of messing about with coding can probably be done in a week now with latest Arduino stuff.

Got some Adafruit LoRa Feather's after installing the IDE and library test code was done in an hour.
500m range verses 10m range, progress, but Boss is worried, last time took too long so progress is stopped by past perceptions.

For me it is not the languages but the tools and libraries, whatever works fastest is best?
For the boss whatever worked before is the best.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

Heater
Posts: 16870
Joined: Tue Jul 17, 2012 3:02 pm

Re: Anyone using Rust on a PI ?

Sat Mar 09, 2019 7:01 am

Gavinmc42,
Got some Adafruit LoRa Feather's ... 500m range verses 10m range.
Something is wrong with that statement. LoRa is designed for ranges in the 10's of kilometers. Or are you working it at some abnormally high speed?

If you have a LoRa + Raspi project going on it would be great to hear about it.
Memory in C++ is a leaky abstraction .

User avatar
Gavinmc42
Posts: 4863
Joined: Wed Aug 28, 2013 3:31 am

Re: Anyone using Rust on a PI ?

Sat Mar 09, 2019 8:00 am

Something is wrong with that statement. LoRa is designed for ranges in the 10's of kilometers.
Even 900MHz has trouble bending over hills, it was testing done in a forest.
I was impressed, it also went through 4 reinforced concrete walls.
Base station on my desk inside and RSSI on Oled display on USB bank powered feather, kept walking until lost signal.
I was quite happy it was not 10km line of sight :lol:

Got as far as Zero size LoRa Hat prototype PCBs, then got side tracked with BLE 5.0.
But LoRa controlled bots is still on my list, waiting for the LoRa satellite networks to be finished
Then I can have solar power rovers in the outback and the oceans ;)
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

Return to “Other programming languages”