[haiku-development] Re: Why not C bindings?

  • From: Ryan Leavengood <leavengood@xxxxxxxxx>
  • To: "haiku-development@xxxxxxxxxxxxx" <haiku-development@xxxxxxxxxxxxx>
  • Date: Sat, 6 Sep 2014 12:58:05 -0400

On Sat, Sep 6, 2014 at 12:07 PM, Ben Dibell <thinkingrodent@xxxxxxxxx> wrote:
>
> I personally don't like C++. I don't like a language that's too big for me
> to master, and it feels a bit cobbled together as a language, and I'm not
> too fond of OO in general either, and I'm not alone.

I've also become a bit of a "C++ hater", because if we are all honest
with ourselves it is a terrible language. Here is a great page which
goes into some detail about why:

http://yosefk.com/c++fqa/defective.html

There are many more such pages of course.

The only good thing I can say is that BeOS and now Haiku has generally
used a minimal subset of C++, but that probably won't last.

I've become a big fan of Go, and I also think (and hope) Rust will
replace C++ eventually.

I think for Haiku to have a better future we should consider adopting
a more modern language like Apple has done with Swift. We don't have
the resources to make our own language so I'd suggest Go or Rust.
Obviously this is something post-R1.

But what would be the best in general is good C bindings which can be
called from pretty much any language. So I definitely agree with you
that we need it.

> Is there any way I can convince someone to begin work on such a thing, or
> consider it for the future? You can't deny it'd make it a bit easier to
> get developers for other applications.

There is the beginnings of this in the form of libcharlemagne by
Jonathan Yoder (aka DarkWyrm):

https://github.com/darkwyrm/libcharlemagne

Specifically:

https://github.com/darkwyrm/libcharlemagne/blob/master/base/CInterface.h

He created libcharlemagne mainly to help himself build a GUI designer
tool for a Haiku IDE.

The CInterface in particular is used to make a Lua binding as far as I know.

I asked him to commit it to GitHub a while ago and as you can see he
nor I have done much with it.

I think Haiku as a project should consider adopting either the above
or creating their own C bindings.

Another option which might work for other languages is just to make
the minimal bindings to communicate using ports (which might also be
doable from the syscall interface) and just talk directly to
app_server, input_server, the kernel, etc. In other words make your
own Haiku API completely in that language and not use the current C++
Kits at all. Because of Haiku's server architecture this is definitely
doable.

Obviously a bunch of things would need to be rewritten, but the API
could be designed in a way that made sense for each language.

I would consider doing this with Go once our Go port is working well.
But honestly I don't have the time in the foreseeable future for that
or much Haiku development at all since I now have a young son.

Lastly I would say that since this is an open source project if you
want C bindings you should consider starting that project yourself :)

-- 
Regards,
Ryan

Other related posts: