Swift on Raspberry Pi
blog.lickability.com
blog.lickability.com
I was hoping for an in depth dive into how Swift performed on a RPi compared to other languages (say, C relative to Swift on x86, then the same for ARM), and a little on how well Swift interacts with the Pi's hardware. But it was just a quick guide on setting up a Pi, installing Swift, and making a quick 'Hello, World' program. The only lines of interest came at the very end:
> Now that Swift is installed, there’s so much more that you can do. To control hardware — like LEDs, motors, and relays — you can use the help of a library for hardware projects on Linux/ARM boards called SwiftyGPIO. Have fun experimenting with Swift on the Raspberry Pi!
That said, SwiftyGPIO looks like a fun little library that I think I'm going to look into more and play around with.
I kind of was expecting this to be bare-metal Swift running on ARM with a Raspberry Pi, when I read both the OP's title and your comment. But I was disappointed to see that this was running on Linux. From the README.md...
> Scripts to clone, configure, patch and build Swift 5.0.2 on Linux ARM devices.
Hopefully in the future, Swift would support bare-metal environments just like how Rust and Zig does.
And you can still SSH into your "bare metal" box, run gdb, etc. Best of both worlds.
Configuring the Linux kernel just to meet the requirements for bare-metal applications might work for some use-cases but not for security and safety-critical applications.
For instance, the IoT industry still suffers from typical security issues in the drivers and firmware due to these Linux/Busybox vulnerabilities in the system. There are alternatives that use safer languages or formal verification that are more secure than configuring Linux for IoT or bare metal development, like TockOS [0] (using Rust) or seL4 microkernel (a formally verified microkernel).
So, is bare metal almost entirely unnecessary in 2019? Security wise, I'd much rather use safer languages like Rust for bare metal in 2019, than to use Linux/Busybox for this use-case.
[0] - https://www.tockos.org/
You can also use apt.
Huh? In what way exactly?
There are also a few shortcuts on the desktop if you install it with the gui... But yeah, it's ultimately a Debian deviate, so anyone with any experience will be able to use it however he wants
> Raspbian comes preloaded with Python, the official programming language of the Raspberry Pi and IDLE 3, a Python Integrated Development Environment.
It also ships with Mathematica, Ruby (via SonicPi), and Scratch.
Source: I think Eben told me himself a while back.
Having said that, a Raspberry Pi running Python under Raspbian is a great little machine for special purpose tasks. I have half a dozen at home, with 15k lines of Python running in my living room (weather station, home automation, etc.).
i died a little inside
So you can use any backend LLVM does.. theres a little runtime friction in porting a small Swift runtime to the target (but you would only need to worry about that, if its not a popular LLVM backend).
But given Apple is a first class consumer of Swift, arm is definetely a strategic backend for Swift, given it needs to run on iOS.
(its a little alpha i guess, but you can even compile your Swift code to run on WASM nowadays)
> So you can use any backend LLVM does.. theres a little runtime friction in porting a small Swift runtime to the target
More than a little friction, I would think.
I actually 'trust' the support if the language declares that they are going to support it. For example, Rust has said they will support the wasm target as first class.
That being said, I'm sure it already works through WSL (Windows Subsystem for Linux), so if Windows is your only platform, you can still probably play with it.