I'm not afraid of programming in general, being a data analyst by trade I often use Python and SQL in my day job. I've trained on Java, and C# (though admittedly with some difficulty) and had dabbled in Delphi (Object Pascal) and Visual Basic as a little girl so the concept of programming isn't new to me. Perhaps the 'low-level-nes' of Rust, a language I would love to learn, is new to me which is perhaps one of the reasons I'm having some trouble understanding it.
I'm struggling with heavy implementations of symbols, and perhaps 'shorthand' reserved keywords in languages like Rust, C++ and to some extent JavaScript; I find they aren't as readable as 'higher level' languages like Python.
Given that Rust is one of the newer languages on the block, Python is 21 years it's senior, was the syntax of Rust determined by performance factors or because of it's 'low-level-ness'? Are languages like Python and SQL more legible because they're interpreted and compiled into bytecode, rather than just compiled into specific machine code? Or is it purely a decision of the language's developer?
This question is focused on Rust specifically, given that's a newer language, perhaps wondering why it didn't adopt some of the design principles of easier to read languages, though I am certainly not singling it out. Are there ADHD friendly tutorials/books on Rust?
And personal preference here, Rust is, with a few exceptions, actually one of the nicer languages to read once you add/remove all the extra information that rust requires.
When your read a program it puts cognitive load on your brain. How much is a bit depended on your education and experience on the subject, but what you have to do is to transfer what you are reading to your mental model what the program is actually doing. Your capacity of things you can process in your brain is limited so you can fairly assume that the more load is put on your brain the more of that capacity is used, and the nearer your are to your maximum capacity the more difficult and exhausting is the task to understand the program.
When you need to decode a "{" or a "@" in the program to a actual processing step. you can assume that
if (a) {
b;
}
else {
c;
}
is more difficult to decode compared to IF a
THEN b
ELSE c
ENDIF.
simply the latter one is nearer to your natural language (I actually think to replace "ELSE" with "OTHERWISE" would be even better) and the "ELSE" implies both the opening and the closing braces.You can argue if
a ? b : c;
is more readable, I would argue it is not.It's not like special characters are always bad. For example
a->b
works quite well when a is pointer and the arrow "->" symbolizes graphically where a is actually pointing at. But nowadays we languages which use "->" and "=>" for different things and for their similarity they interfere which each other when doing the decoding and adding to the cognitive load.When designing a language you have to trade of brevity or number of characters to type and readability. Most, if not all languages, nowadays opt for brevity because it appeals to the developers to type less and makes it more easy have more complex functionality in one statement. The price you pay is readability and finally maintainability of the program.
I think the first programming language which failed by its overuse of badly readable syntax was Perl, which was replaced by the much more easy to read Python.
I personally believe the psychology of programming is an under-researched subject
Disclosure: Alongside to CS I studied cognitive psychology when I attended university.
It's also a big factor of why I enjoy programming in Nim, which provides low level performance but with minimal use of sigils. Though I also appreciated Julia's syntax as well that also provides good access to performance.
My big issue with python (and others like plain JS) is they don't type things and it's easy to forget what is what
Also Rust program are usually small, in the other hand in Python I see objects that extends from 6 objects and they can be as big as 1k lines with data inside
If you really have ADHD after 10mins reading untyped python how can you remember if you are passing a dict or an object? or what it was 200 lines above of the same object ? or what it has the 6 other objects that you are extending from?
I have less of a problem with Rust than Swift for example, because Swift is really hard to decipher at times. You can leave out chunks of code and it's supposed to be obvious what it does but it's not. The whole language can become dialed down to looking an like a DSL; for example SwiftUI. It's confusing as hell, e.g. Button(action:{}, label:{}), Button{} {stuff} etc.
Rust is certainly a mouthful to look at, but it looks like Rust. Python's syntax is a big part of python's success. However I find that personally, I don't like meaning through indentation. I prefer the safety of `;` and `{}`.
My advice is spend more time writing Rust, eventually your brain becomes selective at reading things that matter and ignore things that do less, in context of what you're looking for, whilst reading.
That said, Rust is okay because it uses symbols, but not okay because it uses them in very weird ways. Macro function stuff that needs a ! like whatever!() is aggravating. The exclamation mark is easy to overlook, easy to mix up with letters, isn't surrounded by spaces and frankly I do not see the point. That syntax doesn't really add anything to the safety of the language that couldn't just be done with a few 'you are overriding stuff' warnings. Actually it makes things worse, because if somebody has stuff() and stuff!() defined, there is hard-to-distinguish weirdness going on. Also aggravating but not as dangerous are 'labels. Oh, and angle brackets like <'stuff> that could easily also be comparison operators somwhere else. Rust would have had the opportunity to fix the mistakes in C++, but it just copied them.
Oh, and all the 'mut' everywhere is also weird noise that would be easier if left out. Most things are 'mut', so write out 'const' instead.
My favourite languages are Python, Java and C.
I have written 2 Rust programs. I am not sure I understand C++ "forward" and Rust's lifetimes with the apostrophe. Any explanations would be helpful.
Async Rust, traits all seem hard to understand to me. I would like to understand them better.
I like C programming because it feels simple.
With Rust it feels that everything is a fight, I haven't yet got the mental model to design Rust programs. I think I need to design programs as trees.
I can deal with * symbols and &.
I find into(), forward hard to understand.
I find C++ template syntax hard to understand, things like unique_pointer.
There is a tradition of using symbols in languages of the C family. Rust is in that space because it addresses the same kind of problems that C solves. Familiar syntax helps developers to switch language.
I guess that a Pascal like syntax for Rust is possible. Would C developers have liked it more or less than a C like one? My take is: less.
An example of a compiled language with little use of symbols: COBOL.
An untyped language or a language with a small type system and type inference like SML always looks more readable.
If things get more advanced, the syntax will grow. Now, whether Rust needs to look that ugly is another matter. I think they made some wrong choices and should have evolved more from SML etc.
However, the former also leaves so many details unclear. Like, how long should it last? Who provides the design? How do you inspect the end result? How much should you pay up front, and how much afterwards? Who buys the materials, who pays for them? What happens if they accidentally burn your whole house down? And a hundred others.
Python and Rust are like that. Python is very legible because it doesn't specify a lot of things. What is the type of that variable? Is it declared or not? Both of these are fixed with modern linters and type hints, but type hints already make the language less "legible". Is the code that I'm calling able to modify the data I pass in? How exactly are the objects allocated in memory?
Once again, many of these concerns can be unimportant for small projects, just as simple verbal agreements are enough sometimes. But for huge software systems, especially ones where memory layout and performance are critical, all these details are crucial — just as a good contract is.
Work your way through the Rust Book, but do it slowly. It is all online. It is what I am doing right now. Here is a link for you. https://doc.rust-lang.org/book/
You could get a decent IDE to fill in the gaps for you. Otherwise make lots of snippets and save yourself the mental overhead while you get started on making things.
The opposite end of the spectrum is Go, which I love, but many hate for being too limited. I like seeing everything in the control flow represented as values - context and errors included - but too each their own. I'm not sure if you need to learn Rust for work or are just interested in a new language, if it is the latter I can recommend checking Go out. :)
Whether it's a C, a Lisp, a ML, or an APL — spend enough time getting your hands dirty with it and you just get used to it.
Otherwise, Rust has to have the syntax to mean different things: values, references, mutable references, generics, etc.
In say Java, what’s just an Object is actually something like an Arc
But the problem is being smart is often correlated with being arrogant and not giving a single f..ck about mere mortals and their real life needs.
But mere mortals are not smart enough to create a new programming language.
Therefore you hardly ever see a good devx and well designed syntax etc in a programming language.
Of course simple reasons like this are not appealing to the nerd crowd. They will hyper analyze everything including languages, and come up with exceedingly convoluted reasons as to why things are, the way they are, rather than settle for simple explanations
It's worth mentioning that Python, for example, can still achieve good performance through the use of optimized libraries and just-in-time compilation techniques.
Don't think that's ADHD bud.
Why are moden programming languages, like Go, so plain?