Wednesday, 2 August 2017
I am planning to learn Ada. For those that do not know, Ada is a programming language.
Why? Well, why not? I like to expand my skills and knowledge, and it is a good language.
I have used many many programming languages over the years, high level, object oriented, and even some very "special" ones like postscript and ps-algol. I have done a lot of assembler in a range of processors. However, at the end of the day my go-to language is C, more specifically GNU C (as it has a few invaluable extensions to normal C).
I like C for several reasons. It makes it very easy to work at a low level with the compiler generating code that you expect - or does it? Sadly, times have changed. Once upon a time I could tell you what the compiler is doing - but there have been two key changes. One is some very smart optimisation in compilers, and the other is the way processors (even relatively simple ones like ARM) pipeline and cache things. The combination of the two is a compiler that knows that some things that seem obvious are not so, because of the way the pipelining and caching work. You can end up with compiler output that is quite confusing to understand, but ultimately rather good. You almost have to consider RAM to be a slow peripheral these days, which is a new way of working for me.
I also like C because of the way it allows me to access bits and bytes as I want, or does it? The big and little endian nature of processors matters, and so does the way they handle 32 bit for 64 bit registers. C has types which you cannot always tell are as specific size. Indeed, in the FireBrick code we have types like ui8 and ui32, and so on, so we know exactly what we are dealing with. You can do that with C if you try.
I also like C because all of the libraries in linux, where I do most coding, all work with C interfaces and include files. This remains true and is actually a stumbling block for learning any new language. To be honest, the FireBrick code would probably have benefitted from being done in Ada from scratch as we do not have an existing operating system - we have our own. Sorry to Cliff who did suggest that when we started the latest design (FB2700, etc) - maybe it would have been a good idea.
So, I have started, and Ada is basically a simple procedural language like C, not fundamentally different in concept. Well, to start with. The syntax is different, and in some ways more verbose / wordy. So far it seems to have some very nice features. The data object definitions and very strict typing are excellent, and something we should all use (GNU C is not too bad at some of that). The explicit mapping of data to binary structures is nice too. A nice thing is the option for a shitload of runtime checks, including data types with strict ranges.
It also has good exception handling, which is useful in any system. It also has a multiple threaded operation and scheduling as part of the language - awesome!
My understanding is that Ada suffered from being the recommended, or even mandated, language for military projects, and so people steered clear of it. That is a shame.
Another point that appeals is that it is not a stagnant language - Ada 2012 is the latest version (I think). With C, you have C99 and GNU C, but it is not a progressing and updating language in the same way.
So far I have read a lot, and done the obligatory "hello world" program. I need to read more, and code more. There is a lot to actually learning a language. Far more than the Computer Science degree stuff - you have to really understand it in practice and be able to use it properly in an operating system environment. I have to find code I can make in Ada, and that is where the fun starts.
I work a lot in a linux environment. Lots of standard libraries, from mysql, to tls/ssl, and I use them. I need "bindings" to allow these standard libraries to be used from Ada rather than C. That is likely to be where the work lies.
So, reading a book and playing with code while on holiday next week I expect, and I'll report back. Can I "embrace" Ada as a language, or will this be a small diversion and intellectual exercise, or will I just forget it and watch TV? Yet to see.