Live data from Hacker News

Swift is a more convenient Rust

blog.namangoel.com

171–180 of 318 posts

Re: Swift is a more convenient Rust

#171
Does Swift make it as easy as Go or Rust to produce a single binary for any target platform? Would it be a good choice for a CLI application?

It sounds kind of intriguing but I know very little about the language.

Re: Swift is a more convenient Rust

#173

As someone that’s recently been working on integrating Rust into an iOS Swift app I do agree with a lot of this. I love Rust but the more I’ve used Swift the more I find myself wishing I was just using Swift all the time. That said , the difference between the two has a lot less to do with the language itself than the world surrounding it. You can use Swift cross platform but it’s very obvious that Apple platforms ar…

Swift is in its .NET Framework stage. I’m looking forward to Swift Core!

It might be too late. IMHO Microsoft also did transition too late and these days .NET is less relevant today than it used to be - even many microsoft apps are build using React Native or Electron.

Re: Swift is a more convenient Rust

#174

Earlier quoted context omitted.

> Rust's memory management is not automatic, you have to explicitly manage memory. It's just made extremely easy for you by the language thanks to stuff like RAII, and there is checks that prevent memory safety violations like double free. But those checks won't prevent leaks, although the many lints do make it harder to forget about a value. By this logic no language on earth has automatic memory management. I've sp…

Pointers in JavaScript? I’m far from a JS expert, but didn’t think the language had pointers. Could you explain what you mean here?

Most variables on JavaScript are (essentially) pointers. A common mistake people make in the language is keeping references to objects in a global map, which prevents them from being garbage collected (often a bad caching implementation).

You can use things like WeakMap or WeakRef as one solution, but there are usually better options

Re: Swift is a more convenient Rust

#175

Earlier quoted context omitted.

Pointers in JavaScript? I’m far from a JS expert, but didn’t think the language had pointers. Could you explain what you mean here?

I'm not aware of any mainstream language that doesn't have pointers, the question is whether they expose pointers as a first-class language construct (i.e. you can choose to not dereference them or to do pointer arithmetic) or use them as an implementation detail. In JavaScript's case it's an implementation detail, but one that is extremely relevant when maintaining something in production.

Makes sense, thanks!

Re: Swift is a more convenient Rust

#176

Earlier quoted context omitted.

I think Rust is cool! If it wasn’t actively seeking world domination I’d be like, cool let’s use that sometimes. Rust is so hell bent on a Rust monoculture ranging from stuff like TRACTOR to actively opposing interop that a few of us who know our shit have to be like “easy now” once in a while. I’m trying to decide between tiktoken and sentencepiece for a new vocabulary at the moment, and it would be easier in some w…

> If it wasn’t actively seeking world domination I’d be like, cool let’s use that sometimes. Hylo specifically says it intends "world domination" (next year in fact, having apparently completed all the delayed 2023 goals and also all its 2024 goals this year, I guess maybe they're going to do it all in December?) But I don't really see this from Rust. I'm sure Hylo's "world domination" is a joke, but, so is the "Rust…

Haha we’ve tangled before and in my experience when the Rust evangelism strike force is on the case discretion is the better part of valor.

I admire both the technical sophistication and passion you folks bring to the table, the one true language thing just isn’t my bag. I pine for the Halcyon days when HN was run by the Rust people rather than the LLM idiots.

Keep doing what you’re doing, one hacker to another.

Re: Swift is a more convenient Rust

#177
> But when you need extra speed you can opt into an ownership system and “move” values to avoid copying.

I've been using Swift a long time and don't quite get what this is referring to.

Also:

> Swift too gives you complete type-safety without a garbage collector.

Type-safety and memory-safety are two entirely different things; this is an odd sentence.

Re: Swift is a more convenient Rust

#178

Earlier quoted context omitted.

Also they probably have their understanding upside down. What's going on here isn't that either Swift or Rust treats the enum types as "more than just types" but that they are indeed first class types, whereas in C and C++ what you get isn't a type at all, it's just a strange way to spell an integer. I don't think Swift has union types, but Rust does and so does C++ and in both languages the unions, just like their m…

C++'s scoped enums are strict types.

They are still a long way from the features of enums in Swift.

Re: Swift is a more convenient Rust

#179

My interest in Rust stems from a very good Python interop. There's a very small handful of compiled languages with that property: Rust, C++, Nim (which is itself quite niche)... That's basically it as far as I know. Swift doesn't seem to tick that box. I would happily have something 50-100% slower than C++/Rust with good interop, alas there seems to be very little / nothing. Cython for various reasons isn't ideal.

There used to be Swift for Tensorflow but google killed it and then Chris Lattner created Mojo. AFAIR the punchline was that Swift was either too complicated for data scientists or they just preferred to use python that already knew.

Re: Swift is a more convenient Rust

#180

Earlier quoted context omitted.

> first language to bring non-GC automatic memory management to the mainstream ... Other languages in this space include Swift Ugh, “Arc”, aka (automatic) reference counting, is an implementation of GC as well. It may have certain characteristics, like having worse throughput, corner cases, and better predictability/latency characteristics, but it's GC nonetheless. That's not manual memory management. Swift is not a…

Both ARC and garbage collection are memory management techniques. ARC does not equal garbage collection though. Garbage collection runs at intervals and is triggered by certain signals (memory pressure, etc), pauses all threads and scans for objects that can be deallocated. It is a very different concept than ARC.

ARC is a method of implementing garbage collection, and is discussed as such in academic literature.

What you are equating with "garbage collection" is Mark-Sweep, which is an another way to implement GC, with a very different set of tradeoffs. (Broadly, better throughput at the expense of higher latency.)

Post reply on HN