top | item 47077509

(no title)

majorchord | 10 days ago

Syntax is what keeps me away from Rust. I have tried many times to get into it over the years but I just don't want to look at the syntax. Even after learning all about it, I just can't get over it. I'm glad other people do fine with it but it's just not for me.

For this reason (coming from C++) I wished Swift were more popular because that syntax is much more familiar/friendly to me, while also having better memory safety and quality of life improvements that I like.

discuss

order

rtfeldman|10 days ago

Wow, this is one of the most surprising comments I've ever read on HN!

Personally, I bucket C++ and Rust and Swift under "basically the same syntax." When I think about major syntax differences, I'm thinking about things like Python's significant indentation, Ruby's `do` and `end` instead of curly braces, Haskell's whitespace-based function calls, Lisp's paren placement, APL's symbols, etc.

Before today I would have assumed that anyone who was fine with C++ or Rust or Swift syntax would be fine with the other two, but TIL this point exists in the preference space!

zahlman|10 days ago

There are a lot of important points of difference. Whether functions are introduced with an explicit keyword; how return types are marked; whether semicolons can be omitted at end of line; how types are named (and the overall system for describing algebraic types). Not to mention semantics around type inference (and whether it must be explicitly invoked with a `var` or `auto` etc.) and, again, algebraic types (what means of combination are possible?). And specifically with Rust you have the syntax required to make the borrow checker work. Oh, and then there are the implicit returns. Rust certainly didn't invent that (I seem to recall BASIC variants where you could assign to the current function name and then that value would be returned implicitly if control flow reached the end), but it reflects a major difference in philosophy.

... Which is really all to say: different people are focused on different details, at different levels.

g947o|10 days ago

Swift's syntax may look nice, but as soon as you run into "The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions" you'll forget all of that. Hint: they are related.

O-stevns|10 days ago

It didn't have to be like that though... It hasn't always been this bad. Personally I think they've been ruining Swift since version 4.

It's particularly terrible in SwiftUI context nowadays but you can also make it chuck on something as simple as a .map(...)

cfiggers|10 days ago

Definitely second this sentiment. Rust just... Looks wrong. And for that reason alone I've never tried to get into it.

I understand exactly how shallow that makes me sound, and I'm not about to try and defend myself.

O-stevns|10 days ago

No need to defend yourself, I share this sentiment as well. If I'm going to spend time writing and reading a lot of code in a new learning language, I want my previous knowledge to be somewhat reusable.

For this reason I was able to get into Odin as opposed to Zig because of some similarities with Swift Syntax as well how easy it is to parse.

The less I need to rewire my brain to use xyz language, the greater the chance of me getting into it.

If my life depended on it, I could get over such a shallow reason to dismiss a language but fortunately it doesn't and that's why I write Swift rather than Rust.

tialaramex|10 days ago

Do you have some examples of what you couldn't get along with? I know this is a lot to ask, but to me while I do write Rust and I don't write C++ or Swift in volume (only small examples) the syntax just doesn't feel that different really.

If you do like Swift you might want to just bite the bullet and embrace the Apple ecosystem. That would be my recommendation I think.

rrgok|10 days ago

This resonate so much to my relationship with Rust. Also with Go. I'm having hard time learning Rust's advacend concepts because of its syntax.

Strangely enough I find Lisp's parentheses much more attractive.