5 ms·
I think any language that has the concept of storage classes will be complicated because you have to deal with copy versus move vs borrow semantics. Other langu
by CountSessine 4y ago
I think any language that has the concept of storage classes will be complicated because you have to deal with copy versus move vs borrow semantics. Other languages get around this by just saying that primitives are on the frame and everything else is on the heap.
Efficiency has its price.
- andrewstuart 4y agoAs I understand it Rust is composed of 5 or 6 sub languages. I find it hard to believe that there's no way to get the benefits of Rust without 5 languages. Why can't a programming language be one language that does everything it needs to do? Seems crazy to me to have 5 or 6 sublanguages.
- kibwen 4y ago> As I understand it Rust is composed of 5 or 6 sub languages. Where have you heard this? That's certainly not the case.
- aussiesnack 4y agoNot quite sure what you mean by sublanguages - procedural and declarative macros perhaps? In any case I wonder about the simplicity/complexity dance. Simplification ends up with something like Lisp, in which you write DSLs that each has to be independently learned. Elixir does something similar. Some differentiation might just be a natural consequence of chasing ergonomics.
- woodruffw 4y agoIf I had to guess: Safe Rust, Unsafe Rust, proc macros, declarative macros, the attribute language, and maybe async Rust (although I'd really just consider this sugar on Safe Rust). I love Rust, but I would love to see more syntactic unification between these components. Both macro languages, in particular.
- andrewstuart 4y agoThere's something wrong if a language is so unsuited to programming itself that it needs another language - or five more languages - to get the job done. This is one of the great things about JavaScript - it's flexible enough to do everything in its ecosystem.
- woodruffw 4y agoI don't think that's a good metric. Most of the most successful programming languages of all time have had at least one macro or attribute language attached to them.
- aussiesnack 4y agoAh yes that'd be right. Haven't needed to write any unsafe Rust, so that's kind of under my radar. But agree about the macro langs.
- kibwen 4y agoUnsafe Rust is a minimal superset of Safe Rust, proc macros aren't their own language, there's no such distinction between Rust and "the attribute language", and async Rust isn't its own distinct thing, it's all just Rust.
- woodruffw 4y agoUnsafe Rust is, in the Rust Language book's own words, a "second hidden language" within Safe Rust[1]. You're absolutely right that it's a superset; that's what makes it distinct and therefore a unique language with unique semantics (even if the syntax is nearly identical). Procedural macros can be used to define new languages within Rust, which means that grokking them requires the developer to understand their expressive capacity. For example, the paste[2] crate introduces a little bit of novel syntax for combining identifiers. Attributes are the counterpart to Unsafe Rust: their syntax is described separately from the rest of Rust[3]. Understanding how to use them involves components of Rust that aren't tied to the syntax of programs (e.g. doc and feature attributes, which connect to Rust's standard tooling instead). I agree that async Rust isn't its own distinct thing. I threw that one in as a possible interpretation, to make the count work. [1]: https://doc.rust-lang.org/book/ch19-01-unsafe-rust.html https://doc.rust-lang.org/book/ch19-01-unsafe-rust.html [2]: https://docs.rs/paste/latest/paste/ https://docs.rs/paste/latest/paste/ [3]: https://doc.rust-lang.org/reference/attributes.html https://doc.rust-lang.org/reference/attributes.html
- rascul 4y agoI think you might be referring to this: https://gist.github.com/brendanzab/d41c3ae485d66c07178749eaeeb9e5f7 https://gist.github.com/brendanzab/d41c3ae485d66c07178749eae... In which there is: >Many sub-languages to learn, many with different syntaxes and semantics. For example: > the expression language > unsafe runtime language > safe runtime language > compile time language > the type language > the trait language > the macro language > the attribute language And was discussed (122 comments): https://news.ycombinator.com/item?id=32819444 https://news.ycombinator.com/item?id=32819444
- kibwen 4y agoWorth noting that bjz is a compiler hacker, and this is a list of "languages" from a language implementor's perspective. From the perspective of a user of the language, nearly all of these are just "Rust, the language"; to a user there's no such thing as e.g. a "trait language" or an "attribute language", there's just Rust, which has traits and attributes in the same way that JavaScript has objects and closures without having an "object language" or "closure language". Of the things that can be described as actual languages there, Unsafe Rust is just a minimal superset of Safe Rust, whereas Const Rust is just a subset of Safe Rust; it's not three languages to learn, it's one language where a handful of things are either available or not in certain contexts. The one thing that legitimately is its own language is the macro-rules language, which is a DSL for syntax manipulation.
- jjtheblunt 4y agoThe counter-observation might be that Rust exposes, as a responsibility of the programmer, the completion of what would otherwise be compile-time analyses in sophisticated compilers. (Borrow and move look what SSA could comment on, for a simple example.)