Making a game in Ada with Raylib

The Twitch streamer Tsoding has been learning Ada over the last week by building a game with the raylib graphics library.

It’s been fun to watch, albeit a bit frustrating when he only skims the documentation then claims it doesn’t answer his question.

Day 1
Day 2
Day 3
Day 4
Day 5
Day 6
Day 7

10 Likes

Wow! It’s a pleasant surprise he is revisiting Ada. I really hope this time around it has been a smoother experience, though your comment already has me a little concerned. Hopefully some who knows Ada and were watching the live streams were able to provide some advice to him. Definitely will start watching the videos.

I finished watching Day 1 and watched some of Day 2. It’s good to see that he is actually making progress and liking Ada despite the various small issues he experiences.

@JeremyGrosser I agree that it is frustrating to see him missing some details, despite being right in front of him in the documentation. If he were more patient then I think it would go smoother for him. It also doesn’t help when he makes some wild remarks which are not the fault of the language (eg he complained about the highly abbreviated file names that GNAT library files. )

Hopefully he has a good experience in the later episodes.

OMG, the first half an hour is whining about the ONCD report stating that C and C++ are dangerous and should not be used, no shock there.

All he’s really doing is programming in C in Ada in this video.

Just started on the second one, the C_Pass_by_Copy stuff, I should know this, but I didn’t really even though I use it for colours in SDLAda too (been years since I originally wrote that, so cannot remember). I thought Ada could put small records into registers directly too.

If my memory is correct, the C_Pass_By_Copy came about because the ARG goofed and thought all C structs were passed by reference, but that’s because most C code they came across would passed the address of the object. Ada compilers would implement pragma Import and Export to pass records via C convention by reference. Since it was too late to undo that (eg break existing code) they had to introduce C_Pass_By_Copy.

1 Like

Who’s the Ada dev (ExitCode0) in the chat on stream 2?

Oh, it’s the Ada Doom 3 guy.

Ok, it’s kind of infuriating watching these videos, but maybe the next revision should have a legacy runtime and a new runtime?

I watched way too much of these.

It’s like he’s doing this as a joke, and he has huge frustrations interspersed with disbelief of cool features every now and then.

1 Like

I hope people are smart enough to realize what he is displaying in the link below is not a reflection of the Ada language, but rather of his code organization skills.

https://twitter.com/tsoding/status/1766571137402646813

While I am not a fan of his approach to learning Ada, my hope is that he actually helps to generate more interest in it.

2 Likes

Are you aware of how ignorant people view Ada??

This seems to be a thing now. Books? Nah! Website with the reference manual? Nah. Let’s just guess based on having used C.

I’m afraid you’re right. The amount of misinformation and FUD that’s spread about Ada on social media dwarfs the amount of genuine info and experiences.

I’m trying to do what I can to correct or point out the most blatant misinformation and invite everyone knowledgeable to do the same…

Thing is, I don’t think he’s wrong about the runtime though. Problem is, the runtime is directly linked with the compiler.

Simpler languages, even Fortran, were easier to update to be more modern than Ada has ever been; Ada has always been complex.

By updating the runtime to be more modern, you could get rid of the mess of strings, the old antiquated I/O stuff, the containers with tampering which just seems like a mess.

In the second half of episode 3, he acknowledges the fact that his approach and the things he says can be polarizing, but it’s just how he is. He goes on to state that viewers should focus on whether he can make progress and what he is able to achieve in the end.

He did make a comment that he thinks better documentation and more examples need to be available. There is room for improvement in both those areas, especially with regard to insufficient examples. There are still some good sources of documentation. However, I think part of the issue is that he often just doesn’t have the patience to read what is there, which is a shame.

Regarding standard library, yeah the whole string standard library can use a revamp.

2 Likes

I stopped watching that one as it was just too painful.

Doesn’t matter what documentation is available if you load it, scroll past what you’re looking for and then whine about it not having what you want.

Yeah, and the rest.

These notes were taken after I had already seen about 6 episodes. I wanted to track this info to organise some of my ideas, open a discussion and use this information for a future talk that I want to give.

