Re:Swift System Is Now Open Source
by formerly_proven on Saturday September 26, 2020 @05:18AM
(#24597470)
> My problem with Python is that once you start working with a strongly-typed language, a duck-typed interpreted language starts to feel like it's missing a major tool in terms of writing correct code.
I primarily write C++ and Python and never feel like this.
Not all type systems are created equal. Swift's is powerful and expressive
You could at least explain what features set it apart, in your opinion, from other type systems and why they are important in this case ...
Well a good example would be the 1st class optional handling in Swift - Swift's type system gives you explicit tools which make it possible to guarantee you won't have an NPE at runtime, as long as you write idiomatic Swift. This is a whole class of errors which are systematically avoidable in Swift (and other languages, like Rust), but take special care to avoid in c++ or python. So with Swift you get this "if it compiles it runs" experience, which is a difference you would not feel between c++ and python.
But in general, c++ to python is an awkward comparison because c++ is extremely low-level by comparison. So you do get static typing, which is nice, but you also get a lot of other issues to deal with - namely manual memory management - so with either python or c++ you have a high probability you will have code which fails at runtime. It would just be the case that in c++ most of the time it would be because you handled memory incorrectly, whereas with python it would more often be because you made a type-related error. Swift is much more comparable with Python in terms of reducing cognitive load by obviating low-level details from the programmer.
Re:Swift System Is Now Open Source
by auggierose on Saturday September 26, 2020 @07:06AM
(#24597889)
Yeah, C++ is not a language with a proper type system. Swift is.
I also think S4TF's approach has been really neat here: there's a really nice python interop so you still have access to the entire body of work and tools in python available, and it basically feels like writing native swift code.