Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I really wish we could build iOS/Cocoa apps in Rust. Like Swift, we could use reference counting instead of GC, but Rust has a much nicer type system.


For years and years I've really thought ios/macos should support scripting languages to build apps.

For instance, why can't you build an app that does something useful in python or bash or perl?

The way I see it:

- applescript is not good

- cocoa and swift require compilation and generally xcode

- there are hacks that let you do a thing or two through osascript (back to applescript anyway)

- there are other hacks like PyObjC or python with tk, not really useful


I think you're spot on, in that a lot of iOS/macOS is gluing together existing components, very much like a scripted-components/Software-IC[1] pattern. For most of this, a scripting/coordination language would be great.

However, it needs to be interactive, not require the same (if slightly faster) Xcode build cycles. Also, most of those languages interoperate only partially.

My crack at this is Objective-Smalltalk[2]. It can script interactively [3][4] and is a full-fledged programming language.

[1] https://blog.metaobject.com/2019/03/software-ics-binary-comp...

[2] http://objective.st

[3] https://www.youtube.com/watch?v=sypkOhE-ufs

[4] https://www.youtube.com/watch?v=sypkOhE-ufs


Swift's type system was designed to make developers happy, Rust's to make the borrow checker happy.

As it turns out, some people think like a borrow checker and don't have any issue with Rust's choice. But most don't and we should not make them miserable.


Well, really it was designed for ObjC interop. Hence the limits on (e.g.) generic protocols.


Make some developers happy*

The tradeoffs swift chooses make a lot of sense for mobile app development.


Swift's type system is pretty similar to Rust's (especially with recent proposals covering existentials), but without lifetimes.


What do you think is nicer about Rust's type system?

IMO Rust's type system is more principled but does much less for you, and so is more annoying to use. As a simple example, incrementing a reference count in Rust requires a clone() call; in Swift this happens automatically.


Last time I checked out Swift, I ran into some annoying issues with type erasure and generic protocols (similar to the issues Java has, where one class can't be both Iterable<Integer> and Iterable<String>).

I also find Swift's "inout" params deeply confusing (especially when aliasing is involved), and I wish it made dynamic dispatch more explicit (like Rust).


What would e.g. `view.superview` look like in Rust though? That seems to be the main sticking point. In UI programming it is common to walk up, down, and around the view hierarchy.


I actually think that allowing this sort of traversal is usually a bad thing, but it can always be solved with Rc<T> and Weak<T> in Rust.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: