Hacker Timesnew | past | comments | ask | show | jobs | submitlogin

> I'm an incredibly lazy developer and Rust only makes me lazier

You can't be that lazy, or you would use a language that doesn't force you to do memory management.

> Rust is the only language where I can open something like Notepad without an LSP or highlighting

This is a very weird and arbitrary qualifier that seems designed to filter out other languages with type systems.



> force you to do memory management

This is not my experience at all. I never think about memory management when I'm writing Rust, let alone am I "doing it" (active voice).

Your second comment is a very weird sentence that is very difficult for me to grok.


> I never think about memory management when I'm writing Rust, let alone am I "doing it" (active voice).

Worrying about lifetimes is memory management that is unnecessary with GC languages and directly increases cognitive load.

My second paragraph is pointing out that "where I can open something like Notepad without an LSP or highlighting" is a strange qualifier. Why does it matter if you don't have semantic analysis in your editor? You certainly didn't explain it.


> Worrying about lifetimes

Again, not my experience at all. I simply don't think about any of that stuff when I write Rust, all my mental energy can safely go towards working on whatever I'm building.

If you don't believe me, you're welcome to watch the literally hundreds of hours of me live coding in Rust on YouTube.


> Again, not my experience at all. I simply don't think about any of that stuff when I write Rust

Your subjective perception is not reality. You have to think about it, or your programs will be incorrect. The mental load may be low to an experience Rust programmer, but it is there, and it's very intrusive to Rust beginners like myself.

> If you don't believe me, you're welcome to watch the literally hundreds of hours of me live coding in Rust on YouTube.

That's not relevant. Lack of external indicators of cognitive load does not mean that it's not happening.


In most Rust code I write, I never have to use an explicit lifetime marker other than ‘static (which is more of a global const thing). It’s really only something you have to worry about under certain conditions.


> Your subjective perception is not reality.

A self-whoosh? I'd consider myself a Rust beginner (e.g. I've completed Rustlings, I have written a handful data parse and transform programs on my own and a couple of web servers to benchmark stuff, nothing grandiose) and lifetimes haven't ever gotten in my way, they usually get automatically inferred or the compiler tells you what is wrong and how to fix it. Most code examples and docs I've worked with, like Rust By Example, Rust Cookbook, even Rocket's docs, don't even feature code with a lifetime annotation or they don't really need you as a developer to do anything with them other than copy and paste if necessary. This is the smallest hill to die on.


Glad I noped out of this particular bad-faith subthread last night.

I am pleasantly surprised to see however that this unfortunate subthread produced interesting and well-intentioned comments from others.


Perhaps consider not violating the literal letter of the HN guidelines:

> Assume good faith.

https://hackertimes.com/newsguidelines.html

You have no idea what's going on it my head, yet you choose to believe that you do as a result of me countering your arguments. This is a great example of why the Rust community has a bad reputation.


> I'm an incredibly lazy developer

> Watch the literally hundreds of hours of me live coding in Rust on YouTube

Your definition of "lazy" seems quite different from the standard definition.

In my view, the average "incredibly lazy developer" of 2024 tries to have an LLM write most code for them (probably in JS/TS/Python), doesn't notice the subtle bugs introduced by said LLM, and ships straight to prod. If using an LLM fails, they go back to StackOverflow to look for an answer that they can copy-paste. When that fails they give up and ask a less lazy developer for help. At no point in this process did they read the documentation for the language/framework/etc they are using to accomplish their goals.


> Worrying about lifetimes is memory management that is unnecessary with GC languages and directly increases cognitive load.

As soon as you start writing large enough programs to start to learn/worry about variable scoping you are kind of "worrying about lifetimes though. If you know that using global variable is often a bad idea, then you are, in some sense, worrying about lifetimes.

I first learned this in the mid/late 90s as my Perl4 cgi scripts started to grow beyond about a screens worth of lines, and it really solidified into an almost unconscious background task as I wrote code once I started writing a lot of Perl5 apache mod_perl stuff a few years later.

These days, I find myself experiencing slight cognitive dissonance writing tiny Arduino sketches with a bunch of global vars declared right up the top.


> As soon as you start writing large enough programs to start to learn/worry about variable scoping you are kind of "worrying about lifetimes though.

Yes, to a much smaller extent. Rust's object lifetimes, for all the performance gains you get, add on a layer of additional cognitive and development overhead that is simply not present in memory-managed languages.


> Rust's object lifetimes, for all the performance gains you get

Lifetimes are not about performance gains. They're about correct behavior under concurrency, which you have even on JS with async-await.

Heck, let me correct that: even under programs without concurrency it's very easy introduce subtle bugs due to shared mutable state (something as simple as having a global mutable variable, you don't even need concurrency to mess that up, concurrency just introduces more issues like race conditions).

> cognitive and development overhead that is simply not present in memory-managed languages

No, the cognitive overhead is there, you're just ignoring it (and thus more likely to introduce subtle bugs).

If anything, Rust lowers the cognitive overhead by taking care of that for me statically at borrow check time.

Lifetimes are just types (literally). If you think lifetimes are cognitive overhead, so are regular types. Same argument could be used there since types are "cognitive and development overhead that is simply not present in dynamically typed languages". But I wouldn't write anything beyond a few thousand lines of code without them.

When I write Rust I spend more time thinking about types than about lifetimes.


> As soon as you start writing large enough programs

...or small enough programs!

I fought a lot with the borrow checker when I started learning Rust, and then I learned to embrace it. The borrow checker only occasionally bugs me!

As I write more embedded Rust and Rust for WebAssembly, removing implicit dynamic memory allocation forces me to think a lot about lifetimes again.


> Worrying about lifetimes is memory management that is unnecessary with GC languages and directly increases cognitive load.

That's why I just... don't. I use `clone` liberally. That's it.


A better metric for whether you think about it or not would be at refactor time.

In Java, you can just move something around in any way or shape, change its lifetime semantics very liberally (e.g. make it have a single instance, or make every thread have its own, or make it have its own instance of X as a field, or just use a shared one), and it will compile without a word and the runtime will handle it.

In rust, in my experience (though it is surely significantly less than Yours), these kind of refactors actually require code changes at almost every location, and might recursively cause further such issues. I think there is a sort of bias here as well, that people kind of like this kind of refactor where the tooling readily shows you the exact error and it may not be too difficult to solve each case, so this might not register as annoying, but quite obviously a stricter lifetime system will have to have some downsides as well.


Laziness with a long view: I probably won't have to rewrite it, and if I do, it will be easy. I can write code like that in Python or something, but I have to be on my best behavior to do so and that's not lazy.

Using notepad for code is just masochistism though


> You can't be that lazy, or you would use a language that doesn't force you to do memory management.

Eh, depending on what you're building you don't do much if any memory management in Rust. You just declare what you want and it's automatically released at the end of scope.

Yes I know the borrow checker. With experience it stops getting in the way while catching the occasional bug.

And no, building linked lists or recursive data structures are edge cases that you don't need to develop for most applications.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: