Live data from Hacker News

My Swift Dilemma

owensd.io

1–10 of 129 posts

Re: My Swift Dilemma

#2
Great post. I'm not sure if it's because of my Objective-C bias or not but Swift just seems messy to me. Everything from how it's spaced and structured in the editor to how it's read. (Lack of headers, clear separations between data structures, methods..etc). Say what you want about Obj-C but it was damn organized.

Re: My Swift Dilemma

#3
I'm not sure I understand the point of his post.

In all the examples he gives Swift comes with better and more succint syntax plus more safety than Obj-C, and on par with his "Obj-C 3.0" idea.

And of course it has tons of other features and flexibility he doesn't delve into.

The whole post for me boils down to his "I hate Generics" rant at the end.

Re: My Swift Dilemma

#4

Great post. I'm not sure if it's because of my Objective-C bias or not but Swift just seems messy to me. Everything from how it's spaced and structured in the editor to how it's read. (Lack of headers, clear separations between data structures, methods..etc). Say what you want about Obj-C but it was damn organized.

Lack of headers?

What is this, 1975?

Re: My Swift Dilemma

#5
As he predicted, I was with him until his rant about generics. While the example he makes support his point, that's nothing specific to generics but instead to the implementation of generics. For example, he uses the following example as "bad" generics:

    func reverse(source: C) -> [C.Generator.Element]
and the following example as "good" non-generics:

    func reverse(source: CollectionType) -> CollectionType
However, you can have equally clean syntax with generics. For example, consider the hypothetical syntax:

    func reverse(source: CollectionType[a]) -> CollectionType[a]
in which `CollectionType` is parameterized by the type variable `a` [0].

I also take issue with the idea that removing static checks isn't a big penalty. In particular, I cringe a little at the following sentence

> Because it does not actually matter. If an Int gets in my array, it’s because I screwed up and likely had very poor testing around the scenario to begin with.

The benefits of static typing is that you don't need testing of things like that. The compiler guarantees safety, allowing you to avoid writing test case that are mundane and boring, such as checking that you don't put an Int into a String array.

The following paragraph also seemed questionable to me:

> Yes, in this example, I’ve moved the validation from compile-time to runtime. But you know what, that’s likely where many of these types of errors are going to be coming from to begin with because the content of the array is being filled in with dynamic content getting coerced into your given type at runtime from dynamic input sources, not from a set of code statements appending items to your arrays.

I think this is somewhat incorrect. You should never just be type-casting your inputs. (In fact, I think it should ideally be impossible to do so without the compiler generating really big flashing warnings saying "THIS IS DANGEROUS!"). The static verification here will prevent you from doing silly things, and should ideally force you to do input validation at the location of input, instead of blindly casting things to the type it needs.

All in all, not a bad discussion, but I think that this piece demonstrates that bad implementations of static typing can severely detract from the good qualities of static typing, and that it takes some getting used to to program well in a statically typed language (not casting things spuriously is a good example of that). That said, I know very little about Swift, so take all of this with a grain of salt.

[0] It may at this point be clear that the inspiration here is Haskell and ML; I am a big proponent of these languages, and believe that static typing can eliminate many common errors.

Re: My Swift Dilemma

#6
post #3

I'm not sure I understand the point of his post. In all the examples he gives Swift comes with better and more succint syntax plus more safety than Obj-C, and on par with his "Obj-C 3.0" idea. And of course it has tons of other features and flexibility he doesn't delve into. The whole post for me boils down to his "I hate Generics" rant at the end.

This is just a side-effect of the blub paradox disease. One of the symptoms for those that are afflicted with it is ranty blog posts about new languages that the afflicted person does not perceive as being better because it doesn't really have the same semantics as the one language they are used to.

I think it was Douglas Crockford that said this. We don't get new and better technology because the old people accept it. We get new and better technology because the people using the old crap just die out.

Re: My Swift Dilemma

#7

Great post. I'm not sure if it's because of my Objective-C bias or not but Swift just seems messy to me. Everything from how it's spaced and structured in the editor to how it's read. (Lack of headers, clear separations between data structures, methods..etc). Say what you want about Obj-C but it was damn organized.

You should add a sarcasm tag.

Re: My Swift Dilemma

#8
"I look at the feature set of Swift, and I have to ask myself the question: what’s the point? What is really trying to be solved? And does it provide significant benefits over languages that already exist?"

One reason may be that large companies want ownership of a modern, C#/Java/Go-like language [1]. I was an intern at Adobe when it was trying to develop such a language (ActionScript 4) + VM, and a primary reason not to adopt an existing language is that they wanted control and to be free of legacy baggage as much as possible. Obj-C is reasonable to use today, but its C and Smalltalk underpinnings sometimes feel like anachronisms for people writing App Store apps. This is probably especially true if you're a language designer like Chris Lattner at Apple and are tasked with fixing the most prominent pain points that your language users face.

[1] I realize these are somewhat diverse languages.

Re: My Swift Dilemma

#9
The author's comment on the first example is:

> what is the type of $0 and $1?

Surely a great thing about Swift is that the compiler knows the types of $0 and $1 and will prevent you from doing stupid things with them like you can in Obj-C?

Re: My Swift Dilemma

#10
post #3

I'm not sure I understand the point of his post. In all the examples he gives Swift comes with better and more succint syntax plus more safety than Obj-C, and on par with his "Obj-C 3.0" idea. And of course it has tons of other features and flexibility he doesn't delve into. The whole post for me boils down to his "I hate Generics" rant at the end.

This is just a side-effect of the blub paradox disease. One of the symptoms for those that are afflicted with it is ranty blog posts about new languages that the afflicted person does not perceive as being better because it doesn't really have the same semantics as the one language they are used to. I think it was Douglas Crockford that said this. We don't get new and better technology because the old people accept i…

Max Planck said something similar about new theories in physics.
Post reply on HN