Good parts:

  • He is enjoyable to listen to, his main goal is to entertain.

    • Being entertaining is a huge plus, but he prefers to be fast and make jokes rather than being good at what he is doing. This sometimes leads to people misunderstanding positive comments and he potentially gives Ada a negative spin sometimes. Though I do sympathise with his didactic methods, so I am okay with that.
  • He is extremely knowledgeable and a quick thinker. He has worked on plenty of projects and languages.

  • He is not bothered that Ada is not so well-known and that his viewership may not be that high, but he does not care about it, he wants to use it.

    • He also mentions that he will finish the game because he is really enjoying writing it.
  • He had already used Ada in a previous project (game of life), so he already has a good grasp of the nature of the language.

  • He clearly states that he likes Ada. Even though he is mad at it several times, he explains he wouldn’t be so angry if he didn’t care about the language itself. The reason he gets mad is because he genuinely likes the language.

  • The type system is something he thoroughly enjoys and praises Ada about.

    • He is very happy with the type system being so expressive, complete and helpful during compile and runtime.
    • He is happy with the flexibility of indexes.
    • He is happy with the syntax of for loops/iterating over data.
    • He is happy with enums.
    • He understands that one may need to cast more often with this strict and expressive type system. This is uncommon for new people coming to Ada.
    • Though he finds generics quite a pain. More on this later.
  • He is very happy about the ease with which C code can be bound and used

    • He manually and quickly binds the functions he needs. He did not use the automatic generator from GNAT, which made him miss some documentation regarding some issues/details of structs…
  • He is happy that one can define functions/procedures inside the declaration blocks of other functions/procedures and he exploits this to his advantage.

  • He is happy he can easily create his own exceptions.

