Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411518 Posts in 69377 Topics- by 58431 Members - Latest Member: Bohdan_Zoshchenko

April 28, 2024, 03:36:10 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)ALAda test release - OpenAL binding for Ada 2005
Pages: [1]
Print
Author Topic: ALAda test release - OpenAL binding for Ada 2005  (Read 1782 times)
Average Software
Level 10
*****

Fleeing all W'rkncacnter


View Profile WWW
« on: April 23, 2009, 02:26:53 PM »

I'm a big fan of both the Ada programming language, and OpenAL.  It seems as though the only existing OpenAL binding for Ada has vanished from the Internet, so I decided to remedy the situation myself.

I've just posted a test release of ALAda, my Ada 2005 OpenAL interface.  It features full access to the OpenAL, ALC, and ALUT APIs, and uses strong Ada typing to cover up a lot of the underlying C nastiness.  In the test cases I've done so far, I find it much more pleasant to work with than the original C API.

I don't know if there are any Ada programmers here, but I would appreciate some help in testing this baby out and would welcome suggestions for improvement.  Anyone interested can download the code here.  It is written in Ada 2005, so a recent Ada compiler is needed.  The code should be totally platform independent, but I haven't tested it on anything but Linux.

The code is licensed GPL 3 (not LGPL), so take that into consideration.

Logged



What would John Carmack do?
mcc
Level 10
*****


glitch


View Profile WWW
« Reply #1 on: April 25, 2009, 11:59:03 AM »

You're doing game programming in Ada?

Sir, you are a braver man than I.
Logged

My projects:<br />Games: Jumpman Retro-futuristic platforming iJumpman iPhone version Drumcircle PC+smartphone music toy<br />More: RUN HELLO
Average Software
Level 10
*****

Fleeing all W'rkncacnter


View Profile WWW
« Reply #2 on: April 25, 2009, 04:56:55 PM »

Ada is actually a great language for game programming.  I've often thought that Ada is what C++ would have been if Stroustrup wasn't so committed to C compatibility.

There are tons of things in Ada that I really want in C++ and other languages.  Things like ranged types, true separate compilation for generics, threading as part of the language, unit initializers, nested functions, and lots of other things.

Ada is actually very close to C++ in terms of capabilities, C++ has a few things Ada doesn't, and vice-versa.  The biggest issue with Ada game programming is finding libraries, hence my project.  Ada's insanely strong typing catches lots of bugs at compile time too.

If you have the time to learn it, I strongly recommend it.  Even if you never use it, Ada encourages (sometimes forces) lots of good programming habits, and will influence the way you use other languages.  My C++ programming style changed quite a bit after working with Ada.
Logged



What would John Carmack do?
BorisTheBrave
Level 10
*****


View Profile WWW
« Reply #3 on: April 26, 2009, 01:23:42 AM »

I've heard that Ada's strong typing makes it painfully verbose to use, so it's only good for NASA and military contractors who want that level of security. How does it measure up to D?
Logged
muku
Level 10
*****


View Profile
« Reply #4 on: April 26, 2009, 07:38:09 AM »

Interesting. I've heard about Ada before, but I never knew people programmed games in it. How's performance? Also, is there a good free Ada compiler?
Logged
Average Software
Level 10
*****

Fleeing all W'rkncacnter


View Profile WWW
« Reply #5 on: April 26, 2009, 08:32:24 AM »

I've heard that Ada's strong typing makes it painfully verbose to use, so it's only good for NASA and military contractors who want that level of security. How does it measure up to D?

Ada's strong typing only gets verbose if you end up doing a lot of casting, which usually means you designed your types wrong.  In my experience, Ada's typing actually results in less code, since it allows the compiler to check things that other languages can't.  For example:

Code:
subtype Little_Int is Integer range 1 .. 10;

Now the compiler knows the acceptable range for Little_Int, so you never need to verify that data of this type has a valid value.  The compiler checks it for you, giving warnings if it detects violations at compile time, and raising exceptions at runtime for cases that can't be checked while compiling.

Ada does tend to be more verbose in some cases, just because it favors keywords over symbols.  For example, declaring a type that inherits from some other type but adds nothing looks like this in C++:

Code:
class Derived : public Base {};

While in Ada:

Code:
type Derived is new Base with null record;

Longer, but probably more understandable.

How does it measure up to D?

I don't know D, so I can't compare it to that.  The best comparison I can make is with C++, which is the language it is closest too.

Ada supports procedural programming at least as well as C++, possibly better.  Ada has neat things like nested functions, the ability to overload on return types, function renaming, positional as well as named parameters, and a very nice package system.

C++ has more advanced object-oriented features.  Ada uses interfaces rather than true multiple inheritance, and Ada is the only language I've ever used that got interfaces right.  Ada interfaces can have required overrides, optional overrides that simply do nothing if not overridden, and non-overridable methods that can actually have bodies.  It also has the interesting notion of interfaces to threads, which I'm still exploring.

Ada has full language level support for threads, including inter-thread communication and simple thread-safe data structures.  I have to emphasize that Ada threading is actually part of the language, not the standard library.  Most languages sort of half-ass this, like how Java has the Thread class and Runnable interface in its library, but has the synchronized keyword in the language.  Everything about threading is fully integrated into the Ada language itself, and I've never had an easier time doing concurrency.

I'm pretty sure that Ada invented generics as we know them today, 30 years ago.  C++ templates were largely based on Ada generics.  C++ templates are more powerful, but Ada's generics have a number of great conveniences, like true separate compilation, which Ada has had for three decades but most C++ compilers still can't come to terms with.  Ada generics also have a full constraint system, and C++09's template concepts have taken this idea and done some great things with it.

How's performance? Also, is there a good free Ada compiler?

I don't have numbers to back this up, but I believe that Ada's performance is comparable to C++ in most cases.  Ada has a lot of safety checks (array bounds checking, for example) but the interesting thing is that most of the checks can be done at compile time if you do your types correctly.  Ada only does runtime checks for the things it can't verify at compile time, and if you're truly performance paranoid, you can compile with all checking disabled for the final product.

GCC compiles Ada, version 4.3 has the complete Ada 2005 implementation.
Logged



What would John Carmack do?
Gold Cray
Level 10
*****


Gold Cray


View Profile WWW
« Reply #6 on: April 26, 2009, 08:00:19 PM »

How's performance? Also, is there a good free Ada compiler?
I read somewhere that Ada is comparable to Fortran, so at least when it comes to heavy math and scientific computing, it would be one of the fastest high level languages. I've never used it though, and I also don't have any numbers to back this up.
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic