Live data from Hacker News

My Struggles with Rust

compileandrun.com

151–160 of 329 posts

Re: My Struggles with Rust

#151

One thing I've found with rust is that you struggle struggle struggle trying to do a simple task, and then finally someone says "Oh, all you need to do is this". Rust has already reached the point where it leaves the world behind. Only the people who have been there since the early days really understand it, and getting into rust gets harder and harder as time goes on. Yes, there's some awesome documentation, and the…

> Rust has already reached the point where it leaves the world behind. Only the people who have been there since the early days really understand it

This was my feeling when I got into Ruby on Rails (years too late).

Re: My Struggles with Rust

#152

One thing I've found with rust is that you struggle struggle struggle trying to do a simple task, and then finally someone says "Oh, all you need to do is this". Rust has already reached the point where it leaves the world behind. Only the people who have been there since the early days really understand it, and getting into rust gets harder and harder as time goes on. Yes, there's some awesome documentation, and the…

How is this problem solved for C++?

The nice thing about C++ is that it is so widely used that for just about any task you can find examples of how to do it (usually many different ways to do something), especially for tasks like this article. You will also find plenty of C example, which you could also use in C++.

Re: My Struggles with Rust

#153

One thing I've found with rust is that you struggle struggle struggle trying to do a simple task, and then finally someone says "Oh, all you need to do is this". Rust has already reached the point where it leaves the world behind. Only the people who have been there since the early days really understand it, and getting into rust gets harder and harder as time goes on. Yes, there's some awesome documentation, and the…

How is this problem solved for C++?

It changes slightly more slowly (written reference books aren't immediately out of date) and there are far more practitioners answering stack overflow questions :-).

Re: My Struggles with Rust

#154

Earlier quoted context omitted.

The author was using this as an opportunity to learn Rust so while it might look sort of crazy to use a systems programming language for build failure notification there was a reason behind their decision. Nim is a lovely language but in the author's case he doesn't really care about speed for the use case so if they were being strictly pragmatic they could have just stuck with Python.

What!! Just as I was responding another of my hard earned points got deducted Who are these mean Rustaceans? Is Nim considered such a threat to Rust?

Your post provided no content. Why should I even look at nim? I don't have time to look at every new language that comes along.

Re: My Struggles with Rust

#155
post #2

These struggles are real. I don't see a way around them other than just learning them (and then they go away, because you know what code won't work, and don't fight it). It's probably because Rust looks and operates mostly like a high-level language, but still satisfies low-level constraints. e.g. the confusing difference between `&str` and `String` is equivalent of C's `const char * str = ""` vs `char * String = mal…

The was an easy solution that he failed to use. His return type could have just been Result> and he could've used try!/? freely

Re: My Struggles with Rust

#156

One thing I've found with rust is that you struggle struggle struggle trying to do a simple task, and then finally someone says "Oh, all you need to do is this". Rust has already reached the point where it leaves the world behind. Only the people who have been there since the early days really understand it, and getting into rust gets harder and harder as time goes on. Yes, there's some awesome documentation, and the…

(someone recently told me that they were working on just that -- a cookbook -- for common rust tasks. Let's see!)

Re: My Struggles with Rust

#157

> import json > with open("config.json") as f: > contents = f.read() > config = json.loads(contents) translates to: extern crate serde_json as json; fn read_json() -> Result > { let file = std::fs::File::open("config.json")?; let config = json::from_reader(&file)?; Ok(config) } And > import configparser > config = ConfigParser() > config.read("config.conf") can be translated to: extern crate config; use config::{Conf…

I think this highlights that while there are easy solutions to the problem the OP faced, they're difficult for a newcomer to discover. (I have been using Rust for a couple of months and I'd also have reached for serde and maybe serde_derive to solve the problem). Hopefully this is something the Libz Blitz[0] will solve with their Rust Cookbook[1]. (You could almost but not quite arrive at as simple a solution from ch…

The curious thing is that OP linked to the error handling docs, and the solution with Box is right there.

Re: My Struggles with Rust

#158
post #31

Hello Justin Turpin! Sorry to hear your struggles with rust. It's always going to be a bit more verbose using rust than Python due to type information, but I think there are some things we could do to simplify your code. Would you be comfortable posting the 20 line code for us to review? I didn't see a link in your post. Anyway, so some things that could make your script easier: * for simple scripts I tend to use the…

I cant even opt out of using exceptions? Good thing I didn't waste my time with this lang.

Re: My Struggles with Rust

#159
post #5

Being able to port a 20 line Python script to a 20 line Rust is the holy grail. Surely Rust has the ambition to one day achieve that, but it is by no means the main priority nor the original design goal of the language. Justin criticizes the file_double function, it being complex with nested maps and conditionals. All of this complexity is also in the Python code, just hidden away in abstractions, the library and the…

Too much kool-aid. Most programmers are not writing system code and they'd be much better served with languages like Go, Nim, and D. In fact, the example the author is trying to port over would have been much easier in Nim.

The actual question is then about the author learning a new paradigm and way of expressing system code. If that is the case these are just pains he has to go through because Rust will never be like Python for quick and dirty scripts, nor should it be.

Re: My Struggles with Rust

#160

Earlier quoted context omitted.

> The one exception to this is that, recently, there has been a surge in use of crates like error-chain to cut down on the code you need to write for defining custom error types and their corresponding `From` impls. But it's still all built on the same fundamental building blocks. One takeaway I got from playing around with Rust (and using GitHub code search to work through my issues) was that coding style will proba…

We are actively working on rustfmt, which should add some consistency overall. Some people won't use it, of course, but many have said they will.

The kind of 'coding style' that is varying here is probably more in the domain of Clippy than rustfmt. But there are people working on that too!
Post reply on HN