How much effort will it be to learn to deploy #rust on my #arduino vs learning enough C to get by?
-
Riley S. Faelanreplied to Yeshaya Lazarevich last edited by
@alter_kaker It basically depends on how much of any C-like programming languages you already know. Rust's main point of complexity is that it does certain things significantly differently from the traditional way, the way most imperative programming languages do them. If you already know the tradition, this difference might get in your way; if you're learning from scratch to begin with, it probably won't. (And there's people who would argue that it's better to learn to think using the Rust's ways first, on the basis of it contributing to your code having less bugs in it in the future.)
-
@alter_kaker Oh, and just in case: the programming language that the Arduino company has been popularising the most is actually C++, not C. C toolchain for the AVR8 chips exists, and is reasonably widely used, it's just not quite as popular among the (fresh) hobbyist crowd, and has a bit of an association with professional embedded system development folks instead.
The difference might not matter for what you're planning to do, I'm only mentioning it just in case.
-
Yeshaya Lazarevichreplied to Riley S. Faelan last edited by
@riley
Well I work in Java professionally, and I can do a lot in Rust already. But I'm consistently stumped in c/c++ -
Riley S. Faelanreplied to Yeshaya Lazarevich last edited by
@alter_kaker Then, feel free to start from Rust, and skip the C(++) entirely. I believe these days there's ready Rust toolchains that you can get, and once the compilation is done,
avrdude
won't care what language it was originally written in.If you like the Arduino IDE, check if it supports Rust for AVR8 as a downloadable extension. It has been adding a number of new languages and toolchains in the couple of recent years, as a whole bunch of new SBCs becam popular, and if somebody has prepackaged AVR8 Rust for it, it might make getting it set that much easier for you.
-
Yeshaya Lazarevichreplied to Riley S. Faelan last edited by
@riley
I prefer vscode. There's something called avr-hal that I'm trying to get to work. Running into configuration issues, we'll see how it goes -
Riley S. Faelanreplied to Yeshaya Lazarevich last edited by
@alter_kaker I have only used vscode for C#, so I don't have useful experience to share, I'm afraid.
-
Yeshaya Lazarevichreplied to Riley S. Faelan last edited by
-
Riley S. Faelanreplied to Yeshaya Lazarevich last edited by
@alter_kaker Happy hacking!
-
Yeshaya Lazarevichreplied to Riley S. Faelan last edited by
@riley
Status update: I'm back to C++ because I was having issues with the Rust SPI and SD Card libraries...I've been avoiding learning C++ since about 2000CE...
-
Riley S. Faelanreplied to Yeshaya Lazarevich last edited by
@alter_kaker I have done some work with C++. If you have any questions, I might be able to answer or suggest useful googlewords.
Also, what kind of issues were these? Perhaps these could be fixed, as well.
-
Yeshaya Lazarevichreplied to Yeshaya Lazarevich last edited by
@riley
Right now I'm running into very irritating problems. I got my program to work in procedural code, and I tried to convert a small part to OO. Now it's compiling, but always crashes or hangs, each time at a different point in the program. I don't really know how to debug something like this. -
Yeshaya Lazarevichreplied to Riley S. Faelan last edited by
@riley
It was failing to read the SD card despite the fact that the hardware was correctly connected, and the configuration was the same as what I used in the regular Arduino.I could raise some tickets and I still might, but it's kind of a hassle.
-
Yeshaya Lazarevichreplied to Yeshaya Lazarevich last edited by
@riley
@project1enigma it never ends -
@alter_kaker @riley Break down the changes to very small ones. a) plain C code but compiled in C++ mode (this might already be a relevant change). b) the other steps. Really break them down. Then git bisect them.
-
@project1enigma
Hmm. Yeah, this already works in c-like c++ code. I'll try to make the changes smaller. Thank you. I hope it'll be worth it
@riley -
@alter_kaker @riley Small iterations is always my fave. At least where there are fast enough turnarounds. Behatzlacha!
-
@project1enigma
Yes. I made a small change but I reduced it even further. Instead of writing and reading from two byte arrays, I encapsulated them in a Buffer class. Total less than 50 lines... Still crashes right at the beginning. Would you be willing to look if anything jumps out at you? This is my very first C++ class... -
@alter_kaker @riley Where do buf_a/buf_b point to?
-
@project1enigma
haha I just fixed it, they were not pointing to anywhere... Updated to initialize in the header file as arrays. @riley -
@alter_kaker @riley That's probably what you need, arrays.