this post was submitted on 11 Jan 2024
0 points (NaN% liked)

Rust

5938 readers
1 users here now

Welcome to the Rust community! This is a place to discuss about the Rust programming language.

Wormhole

!performance@programming.dev

Credits

  • The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)

founded 1 year ago
MODERATORS
 

Almost five years ago, Saoirse "boats" wrote "Notes on a smaller Rust", and a year after that, revisited the idea.

The basic idea is a language that is highly inspired by Rust but doesn't have the strict constraint of being a "systems" language in the vein of C and C++; in particular, it can have a nontrivial (or "thick") runtime and doesn't need to limit itself to "zero-cost" abstractions.

What languages are being designed that fit this description? I've seen a few scripting languages written in Rust on GitHub, but none of them have been very active. I also recently learned about Hylo, which does have some ideas that I think are promising, but it seems too syntactically alien to really be a "smaller Rust."

Edit to add: I think Graydon Hoare's post about language design choices he would have preferred for Rust also sheds some light on the kind of things a hypothetical "Rust-like but not Rust" language could do differently: https://graydon2.dreamwidth.org/307291.html

top 15 comments
sorted by: hot top controversial new old
[–] Reptorian@programming.dev 0 points 9 months ago (1 children)

You mean a interpretative language with similar role to Python, but more like Rust/C++ style? I actually want that so that I can ditch Python even if I learned it and use this instead.

[–] BatmanAoD@programming.dev 0 points 9 months ago (2 children)

Not necessarily interpreted, but possibly. I think a more likely path is something like Go that's compiled but still has a garbage collector.

[–] sebsch@discuss.tchncs.de 0 points 9 months ago (2 children)

If you use a garbage collector the whole borrow checker would not make any sense.

Do you want to have error handling and functional paradigms in go? I think you should start there and ask go Devs why their language is lacking such basic stuff.

[–] 80avin@programming.dev 0 points 9 months ago* (last edited 9 months ago) (2 children)

Not sure if this is what OP is seeking, but I would be fine to have borrow checker removed, replaced with Garbage collector like Go/Python in such a language.

To build prototypes, I don't want to fight with borrow checker and neither I care for efficiency much. But I do want the macro system, traits, lazily asynchronous runtime, cargo like package manager, easy build system, etc.

Rust has so many powerful features, but only because of borrow checker (IMO) we can't use it for rapid prototyping like Python. With that replaced, this subset of Rust would be something which can be a great contender to Python/Go, etc.

[–] crispy_kilt@feddit.de 0 points 9 months ago

To build prototypes, I don’t want to fight with borrow checker and neither I care for efficiency much.

Then use .clone() or Arc everywhere?

[–] Fal@yiffit.net -1 points 9 months ago

Why would you want to prototype incorrect code? You don't fight with the borrow checker. The borrow checker prevents stupid mistakes. Anything that is correct that the borrow checker rejects is almost certainly a very bad idea in a prototype

[–] rook@awful.systems 0 points 9 months ago (1 children)

I spend an inordinate amount of time at my C# day job adding documentation comments about exclusive access and lifetimes and ownership… things which are clearly important but which dotnet provides little or no useful support for, even though it has a perfectly good garbage collector. The dotnet devs were well aware that garbage collection has its limits, especially when interacting with resources managed outside of the runtime, and so they added language features like IDisposable and finalisers and GCHandle and SafeHandle and so on to fix some of the things GC won’t be doing for you.

I’d happily use a garbage collected language with borrow checking.

[–] crispy_kilt@feddit.de 0 points 9 months ago

Sounds like you're using C# for something that it wasn't designed for. You can, of course, but it is obviously painful

[–] crispy_kilt@feddit.de 0 points 9 months ago* (last edited 9 months ago)

F#? It's compiled, statically typed, somewhat fast, garbage-collected, and supports Rust-style error handling

[–] asdfasdfasdf@lemmy.world 0 points 9 months ago* (last edited 9 months ago) (1 children)

I didn't love that article - Rust isn't strictly a systems language. It's general purpose, and a lot of the mechanics are very useful for general programs.

[–] BatmanAoD@programming.dev 0 points 9 months ago* (last edited 9 months ago) (1 children)

I feel like you may have missed the point, then? Or at least interpreted the article very differently? Rust isn't "strictly" a systems language, but neither is C or C++; people use them for application development all the time. But all three languages have very specific limitations (most obviously, that adding a garbage collector would be an unwelcome change) imposed by the need to fulfill the "systems" niche.

Compare Golang: it can't replace C++ for every use-case, because it has a garbage collector, and because you need cgo to use FFI. But it's otherwise a very flexible language that can be used for most types of software.

What I would like to see is something that shares these advantages with Go:

  • quick to build
  • easier to teach & learn than Rust
  • easier to quickly prototype with than Rust (though of course it's debatable how well Go does at this one)

...but I don't like the actual language design of Go, and I think it's possible to design a language that's more Rusty but still simpler than actual Rust.

For instance, error handling in Rust is both more ergonomic and more rigorous than in Go. That's huge! A language like Go but with sum types, Result, and the question-mark operator would be leaps and bounds nicer than Go itself.

To be clear, I don't imagine that a "smaller Rust" would replace Rust. But I also don't think we've reached optimal language design when the language I'd pick to write an OS is also the language I'd pick to write a small CLI app.

[–] crispy_kilt@feddit.de 0 points 9 months ago

The designers of Go actually discussed civilised error handling (like Rust and others), but in order to make it useful they'd have to include other features like ADTs and something like an Either monad (Result type), which they felt would make Go too difficult to learn for the developers they envisioned Go to be used by.

One of the most important reasons for the popularity of Go is exactly that it is extremely limited, and can be picked up by any developer in a few hours. It takes no time to learn because there is nothing there that would need to be learned. This isn't a limitation, it's a feature (opinion of Go designers, not mine).

The key point here is our programmers are Googlers, they’re not researchers. They’re typically, fairly young, fresh out of school, probably learned Java, maybe learned C or C++, probably learned Python. They’re not capable of understanding a brilliant language but we want to use them to build good software. So, the language that we give them has to be easy for them to understand and easy to adopt.

  • Rob Pike
[–] crispy_kilt@feddit.de 0 points 9 months ago (1 children)

If you want a high-level, convenient Rust, it's already there: It's Rust with liberal use of Arc and .clone() and Box<dyn Trait> and so on. If you want things to be convenient instead of efficient, Rust already has everything you need.

[–] BatmanAoD@programming.dev 0 points 9 months ago (1 children)

If you think that's convenient, then I fear you may never have experienced a convenient language.

[–] crispy_kilt@feddit.de 0 points 9 months ago

I guess we're coming at this with different opinions on what is convenient. Python is extremely easy and quick to write - but then writing more code for tests than the actual program itself because the compiler catches next to nothing and still dealing with the occasional runtime error is highly inconvenient to me. I look at the "ease of use" - or painlessness if you will - of a programming language over the whole lifecycle of the program, not just initially writing it.

Initial development is like 2% of the total effort over the whole lifecycle of a program, at most. The vast majority of time is refactoring, troubleshooting, changing, testing, building, deploying, monitoring.... and so on. With Rusts strong type system, I will probably spend 30% more time developing than with an easier language like Python/Go/Kotlin, but I will save 300% of time debugging, troubleshooting, deploying. Moreover, writing code is something I enjoy, while debugging is something I'd rather avoid. Any language that enables me to spend less time teoubleshooting runtime errors and debugging edge cases is a desirable language for me.

What would you consider a convenient language, and why?