Porting Swift to Haiku
haiku-os.orgI wonder what the plan is for getting swift interop with C++, given that all the Be/Haiku APIs are C++ (IIRC) and swift has no ability to call into C++ code directly.
If you want to see one way of doing this, have a look at how D does it: The function mangling and v-table (for single inheritance) are matched between the two languages.
Nitpick: C++, the language, has function name mangling nor v-tables.
Both are implementation-specific (and need not even be identical on a single platform. Early C++ compilers on Windows were incompatible with each other, for example)
For now i think you can just wrap it all up in C headers, and implement them in C++, calling the right API.
But giving the way the Swift compiler is itself written in C++ and tied to the LLVM, i bet it will be "easy" for the Swift compiler team to create interoperability between C++ and Swift.
I think their current goal with ABI compability is one step in that direction.. so it will be just a question of Swift understanding C++ mangling in elf/coff/mach-o objects for the link time, and interpret C++ headers using Clang for the compile time.
Given all that, is not hard to predict that Swift will probably have the best interop with C++ code than any other language out there.
The swift compiler being written in C++ has nothing to do with how swift calls into C++ code.
Theres a first part of my comment where i talk about ABI, name mangling, etc.. a goal Swift 4 is achieving, and i bet the possibility to reference C++ linked symbols will be there eventually, giving the project is very tied to LLVM and Clang.
Then there's a second part where i comment about the ability to parse C++ header using Clang when parsing Swift code, so you can get this in compile time. (You probably noted this part and lost some of the information that i've implied from the first).
So, i didnt imply that it was because the Swift compiler was written in C++ that it would have these properties, but because of its history of being tied together with LLVM and Clang, being coded by the same people behind LLVM and Clang.
I hope it gets more clear what i've meant to imply with my comment now.
Haiku is POSIX compatible, so at the very least there are the standard C APIs. It is true you need to call into C++ for things like GUIs though (unless you use a port of a C GUI library).
you can call c/c++/obj-c functions from swift
You can call C and Obj-C. You can't call C++ code directly, it would have to go through a C/Obj-C shim first.
I am really sad
this isn't about writing
swift as a haiku.
That will be in Swift 5!
Hooray!
Great to see. I personally don't use Swift (and don't really want to use Swift), but I do use Haiku, and more language support means more software, so I'm all for it.
I know it's blasphemous... but wouldn't mind seeing Haiku as an electron target platform. But I've thought that would be a good way to go for many things since first playing with ChromeOS.
I get it is not related, but, what are some of the things people do with Haiku?
You can browse the web, what else?
What other languages are supported, is there Haiku Ruby?
> You can browse the web, what else?
There's a decent office suite, Vim, IRC client, etc
> What other languages are supported, is there Haiku Ruby?
The usual complement of scripting languages (Ruby, Python, Perl, Lua), any JVM language, Go, partially working ports of Haskell and Mercury, Rust (no Cargo port yet), probably some others.
Thank you very much for taking the time to clarify this for me.
the bare minimum it needs is an IDE that can be used to code apps for the OS itself. and after that being able to run all kinds of programming languages.
Personally i'd like to see the latest version of ruby work and postgres.
But also docker support would suffice too.
> IDE that can be used to code apps for the OS itself
I'm pretty sure Haiku has exactly that already? Pretty sure it did last time I ran it...
Haiku has an editor. Perhaps that's what you're remembering?
>the bare minimum it needs is an IDE
Huh? Wouldn't the "bare minimum" be a programming editor?
Docker would be nice, but keep in mind that it would require running a Linux kernel in virtualization (Haiku has a POSIX layer but isn't directly Linux compatible). Still, if Macs can do it, there's no reason it couldn't work.
You can run Qt Creator, which I think is one of the best C++ IDE's out there.
The Haiku OS
Could use a modern language
Port Swift to HaikuTo be fair, it does have Rust (but no Cargo port yet).
And Go, if that counts as a “modern” language.
I just feel like this project has lost track of priorities, or doesn't want to be a credible alternative OS anymore. As a long time fan of the project - who cares about Swift? Where's the next release?
Open source community (as opposed to corporate-sponsored open source) has never worked that way. There are different people focusing on different things. Speed of the release team has no bearing on progress of other activities. It's likely not even the same people.
>> I just feel like this project has lost track of priorities
I've been following the development of Haiku (OpenBeOS) on and off since BeOS got discontinued -- for something like 16 years now.
While the effort and progress of the Haiku team is commendable, 16 years is a long time to produce an OS, so one might argue that they never had a good grasp of their priorities in the first place.
In the 16 years since OpenBeOS was announced, the world has changed drastically.
I remember running BeOS on a Pentium II, and it was amazing... at the time. It did some stuff that Windows and MacOS couldn't easily do performance-wise, because of its time slicing.
I remember simultaneously playing back four or five videos on BeOS at the same time without any hiccups, and you could barely do that with two videos on Windows on the same hardware. Because modern processors are so powerful, even on phones, most of the benefits I wanted out of OpenBeOS (Haiku) around 2000 no longer have value today.
I still follow Haiku's progress because of some BeOS sentimentality, but to me, it's now a novelty more than anything.
It's kind of off-topic for this thread, but I think there are quite a number of arguments to be made for Haiku's continuing relevancy (although I'm clearly biased :). You're right of course about performance being much less of a big deal these days (Haiku still far outshines even Linux in efficiency, though not in raw speed, mostly due to our lack of GPU acceleration).
Instead, the relevancy now mostly has to do with the unity -- or rather the lack thereof -- amongst NIX operating systems. While Linux dominates the server market, the "year of the Linux desktop" that everyone's been hoping will arrive for at least a decade now hasn't arrived. Sure, there are new challengers now and again but most of the problems and criticisms of Linux aren't about the look and feel, but usually fall on a more fundamental level: "Stuff breaks and then it's impossible to fix." -- "My audio drivers don't work and this tutorial to troubleshoot it is incomprehensible to me." -- "I took some updates and now Kdenlive doesn't export audio anymore."
Haiku is very different in this respect because its underlying architecture is the one thing Linux/BSDs are not and never will be: unified. The entire system, kernel to HTTP client to file manager, is developed by one team on one infrastructure inside one git repository. Which means as a result, you always know whose fault it is when something breaks (ours), and that when we fix it, it'll appear in the "nightly" update channel by the next day. It also means that there's no long series of configuration changes to try when something doesn't work; almost universally, stuff either works or it doesn't. Really -- there's only one exception to this I can think of (relating to a bug in our port of FreeBSD's Intel WiFi drivers.)
Linux has been trying for a more unified system both up front (e.g. elementaryOS) and in back (systemd...), but the more I use it, the less I want to use it and the more I want to use Haiku.
It's somewhat unjust to lump the BSDs in with Linux operating systems there. One of the noticeable things about them in contrast to Linux operating systems is that they do develop the operating system (which is a "kernel" plus a "shell" of applications, of course) as a single coherent whole.
Ironically, you provided an example of this: Lots of things can qualify as an HTTP client. FreeBSD's "fetch" utility and OpenBSD's "ftp" utility are certainly among them. Those are both parts of the operating system, developed by the FreeBSD/OpenBSD developers.
I suppose I am a bit in error here, yes. The BSDs are indeed more unified than Linux is, anyway, although the unification only extends a few levels up from the kernel. Desktop environments are still mostly developed by other teams (and are usually just ports of Linux ones.)
All fair points, although I do have one nitpick:
>> the "year of the Linux desktop" that everyone's been hoping will arrive for at least a decade
Everyone might be a little hyperbolic, considering that the majority of people are satisfied with OSX, Windows and/or ChromeOS. And there are plenty of other people who are satisfied with Ubuntu and Mint as their desktops. I would counter that the number of people waiting for the "year of the Linux desktop" is probably a small number.
I meant "everyone" in the sense of "everyone who already uses Linux/BSD/etc." not "everyone" = "general population", sorry for the ambiguity.
And of course one can be satisfied with Ubuntu and Mint as desktops. It's just that when it breaks, you really have to know your way around the plumbing -- which end users don't.
Even then, for the "everyone who already uses Linux/BSD/etc.", I would posit that most of them are probably using Macs and/or aren't waiting for "The Linux Desktop" to arrive.
For a huge swath of *nix users, Mac OSX accomplished everything they wanted from a "Linux Desktop" outside of being free and open source. That probably leaves a very small number waiting for the Linux Desktop.
FWIW, OSX is also unified, and requires little knowledge of the plumbing for end users.
> who cares about Swift?
Someone, obviously, cares. They took the time to port it.
These same sentiments were said about another alternative open source OS 20 years ago. And yet, here we are 20 years later and it powers everything from supercomputers to mobile phones and TVs
> Someone, obviously, cares. They took the time to port it.
Yeah, and I have to figure that with Swift being Apple's darling right now that there's the opportunity to attract more interest from idle developers that otherwise wouldn't have given Haiku a moment's thought.
This is a Google Summer of Code project. So in essence this is an R&D project that is "free" for the community. The Haiku devs are busy working on getting a Beta 1 release that should be here real soon now.
Package management is in and the infrastructure around it is being worked on.
A credible OS needs applications. So ports matter, and languages matter.
If I had to guess, it looks like someone wanted a really fast language with high level features. They could've also ported D, Rust, Nim...etc, but Swift is not a bad one to port. What is most of Haiku written in, C++? I think Swift would be a good app language now that it is Open Source.
I believe there is also a working Rust port. Still, more options is nice.
If they have LLVM up and running then any language that depends on it (swift, rust) should be doable.
https://forge.rust-lang.org/platform-support.html
* i686-unknown-haiku
* x86_64-unknown-haiku
They're basically cross-compile only, Tier 3 supported at the moment.
It hasn't been packaged yet, but I've both bootstrapped rustc & cargo, and also compiled rustc & cargo on Haiku itself from the bootstrap packages, so it shall be self-hosting from here on out.
Excellent!