Live data from Hacker News

Easy Mode Rust

llogiq.github.io

51–59 of 59 posts

Re: Easy Mode Rust

#51
post #20
post #13

The self-modifying code mentioned in the Macros section could be automated in an IDE! That is, your IDE should be able to show you the expansion of a macro at that specific place. This feature would help me much more to understand what's going on than navigation to the macro source. I'm not sure if there are any IDEs supporting (temporary) macro expansion already. The output showing all macros expanded is usually too…

Rustrover (IntelliJ) can do some of this. You can use quick actions to expand a macro inline in the IDE.

Intellij can also expand macro inline, But iirc you have to enable it in advanced settings.

Re: Easy Mode Rust

#52
post #28

Earlier quoted context omitted.

As can rust-analyzer, btw. It's very useful sometimes.

How would you interface with rust-analyzer to make it do this? As I understand it rust analyzer acts like an LSP to your IDE, which in turn doesn’t let you just make raw calls to rust analyzer

In VSCode it’s just a command away (on the command palette).

Re: Easy Mode Rust

#53
I think it would be helpful if Rust had a much more verbose mode. Nothing changed, just that symbols and operators have an alternative mcuh more verbose syntax that will make it easier for someone without a Rust background to read Rust code.

A script / compiler could go from one to the other and back again without any changes having occurred.

The syntax is good once you have figured it all out its it is faster to type.

Re: Easy Mode Rust

#54

I think it would be helpful if Rust had a much more verbose mode. Nothing changed, just that symbols and operators have an alternative mcuh more verbose syntax that will make it easier for someone without a Rust background to read Rust code. A script / compiler could go from one to the other and back again without any changes having occurred. The syntax is good once you have figured it all out its it is faster to typ…

What's an example of what this would look like?

Re: Easy Mode Rust

#56
post #28

Earlier quoted context omitted.

As can rust-analyzer, btw. It's very useful sometimes.

How would you interface with rust-analyzer to make it do this? As I understand it rust analyzer acts like an LSP to your IDE, which in turn doesn’t let you just make raw calls to rust analyzer

In addition to the already mentioned Command Palette, macro expansion is also available as a quick fix, either by clicking the light bulb icon when it appears, or triggering it via hotkey (Ctrl+. by default).

Re: Easy Mode Rust

#57
post #39

for item in items.iter() { if predicate(item) { items.push(modify(item)); } } This is not a good idea in Python either. You are better off creating a new list in which you accumulate all items, both modified and unmodified.

I don’t think I’ve ever seen code of this shape in general, ever. Lists are homogeneous in their semantics, aka items stand for the same semantic thing. This is in contrast to tuples. Both lists and tuples exist in both Rust and Python as well was a bunch of other languages. After you’re done with the above iteration, what are you going to do with the items list? It’ll contain a mix of semantically different things (…

I've seen it in Python. Not in Rust, because I haven't worked with Rust.

Re: Easy Mode Rust

#58
post #5

Earlier quoted context omitted.

Sibling doesn't really cover the benefits vs. Go, so here's my attempt at a list. * Rust offers memory safety without a GC. You may or may not want a GC. If you don't, then Rust is the better option. * More broadly, Rust has a C++-like focus on providing zero cost abstractions. Go is generally happy to accept a small runtime cost for abstraction. * Rust can generate small WASM targets because it doesn't need to bundl…

I'd like to elaborate on the "fancier type system". It's not all academic. There are obvious practical advantages: - No more bugs where a value that shouldn't be mutated is accidentally mutated in another place. - No more bugs with writing to a closed channel or file. - No more bugs with forgetting to close a file. - No more null pointer errors at runtime. - No more runtime reflection errors. Compared to Go, safe Rus…

> No more null pointer errors at runtime

This is the most glaring thing IMO. Go repeating the billion dollar null pointer mistake is inexcusable IMO. There’s zero reasons for a language designed in the last 20 years to have this problem. This alone is enough for me to want to stay away from Go.

Re: Easy Mode Rust

#59

Saving this article to point to next time someone asks me yet again "why not rust". I think one could explain the entirety of C in fewer words than this "easy mode" rust.

> I think one could explain the entirety of C in fewer words than this "easy mode" rust. You really want to skip over the ruleset for undefined behaviour, otherwise "easy mode rust" becomes as long as the just the first chapter of the first book of "a quick intro of undefined behaviour in c".

Basejumping is so much easier if you don't have to fold a parachute beforehand.
Post reply on HN