News for hackers. Stuff that matters.
Re:Rust in Android: move fast and fix things by mk89 on Thursday November 13, 2025 @03:56PM (#45920425)
I cannot like Rust syntax, sorry.

For me the ideal syntax is C/Go, just to be clear what I like.

But I agree that the tooling that cargo introduced is a breath of fresh air in a world dominated by huge makefiles, libraries copied in the repository (I know, there is Conan, vcpkg etc)...

Re:Rust in Android: move fast and fix things by dontlaugh on Thursday November 13, 2025 @04:25PM (#45920763)
All three have very similar syntax when compared even to something like Python or Ruby, let alone ML or Haskell. Seems like a spurious complaint.
Re:Rust in Android: move fast and fix things by gf000 on Thursday November 13, 2025 @05:24PM (#45921476)
I mean, Rust is quite a different category than C or Go, if this is the 3 languages you reference.

Rust has plenty of syntax coming straight from ML (okay, not straight, probably through OCaML)

Pattern matching, destructuring, expressions everywhere, etc are stuff that C/Go never even heard about.

Re:Rust in Android: move fast and fix things by baq on Thursday November 13, 2025 @04:38PM (#45920940)
No need to like it. It isn’t brainfck and does the job.
Re:Rust in Android: move fast and fix things by MBCook on Thursday November 13, 2025 @04:54PM (#45921117)
I don’t disagree, that’s part of why I like Swift so much. Rust looks very C++ to me.

But if I was working in C++ and had a choice of C++ or Rust, I’d go Rust based on this.

Re:Rust in Android: move fast and fix things by mk89 on Thursday November 13, 2025 @04:58PM (#45921166)
Agree! Swift I forgot to mention. What a nice and elegant language.
Re:Rust in Android: move fast and fix things by claudiug on Thursday November 13, 2025 @04:59PM (#45921175)
in the beginning I also hate it, but now is fine.
Re:Rust in Android: move fast and fix things by guywithahat on Thursday November 13, 2025 @05:16PM (#45921368)
Go is such a great language. If your code base doesn't mind garbage collection and doesn't depend on some external library, everyone should really look at go. Great multithreading, memory safe, great error handling, and a familiar syntax for people coming from C++/Java/etc.
Re:Rust in Android: move fast and fix things by mkehrt on Thursday November 13, 2025 @05:46PM (#45921692)
> great error handling

Go get this completely wrong! It use a tuple rather than an enum for potential errors. This means you can forget to check errors and just use the invalid (nil?) return value from the function.

On the other hand, rust uses the Either enum to force you to handle the error. Alternatively you can use the ? operator to pass it to the calling function, which is reflected in the enclosing function's type.

Re:Rust in Android: move fast and fix things by ikety on Thursday November 13, 2025 @05:54PM (#45921803)
Yep Rust approach won. Pretty much every new language is adopting Result style errors and it's been adapted to plenty of existing languages.

It's a product of functional programming, and for me I can't see how you would ever want to handle errors outside of the functional programming railway-oriented style. For me it's just superior.

Re:Rust in Android: move fast and fix things by tczMUFlmoNk on Friday November 14, 2025 @12:54AM (#45924268)
Umm, actually, it's specifically a coproduct of functional programming. ;-)

https://en.wikipedia.org/wiki/Coproduct

Re:Rust in Android: move fast and fix things by ikety on Friday November 14, 2025 @09:47AM (#45927226)
Ha learned something
Re:Rust in Android: move fast and fix things by Mond_ on Thursday November 13, 2025 @06:19PM (#45922013)
Pet peeves nitpick: it's not even a tuple. Go doesn't have tuples. It just has special-cased "multiple return values", which means that it's often impossible to just stuff the return of a function call (error value and all) into any data structure to aggregate them. You just can't do without first defining a struct since tuples don't exist in Go.
Re:Rust in Android: move fast and fix things by tuetuopay on Thursday November 13, 2025 @07:06PM (#45922328)
How is Go memory safe? Memory safety does not mean "leaking memory".

It's absolutely possible to compute wrong pointer offsets. It's absolutely possible to dereference nil. It's absolutely possible to bork ownership and have multiple thread trample a struct. It's absolutely possible to reinterpret memory the wrong way.

I do agree that UAF is not possible (in most cases) due to the GC. That array indexing out of bounds is not possible. But it is by no means "memory safe" to the level Rust is.

Re:Rust in Android: move fast and fix things by gpm on Thursday November 13, 2025 @08:04PM (#45922694)
> It's absolutely possible to bork ownership and have multiple thread trample a struct.

This is specifically the one place where go is not memory safe IMO.

> It's absolutely possible to compute wrong pointer offsets.

In Go? Without the `unsafe` package (at which point you are explicitly opting out)? How? There's no pointer offset in the first place.

> It's absolutely possible to dereference nil.

Yeah, but that's safe defined behavior in go equivalent to "unwrap"ing a None option in rust. It reliably crashes. It's not like C where it's undefined behavior and you might crash of you might just corrupt random memory or have the optimizer make your code do something even stranger.

It's (really the lack of non-nil types) is one of many reasons why go doesn't produce as reliable software as rust, but it's not a memory safety issue.

> It's absolutely possible to reinterpret memory the wrong way.

Again, without the unsafe package? How?

Re:Rust in Android: move fast and fix things by uaksom on Thursday November 13, 2025 @08:48PM (#45922935)
Re:Rust in Android: move fast and fix things by gpm on Thursday November 13, 2025 @09:51PM (#45923342)
Right, that's the first category, "It's absolutely possible to bork ownership and have multiple thread trample a struct" resulting in undefined behavior.
Re:Rust in Android: move fast and fix things by tuetuopay on Friday November 14, 2025 @05:04AM (#45925500)
My Go is a bit rusty (pun intended), so I may have misremembered, especially with the pointer offsets. (just googled it, I did remember it, sorry for the confusion).

>> It's absolutely possible to reinterpret memory the wrong way. > Again, without the unsafe package? How?

Again my go is rusty, but I saw quite a bit of shenanigans in go with pointer casting from what's essentially a collection of void*. However perhaps those casts blow up at runtime? I'm too used to rust where it's explicit where it'll blow up.

>> It's absolutely possible to dereference nil. > Yeah, but that's safe defined behavior in go equivalent to "unwrap"ing a None option in rust. It reliably crashes. It's not like C where it's undefined behavior and you might crash of you might just corrupt random memory or have the optimizer make your code do something even stranger.

Agreed. I conflated "safety" and "robustness" here. The existence of nil is a thorn in the language.

Thanks for the corrections!

Re:Rust in Android: move fast and fix things by rascul on Thursday November 13, 2025 @08:01PM (#45922675)
Rust doesn't consider leaking memory to be unsafe.
Re:Rust in Android: move fast and fix things by tuetuopay on Friday November 14, 2025 @05:06AM (#45925515)
I mentioned it because I often hear people (not in this thread though) that thanks to its GC preventing memory leaks, Go is memory safe. The GC's role in memory safety is preventing dangling pointers though.
Re:Rust in Android: move fast and fix things by Zambyte on Thursday November 13, 2025 @06:43PM (#45922182)
Zig in spirit is essentially Go without GC. If GC is not reasonable for your usecase Zig seems like an awesome choice. Unfortunately it's probably about 5 to 10 years out from being stable enough for most people being able to write serious applications in it though (notable exceptions being Bun and Ghostty, but they have solid effort behind them keeping them up to date with Zig).
Re:Rust in Android: move fast and fix things by pjmlp on Friday November 14, 2025 @05:02AM (#45925492)
More like Modula-2 in C clothing, given the safety guarantees.
Re:Rust in Android: move fast and fix things by Zambyte on Sunday November 16, 2025 @09:22AM (#45945345)
If you're focusing on safety guarantees, sure. If you measure by safety checks included by default instead, it actually has more safety checks than Go (in particular, safety checked numeric operations for overflow).

The other big thing that makes it spiritually like Go is that you follow the same pattern of: allocate resource, immediately defer deallocation.

Re:Rust in Android: move fast and fix things by gf000 on Thursday November 13, 2025 @05:25PM (#45921486)
> If your code base doesn't mind garbage collection and doesn't depend on some external library, everyone should really look at go

I mean, at that point pretty much every language would be a decent choice.

Re:Rust in Android: move fast and fix things by tonyhart7 on Thursday November 13, 2025 @06:55PM (#45922261)
>mention Go

>great error handling

why people so confident being so wrong???

Re:Rust in Android: move fast and fix things by ViewTrick1002 on Thursday November 13, 2025 @05:31PM (#45921542)
> Great multithreading

Until you stumble upon the countless footguns. At least they generally don’t lead to memory unsafety, just garbage data.

Data Race Patterns in Go

https://www.uber.com/blog/data-race-patterns-in-go/

Re:Rust in Android: move fast and fix things by array_key_first on Thursday November 13, 2025 @08:41PM (#45922903)
Go has some of the worst error handling I've ever seen, even worse than most exception implementations IMO, and the type system is stupid enough that it's still very easy to write bugs. Go is only surface-level memory safe, you can definitely segfault in Go. And I mean real segfault, not nullptr dereference.
Re:Rust in Android: move fast and fix things by josephg on Thursday November 13, 2025 @06:16PM (#45921996)
> I cannot like Rust syntax, sorry. For me the ideal syntax is C/Go, just to be clear what I like.

I’m sorry if this comes across as dismissive, but I find it hard to take people seriously with complaints about syntax like this. Learning new syntax is really easy. Like, if you’re familiar with C & Go, you could probably learn all the syntax of rust in under an hour. The only surprising part of rust’s syntax is all the weird variants of match expressions.

Rust has some surprising semantics. Like how lifetimes work (and when you need to specify them explicitly). That stuff is legitimately difficult. But learning that if statements don’t need parenthesis is like - seriously whatever dude. If you want to spend your career never learning new stuff, software isn’t for you.

I picked up objective C about 15 years ago. The only thing most of my friends knew about it was that it had “that weird syntax”. It took no time at all to adjust. It’s just not that hard to type [] characters.

Re:Rust in Android: move fast and fix things by vacuity on Thursday November 13, 2025 @06:47PM (#45922211)
I'm very vocal that I don't like Python syntax, but I wouldn't refuse to write Python because of the syntax. If I had reason to write Python, I would grumble a bit but write the Python.
Re:Rust in Android: move fast and fix things by samdoesnothing on Thursday November 13, 2025 @08:27PM (#45922839)
It's not about learning syntax, it's about finding it generally tolerable to read. I personally find Rust syntax repulsive and would opt for a different language unless Rust was literally the only option. Thankfully it's never the only option, now or in the future.
Re:Rust in Android: move fast and fix things by josephg on Friday November 14, 2025 @05:11AM (#45925540)
Can you give some examples? Its hard to agree or disagree if you're not going to make any substantive claims.
Re:Rust in Android: move fast and fix things by cogman10 on Thursday November 13, 2025 @08:38PM (#45922888)
I'd say that rust has a weird level of being both verbose and terse in strange ways.

If you ever have to deal with lifetimes, then the verbosity goes up pretty significantly. And, dealing with pointers ultimately introduces multiple layers of concepts that you don't necessarily run into with C++/Go/Java.

Yet, with the type inference by default, rust can often feel shockingly terse. Doing collection manipulation is just as terse as any language you could imagine.

I think that's probably where complaints about syntax comes in.

C++ hides a lot of that complexity with move semantics, shorthands, autocoersion, and by making lifetime issues runtime problems. Languages like Go/Java/Python simply push everything onto the heap and try to avoid exposing low level memory semantics.

It's easy for me to see why someone wouldn't like rust. I think it's fine, but I'm also brain broken from perl and php.

Re:Rust in Android: move fast and fix things by josephg on Friday November 14, 2025 @12:15AM (#45924085)
> I'd say that rust has a weird level of being both verbose and terse in strange ways. If you ever have to deal with lifetimes, then the verbosity goes up pretty significantly.

I find rust generally more terse than both C and - especially Go, to which rust was compared upthread. Writing out lifetimes explicitly can be confusing. But I don't think it adds that much syntactic noise. Maybe 1/20 functions in my code have explicit lifetimes. That will confuse beginners, but I don't think its too bad once you're used to them.

> And, dealing with pointers ultimately introduces multiple layers of concepts that you don't necessarily run into with C++/Go/Java.

This is my #1 complaint about rust's syntax. If you ever need to interact with raw pointers within unsafe blocks, I feel like the language really fights you. It seems so strange, too - since unsafe blocks are exactly the place where it matters the most that my code is easy to read. Improving the syntax around pointers (for example by adding C's -> operator) would make unsafe blocks clearer.