Negatives parts:

  • HE BARELY READS THE DOCUMENTATION, WHICH MAKES HIM MISS QUITE A LOT OF THE ANSWERS HE IS LOOKING FOR.

    • This is a much bigger issue than what people realise, and it is not unique to Tsoding. A lot of people rely of forums, examples and (specific) tutorials, not on actually reading the documentation, not even reading a full fucking paragraph. This is how a lot of people learn. Ada, historically and even today, relies heavily in narrated documentation and takes its time to lay down the ideas and concepts. This is good. Sadly, we live in a world that does not appreciate/utilise this to their advantage. Queue the meme “Why spend 10 minutes reading documentation when I can spend an hour doing trial and error until it works?”.
    • Also, I believe he did not realise that he found himself several times reading the actual Ada standard. He complained that there were no examples or direct answers.
      • I am pretty sure that if he had realised this, he would probably praise Ada, as no other standardised programming language has a standard so easy to understand and read that even a beginner like him could use it.
  • He is a very knowledgeable guy, so he relies on intuition quite heavily.

    • Ada is not similar to any modern programming language. Therefore, a lot of the naming conventions, code structures, libraries, etc; that are common elsewhere, are not present in Ada. This makes Tsoding (and many other programmers that try Ada) fail miserably trying stuff out that in the end does not work. This leads to a waste of time and frustration. And this issue is compounded by the aforementioned point, the lack of reading documentation; a lot of the times he had the answer right in front of him and he failed for a while to find it…
    • Continuing with the above, I think this is why other languages such as Zig, Rust, etc; are so loved; they are similar to what people tend to already know, so they have to think less and tinkering around tends to work. This leads to a feeling of increased productivity and a nicer experience. Nonetheless, this is not a clear indication that a language is technically better; it just has a lower barrier of entry.
    • Nonetheless, when his intuition pays of or he finds that Ada does things better than in other languages, he is very positively impressed (“pog”).
  • Regarding the type system:

    • Though he likes the type system, he never got any deeper than what he actually needed at every step, which basically boils down to Enums, Ints, Mods and Floats. He was surprised to see that “delta” was a keyword and after looking deeper into it, he found out that was part of “fixed point” types. He complemented fixed points, but never gave it a second thought…
    • Since he is binding to Raylib (a C library), the interfaces to the external functions use C types for its signatures. Since he never wrapped them, his code became filled with “To_C()”, making it more polluted and noisy. He also did not want to convert variables back and forth to their C equivalents, so he used C_Floats, C_Ints, etc; as the main types for his data. This completely defeats the type system of Ada…
      • Summary: due to the extensive use of C types and lack of wrapping, his code was less readable/noisy and did not take full advantage of the Ada type system.
    • He thinks Enums are just Enums and that they cannot hold/represent a value… This is wrong, as he never researched representation clauses in the documentation…
    • He admits he does not know how to use discriminated types and that he will not read about it…
    • He did not learn about “tagged” types. He did not use them, but some in the chat thought that some OOP would have helped and Ada did not provide such features, which is incorrect…
  • Regarding Maps and the issues he had using/deallocating them:

    • He did not learn about generics properly and therefore had issues understanding generic instantiation.
    • He skimmed the documentation/standard library, making it a lot more difficult/slower for him to correctly comprehend the concepts and the available functions/methods.
    • He spent a looooong ass time searching for a “simple” and “quick” why to deallocate/delete data. When he found the answer (instantiating Unchecked_Deallocation) he dismissed it, got lost, heavily complained about Ada not having simple and an easy way of deallocating data and finally caved in and used Unchecked_Deallocation… Which he only had to use once. He failed to realise that this fairly large inconvenience is a rare occasion, since in Ada, explicit allocation/deallocation of data is not as common in other languages (which is a good thing). This greatly reduces the burden of the programmer and it forces the programmer to take time and think about deallocation carefully. To be fair, Rust is MUCH better at this than Ada due to its set of features.
      • After this huge issue he had and spending about half an hour, I noticed the amount of praise that he gave Ada decreased substantially and he started seeing it with a more negative view. Nonetheless, he had already seen a lot of the good stuff, so of course the praise had to be dialled down.
    • He correctly complained about the naming scheme of the Standard Library files within GNAT. They are everything but intuitive.
  • He hates string management in Ada

    • I agree with him, strings in Ada are quite a mess.
    • But had he read a bit about them, instead of expecting everything to just behave like in every other language, he would have understood Ada better and would have had a better time.
  • He admits that Jai is clearly better and the only reason he is using Ada is because Jai is not currently widely available. But that he would switch in a heartbeat.

    • This comment appeared after noting that Ada has no metaprogramming. This issue popped up when he had to decide what state to save. In Jay he could have marked data with a “saveable” tag and that the metaprogramming features would generate the data and code to do most of the work.
    • He also pointed out that he found it very natural to find how Jai does things and that is not the case with Ada.
  • He barely used the package system to better structure his code. Making the code look a lot worse than what it needs to. Packages are one of Ada’s strengths!

    • Being fair to Tsoding, he admits he wants to get things working first and then refactor it into a better program. Sadly I doubt much refactoring will take place as this is a private project and that packaging the code nicely will just not take place…
  • Slow compile times

    • He complains about Ada being slow to compile (as his project grows larger). However, he has all the generic instantiations in the same file he is constantly modifying. Generics are known to be very slow to compile in Ada… Someone in chat recommended to put the generics in another file, but he did not see that… Nonetheless, he has a point.
    • He is annoyed with exceptions not telling him exactly, in which line, they took place.
  • He does not like to learn a new build tool (GPRbuild) and does not like incremental builds

    • This is a fair and honest point.
    • However, he had issues with incremental builds due to not spending a bit of time learning about gnatmake.
    • He praises gnatmake (a bit later) for doing the binding/linking all automatically. He does not understand that gnat is just GCC (see his doubts about optimization levels…).
  • He thought that the compiler ± enforced a formatting style.

    • Later, he switched to using 4 spaces for indentation and he was happier.
  • Debugging

    • Oh boy… He is aware that in Ada you do not need a “main” entry point. Nonetheless, his programming reflexes kicked in and he failed to find a way to set a breakpoint where he wanted. He thought that Ada_Main is the program entry… and he is not entirely wrong, but that is not correct either. He became really frustrated and stopped trying to add a proper breakpoint.
    • Nonetheless, being fair to him, he did admit that he is probably failing at understanding something and that Ada is likely easily debuggable.
    • His issues hit me personally really hard, as I had a wonderful experience debugging Ada and I would not have found some very difficult bugs in large/unknown codebases (to me) without the advance runtime checks and easy GDB integration (see the “catch” GDB keyword).
  • He pointed out that finding which type attributes are available is very annoying and unclear. I partially agree with him on this, but then again, he failed to RTFM… He did not use them as much as he could have due to this reason, which I think is a shame.

