Live data from Hacker News

Go Home Swift Compiler, You’re Drunk

spin.atomicobject.com

1–10 of 29 posts

Re: Go Home Swift Compiler, You’re Drunk

#3
The problem, by the way, is that the use of nested literals (string and dictionary, here) causes the compiler to do a very large search to resolve the types. A quoted string, e.g. "foo", could be any type that conforms to StringLiteralConvertible. It's evaluating all permutations of potential type assignments to each literal that appears.

I thought they fixed this, though. I filed it for Array> long ago, and they patched that case. https://twitter.com/kongtomorrow/status/565844856690339841

Re: Go Home Swift Compiler, You’re Drunk

#5
post #3

The problem, by the way, is that the use of nested literals (string and dictionary, here) causes the compiler to do a very large search to resolve the types. A quoted string, e.g. "foo", could be any type that conforms to StringLiteralConvertible. It's evaluating all permutations of potential type assignments to each literal that appears. I thought they fixed this, though. I filed it for Array > long ago, and they pa…

Jeez. Is there some sort of hint to indicate that a string is just a string? Otherwise that seems like it will always be slow.

Re: Go Home Swift Compiler, You’re Drunk

#6
post #3

The problem, by the way, is that the use of nested literals (string and dictionary, here) causes the compiler to do a very large search to resolve the types. A quoted string, e.g. "foo", could be any type that conforms to StringLiteralConvertible. It's evaluating all permutations of potential type assignments to each literal that appears. I thought they fixed this, though. I filed it for Array > long ago, and they pa…

Jeez. Is there some sort of hint to indicate that a string is just a string? Otherwise that seems like it will always be slow.

Well, yes; it's called type annotation (as noted in comments both here and at the original article). Telling the compiler it's "just a String" (or more precisely a dictionary containing strings) cuts the compile time to 100ms.

Yes, the type inference in this case could use some improvement -- maybe guess the simplest possible interpretation first, and search the space of alternatives in the background, assuming there's a mechanism to go back for a do-over if any are eventually found...?

Re: Go Home Swift Compiler, You’re Drunk

#7

Wow, this is so sad, that compiler has to be extremely bad implemented

It's just a bug. It's pretty easy to accidentally have such cases in a generic type inference algorithm, particularly one with implicit conversions. Other similar languages have had pathological cases in type inference too.

Re: Go Home Swift Compiler, You’re Drunk

#8
post #6

Earlier quoted context omitted.

Jeez. Is there some sort of hint to indicate that a string is just a string? Otherwise that seems like it will always be slow.

Well, yes; it's called type annotation (as noted in comments both here and at the original article). Telling the compiler it's "just a String" (or more precisely a dictionary containing strings) cuts the compile time to 100ms. Yes, the type inference in this case could use some improvement -- maybe guess the simplest possible interpretation first, and search the space of alternatives in the background, assuming there…

The background check would still take 12 hours in this case.

Re: Go Home Swift Compiler, You’re Drunk

#9
How many other two year old languages are there in large scale use? It's not surprising there are issues in compiling things. I've used so many languages early on since I started in the 80's and you can always find some syntax the compiler doesn't like. Given the pedigree of the people building Swift who also built the entire llvm system it's pretty good for something still in diapers.

Now take XCode, that is some real drunk.

Post reply on HN