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

Definitely one of the things that frustrates me about Rust, is that I feel like I can't write "pretty" code. Multiple times it was even the reason I gave up learning Rust. Clarification: I think my definition of pretty has come from a certain feel/comfort you have when reading Ruby code (which I have written/read for only a couple months).

Meanwhile, to continue learning Rust, I've done myself a favor. I just told myself: "Rust is worth writing but it isn't for pretty code. Sorry!".

The other, related, mental block I haven't been able to overcome yet: In Java/Python/Ruby/(even C++), the runtime "seems so heavy" I don't care when I "waste" allocations or memory. However, the fact that it says on Rust's home page "featuring zero cost abstractions" makes me feel guilty/incompetent every time I introduce a cost-full abstraction. Again a reason I stopped learning Rust a few times.

Sadly this feeling of inadequacy/guilt extends even to applications. Which is ridiculous since if your application isn't doing expensive things, you probably have a very simple application. This definitely plays a part in why I can't write code as elegant as Rust will allow it.

For the record, sorry, I don't usually like critiquing something I don't have a solution for. However, I thought this was worth bringing up. Mostly I needed to vent, but does anyone else feel similarly? Am I really the only one?

If other people are feeling the same way, I hope it doesn't become a habit for us to feel the only way to write good Rust is to allow it to be inelegant. It would be disheartening if the next systems programming language was memory safe but still noone enjoyed reading it. I'm curious what peoples thoughts are?

Mostly joking, but maybe just a line on the website or guide saying: "We take care of the performance so you can write expensive applications"?



Yes, I think I know exactly where you're coming from. I've gone through the same cycle of starting and stopping with it, for the same reason. I will sometimes spend hours looking at a simple function thinking "There has to be a way to get this to work," when I would have long since put the sequence of if-else statements in a C program, or just allocated some heap memory and been done with it. It's like I want Rust to be Haskell, but without the GC, and I feel like I'm dumb for not being able to make it work that way. It seems like the abstractions Rust makes available should be composable in a way that is prevented by the memory model. The language features are mostly there, but it's just tantalizingly out of reach and it seems to trigger my "puzzle solving" response.


Hear! Hear! I often have to persuade myself: “It’s OK to use String/box, buddy. There are more wasteful programmers in the world. No need to feel guilty of not using references as much as you can,” etc. But still, you can’t stop thinking there may be a better way to do this...


Very interesting point and I also feel similar a need to "overoptimize" my code when I program something in C. This is specially notable when working with strings: In high level languages I use strings concatenation and splitting willy nilly but in C all those strcats and for loops "feel" suboptimal so I have a tendency to write hairy code full of pointers and strtok.


Developers are a strange bunch. I've never heard someone say, "Wow, look at that optimized code! I can't wait to work with this dude!". However, I have heard many times, "Working with this person is great. They do everything from expressive code, to small logical commits to make my life easier."

It's almost as if many of us would rather be seen as an elite, rather than seen as a pragmatic developer.


I usually just tell myself "bad code gets run". Optimizing string concatenations and the like is something I can do after the code is done, doesn't leak, and has enough form that I can write function tests around it.

Its not something to do before.


Next time you feel the urge, think about me.

I will be there. Looking at your code. Judging you.


I have the opposite problem here: When I write Ruby now, I go "my God, look at all these allocations!"


I can definitely see that.

I think I've never had that issue since I started with C -> C++ -> Java -> JavaScript -> Python -> Scala -> Ruby -> ...

It was always more expensive (performance wise) to be more expressive. And I suppose since the whole community is making that performance compromise, I think it never really effected me.

Meanwhile, in Rust, the majority of the community is looking for the most performant best possible API, and it just seems overwhelming to always try to be a part of that. I'm sure I'll get over it soon. Most likely as the community grows the majority of Rust users will care less about optimal performance.

Actually, I suppose that is what happens to most languages. As the community shifts to users of the language rather than builders of the language, things might seem less overwhelming. Maybe I'm just coming to Rust too soon for ergonomics. For example in Java, there are the people that build the Netty Client / Server and they care very much about performance. Then there are most Java developers who don't really care.




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

Search: