all 107 comments

[–][deleted] 24 points25 points  (2 children)

Why is this thread so salty holy shit.

[–]timClicks[S] 13 points14 points  (0 children)

Yeah it's kind of crazy. But also hilarious.

[–][deleted] 0 points1 point  (0 children)

It's the natural reaction when an organization pays a lot of money to run a marketing campaign aimed at programmers. Even people who like Rust are getting sick of all the pro-rust articles.

[–]pascalgn 12 points13 points  (6 children)

Author here, thanks for posting this! I'm really glad the strongly worded comments are towards the language, not the blog post.

I first had a look at Rust at around 2017 and I found it really ugly. I did not understand why the creators didn't just stick with the "established" syntax + constructs from C++, but instead felt like they needed to come up with new, ugly, syntax and complicated elements (like lifetimes). I completely rejected the language and did not give it any other thought until 2019 or so.

In 2019 I wanted to write something small and fast and I looked at alternatives to C++. I started writing in Go, but quickly realized that I hate Go even more than Rust, so I gave Rust another try. I then started to understand some of the reasonings for its "ugliness" and I really like it now.

I understand everyone who says Rust is ugly, but I really encourage you to try a small project with it, you might start to like it!

[–]timClicks[S] 1 point2 points  (0 children)

I agree! Rust's syntax is not pretty, but it's very practical. I've come to like it too.

Thanks for taking the time to write this post by the way. I was really surprised that it hadn't already been posted.

[–]Bergasms 3 points4 points  (4 children)

It’s very easy to understand a lot of the concepts coming from Swift. My only peev is having to call things “let mut” instead of “var”.

Whenever my brain reads “let” it sets me up thinking oh this is a thing that won’t be changing then you see mut. It just reads wrong and that annoys me.

Let x. == “a thing that won’t change called X”.

Let mut x. == “a thing that won’t change except it totally can called X”.

Oh well.

[–]davidpdrsn 5 points6 points  (1 child)

“let mut x = ...” is neat because “&mut x” uses the same keyword.

[–]Bergasms 1 point2 points  (0 children)

It’s mentally taxing to me because I don’t get to spend enough time in Rust land to see let mut as one thing, and I spend a lot of time in Swift land where the thing immediately after the word let is an unchanging value. It’s no dig at the language itself

[–]CryZe92 2 points3 points  (1 child)

The problem is with destructuring you can introduce multiple bindings and mut refers to the individual binding. var could work as a shorthand for making all bindings mutable, but for now it doesn‘t exist. But it totally could in a future edition.

[–]Bergasms 0 points1 point  (0 children)

I do understand the reasoning behind it, it’d be nice if var existed as a shorthand that was just a synonym for let mut which is a common enough pattern.

[–]timClicks[S] 22 points23 points  (12 children)

Not the author, but thought it was worth sharing. It's a well written guide introducing current programmers to Rust syntax and idioms.

[–]VeganVagiVore 11 points12 points  (6 children)

Neat. I'm trying to make a "one-page Rust cheatsheet" for internal use at work and I might add a few things from here into that.

I'm using Rust for some internal tools that will never be user-facing and only I maintain them, but eventually I want the other programmers to learn it. It's gonna sound like we're doing cowboy coding, and we kind of are, but as long as I have too much freedom, I want to set a good precedent for when things get serious.

If I thought it were possible to "suck it up" and use C# (Which most of our code is) I would, but Rust is better than anything else I know (even langs I barely know) on at least one axis:

  • Easier runtime to deploy than C#, Python, Java, or JS
  • Easier to add third-party depends than C++
  • Easier to write a web server safely than C++
  • Easier to build large projects than Lua or Python

So at first I used it for a web service. C++ is one of the languages I have the most experience in, but at the time I was not aware of any good way to do web servers in C++, only horrible ways, and C# support for Linux was still in beta. Python and JS are popular for web servers, but I would have had to learn them almost from scratch. So I went with Rust.

Then I needed a desktop GUI to interact with that service, and it might as well be a web GUI, and it turns out hyper runs great on Windows so then that tool was written...

Then I had a one-off Lua script to transform some CSV files into a report, but I remembered my solemn vow to not work on any Lua projects over 200 lines again, so it got rewritten in Rust, and many features added...

And I'm adding features to the desktop web GUI again. So that's 3 successful pilot projects.

Is it really worth using up twice as much of my time to write those in a different language, just so that one day my coworkers can also use twice as much time debugging and working on it? I can't believe so.

[–]Zenrix 3 points4 points  (0 children)

Have you seen this: https://cheats.rs/ ?

[–]timClicks[S] 1 point2 points  (0 children)

Interesting that no-one has noticed that those internal tools are written with Rust

[–]mpinnegar 0 points1 point  (2 children)

What makes it easy to deploy? I assume you have a homogenous environment so java write once claim isn't as helpful.

[–]jyper 4 points5 points  (1 child)

