Developing for Haiku

From BeOS & Haiku Fans Wiki

How to develop for Haiku

Introduction

Want to write programs for Haiku? You are so welcome!

Let's get something out of the way: you are not going to get rich with this. The Haiku community is tiny, and has gotten used to getting free and open-source software ported. Still, the advantage of working in a small community is a lack of competitors and immediate recognition. Write a better widget and you may find a large proportion of the community adopting it. Getting your application adopted by the Windows, MacOS or even Linux communities can be a very slow business.

The best way: C++ and the Haiku API

Apps written with C++ and the Haiku API, know by the community as "native" apps, are the top contenders among Haiku apps. These applications can make full use of what makes Haiku unique: replicants, extended attributes, translators ...

Probably the best way to get into this is to read two e-books, both by Darkwyrm (Jon Yoder):

The Haiku API has advanced considerably since Darkwyrm wrote these e-books, but they remain indispensable. If you already know C++, you can skip the first book.

The easy way: Yab

Yab is a dialect of BASIC that can be used to create graphical Haiku applications. It does not have access to the entire Haiku API, But it can access a lot of it. It is most commonly used to build GUI front-ends to CLI commands.

Michel Clasquin has produced a series of YouTube videos explaining yab programming. There is also an e-book by the same author, but it is getting a bit dated now.

The other ways

Over the years, many other programming frameworks have been ported to Haiku. We have many programs available as a result, but it needs to be said that these are mainly ports of programs first produced on and for other operating systems. Still, there is no reason it always has to be that way: Be among the first to produce a QT or Java program specifically for Haiku!

Java

Java once held out the promise "Write once, run everywhere". It didn't quite work out like that, but there are still a number of Java apps that can be made to run on Haiku. Java apps use a variety of interfaces (Swing is probably the most popular) and they will have their own look and feel. unlike native applications. This can be disconcerting to the user, for example, if you are used to double-clicking in a file selector dialog and the Java app uses single-clicks.

QT

QT (pronounced "cute") is the best integrated foreign framework in Haiku. Well-written QT apps look and behave so much like regular Haiku programs that you may have difficulty seeing which is which. We also have support for KDE, a superset of QT.

Version 4 of the QT framework is now obsolete, but with the appropriate library old ports of these apps can still work. Ideally, they should be ported to a more recent version of QT. Development should now focus on QT5 or, even better, QT6. These are the latest QT versions we have available. Most of this will be done in C++, but FreePascal and the Lazarus IDE are also available. So are Python and other language bindings.

GTK

Of course Haiku has GTK too - how else would we run the GIMP? Having said that, GTK is not as cleanly integrated into Haiku as QT. Also, we are stuck at GTK3 at the moment, while more and more GTK software is moving to GTK4.

SDL

Simple Direct Layer (SDL for short)  is a framework most commonly used for games. The apps made with SDL may not look like Haiku programs, but they do work!

FLTK

FLTK (the Fast Light Toolkit) is the most recent framework to have become available on Haiku, although it seems we've had Dillo for ages ...

TCL/TK

TCL/TK ((pronounced "tickle teak") is another framework that can be made to work on Haiku. The tclsh interface seems broken, but wish works well enough, which is why these apps float in a blue "desktop" of their own.

CLI programs

Haiku is not a graphical layer on top of a command-line base, like most UNIX-derived operating systems. It is the other way round: Haiku is graphical from the start, but there is a terminal emulator program called Terminal that runs like any other application. Within Terminal, the default shell is bash (other shells are available). If you know your way around the Linux command line, you'll feel right at home.

All that means that there are a lot of ported and native CLI programs for Haiku, written in a staggering variety of computer languages. Perl, OCaml, Ruby ... The list goes on and on. Even if your only IT skill is in bash scripting, you can achieve fame and fortune in the Haiku community.