Making a game in Ada with Raylib

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

I think it would be interesting for you to interview him.

As for GDB, use the catch command to catch all exceptions and b command to set a breakpoint, i.e. hello.adb:10 or mangled name to break at the start.

@Irvise It would be interesting for you to find others who have tried ada too, like getintogamedev (yt).

Shame that tomekw stopped doing them.

I finally finished watching Ep 4. I am glad it went much smoother for Tsoding, which made the video more enjoyable to watch. He even stated at one point that he really enjoyed working on the project. On to Ep 5…

In his tea break he says he isn’t convinced about doing anything serious in Ada because it feels “enterprisey” and “bureaucratic.”

People at the ARG should watch this bit specifically up until 2:34:55 and from 2:38:45 to 2:39:35.

This is VERY important.

Yeah, lack of sufficient documented examples is definitely a sore spot. However, I think it is more of an opportunity for the community to help address rather than the ARG.

You missed the point completely. The bit where he says “they’re killing the language,” is the bit that needs driving home.

In the segments I’ve seen I haven’t seen him find ada-lang.io at all in search results.

I’ve streamlined the process as much as possible for writing docs for ada-lang.io and a lot of people have done so - I’m going to forget people if I try to a full list, but at least Max, Fer, Simon, etc.

I was thinking of putting up demo programs on Alire and then having a “example program walkthrough” section on ada-lang.io. This would include my “Raytracer in a Weekend” example and a “How to send an ICMPv4 ping from scratch (writing your own binding to C) on Windows/Mac/Linux”.

2 Likes

He doesn’t scroll down too far in search results and the things he searches for don’t show this site up at the top.

I learned how to use GDB from its man page; so, directly in the terminal. :grin: As in, you’re not alone.

A breakpoint in Ada is not really that different from one in C imho :slight_smile:

Maybe things have improved since I last used gdb to debug Ada, but there was a while where the support for Ada wasn’t all that great compared to C/C++, roughly 6 years ago, as I recall, because that’s when I was learning Ada, and learned that certain things I was accustomed to doing in C/C++ didn’t work with Ada – not in the same way, anyway. Unfortunately, after 6 years the only thing I don’t remember what the issues were, and to be honest they are probably one reason I’ve avoided using gdb with Ada.

The other reason woudd be that Ada is such a great language I haven’t needed gdb. Then again, that may say more about how little I use Ada, and the tasks I use it for.

Here goes another summary of the videos with respect to Ada. This time, it includes videos up until Episode 13/20, which was streamed yesterday:

The Good Parts

  • He was kinda happy with generics when he actually had to implement a generic Queue.
    • Though he is still not happy about using them.
  • He was extremely pleased with the use of Enums in/as array indexes. He said that it is incredibly sad how modern programming has forgotten about this behaviour and he is very pleased with how simple they are to use and how close they are to look-up tables.
  • He pointed out that working with Ada has been an “extremely educational experience”.
    • Maybe this was said with a bit of bitterness, as in negative experience too.
  • He really liked that there are runtime checks for arrays.
  • He really likes Enums in general and that arrays are their own type.
  • During refactoring in Episode 12/20, he pointed out that some solutions in Ada are very elegant. He seemed proud of how “obvious”/“clean” the code looked in Ada.
  • When he implemented his Queue implementation he said “I implemented it first try, which I don’t like as I don’t know if I made any errors.”
    • He was pleased with how “easy” and direct everything went. But it seemed that he was honestly disappointed as he wasn’t sure that he had done everything correctly, but it all seemed to work so he just went ahead.
    • He also had a few bugs, so it wasn’t a clean “first try”, but it mostly “just worked”, which I believe he did like it a lot.

The bad parts

  • He struggled a bit with Files and IO in Ada. He did not understand and did not care to understand about Direct IO, File_IO, etc.
  • He struggled quite a bit on episode 11 with parsing and printing Floats in Ada. On Episode 13 he struggled A LOT and he became very bitter about the experience. He only wanted Floats to be printed like in any other language, not with scientific notation. He was very annoyed with regards to how numbers are transformed into strings in Ada.
    • By the end of episode 13 (the latest at the time of writing this post) he was VERY underwhelmed with Ada and he felt Ada just wasted his time.
    • He pointed that Floats are very anal in Ada.
  • Strings having their size fixed bit his ass a couple of times with regards to run time checks and code organisation/type use.
    • I think he does not know that strings can have their size undetermined up until they are declared…
    • But he was not mad about this: “Ada is anal, but it makes sense”.
  • He feels generics are unwieldy and very bureaucratic. He hates the idea of having to create a new package just to use generics.
    • But he liked them when he implemented his own Queue.
    • He also pointed out that it is “interesting” how generics are basically generating a specific package definition for the type you give it during compile time.
  • He did not seem to like that Ada does not allow for anonymous types in arrays, as, in his opinion, declaring a type just for a simple index is “Too many layers of bullshit”.
  • He had issues with exceptions and printing a message when they happen.
    • Once again he complained that there were no clear and simple examples on how to do this, just documentation and lengthy explanations.
  • He dislikes the cryptic nature of attributes. He would have preferred if they were just function that one can call and that learning/finding information about them were obvious and not “hidden away”.
  • He implemented his own Queue as he did not find one that he liked in the standard library.
    • In the end, performance wise, it was similar to the use of Vectors from the standard library, as the performance issue was in the algorithm.
    • I would be surprised if Ada did not have a Queue implementation that he would have kind liked?

General comments

  • He is now spending a bit less time dealing with Ada and spending more time with the game, this can be seen on his work of the pallet editor, map/game design and pathfinding/AI.
  • He said “Ada is not going to be my new goto language”
  • He said he has “mixed feelings about the language” on Episode 12/20.
    • I am pretty sure he really likes some features (types, Enums, checks, arrays), but he really dislikes the documentation, lack of examples, the bureaucracy of the language and the cryptic nature of type attributes.
5 Likes

He says he doesn’t do much on twitter, but might be worth asking him if he would be willing to be interviewed by you about it all?

Re: the generics stuff, Shark8 submitted a proposal to automatically instantiate them.

1 Like

You’re making a true new-user experience analysis with this subject :slight_smile: I hope this can be used for improving some aspects in the language ecosystem and community.