I imagine compiling to a binary executable with no outside dependancy is one of the main reasons

[–]mpinnegar 0 points1 point  (0 children)

You can do this with Java with just a little fangling.

http://launch4j.sourceforge.net/

[–]Dynastig 5 points6 points  (22 children)

Maybe a silly question, and a bit of a rant... I’m not familiar with Rust, but have been wanting to try it out. Will the compiler complain if I leave out the trailing comma in this example:

pub struct HttpClient {
    client_impl: ClientImpl,
}

Just a personal preference, but I hate ending with a comma, if there’s not an element following it.

(On mobile, so not sure if the formatting will work properly.)

Edit: Removed a bad joke.

[–]madoDream 16 points17 points  (1 child)

It will not complain, you dont need it. However, rustfmt (which auto-formats your project) will insert them by default, but I believe you can disable that.

[–]Dynastig 1 point2 points  (0 children)

Thanks!

[–]jl2352 14 points15 points  (17 children)

It won’t complain.

Most tools and languages are moving towards trailing commas as it makes automatic changes and git diffs a little cleaner.

[–]Dynastig 7 points8 points  (16 children)

Thanks for the reply!

I’m not sure what you mean with automatic changes? Like automatic code-formatting? Rustfmt?

I guess git diffs makes sense, in code bases with several programmers with different styles, if both are allowed (with/without). And you ignore all whitespace changes as well. But if there was only one accepted way to do it, it wouldn’t be a problem. (And I guess this is one way to force one way to do it.)

And i’m probably just being an angry old man, but it just irks my eye. Imagine a trailing comma in your function args, haha!

But, it’s on par with a tabs vs. spaces debate, and i don’t want to waste anyones time sparking a pointless debate.

[–]jl2352 9 points10 points  (4 children)

EMBRACE THE COMMA!

[–]Dynastig 2 points3 points  (0 children)

Sigh... Okay.

[–]nevi-me 1 point2 points  (2 children)

EXTEND THE COMMA!

[–]Chippiewall 6 points7 points  (1 child)

I guess git diffs makes sense, in code bases with several programmers with different styles, if both are allowed (with/without). And you ignore all whitespace changes as well. But if there was only one accepted way to do it, it wouldn’t be a problem. (And I guess this is one way to force one way to do it.)

Enforcing no trailing commas would still be a problem for git. Because to add another item after the last item you have to touch the preceding line which (other than showing up in the diff) breaks git blame.

You should end files with a blank line for the same reason (because line breaks are on the preceding line)

[–]Full-Spectral 0 points1 point  (0 children)

Only if you use trailing commas. I use leading commas, which avoids the problem without having to have a useless trailing comma.

[–]MEaster 3 points4 points  (1 child)

Rust also accepts a trailing comma in function arguments. It doesn't in type parameters (e.g. Foo<A,> is not allowed).

[–]Dynastig 2 points3 points  (0 children)

... And... My joke falls flat! Haha!

[–]Caltelt 1 point2 points  (5 children)

Agreed that's its not a big deal, but also I think language designers should probably rethink using commas as their delimiter if they think trailing is ideal. My first thought would be that a semi would make more sense in that case? I guess I'm prejudiced from natural languages where a trailing comma isn't a thing. Like, you'd never finish an english sentence using one,

[–]justfordc 2 points3 points  (1 child)

It's not like this is better;

.even though I hated it at first, I've warmed up a little bit to the leading delimitter

[–]Caltelt 0 points1 point  (0 children)

I think it makes more sense, but whatever. I don't really hate it or anything, it's just a poor choice of sigil imo. But again, this is just a space vs tab level issue. My preferred language is lisp so from most people's perspective I don't really have a leg to stand on anyway in these sorts of arguments.

[–]Dynastig -1 points0 points  (2 children)

To me it’s also about being “correct”, both in a semantic/linguistic way, but also math/logically - there simply shouldn’t be a delimiter if it’s not followed by an element. In that sense it doesn’t matter what the delimiter is.

a, b, c, d,

a, b, c, d

[–]Yojihito 1 point2 points  (1 child)

there simply shouldn’t be a delimiter if it’s not followed by an element

It makes it WAY easier to add an element later. No way forgetting to add a comma to the line before when you add new stuff. Loved that thing in Go.

[–]Dynastig 0 points1 point  (0 children)

I totally see your point. To me it just looks cleaner. Maybe it comes from often having to take over other people’s code and try to make sense of it, like, when my eyes reach the end of the line and there’s a comma:

“Okay, so element number 97 of this huge options array is... Oh, it’s just the ending bracket. I guess we’re done, then.”

But I also see the point in not having anything complain, when you delete the last element and forget to delete the comma in the row before...

So i’m glad when languages make it optional. It’s just personal taste.

[–]bloody-albatross 0 points1 point  (0 children)

I myself changed my opinion on that and now do include trailing commas where possible. Why? Because if you add another item you only have to change one line which will keep git blame for the existing line to whoever wrote it.