Live data from Hacker News

Swift Programming Language Evolution

github.com

41–50 of 181 posts

Re: Swift Programming Language Evolution

#41
post #36

Am I the only one as a JS dev, who find it hard with types & casting in Swift?

Probably not. Types and casting seem complex to people coming from more dynamic languages – that's okay though! It formalises something that you generally don't have to think about in Javascript – the tradeoff being that you have more consistent, less buggy software at the expense of more effort while writing it.

Re: Swift Programming Language Evolution

#42
post #33

Earlier quoted context omitted.

Lots of languages ARE faster than C, including older languages than C, like Fortran and Forth. Being faster than C is not anything special in itself. Most things being equal (typed, optimized, compiled, no runtime etc) C is mostly faster when it does something with a lower overhead than some other language (e.g. a specially written hashmap algorithm targeted to some program vs C++ std map type), not because of its pr…

Fortran especially. Forth seems to depend on processor characteristics. I seem to remember that Ada compilers routinely produce faster code than C compilers.

C has very loose semantics that make it difficult for a compiler to reason about code, as the saying goes, C is often little more than portable assembly. There's a reason that CLion was a big deal when JetBrains announced it, reasoning about C/C++ code is HARD.

Re: Swift Programming Language Evolution

#45

So Swift has been out awhile, what do people think of it? What other language would you compare it to (e.g. C#, C, C++, etc)? What about the libraries are they well laid out?

The neat syntax is sometimes butchered by unnecessary casting orgies. Swifts outstanding feature is its simple C interoperability. The compilation times (Xcode) are lengthy compared to C or C++.

Example: https://youtu.be/mgpAmqdiPKE

Re: Swift Programming Language Evolution

#46
post #4

So Swift has been out awhile, what do people think of it? What other language would you compare it to (e.g. C#, C, C++, etc)? What about the libraries are they well laid out?

I've been playing around with it a little and it's... fine? Very capable. Not run into any moments that have blown my mind, but neither have I found any that disgusted me. In a weird way it actually reminds me most of TypeScript - JavaScript-y, but with types and stronger enforcement of rules.

I've been quipping that Swift is the Javascript of tomorrow, today!

Re: Swift Programming Language Evolution

#48
post #39

Earlier quoted context omitted.

Me too. Is something similar available in Rust? I'm familiar with smart pointers in C++ but I love that Swift manages a lot of that mess for me.

Generally data lifetime in rust is fully deterministic and the borrow checker can statically determine when data should be deallocated. If for whatever reason you do need reference counted semantics there are options in the stdlib (alloc::rc).

And to elaborate on this, there's a namespace clash: Arc in Rust is _atomic_ reference counting, and Swift is _automatic_ reference counting, which, even more confusingly, is implemented using atomic reference counting in my understanding.

Automatic reference counting inserts all of the refcount bumps. In Rust, you have to write the up count yourself, but not the downcount.

But, reference counting isn't used very often, at least in my experience. It's very useful when you have non-scoped threads, though.

Re: Swift Programming Language Evolution

#49

The removal of prefix and postfix ++ and -- operators and the removal of C-style for loops are mistakes, IMO.

I gotta disagree with this one. Those operators have always been confusing and unnecessary. j = i++ being different from j = ++i alone is enough to convince me it's gotta go.

Re: Swift Programming Language Evolution

#50

Earlier quoted context omitted.

Do you have a link to some benchmarks at hand? Your "possibly faster than C" claim sounds too good to be true without a source, but I'd very much like to be proven wrong :)

By http://benchmarksgame.alioth.debian.org/u64q/which-programs-... Swift's performance is similar to Java's, but quite a bit faster when working with many objects: http://benchmarksgame.alioth.debian.org/u64q/swift.html On a few benchmarks it's faster than C as well: http://benchmarksgame.alioth.debian.org/u64q/compare.php?lan... though not most. I suppose they were able to do the binary-tree benchmark so much better…

>> I suppose they were able to do the binary-tree benchmark so much better than Java, because

… because it's faster to use a memory pool than GC for that … ditto C Rust Ada Fortran C++ …

http://benchmarksgame.alioth.debian.org/u64q/performance.php...

Post reply on HN