7 ms·
Rust is so full of symbol soup. <'_>) is a very simple one, but there are ones with ~7 consecutive symbols, and there are a lot of symbols all over Rust cod
by johnisgood 2y ago
Rust is so full of symbol soup.
<'_>)
is a very simple one, but there are ones with ~7 consecutive symbols, and there are a lot of symbols all over Rust code.
How come it is in demand?
Cool book though.
- stouset 2y agoSymbols are just other letters in the alphabet. Something like <‘_> is as natural for me to read at this point as any of the other words in this sentence. Math is also symbol soup. But those symbols mean things and they’ve usually been designed to compose nicely. Mathematicians using symbols—just like writers using alphabets—are able to use those symbols to concisely and precisely convey complicated concepts to one another. I guess my point is that symbols shouldn’t be looked at as inherently a positive or negative thing. Are they clear and unambiguous in their use? Do they map clearly onto coherent concepts? When you need to compose them, is it straightforward and obvious to do so?
- Etheryte 2y agoI think many programming languages could benefit if we had an easy way to have both custom symbols and a convenient way to input them without extra friction. Take APL for example, once you know the language it's incredibly expressive, but the overhead to typing it is so strong that many use custom keyboards/caps.
- ufo 2y agoI wish compose keys were more prevalent. There's something nice about typing -> and getting →
- bombela 2y agoTo be fair the basic ASCII keyboard is also default in US/Britain. And most people assume that's all they get. I have always used the "international" version of the US English keyboard on Linux. And I can enter all common symbols pressing altgr or altgr-shift. I also use right Ctrl as a compose key fore more. I would be hard pressed remembering what combo to press, after years it's just muscle memory. But how do you find out what layout and what compose key does what? Good luck. It's as documented as gesture and hidden menus on iOS and MacOS. sigh.
- jonahx 2y agoUiua (https://www.uiua.org/ https://www.uiua.org/), broadly in the APL lineage, solves this problem nicely. Like APL, it has a set of well-chosen symbols, but each symbol has an english name you can type just as you would a function name in another language, and it's automatically converted to the symbol when you run it.
- johnisgood 2y agoWell, I wish I could find the ones I have seen in the wild. Perhaps HRTBs and Fn traits, or double turbofish generics. I really cannot remember sadly.
- stouset 2y agoEven something like foo::<‘_, [T]>() is just not that hard to follow. Again, the symbols involved all compose nicely and are unambiguous. And frankly, you just don’t need something like that all that often (and when you do, there are usually other alternatives if you’re really put off by the symbols.
- johnisgood 2y agoSomeone mentioned the use of ")?)?" (in terms of error handling), I am quite put off by this, too. :P Anyways, I will try to look for the code, it is somewhere in my comment history but I have left way too many comments, so no promises.
- stouset 2y agoI would one million percent rather type (and read) foo(bar()?)? over something like if a, err := bar() { return nil, err } if b, err := foo() { return nil, err } But also even better is just let a = bar()?; let b = foo()?;
- deleted 2y ago[deleted]
- johnisgood 2y agoI prefer ("if a, err := bar() {"), the same things you said applies here, too. I write a lot of Go and I can glance through it quickly, there is no cognitive overhead for me. Edit: actually, it was someone else who said this: "Human brain has a funny way of learning how to turn off the noise and focus on what really matters.".
- jcelerier 2y ago> Math is also symbol soup. But those symbols mean things and they’ve usually been designed to compose nicely. Mathematicians using symbols—just like writers using alphabets—are able to use those symbols to concisely and precisely convey complicated concepts to one another. I just don't understand why one may take maths of all things as a positive example of something readable, when it's widely known to be utterly inscrutable to most humans on earth and even so many papers have differing conventions, using the same symbol for sometimes widely different or sometimes barely different things
- pharrington 2y agoLiterally every language is inscrutable to most humans on Earth. But they all work fairly well for those in the club that know them!
- DistractionRect 2y agoIt's more batteries included and the packaging ecosystem story is better than alternatives. Certain safety guarantees are a nice to have. If you just want a better c/c++ afaik that's zig, but I have no experience with it
- no_wizard 2y agoAn aside question I have is what’s the best beginner Rust book out there that is up to date? I been learning Rust off and on and I have a more serious need to get up to speed with it but I’m unsure where it’s best to start in this way
- smodo 2y agoThe Rust Programming Language does a great job imho. It got me up to speed by reading it before bed for a month. I’d never written C/C++ before, just a lot of Python. It starts out really simply by explaining the type system and the borrow checker. Take it from there and do a couple of side projects, I’d say.
- kshri24 2y agoIn this order: 1. The Rust Book (Free) - https://doc.rust-lang.org/book/ https://doc.rust-lang.org/book/ 2. Rust by Example (Free) - https://doc.rust-lang.org/rust-by-example/ https://doc.rust-lang.org/rust-by-example/ 3. Rust Atomics and Locks - https://marabos.nl/atomics/ https://marabos.nl/atomics/ 4. Rust in Action - https://www.rustinaction.com/ https://www.rustinaction.com/ 5. Rust for Rustaceans - https://rust-for-rustaceans.com/ https://rust-for-rustaceans.com/ Also Jon Gjengset's channel is immensely valuable: https://www.youtube.com/c/JonGjengset https://www.youtube.com/c/JonGjengset
- crablearner 2y agoI have a hard copy of Programming Rust by Jim Blandy et al would that slot in nicely anywhere here?
- 2y ago
- kshri24 2y agoLifetimes and annotations only look like symbol soup initially (when you have little to no experience in Rust). The more proficient you become in Rust more you end up ignoring it completely. Sort of like ads you see (or don't) in Search. Human brain has a funny way of learning how to turn off the noise and focus on what really matters.
- gauge_field 2y agoRust's design is designed to be more in the mentality of if it compiles that it is good enough, leaving less for runtime issues to occur unexpected, dictated by type and memory safety. So, it requires more type info (unless you use unidiomatic unsafe code) and talking with borrow checker. But, once you internalize its type system and borrow checker, it pays off if you care about compiler driven development (instead of dealing with errors in runtime).
- BrouteMinou 2y agoYou become used reading this. Typing it is such a pain; I mean real pain like muscle pains. I developed some muscles I didn't know I had.
- dcminter 2y ago> How come is it in demand? It's a curly-brace language with some solid decisions (e.g. default immutability) that produces static binaries and without a need for a virtual machine, while making some guarantees that eliminate a swathe of possible bug types at compile time. As others note, the symbol soup is something you learn to read fluently and isn't worth getting hung up on. Basically it occupies something of a sweet spot in the power/useability/safety space and got a decent PR shove by coming out of Mozilla back when they were the cool kids. I like it a lot. YMMV.
- colonial 2y ago"Curly-brace language" is a good way to put it. Rust does an excellent job of cribbing features that aren't mainstream and giving them a more intuitive name and design. Most people will conk out if you start talking about how your language has "algebraic data types." But if you rephrase that as "we let you put payloads in your enum," well, that piques people's interest. It certainly worked on me.
- n_u 2y ago> It is a curly-brace language What does this mean? Not Python?
- dcminter 2y agoA language that demarks code blocks with curly braces {} instead of whitespace, begin/end keywords, round brackets (), etc. They often share other syntax similarities but not one particular common set across all of them.
- booleandilemma 2y agoWhat is this constant push in software development to dumb everything down to the lowest common denominator? I don't see it in other fields, at all.
- codr7 2y agoI have to say I have no trouble seeing it absolutely everywhere.
- worik 2y ago> dumb everything down to the lowest common denominator What do you mean?
- the_gastropod 2y agoOff the bat: I like Rust. I'm still very much a novice with it, but I enjoy it. But almost the entirety of Computer Science is based on abstractions because they're helpful to "dumb down" some details that aren't super-important for our day-to-day work. E.g., writing TCP protocols directly is Assembly would be too fine-grained detail for most people's usual work, and using some existing abstraction is "good enough" virtually all of the time (even though we might be able to optimize things for our use-cases if we did drop down to that level) There exists programming work where fiddling with lifetimes is just too fiddly to be worthwhile (e.g., web development, probably is more than fine using a good ol' garbage collected language). This isn't about "dumbing down" anything, it's about refocusing on what's important for the job you're doing.
- johnisgood 2y agoI am against dumbing things down, too (although I do not see its relevance to my comment), but for example I have no issues with OCaml, C, Factor, Ada, Common Lisp, etc. It is just a personal preference anyways.
- deleted 2y ago[deleted]
- airstrike 2y ago<'_> is one of the most basic symbols in Rust. Reading that is almost like reading the letter 'a after just some very modest amount of time with the language. > How come is it in demand? Because there's a lot more to the language than just those not-really-unfamiliar symbols
- jeroenhd 2y agoI agree that Rust can look pretty weird to an untrained developer when lifetimes get involved. But, in Rust's defence, I haven't seen any other language write down lifetimes more concisely. The underscore could've been a name if the name mattered, which would be required in many languages. Rewriting it to <'something>) may help readability (but risks introducing bugs later by reusing `something`). Many C-derived languages are full of symbol soup. A group like <?,?>[]) can happen all over Java, for instance. Many of these languages have mixes of * and & all over the place, C++ has . and -> for some reason, making for some pretty unreadable soup. The biggest additions I think Rust added to the mix was ' for lifetimes (a concept missing from most languages, unfortunately), ! for a macro call (macro invocations in many other languages aren't marked at all, leaving the dev to figure out if println is a method or a macro), and ? to bubble up errors. The last one could've been a keyword (like try in Zig) but I'm not sure if it makes the code much more readable that way. If you know other programming languages, the symbols themselves fall into place quite quickly. I know what <'_> does in Rust for the same reason I know what <T, R> T does in Java, while a beginner or someone who hasn't learned past Java 6 may struggle to read the code. Out of all the hurdles a beginning Rust programmer will face, the symbols are probably your least concern. As for books, the Rust book on the Rust website is kept up to date pretty well. There are books for programmers coming from various other languages as well. The language itself hasn't changed much these past few years. The standard library gets extended with new features, but a book a few years old will teach you Rust just fine. In many cases, changes to the language have been things like "the compiler no longer treats this as broken (because it isn't)" and "the compiler no longer requires you to write out this long definition because it can figure that stuff out itself". I'd recommend running a tool called "clippy" in your IDE or on the command line, if you can leverage a modern language feature for better legibility, clippy will usually suggest it.
- dietr1ch 2y ago> I agree that Rust can look pretty weird to an untrained developer when lifetimes get involved. But, in Rust's defence, I haven't seen any other language write down lifetimes more concisely. Can you do a lot better? I don't think so and it wouldn't help that much. The truth is that most of the time we want to rely on some inferred lifetime annotations, but will obviously need an escape hatch from time to time. Rust doesn't waste a lot of typing around the annotations, but if you were to improve Rust, you'd improve the implicit inference, not the syntax for being explicit.
- thrance 2y agoWait til you learn about APL... Seriously though, I immediately parse it as "generic bounds containing the erased lifetime, close parenthesis". It's not a big deal. And of all the critics one might have on Rust (or any other programming language), "too much symbols" appear like a weak one.
- johnisgood 2y agoWell, if someone does not like Common Lisp due to the parentheses, is it a weak _preference_?
- dhruvrajvanshi 2y ago> How come it is in demand? Because it's a complicated language for building extremely low level things, when you have no other choice. IMO it's not the right tool for high level stuff (even though it does have some stuff which higher level languages should probably borrow). The only other language that directly competes with Rust IMO is C++, which is equally full of symbol soup.
- worik 2y ago> IMO it's not the right tool for high level stuff I thought that for a long time. But as time passes and I spend more time in languages like Typescript (Semi-Type Script more accurately) and Swift the more I yearn for Rust. It is not the right tool for scripting, true.
- gauge_field 2y agoYeah I feel that, not the entire language but, many of its choices, like error handling, sum types (with exhaustive enum matching) especially when writing in python.
- dhruvrajvanshi 2y agoYeah this is the stuff I meant when I said high level languages should borrow from Rust. It's also good to remind people that these things were borrowed by Rust from other languages too. Primarily the ML family of languages.
- dhruvrajvanshi 2y agoI think most server type software can trade off the borrow checker for a GC while still benefiting from other Rust stuff. IMO there's still need for a higher level Rust where you don't need that last 20% of the performance and control. Some people say that OCaml is the high level rust, but I think it's got a lot of gaps which rust doesn't.
- colonial 2y ago
- hardwaregeek 2y agoRust's syntax isn't gonna win any awards, but it looks sufficiently like C++ to hide that Rust is essentially an ML variant with linear types.
- indulona 2y ago[dead]
- satvikpendem 2y agoNow try BQN (Advent of Code 2020 Problem 2): Split ←((⊢-˜+`׬)∘=⊔⊢) input2←' 'Split¨•file.Lines "../2020/2.txt" # change string to your file location Day2←{ f←⊑{(⊑)+↕1+|-´}‿{-1} # Select the [I]ndex generator [F]unction I←{F •BQN¨ '-' Split ⊑} # [I]ndices used to determine if the C←{⊑1⊑} # [C]haracter appears in the P←{⊑⌽} # [P]assword either Part1←(I∊˜·+´C= P)¨ # a given number of times Part2←(1= ·+´C=I⊏P)¨ # or at one of a pair of indices ⊑+´◶Part1‿Part2 } •Show { Day2 input2}¨↕2
- LtdJorge 2y agoOr Brainfuck https://github.com/nicuveo/advent-of-code/blob/main/2022/brainfuck/01-A.bf https://github.com/nicuveo/advent-of-code/blob/main/2022/bra...
- LtdJorge 2y agoIt was designed to be used with syntax highlighting and LSPs. The highlighting makes it pretty easy to read for me. Although there are some arcane generics with lifetimes that can be indecipherable in some libraries.
- ramon156 2y agoIts not required. There's a high chance you can avoid writing explicit lifetimes, it's just another tool for you to use
- selfmodruntime 2y agoInitial Rust development set out to avoid symbol soup. With some switches in leadership, this was forgotten.
- johnisgood 2y agoThanks, this is interesting to know.
- steveklabnik 2y agoFwiw I don’t think your parent is lying but I also don’t feel it’s really accurate. If you read https://graydon2.dreamwidth.org/307291.html https://graydon2.dreamwidth.org/307291.html for example, there’s some references that imply this, but it’s not really that “less symbols” was a goal so much as it is a secondary effect of other choices. Graydon wanted a simpler language and that implies simpler syntax, not the other way around. Even the grammar bit isn't really about "symbol soup." Early Rust had other sorts of things that a lot of folks would consider readability problems unrelated to symbols too: no keyword was allowed to be over five characters, so return was ret, continue was cont, etc.
- selfmodruntime 2y agoIt‘s not a lie, it‘s a loose quote of Steve Klabnik when I asked him on Reddit
- steveklabnik 2y agoHa! Well maybe my opinion has changed over time. To be honest, I struggle to call Rust “symbol soup” now or then; other than lifetimes, which is just one symbol, I don’t think Rust is a particularly symbol heavy language, or at least, not much more than any other curly brace and semicolon language.
- johnisgood 2y agoWell, if you can have (and projects do have) >5 consecutive symbols, then it is symbol heavy. I am pretty sure I made this comment a long time ago with an example but paging on HN is dreadful and time-consuming. I will try to look for it. It was on GitHub. I came across it when I was interested in Rust and checked somewhat popular Rust codebases. Can you think of such cases?