Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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 than Java, because Swift supports 'UnsafeMutablePointers': http://benchmarksgame.alioth.debian.org/u64q/program.php?tes...

Edit: This Quora question mentions the performance of Swift before and after unsafe programs were included: https://www.quora.com/In-terms-of-performance-speed-is-Swift... The memory safe version used to be about 24x slower than C.


I don't think these benchmarks are realistic. Yes, you can use UnsafePointers, but that's not the real world case. ARC, runtime generics and structs have a huge cost in real world programs.

Swift is unfortunatelly usually an order of magnitude slower then Java and C# in real world according to last benchmarks I've made. I'm hoping that will change because I really love Swift.


Please contribute Swift programs that you think are "the real world case":

http://benchmarksgame.alioth.debian.org/play.html


Agreed. Swift is quite high-level compared to C or C++, for examples. As with any languages, there are tradeoffs with performance.


>> 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...


>> Edit: This Quora question mentions the performance of Swift before and after unsafe programs were included

That Quora answer makes claims which are not true.

The Swift benchmarks game programs were always compiled with -Ounchecked (since Dec 7 2015).

The before was naive transliterations (from other programming languages) of single-core programs -- just to demonstrate that Swift was installed.

The after was someone doing the work and contributing programs written for Swift and written for multi-core.


Obviously keep in mind the various caveats that come with benchmarks, but it seems that Swift is at least capable of achieving C-like performance[1] in some circumstances.

[1]: https://benchmarksgame.alioth.debian.org/u64q/compare.php?la...


See https://gist.github.com/MatthiasWinkelmann/d1f19a11d539e609f... for something quick&dirty.

Note that I don't want to claim that Swift is faster than C in general/real life/anything but a few microbenchmarks. But the two just being within an order of magnitude makes a really strong case for Swift, I believe.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: