This is a question I've often wondered, and am perhaps asking now out of sheer frustration. I have ADHD, of which my particular 'mutation' of ADHD makes it difficult to read and absorb written text.<p>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.<p>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.<p>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?<p>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?
The problem isn't the syntax, it's the semantics. Matklad has a great post about this. You can try a bunch of different syntaxes, but rust doesn't get more readable with any of them. You need to remove information (and thereby change how the langauge works) for readability to improve.<p>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.
I don't think this is related to your ADHD.<p>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.<p>When you need to decode a "{" or a "@" in the program to a actual processing step. you can assume that<p><pre><code> if (a) {
b;
}
else {
c;
}
</code></pre>
is more difficult to decode compared to<p><pre><code> IF a
THEN b
ELSE c
ENDIF.
</code></pre>
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.<p>You can argue if<p><pre><code> a ? b : c;
</code></pre>
is more readable, I would argue it is not.<p>It's not like special characters are always bad. For example<p><pre><code> a->b
</code></pre>
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.<p>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.<p>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.<p>I personally believe the psychology of programming is an under-researched subject<p>Disclosure: Alongside to CS I studied cognitive psychology when I attended university.
As someone also with ADHD I agree. I can and have programmed in C++ and Rust but I very much dislike the noise and clatter. I don't believe it's necessary given the rise of LSPs and the ability to query relevant information as needed.<p>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.
I think I'm in the other side of your problem? I found easier to read Rust code than untyped Python.<p>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<p>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<p>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'm a polyglot, I've used many languages over the years.<p>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.<p>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 `{}`.<p>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.
Just wanted to mention Nim here. Others mention Go but it has a lot of "noise" because of the error handling and other features. For native binary creating languages, I haven't seen any language "neater" than Nim although I hardly go out of my way to sample languages.
I find languages with symbols far easier to read than verbose textual syntax like in BASIC or pascal. Symbols like (), {}, [] satisfy my need for symmetry and are far easier to correlate than BEGIN/END. I find Python very unreadable due to the whitespace/alignment thingy, I always get the urge to hold a ruler to my screen to see if somebody forgot a space somewhere.<p>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.<p>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.
It's not modern languages, it's Rust specifically - they didn't optimize for readability and ended up with a language that's hard to read.
I am a beginner to programming language implementation. I have a JIT compiler that compiles a language that looks similar to Javascript.<p>My favourite languages are Python, Java and C.<p>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.<p>Async Rust, traits all seem hard to understand to me. I would like to understand them better.<p>I like C programming because it feels simple.<p>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.<p>I can deal with * symbols and &.<p>I find into(), forward hard to understand.<p>I find C++ template syntax hard to understand, things like unique_pointer.
Syntax is a decision of the language's developers.<p>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.<p>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.<p>An example of a compiled language with little use of symbols: COBOL.
Asking out of genuine curiosity: What defines an ADHD friendly tutorial?
Might be easier for non-ADHD developers to help find what you are looking for if we know what to look for.
Leaving aside the question whether Python is actually readable outside of small scripts:<p>An untyped language or a language with a small type system and type inference like SML always looks more readable.<p>If things get more advanced, the syntax will grow. Now, whether Rust needs to look <i>that ugly</i> is another matter. I think they made some wrong choices and should have evolved more from SML etc.
Think of it like this. When you hire a team to remodel your kitchen, you can just write your agreement as "do the kitchen, get X money". Or you could go with a over-complicated, lawyered up contract for 10 pages. Obviously, the former is more legible than the latter.<p>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.<p>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?<p>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.
> Are there ADHD friendly tutorials/books on Rust?<p>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.
<a href="https://doc.rust-lang.org/book/" rel="nofollow noreferrer">https://doc.rust-lang.org/book/</a>
Legibility is also based on what you're used to. E.g. I find nested parentheses horrible to read, but Lispers swear by them.<p>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.
This is a conscience choice that has been made by the Rust team - they've chosen to create a very "powerful" language (which makes sense if they are trying to compete with C++) and thus require a very powerful syntax, at the cost of clarity and simplicity. I'm with you personally, it reads as a mess to me.<p>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. :)
I think legibility in programming is mostly familiarity.<p>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.
Try Crystal. (edit: or rather consider it. It's incredibly fast to execute, slow to build, and is as readable as Ruby)<p>Otherwise, Rust has to have the syntax to mean different things: values, references, mutable references, generics, etc.<p>In say Java, what’s just an Object is actually something like an Arc<Box<Option<Object>>>> Things are just more explicit to get the kind of fine grained control needed.
Things like rust, scala etc are obviously created by brilliant and scary smart people.<p>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.<p>But mere mortals are not smart enough to create a new programming language.<p>Therefore you hardly ever see a good devx and well designed syntax etc in a programming language.
It's unlikely to be your fault/disability, it's (mostly) them. The average designer of a programming language is a nerd sociopath. He optimizes things for _his_ readability not the readability of his fellow nerds.<p>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
I have almost a mirror issue. After years of working with it I still find Python incredibly hard to read. I had always chalked it up to just differences between people.
Low-level languages like Rust and C++ tend to have more complex syntax and symbols because they provide finer-grained control over memory management and what not, while high-level languages like Python prioritize readability and ease of use, sacrificing some low-level control in the process.<p>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.
> I have ADHD, of which my particular 'mutation' of ADHD makes it difficult to read and absorb written text.<p>Don't think that's ADHD bud.