Live data from Hacker News

Swift: Things I really wanted that won’t make it

ericasadun.com

51–54 of 54 posts

Re: Swift: Things I really wanted that won’t make it

#51
post #46
post #9

Earlier quoted context omitted.

Idiomatic Swift is primarily protocol-based, object-orientation is mostly used when talking to the Cocoa frameworks, which aren't idiomatic Swift code. But the main problem with subclassing is: https://en.wikipedia.org/wiki/Fragile_base_class

Objective-C (and Swift) don't have the fragile base class problem: http://www.sealiesoftware.com/blog/archive/2009/01/27/objc_e...

They don't have it for ivars, but that's just one potential problem.

Re: Swift: Things I really wanted that won’t make it

#52

Earlier quoted context omitted.

> "functional" (which means it has immutable values I guess?) No, it means that it's a functional language. Please consult google if you are not sure what that means. > "pretty good type system" (which means it has generics?) No, it means that it has a more advanced type system than any of the languages you mentioned. It's most likely the most popular language with a type system that can be considered somewhat advanc…

It's not a functional language: http://robnapier.net/swift-is-not-functional Please inform me what Swift's type system has over, say, Java as I don't know of anything and neither does a cursory Google. The lack of an HTTP server is only an example. Let's see you parse JSON, or stream a Unix socket, or any of countless basic things that even Node includes in its standard lib. Swift doesn't really have much of anything…

The Foundation libraries provide that functionality, they're not core to the concept of a programming language, so they're not part of the minimal standard library. There are also numerous community provided implementations.

One way that Swift's type system is more advanced than Java is the ability to define extensions to protocols (interfaces) constrained to specific types, i.e. you can add "average" to "SequenceType where Generator.Element == Double". You can also use this to provide default implementations for protocols, but only in the case of specific associated types.

Re: Swift: Things I really wanted that won’t make it

#53
post #43

Swift is not perfect but I've been writing it a bunch recently and it's hands down one of the most productive languages I've written in. Fundamentally I believe that it might be one of the most important languages because it's relatively close to the metal, it's a 'modern language' (i.e. functional, has a pretty good type system), open source, and a major company and platform behind it. I think that if Swift 4.0 adds…

And you gotta love the Swift REPL :)

As a longtime lisp developer I thought I'd love the REPL, but so far I really haven't had much use for it. I find myself using playgrounds quite a bit though.

Re: Swift: Things I really wanted that won’t make it

#54

Earlier quoted context omitted.

I don't have any experience with Swift, but how to you approach unit testing with everything `final`? Being able to inject mock subclasses is a staple of OO testing.

I don't know Swift, but I know I testing... your constructors should be accepting interfaces (for things that are complex enough that you'd want to mock them), not concrete types. In Swift I gather you'd use protocols.

Shrug... at least in the Java world, modern mocking frameworks render obsolete the J2EE-era "interfaces for the sake of interfaces" boilerplate. On the other hand, none of them work if the class you're mocking is `final`.
Post reply on HN