Making a game in Ada with Raylib

I think a big takeaway I got was how we present examples for Ada. A lot of what got him were like paragraphs discussing language philosophy and nuances, when all he wanted was a quick straightforward example. Even some of the examples he found were super complex with really large names that obscured the information he was looking for. The ARM can be bad this way too. They try to make sure all the examples flow together and refer to each other when possible, but this leads to some really not useful examples sometimes, despite the good intentions.

Things of note he had trouble finding quick examples on:

  • Dynamic arrays (he never found that Vectors is the answer he was looking for…at least up to ep7 so far).
  • Reading a file directly into a string (a common idiom for smaller projects and small configuration files)
  • He has no context for indefinite/definite variables in Ada, so he doesn’t know to look for indefinite containers for things like strings. I am sure he understands the concept notionally, but other languages don’t distinguish on it as much as Ada does
  • complete examples using strings with thin c bindings. He struggled with this one for a while but eventually figured it out playing with the language. It doesn’t help that Ada provids 3-4 methods to pass a C string in the interfaces packages.
  • he never figured out how to access container elements via indexing (as of early ep7), so he is doing a lot of gymnastics trying to get procedures like Replace_Element to work the way he wants

I"m sure there’s more…those were just off the top of my head,

I usually hit up Rosetta code for Ada examples, but I know to go there and it rarely shows up on search results for me. Some of the examples are out dated but it usually helps me. The ARM is rough hit or miss with examples. I have gotten some good ones from Rationale documents, but those are discontinued. The Adacore site is good for a reference section, but it does approach it in a way expecting you to read through all the paragraphs, so using it to search for examples that are easy to read out of context is a bit hit or miss.

Side note, the version of the RM he kept pulling up had horrid background color (it legit hurt my eyes). When I pull it up here, the background is much different. that seems so odd to me.

4 Likes

My experience is that concrete examples showing common usage patterns for specific things (programs, data structures, functions etc.) are so important. Particularly for things that people are only incidentally trying to use to complete a more general task, but also in cases where people are trying to get a rough feel for a system - like here - without necessarily intending (or needing) to become an expert in it.

When i was learning Haskell, years ago, there was a attitude from some quarters that concrete examples of how to use a library weren’t needed: “Just follow the types!” One person described what learners were then forced to do as “playing Type Tetris”.

Are people here already aware of the “tldr” project, where people can contribute usage examples to accompany the official man pages for various things? Is there something similar for Ada?

2 Likes

There indeed were “official” Rationale documents up to Ada 2012.

For Ada 2022 a similar document is “An overview of Ada 2022”, which describes what’s new, with examples. It is available at: http://www.ada-auth.org/standards/overview22.html .

I think he had this problem with the background color of the site due to his experimental black theme mode in Chromium, he has had similar problems with other sites (such as LLVM) in the past, here is an example: https://youtu.be/JTjNoejn4iA?feature=shared&t=194 (3:14 timecode)

IMMO, the answer to all this is Ada FAQs: if there were a book like the C++ FAQs (2nd ed.) for Ada, I’m pretty sure the experience of Tsoding would have been radically different, and the online version would have been a very valuable resource for his work.

My experience with that book dates back more than 20 years, when I ruined my ankle and had to be in bed for more than a month. I read that book cover to cover, and my C++ knowledge improved by orders of magnitude. The book covers not only the C++ language, but also good design principles (currently known as SOLID principles) and other interesting topics (e.g. design by contract). The book is well structured, easy to read, with terribly useful examples and lot of Aha! moments. It is not meant to learn C++ from scratch, but highly recommended for programmers with an intermediate knowledge of C++.

How do I wish there was something similar for Ada and SPARK!!

Do you think it would be worth starting a collaborative project like this?
(of course, ada-lang.io is the perfect place to do it)

3 Likes

There are some (old or very old) Ada FAQ’s:

https://www.adahome.com/FAQ/programming.html
Programmation Ada/FAQ/Généralités — Wikilivres (in French)

There’s also Category:Ada - Rosetta Code
with lots of code examples.

And this site already has Ada Quality and Style Guide | Ada Programming Language that offers lots of advice on how best to write Ada code.

