I learn ada just for fun, but I got experience from c-like language a lot,
so I want to learn ada the c/c++/java way
any tutorial? thanks ![]()
I learn ada just for fun, but I got experience from c-like language a lot,
so I want to learn ada the c/c++/java way
any tutorial? thanks ![]()
The best way is IMO to start a small project. You could take some old program of your own and try to implement it in Ada. Do not forget asking questions about Adaâs programming patterns, since they differ from C/C++/Java. Especially pay attention to Adaâs ability to define scalar user types, avoid predefined types. Another key feature is returning indefinite objects. You do not need malloc(). So avoid pointers. Furthermore, avoid any libraries including the standard one. Ada can be effectively used and learned in its pure form. Once you master Ada you can start using libraries with the knowledge how things works there, should you be asked to implement them. Differently to modern C++ (the old C++ was quite transparent) in Ada you can trace practically any construct down to the machine instructions.
Good luck!
You could try old Advent of Code puzzles. A group of us work on them every year, so you can find solutions on this website, complete with links to GitHub repos, and compare what you might write in C/C++/java with Ada. Itâs instructive to compare how an algorithm is implemented differently in different languages.
I did this with Rust a couple of years ago. Interestingly, Ada has a reputation for verbosity, but I found several cases where Rust was more verbose and awkward. And of course Adaâs type system allowed me to do things I can only dream of doing in Rust.
Not a tutorial, but more advice on how to use Ada: describe the problem-space with the type-system, then use that to solve the problem.
There is also this ebook: Ada for the C++ or Java Developer â learn.adacore.com
oh, shit, I didnât notice it, finally got it, thanks
That ebook is very basic. It will show you the equivalent code but it doesnât cover a lot of problems that you will encounter when going from C++/Java to Ada, especially if you use STL a lot. Also doesnât cover casting/boxing which many C++/Java developers tend to use.
Well if youâre familiar with the STL, you should have no trouble using the Ada container library.
Iâd caution that that really depends on how familiar one is with Ada before setting out to use its container library.
I was familiar with the STL back in 2017-2018, which was rougjhly when I started with Ada. Admittedly I didnât use Ada regularly, but it took me quite a while to wrap my head around Ada and its container library.
Welcome to the forum! Nice to see a post from the person who had a big influence on the creation of the Ada container libraries.
casting/boxing ? If you need casting to convert a malloc returned value, youâre fortunate, in Ada, you spell new Typeand you have a value of the needed type. You want to implement a fancy generic structure (lets says a Red-Black balanced tree with no hardwired leaf type) ? use a generic type/package, and you have what you want. You want to check if Objis in Childclass, then have a variable with the Childclass type ? Just use Child(Obj).
And if you really know what you are doing Ada.Unchecked_Conversioncan be your friend. (But obviously, it shouldnât be used instead of other more âclassicalâ Ada expressions⌠then its use is quite verbose).