One of the interesting tradeoffs in programming languages is compile speed vs everything else. If you've ever worked on a project with a 40 minute build (me) you can appreciate a language like go that puts compilation speed ahead of everything else. Lately I've been blown away by the "uv" package manager for Python which not only seems to be the first correct one but is also so fast I can be left wondering if it real…
The Swift compiler is slow due to how types are inferred
131–140 of 229 posts
Re: The Swift compiler is slow due to how types are inferred
#132HM works great for me. Let's try it elsewhere instead of blaming the algorithm! {-# LANGUAGE OverloadedStrings #-} -- Let strings turn into any type defining IsString {-# LANGUAGE GeneralizedNewtypeDeriving #-} -- simplify/automate defining IsString import Data.String (IsString) main = do -- Each of these expressions might be a String or one of the 30 Foo types below let address = "127.0.0.1" let username = "steve" l…
Your example is different than the example in the post. Specifically, `channel = 11`, an integer. If it was a string then it parses very quickly.
In my code channel is not a string, it's one type of the 31-set of (String, Foo01, Foo02, .., Foo30). So it needs to be inferred via HM.
> If it was a string then it parses very quickly.
"Parses"? I don't think that's the issue. Did you try it?
----- EDIT ------
I made it an Int
let channel = 11 :: Int
instance IsString Int where
fromString = undefined
instance Semigroup Int where
() = undefined
real 0m0.543s
user 0m0.396s
sys 0m0.148sRe: The Swift compiler is slow due to how types are inferred
#133> they’re invalid swift If this isn't valid why are we even taking about it? The compiler should report syntax error or something
The point is that it's valid syntax (invalid syntax is found in an earlier phase of compilation and would report much faster). It's invalid in Swift's type system, and it takes it 42 seconds (in the string example) and 8 seconds (in the math expression one) for it to tell you that it can't type-check it in a reasonable time and then it quits.
Guesses:
1. Successfully compiles
2. Reports an error
3. Never halts
4. Nobody knows
Re: The Swift compiler is slow due to how types are inferred
#134The math type inference example makes the usual claim that "what if Swift can replace Python" a non-starter. As someone who have to deal with this on frequent basis, it is pretty sad. (I maintains s4nnc and a fork of PythonKit).
> what if Swift can replace Python What a ridiculous statement. I’m willing to bet everything I have in life that this is never going to happen.
Re: The Swift compiler is slow due to how types are inferred
#135The math type inference example makes the usual claim that "what if Swift can replace Python" a non-starter. As someone who have to deal with this on frequent basis, it is pretty sad. (I maintains s4nnc and a fork of PythonKit).
Does this improve when declaring all variables with explicit types before using them in expressions?
Re: The Swift compiler is slow due to how types are inferred
#136Earlier quoted context omitted.
So they didn't focus actively on good error messages and fast compile times when designing a new language?
If we have to flatten it to "they chose and knew exactly what choice they were making", then there's no light to be shed. Sure. That's stupid. Its just as stupid to insist on that being the case. If that's not convincing to you on its merits, consider another aspect, you expressly were inviting conversation on why that wasn't the case
This is a perfectly reasonable question to ask. And a straight simple answer might be that no, they didn't. Or not initially but later it was too late. Or here are the circumstances in leadership, historical contexts that led to it and we find those in other projects as well.
That would be interesting to hear.
Re: The Swift compiler is slow due to how types are inferred
#137Earlier quoted context omitted.
Python real strength is the speed it can be taught, read and written.
It is an ilusion that Python is like BASIC, in reality Python 3.12 is rather complex, more like Common Lisp, when taking into account all language breaking changes during the last 30 years, its capabilities, the standard library, and key libraries in the ecosystem.
Re: The Swift compiler is slow due to how types are inferred
#138Earlier quoted context omitted.
That post, while awesome (as is the rest of aphyr's stuff), is a lot to wade through to get to the point you're trying to convey. Can you spell it out for me?
That typeclass resolution can encode some heavy computation, the example being n-queens in the article.
Re: The Swift compiler is slow due to how types are inferred
#139Earlier quoted context omitted.
Python real strength is the speed it can be taught, read and written.
It’s not, actually, any more than any other language. That was Guido’s original plan, but show a page of modern Python code to someone who’s never seen it before and they’ll run screaming. There is a minimal subset where you can say it reads like pseudocode, but that’s a very limited subset, and, like AppleScript, you have to have a fair amount of knowledge to be able to write it fluently.
Python's type ecosystem's support for proper type checked data science libraries is abysmal (`nptyping` is pretty much the most feature complete, and it too is far from complete), and has tons of weird bugs.
The Array API standard (https://data-apis.org/array-api/latest/purpose_and_scope.htm...) is a step in the right direction, but until that work is close to some sort of beta version, data science folks will have tons of type errors in their code, in spite of trying their best.