Live data from Hacker News

Swift is a more convenient Rust

blog.namangoel.com

161–170 of 318 posts

Re: Swift is a more convenient Rust

#161

Hmmm...I disagree with a number of statements in the post but I think the following two hypotheses will make for more interesting discussion than some nitpicks: 1. A large part of why many people love Rust is that it's the first time they've used an ML family language. One of the innovations of Rust was to create a community that felt like home to Unix hackers who weren't programming language nerds. 2. Rust is the fi…

> The age of Smalltalk is over. It's now the age of ML [...] The languages that dominated the 2000s (Ruby, Python, Javscript, PHP) were all more or less derived from Smalltalk [...] The new languages (Rust, Scala, Swift, Kotlin, etc.) are ML family languages.

What drew people to a lot of your examples (Javascript, PHP especially) was the runtimes rather than the language features. Your example sets aren't just demarcated by Smalltalk-ishness/ML-ness but more by runtime type (Scala & Kotlin are odd examples given the VM but for the most part your latter examples have build-time compilation while the former have plaintext interpreters).

We're definitely in a tools-heavy era of programming where, unless you're writing bash scripts, even very basic applications in interpreted languages are layered with a slew of transpilation/compilation/etc., but generally speaking I still don't see the majority of people moving wholesale away from plaintext runtime interpreters. Where are the ML-ish competitors in that space?

Re: Swift is a more convenient Rust

#162

Earlier quoted context omitted.

Also true! And in very real sense literally what I meant. But not so much in the conditional branch sense of the phrase “control flow”. More like, I’ve got a bunch of references and one of them is a reference to a function I might evaluate, damn, I need that reference and the transitive closure of everything it knows about, all of which are probably on the heap.

The proper name for this is a "space leak". Also known as: "you wanted a banana, but what you got was a gorilla holding the banana and the entire jungle". This is of course pretty much the opposite of low-level "performance" - and it's also the kind of problem that tracing garbage collection was actually designed to address when first developed.

Fake news and FUD and other balderdash.

A space leak, much like any memory leak is when you or the compiler or the runtime or whoever misplaces such reference.

GHC having a closure in scope in no way immediately means there is a space leak. Plenty of Haskell code that compiles to thunks will run all day in an amortized fixed-size heap.

Much like Erlang, which is what Joe Armstrong had designed before he said the thing about jungles you’ve quoted.

And it is in no way difficult or even really rare to drop an Arc in a table and leak all over the place.

Rust has all the same computer science problems as anything else. Full stop.

Re: Swift is a more convenient Rust

#163
post #57

I keep trying to get into rust but I always hit a brick wall when looking at examples and the code looks so complicated. Examples like this straight from the rust website just make my eyes glaze over struct Task { future: Mutex >>, task_sender: SyncSender >, }

Honestly that one I can read (I am just now in earnest trying to learn Rust). What I've been banging my head into is trying to get a suite of boilerplate libraries together to make basic things happen. Got directed from slog to tokio-tracing for logging, so dove into setting up my basic "--log-level", "--log-format" CLI options I add to every non-trivial program in Rust and ran into...whatever is going on with config…

Not just you. Best case the tracing ecosystem is weird and the documentation is lacking, but all of the weirdness makes it very performant. Worst case it is weird and badly documented and over-engineered.

Since rustc uses tracing I really hope it's the first...

Re: Swift is a more convenient Rust

#164

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!

The difference is that Microsoft very intentionally decided it was going to make .NET cross-platform as a strategic play. Apple has recently shown a willingness to get out of the way of cross-platform Swift, but I haven't yet seen evidence that they're throwing any significant weight behind it. They have an even worse track record than Microsoft did of investing heavily in locking developers into their ecosystem, so I'll have to see quite a bit of evidence to believe they're actually serious about cross-platform Swift.

Re: Swift is a more convenient Rust

#165
post #157

Always, when I read those postings that praise Swift, I wonder how good is the developer experience is if you don't use any of the Apple/MacOS ecosystem (except Swift, of course). I have not met any Swift developer who is not developing on macOS, usually for macOS. That makes me very skeptical that non-Mac devs are treated as second-class citizens. I am not only talking about the standard library, but also about the…

I recently went through the Swift tutorial for building a REST API using Vapor[0]. I used VSCode, compiled and run on Ubuntu. It’s the only Swift I’ve ever written, and obviously far from a production app, but I did enjoy it enough that it made me want to continue playing with Swift outside of the XCode/Mac ecosystem. [0]: https://www.swift.org/getting-started/vapor-web-server/

Re: Swift is a more convenient Rust

#166
post #157

Always, when I read those postings that praise Swift, I wonder how good is the developer experience is if you don't use any of the Apple/MacOS ecosystem (except Swift, of course). I have not met any Swift developer who is not developing on macOS, usually for macOS. That makes me very skeptical that non-Mac devs are treated as second-class citizens. I am not only talking about the standard library, but also about the…

And even on MacOS you are limited - you cannot avoid not using Xcode pretty much. So in practice you cannot just only use VSCode or Jetbrains IDEs. There is been a talk in WWDC 2024 that apple invest with Swift for embedding systems and some language servers but not sure how mature it is. Apple doesn't have crossplatform in their DNA.

Re: Swift is a more convenient Rust

#167

Earlier quoted context omitted.

Why should every language occupy the same design space? Rust was shaped by Mozilla wanting a language to replace parts of Firefox with. A language that is low-level enough to give very high performance, enforces correctness through the type system, and yet has many abstractions so it feels modern and convenient to use. Rust doesn't have any automatic allocations. You can wrap every type in `Arc >` and treat it like a…

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 Evangelism Strike Force". Rust people I've interacted with strike me as very much more accepting of the "better tool" theory than of some weird cult or panacea. When somebody in a Rust forum says (e.g. about JPEG XL) "Ooh we should use Rust" and I say "No, WUFFS. This problem is what WUFFS is for" the responses tend to be a mix of "Yeah, I guess" and "I didn't know that existed. Thanks for the link" rather than cultist denial.

Re: Swift is a more convenient Rust

#168

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?

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.

Re: Swift is a more convenient Rust

#169
post #69

Earlier quoted context omitted.

Is upgrading every 5-6 years to be able to write code considered normal in the Apple world? I'd been comfortably writing code in several languages using latest toolchains on a decade-old Intel machine just a few months ago, and was forced to upgrade because one of the components died. Otherwise I'd be using it for at least five more years.

I don't see why would anybody complain that the tools they bought 10 years ago don't magically do the things that the new tools are doing. It's not like the old tools stopped doing the things they do, right? Anyway, you sel the old machine and get the new one is pretty normal as the Apple devices tend to hold value.

We are talking about Software though.

It's not really sustainable to throw buy new stuff all the time when there's not a technical reason for it

Re: Swift is a more convenient Rust

#170

I keep trying to get into rust but I always hit a brick wall when looking at examples and the code looks so complicated. Examples like this straight from the rust website just make my eyes glaze over struct Task { future: Mutex >>, task_sender: SyncSender >, }

It's not just you, I watched yesterday [1] that Bun's author initially tried to use Rust but wasn't as productive. Then he switched to Zig and here they are, innovating JS/TS landscape.

[1] https://www.youtube.com/watch?v=eF48Ar-JjT8&t=670s

Post reply on HN