Remix.run Logo
wslh 18 hours 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 18 hours ago | parent | next [-]

It'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 16 hours ago | parent [-]

"feel like running a native app"? Swift apps are native apps, AFAIK

frizlab 13 hours ago | parent [-]

Depends what framework you link it with.

spencerflem 16 hours ago | parent | prev [-]

What'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

wslh 14 hours ago | parent [-]

It 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 14 hours ago | parent [-]

Python has bit_count() as of semi recently :)

But I gotcha now, mistook "I wonder" as "I suspect it's not"