General comments:

  • He had issues getting Ada working in Emacs. The Ada-mode in Emacs needs to be maintained and refactored to become easier to use. Basically, it has to become “plug & play”.

  • He knows about contracts, but does not use them (so it is basically Ada, not Ada/SPARK).

  • He did not touch the tasking system, which is fine.

  • I do not think he used subtypes.

Closing thoughts

I think his streams are a clear positive to the Ada community in general. They are bringing people’s eyes into the language; and he has a quite large audience, In one video he said that about 600 people were watching (live!). They see that Ada has a lot of nice features and that they are not new, it is just that “modern” programming languages just failed to learn anything in the past 40 years. It was common to see comments such as “Ada is very readable”, “this is a nice language to learn”, “pog” / “poggers” (which a modern way of saying “really cool!”), “Can Rust do that?”, etc.

If I missed something, please, feel free to add it!

Regards,
Fer


Edit: some extra points after having seen the 7th, 8th and 9th episodes.

Good parts

  • He noticed that the OOP features in Ada are kinda shoved in and that the original creators didn’t really like it. Tsoding personally agrees with it quite a lot. He likes that OOP is there but it was never heavily integrated with the language.

    • He is not wrong on that. OOP is not something that the Ada community/designers liked.
  • He sometimes refactors parts of his code and creates local procedures which makes his code look cleaner.

    • It is nice that he notices his code is getting a bit out of hand and when he cleans it up he realises how much cleaner it becomes.
  • He is happy that Ada allows for custom indexing.

    • He finally realised that aspects exist :slight_smile:
    • But… Look into the Bad parts section.
  • He implemented his own Queue from scratch, including some methods/procedures pretty much in his first try/compilation.

    • I think this was helped thanks to Ada’s readability. Though this is just my personal and humble opinion.
  • He did not realise that 'Image for Integers has a leading space to account for the minus sing. That is why his debugging information for the path finding looked so nice/squared.

  • I forgot to say that he was happy with the useful error/warning messages that the compiler emits :slight_smile:

  • His content idea is to make a video in his main YouTube channel about his experience using Ada and explain how to build games using it :smiley:

    • Hopefully as he gets deeper and learns about the different topics that he has overlooked, the final result will be positive ^^

