4 ms·
As a casual Swift desktop developer, I also wonder about how practical and fast Swift is, especially when compared to scripting languages like Python. For inst
by wslh 2y ago
As a casual Swift desktop developer, I also wonder about how practical and fast Swift is, especially when compared to scripting languages like Python.
For instance, last week, I was working on bit manipulation and realized that Swift has methods to count 1 and 0 bits:
let value: UInt8 = 0b11010101
let count = value.nonzeroBitCount
- deze333 2y agoIt's fast enough to make running an app feel like running a native app – faster start time, less memory used, less power hungry, more responsive UI – compared to browser based cross-platform apps. One can say it achieves maximum user interaction speed. For most critical calculations, one can easily integrate C++/C libraries – at the source code level – which Swift can compile, link and call directly. Or drop down to unsafe features of Swift and achieve speeds comparable to C++. But that's not really needed in most of real life use cases. Convenience is what really matters when it comes to Swift.
- msk-lywenn 2y ago"feel like running a native app"? Swift apps are native apps, AFAIK
- frizlab 2y agoDepends what framework you link it with.
- spencerflem 2y agoWhat's wrong with that? This is often a single CPU instruction and a lot of languages have support for it, including python https://en.m.wikipedia.org/wiki/Hamming_weight https://en.m.wikipedia.org/wiki/Hamming_weight
- wslh 2y agoIt was a positive comment about Swift showing the batteries included there. It is not normal to have such high-level methods for low-level stuff like bits in an integer. Clearly logical operations and rotation is included in all popular languages.
- spencerflem 2y agoPython has bit_count() as of semi recently :) But I gotcha now, mistook "I wonder" as "I suspect it's not"