Hello, I have used C basically all my life, currently, I am working on a synthesizer and would like to use Ada. I learned Ada recently (mostly from learn.adacore.com) and, although I have done some simple games, I am still not very comfortable writing code in it. Are there any exercises or simple projects you could recommend? I am particularly interested in learning Spark and multithreading in Ada, so if you have suggestions that involve those aspects, that would be very helpful.
A lot of people use Advent of Code problems to force themselves to learn a language (or learn it better), and I did that with Ada. The problems start off relatively easy, then become progressively harder, though not monotonically harder; i.e., you get a hard day, then an easy day or two, then another hard day, then another easy day or two, then a couple of insane days, etc. I don’t think anything strictly needs multithreading, but I used task
s for one year’s solutions, and several people have used Spark for at least some of their AoC solutions.
However, there are important aspects of Ada that Advent of Code doesn’t really exercise; for example, I’ve never had to use Ada’s object-oriented facilities w/AoC, nor protected
objects, nor limited
, nor controlled
. I have used some of them in other contexts, such as Rosetta Code, which is another source of decent exercises.
I’ve heard of other sources, as well, but those are the only two “exercise”-based resources I’ve used with Ada.
You can read the excellent book about common multi-tasking patterns, with illustrations with Ada code :
Concurrent and Real-Time Programming in Ada
by Alan Burns, Andy Wellings
Cambridge University Press [2007]
Other book references on Ada Forge / Learn
Alternatively, there is another group called Protohackers about casual programming challenge in which you create servers for network protocols. Take a look at their progressive challenges.
These need tasking (sync, async) and protected objects, error handling …
Hi!
Is Burns and Wellings book still a good read with Ada 2022? I’m also interested in this domain. Thanks a lot!
Old books remain good read on the topic. You can still learn tasks from Ada 83 by Narain Gehani’s “Ada: An Advanced Introduction” and protected objects from Burns’ “Ada 95 rationale.” Later few additions are not essential to understanding the Ada concurrency model. You would need to learn some common patterns involving dealing with protected actions, guards, entry counts, and, very important, requeuing.
For exercises it is helpful to consider implementation of interlocking mechanisms like mutex. From simple mutex, to reentrant mutex, to read-write mutex. FIFO, pipes, Dining Philosophers with nutexes, mutex arrays, task monitors etc. Compare complexity. Measure and understand differences in performance. Single- vs. multicore etc.
IMO, this is more useful to understanding the concurrency handiwork than network tasks.
I have this book and I found it excellent for learning about the innards of Ada concurrency. It won’t cover the 22 changes obviously so no parallel blocks, but it’ll cover most everything else.
When you did the learn.adacore.com, did you look at the labs section? Just asking cause there are a lot of tasks there to try out of varying difficulty. Just checking. If not, here was the link to them: Introduction to Ada: Laboratories — learn.adacore.com
Thank you for all the responses :).
I haven’t heard of Advent of Code before so I tried to solve some, it was interesting.
Also I am not really experienced & don’t have any interest in network stuff but I’ll bookmark it if I ever need it.
I will take a look at the books mentioned as well.
When you did the learn.adacore.com
Few weeks ago.
did you look at the labs section?
No, but now that I know about it, I will.
The kindle edition is more expensive than the hardback
I’ll never understand that (why E copy is so much more expensive). I have the hardback copy myself, but I saved up for it.
Publishers want to keep the prices of paper books up. I think it is a miscalculation on their part, because it forces many people to piracy.
It is like all that hysterics about vinyl records. Not only vinyl is inferior to CD, people buying it do not care. But the point is that after you played vinyl a few times you would have to buy a new one while CD would last forever. So labels they intentionally kill CDs for mp3 and vinyl.
I think the only correct answer to why electronic books are so expensive is that… People still buy them at those prices, so the publishers don’t feel the need to reduce the price.
Probably lucky for me, otherwise I’d have bought a mass of electronic books I don’t actually read… and would have lost, so I’d have to buy them anew…