News for hackers. Stuff that matters.
Re:Swift System Is Now Open Source by skohan on Saturday September 26, 2020 @09:02AM (#24598489)
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.

There are no comments on this comment yet.