All this might be useful as basis for a new community-maintained Ada FAQ.

1 Like

People who insist on imposing their dark mode obsession on the rest of us get what they deserve once in a while. :grin:

1 Like

Dark mode is super useful for some visual impairments. I know on my end, my eyes see excessive shadowing do to a physical deformity on the surface of my eyes, so inverting the background to black and letters to white for example really sharpens my view because the letters no longer look like they are in a giant clump of black nothingness. Instead the letters have some breaks in them here and there (from the shadowing) but otherwise are more distinguishable than black letters on white.

Somewhat ironically, even though Ada is my favorite language, it tends to be the hardest for me to read. It’s much easier to miss a detail in large sections of text (which Ada looks like) than when I can super space out symbols on a less verbose language. I still prefer Ada but it takes me much longer to do stuff in it. Just trying to figure out how iterators worked in Ada was a serious undertaking for me. The amount of scaffolding you have to set up for it was really hard for me to parse through when I was looking for examples.

That maybe why I am more sensitive to Tsoding’s desire for small easy to parse examples (as that makes it easier for me to read)

1 Like

Thanks, I wasn’t aware of that. I like to work on an electronic ink monitor, in part to avoid damaging my eyes, and dark mode just does not work on that thing. When I use a regular screen I’m in a room with lots of sunlight, and not only is light mode nicer to look at (IMHO) but it’s easier to see in that case. But most of my colleagues seem to sit in dark rooms with the curtains drawn, so they bellow in pain like vampires when I share my screen and I get an earful.

3 Likes

ada-lang.io has a dark mode, so he might have liked it, if he had scrolled a bit more on search results.

Hello here, I wrote a first version of a Raylib binding for Ada: GitHub - Fabien-Chouteau/raylib-ada: Ada bindings for the Raylib library

This library is truly amazing.

6 Likes

You should add raylib as a submodule and build the lib locally.

This is very cool!
I hope that people will contribute more to the Ada community and the language will start to flourish again someday.

1 Like

If you end up using it a lot for fun stuff, it might be worthwhile to gradually make a Thick binding to it.

1 Like

Another contribution after the Tsoding’s new-user experiment. I’ve restored the Vectors tutorial that the now-defunct wiki.ada-dk.org once had. I’ve merged it with the stub already present in Ada Programming/Libraries/Ada.Containers.Vectors - Wikibooks, open books for an open world

I restored the content from the Wayback Machine and you can see the original history in the Discussion page. The original author was thomaslocke, and it was in the public domain.

I’ve made sure it contains the keywords “dynamic arrays” and “resizable arrays” :wink:

Feel free to improve it further.

(it is known that the links to the source code in Sourceforge are broken; that part is work-in-progress).

Awesome job!

For anyone with an account there to edit:
The main thing that appears to be missing at first glance is “indexing” the vector objects: My_Vector(1) := Value for example. It think that is an important feature to highlight.

That and maybe two simple examples of how to iterate (“for of” and “for in”) at the beginning of the iteration section.

2 Likes

I haven’t watched past eps 10, but I just noticed Tsoding stated he believes Ada is suitable for game development: https://x.com/tsoding/status/1773393747008467128?s=20

There are some jewels in his X stream:

This is for you, Ada enthusiasts:
https://x.com/tsoding/status/1771908054893695087?s=20

This time, Ada is the best kept secret (I’m forgetting his closing of my PR):
https://x.com/tsoding/status/1767288966674354252?s=20

We know that feel while searching Ada and getting the American Diabetes Association:
https://x.com/tsoding/status/1767288966674354252?s=20

The “Rationale for Ada 2005” contains m-dash instead of minus in source code:
https://x.com/tsoding/status/1765823410284720600?s=20

And finally, from his itch.io, a possible surprise:

1 Like

:man_facepalming:

Not the first time I’ve seen that happen in code, but it’s still baffling that this is there.

I have an embedded compiler and I swear that if someone on the computer next to me types a non ASCII character (>127) on their machine that my compiler tries to commit ritual suicide. Copy/paste from web pages is like gambling!

1 Like