Hello,
first things first. My name is Saša (this is a male name, i'm from Europe) and this is my first post in this forum. I'm pretty new to Rust. I've been casually playing around with Rust for roughly about a year.
A little bit of background where i'm coming from (technically). I'm a software developer (went to university for CS education)working on embedded and systems software (embedded as in 8051 and ARM; systems as in networking and drivers). I'm looking back at about seventeen years of experience. As for programming languages, i've used quite some, to name a few:
C, C++, Basic, Python, Objective-C, Perl, Go, C#, Assembly. I've been playing around with OCaml, Haskell and Ada as well.
So before asking my question, i would like to name the things i understand and like about Rust:
- Lifetimes
- The borrow checker
- Cargo
I was actually surprised about how fast i got past "fighting the borrow checker", but with my background, this might be normal.
Now on to the point of this (already too long) post (thanks for reading this far ).
What i'm going to write now is going to be a bit of tongue in cheek and is just my way of expressing my own incompetence of understanding Rust completely.
So, my question would be: How can i learn to think types?
To be clear, i know the difference between dynamic and static typing, strong and weak or no typing. This is not the problem.
I will make up an example (probably a bad one, but i want to keep it simple and get my point across). Let's say i have to write a function adding to numbers, let's say in a range from one to ten. As i'm mostly a C guy, i would say "Well, uint8_t sounds good. At the end of the day it's just two numbers between one and ten.".
Let's now assume i'm looking for a Rust lib that does just that (adding these numbers). As there is only one (for the sake of the argument ), i download it and look at it, but have no clue what is going on.
Why? Well, because it seems most Rust users seem to be way better at abstracting things than me.
What does that mean? Well instead of using a type that says something along the lines of "positive number from 0 to 255",
the developer created a type for the numbers along the lines of
"<n-dimensional_Bojackle_Sphere_from_outer_space>::casual_fridays(maybe?)". And when i try to use the function (of course not correctly) the compiler tells me
" error: cannot find DeLorean::Flux_Capacitor::strange_glowing_thinggy in this scope
--> src/main.rs:15:19
As i said, i'm pretty much a C programmer. I think in data structures and keep the types a simple as possible. By the way, the same problems occur every time i have to use boost. The effect of all this is that i like Rust on a technical level, but can not imagine using it in a commercial setting because i cannot build a mental model of code (i.e. the flow and state).
Which, of course, is a shame because it's not Rust's fault, but mine.
So if this unstructured wall of text made any sense for you, and if you have an idea how i could learn to think in types instead of data structures, i would appreciate your help.
I will not be able to respond to answers for the next hours, so please do not think i'm a troll.
So thanks to everyone and see you later.
Saša