2017-11-12

Ada

I did say I was trying to learn Ada.

Well, I thought I would explain that it is a bit stalled, sadly.

I have managed to read a lot of the Barnes book on Programming in Ada 2012. Well, over half anyway. I read a lot whilst on a cruise!

It is a tad more verbose than I am used to, but overall I would have to say it does look good. The very strong typing, and the fact that all types allow value range controls, all make for much safer code. Even the multi-tasking looks interesting.

I have got to the stage that I would like to try using it, and that is where I have come unstuck, sadly.

Obviously, if I wanted to simply code some abstract program, much as one would on a Computer Science course, then of course I could use Ada. Sadly, such simple self contained abstract programs with no more than basic text input and output are pretty much academic now. Nobody does INPUT and PRINT to communicate to the user, they use a range of libraries, web sockets and web pages, javascript, all sorts. And that is just the user side, the back end is all libraries for mysql, or B2B XML, or libcurl, or something else.

A lot of the code I work on, and code I start from scratch even, is run on a linux environment. I have a load of our own C libraries which we use extensively, but of course linux has a lot of C libraries that are used for all sorts of things. I am not against re-working our own libraries - some of the key ones are XML manipulation and SQL front end for the standard client library. I am sure both can be done in Ada with no problem, but I am not re-working OpenSSL from scratch in Ada.

The problem is that to use these from Ada I would have to find or code interfaces or new libraries. That is going to make a huge hurdle for any code I need to write. I get the impression that there are some Ada wrappers and libraries available, but I am struggling to find them.

I mean, is there an Ada library for mysqlclient interface, or openSSL for TLS? Heck, what about something really simple to start with like popt library? There must be a good Ada XML library?! If I can find libraries or wrappers for a large list of key functions that we use regularly on linux then maybe I can start using Ada, but right now it is not looking promising.

There is one closed project we work on, and have for many years. It is a project where every library and functions is written from scratch, including the operating system. It was suggested long ago that maybe we should use Ada, and I decided against it. In hindsight maybe that was a mistake, as it would have been a perfect case where we did not rely on any external systems and could have started from scratch in Ada. That project is the FireBrick. There is even some chance we may start using some Ada modules in future... But that would have been cool - a complete operating system from scratch all based on Ada. I am kicking myself for not doing that when we started now. Sorry Cliff.

If I do make more progress, I'll let you know, but for now it is stalled.

11 comments:

  1. Looking at https://github.com/ytomino/openssl-ada/blob/master/source/crypto.ads creating ada bindings for standard libraries doesn't look *too* difficult.

    Assuming it works: I haven't tried it!

    ReplyDelete
  2. To be honest I am half expecting people too tell me I missed the obvious and that this is easy, and if so I may progress my Ada endeavour.

    ReplyDelete
  3. P.S. Er, I meant to link to https://github.com/ytomino/openssl-ada/ not the individual file.

    Of course, creating bindings for every function is going to be a bit tedious...

    ReplyDelete
  4. That, or start commenting on my book collection.

    ReplyDelete
    Replies
    1. I'm mostly just troubled about the mixing of fiction and non-fiction... :)

      Delete
    2. Now you have me pondering - Ada, like any language (including Klingon) is just "made up", so is it fiction too?

      Delete
    3. You'll be telling us that Terry Pratchett is fiction as well next! ;)

      Delete
  5. I learned Ada many years ago but moved on to the more hardcore Haskell and OCaml. Ada occasionally comes up on HackerNews with the same problem: there is a dearth of third party libraries for the language to do many things. I liked the language but I like the more functionally oriented ones now.

    ReplyDelete
  6. This might help but maybe only for simple libraries.

    https://www.adacore.com/gems/gem-59

    ReplyDelete
  7. I'm currently working in Rust for similar reasons to your interest in Ada, and we're able to work around the "all interesting in-house libraries are in C++" issue by using bindgen to make it easy to write FFI bindings from Rust callers to C++ libraries.

    Is there a similar route in your Ada compiler and runtime, to make it easy to call an existing C library from Ada? You could then write a "nice" Ada interface on top of the raw binding (which we do in Rust for important C++ libraries) so that the rest of your code is idiomatic Ada.

    ReplyDelete
  8. Wonder whether h2pas from FPC would help?

    http://wiki.freepascal.org/H2Pas

    ReplyDelete

Comments are moderated purely to filter out obvious spam, but it means they may not show immediately.

Fencing

Bit of fun... We usually put up some Christmas lights on the house - some fairy lights on the metal fencing at the front, but a pain as mean...