Bad parts

  • Copying arrays, maps etc, is not obvious an normally requires access types, which is not ideal.

    • I agree with him.
  • He missed pragma Debug() and the family. He wanted something to do conditional/debugging compilation.

    • It is true that Ada does not really provide features found in other languages on purpose, so people expecting them are turned down a bit.
  • He is extremely disappointed with discriminated records

    • I believe he understands discriminated records. However, since he didn’t read the explanations and examples in the Wikibook, he missed some of the niceties that they bring.
    • He expected them to be more like polymorphism.
    • He could have used them to better structure his records, which are quite similar and they are used in very similar ways… This would have probably also helped him with the “save state” issue… sight…
    • He states that this feature was so underwhelming that it left a very bad taste and impression on him.
  • Regarding custom indexing

    • He wanted a direct answer in the documentation… Which he obviously did not get and was annoyed.
    • The ARM indicated that this is possible using tagged types, which he really did not want to use. I believe during his testing, he used an access type, which then the compiler told him to use a record instead and he just completely gave up.
    • I am unsure of what he was actually trying to do really… Maybe a simple custom iterator was all he needed?
  • He states that the language starts great, but as one goes deeper and into more complex/advance features and requirements, the language becomes underwhelming (see the points above).

  • A user posted how to do BFS in the chat, from top to bottom. Since the code is unformatted, Tsoding dismissed it saying it was like C++ programmers, where they just throw a large wall of templates and call it a day. Sadly, that was not the case here, the user was just using Priority_Queues…

    • He pointed out that he wanted to find this info by himself and not have it handed/mansplained to him.
  • He complains that Ada has no continue in order to start the next loop iteration

    • He is right.
    • He missed the second entry in the Rossetta Code example, where a double tagged loop is used instead of a goto… Sight…
  • He missed on iterator filters (a new addition of Ada 2022) (see the when in the example below

for E of Some_Array when E /= 0 loop
   Put_Line (E'Image);
end loop;
  • When searching for Queues, he found the Tasking specific constructs and stopped looking for an actual Queue object. And a few seconds before he had actually opened the file with the actual Container specification…

    • RTFM applies here once again very hard…
  • I missed this one, but he does not like that Ada is cans insensitive and that it uses fairly long names.

General comments

  • As he is getting deeper with the game, the amount of time and comments related to Ada’s features are lower. This is to be expected, as he is becoming more used to Ada and wants to add more complex features to the game.
9 Likes

Yeah, I saw a few people say they were wanting to try Ada and I saw one say he’d just bought an Ada book.

Other’s said in the chat numerous times that the emacs ada-mode didn’t work and you had to use the older one, I dunno, I gave up on ada-mode and emacs years ago, because I assumed as did he, that once installed, it should just work, which it never did, because you have to compile it yourself, which is a bad move.

4 posts were split to a new topic: Getting emacs ada-mode working

@Irvise OMG, what an impressive summary of the videos. Did you actually finish watching all of them?

I have only finished the first three and have to take a short break before I see the next one. It’s frustrating to watch him inadvertently making the experience so much more difficult than it should be. That’s not to say none of his comments are fair (some are), but geez he spews so much misinformation when he complains. I’m glad he at least still manages to make progress.

4 Likes

Having learned Ada in isolation - I’ve still never talked to another Ada developer in person - I’d have been pretty lost without Barnes’ book. There’s a lot of things that Ada just does differently and you expect it to work with C or C++ and it doesn’t. Compared to how Rust, C#, C++ and every other language I’ve used, the way Ada does generics is wild. On top of a lot of differences in keywords to search for to find what you’re looking for – e.g. I never would have looked for “Controlled types” or “tagged types” or “discriminants.” Some of this is because Ada was using some things before the terms were standardized.

he failed to find a way to set a breakpoint

I’ve always had to revert to using inline assembly with int3 to break reliably since I don’t use GNAT studio.

The resources have improved now, learn.adacore.com is impressive, and Alire makes things 10x easier.

The streams have been great to watch. Has anyone reached out to him, or pointed him at the forum?

2 Likes

I am just going to say that I lost a few hours of sleep these last days :wink:

Agreed.

I am pretty sure it is just me, but I learnt how to actually use the basics of GDB directly in the terminal. I still remember watching videos and reading blogs and manuals for a couple of hours to correctly set breakpoints, watches, catchers, etc. I will admit that it is pretty complex, but it really just works. A breakpoint in Ada is not really that different from one in C imho :slight_smile:

Not me. I wouldn’t mind “interviewing” him, but he said that he will do an “Ada experience” summary video at the end, so I think this will be a good summary of his journey :slight_smile:


Good parts

  • In his current stream he just found how to properly use variant records/union types!!!

    • He admits that this changed his perspective on the language (he is “not disappointed”) and that the syntax is quite strange. He was never really angry with the language even with his harsh criticism, but he likes the language even more now :smiley:
  • He initially thought that -gnat2022 was an extension, but I think he read that in chat someone said that is was just telling GNAT to use the newly released standard.

    • He was surprised that in Ada 2022 brackets are now used, though he is indifferent(?) to it. He said it makes it look closer to other languages (he mentioned “embrace, extend, extinguish”) ^^
1 Like