Daniel Lemire's blog

, 5 min read

Swift as a low-level programming language?

6 thoughts on “Swift as a low-level programming language?”

  1. The question of whether low-level primitives are available to a programmer is not really a programming language issue, but a standard library issue. For example, Haskell allows extremely low-level programming if you really want to do it there and use the GHC compiler, e.g. https://hackage.haskell.org/package/ghc-prim-0.5.1.0/docs/GHC-Prim.html has all this popCnt stuff for its unboxed machine-level types.

  2. I consider the standard library of a programming language as a defining characteristic of the language.

    It is entirely possible that Haskell is practical for low-level programming. Of course, you should check the resulting assembly. Have you done so?

  3. Oren Tirosh says:

    > If you are not targeting iOS, it is crazy to use Swift for high-performance low-level programming.

    Agreed. Using it *specifically* for high performance low level stuff is probably a bit crazy.

    But using Swift for system programming on a non-Apple platform is getting less and less crazy with every day (for certain values of “system programming”). Especially now that v4 was released.

    For many years, I have been looking for an expressive, safe and concise high-level language that produces native code in standard relocatable object files and interoperates with C. Not some specialized module or class files. No interpreter or runtime required to launch it.

    Definitely not an Apple fanboy here. I was actually annoyed to discover that a language fitting this description was coming from Apple.

    Swift is still far from being a conservative choice in non-Apple shops. But we may be at the point where early adopters of Swift in such environments will benefit from it more than the inevitable pain that will occasionally be caused by such a choice.

    1. I agree with everything you wrote.

  4. Paul Jurczak says:

    Have a look at Julia (https://julialang.org/). It is still a bit of a work in progress, but you may like it.

  5. Gou Long says:

    C++ is really nice if you use stuff like boost. I don’t really like Swift outside of Apple’s frameworks. It’s kind of icky for the high level stuff like Python, and it’s not as general as C++.