Allegro.cc - Online Community

Allegro.cc Forums » Off-Topic Ordeals » Which language is best?

This thread is locked; no one can reply to it. rss feed Print
Which language is best?
Shawn Hargreaves
The Progenitor
April 2000
avatar

No comment :-)

Zaphos
Member #1,468
August 2001

Hah. Well, Wikipedia says yes:

Wikipedia said:

The XNA Framework is based on the .NET Framework 2.0. It has been designed with an extensive set of class libraries, specific to game development exercises, to promote maximal code reuse across target platforms. It will also include a version of the Common Language Runtime, which is optimized for gaming requirements, to provide a managed execution environment to the XNA games. The runtime will be available for both Windows XP, Windows Vista and the Xbox 360. Since XNA games will be written for the runtime, XNA games will run on any platform supporting the XNA framework, with minimal or no modification. Games targeting the XNA framework can be written to using the C# language.

On a similar note, re programming languages and game development, Tim Sweeney has some interesting thoughts.

Shawn Hargreaves
The Progenitor
April 2000
avatar

Oh yeah, I forgot we did that press release. Cool!

I'm still not allowed to talk about it, though, because this is exactly what I'm working on at the moment and there's still a lot of stuff the marketing people are busy figuring out when and how to announce. You know how it goes, they don't want developers going and randomly spouting things in an uncontrolled fashion...

Richard Phipps
Member #1,632
November 2001
avatar

Quote:

You know how it goes, they don't want developers going and randomly spouting things in an uncontrolled fashion...

But that takes all the fun out of it! How else will random rumours spread across the net? :)

Shawn Hargreaves
The Progenitor
April 2000
avatar

Good point. In that case I certainly won't tell you that XNA is going to prove the power of our platform by demonstrating a Visual Basic port of Halo 3 running on a mobile phone.

Zaphos
Member #1,468
August 2001

Quote:

I'm still not allowed to talk about it, though,

Ah ... I did think it was odd that you were seeming to ignore your own project, which will, I think, have a rather significant impact on the question asked! ... but of course, loose lips sink ships and software development houses.

Quote:

I certainly won't tell you that XNA is going to prove the power of our platform by demonstrating a Visual Basic port of Halo 3 running on a mobile phone.

Hey, I hear the DOOM RPG is actually pretty good :)

Richard Phipps
Member #1,632
November 2001
avatar

I've seen the DOOM RPG on a phone. It's rather interesting. :)

Shawn: Now you'll be telling us that your companies next game doesn't feature motorbikes! :o

Shawn Hargreaves
The Progenitor
April 2000
avatar

Motorbikes?

Game?

I don't do games any more!

It's strange how close XNA feels to being back working on Allegro, actually. Instead of worrying about gameplay, I'm back to concerns like "will people actually understand how to use this API?", "is this flexible enough for all the crazy stuff they are going to want to do?", "how are we going to maintain this API as we extend things in the future?" and suchlike fun topics.

Richard Phipps
Member #1,632
November 2001
avatar

I suppose I can see the appeal of making a library rather than a game. :)
As long as you are having fun I suppose!

Marcello
Member #1,860
January 2002
avatar

It's certainly a more...reliable form of work.

Marcello

Shawn Hargreaves
The Progenitor
April 2000
avatar

That's actually very much how I approached game development in any case: I spent way more time building tools and reusable components than working on the actual game code! I always figured if we got the tools right, it would then be trivial and quick to slap a game together at the end, plus we'd be able to reuse the tools once we'd built them.

The nice thing about XNA though is I get to build tools for a much wider audience than just a couple of teams inside one company.

I find it fun, anyway!

Richard Phipps
Member #1,632
November 2001
avatar

I suppose that means more pressure in a way if it's for a lot of external teams. :)
Do you find you have developed as a designer now you are doing XNA work compared to Allegro?

Shawn Hargreaves
The Progenitor
April 2000
avatar

Quote:

I suppose that means more pressure in a way if it's for a lot of external teams.

In some ways, yes: things need to be much more robust and flexible and have good error handling and so on, where internally people could just come ask me if they couldn't figure it out.

In other ways this is easier, though, because I'm not so directly responsible for delivering an actual product. So there's a lot more room to say "sorry, that's just not something we support", where on a game team you don't have any wiggle room to not bother supporting exactly what the game needs!

Quote:

Do you find you have developed as a designer now you are doing XNA work compared to Allegro?

Hugely. I learned an incredible amount during my years at Climax, about how to make games, about teamwork, and about general software design.

Plus there have been so many advances in languages and naming conventions and design patterns and abstraction techniques over the intervening years, it's so much easier to make a nice usable API these days!

I'm finding a lot of the stuff I'm doing for XNA is much simpler than the code I wrote at Climax. Or at least has a simpler surface area. At Climax I got very into using advanced functional templatey C++ tricks in my tool code, which was very powerful and not always easy to understand :-) But fine as long as I was the only one who had to use the resulting API! For XNA we're targetting a completely different kind of developer, so I'm having to do a lot more thinking around what at first glance seem to be more superficial kind of usability issues like exactly what a method should be called, or giving related methods alphabetically related names so they sort next to each other in the class viewer. Little stuff that if we get it all right, makes the final product so much nicer to work with.

Richard Phipps
Member #1,632
November 2001
avatar

Sounds good! I didn't realise you weren't working at Climax anymore. I take it you work for Microsoft now?

I must admit I'm still a little confused about exactly what XNA is. :)

Shawn Hargreaves
The Progenitor
April 2000
avatar

Quote:

Sounds good! I didn't realise you weren't working at Climax anymore. I take it you work for Microsoft now?

'fraid so. I'm an American living in Seattle these days...

Quote:

I must admit I'm still a little confused about exactly what XNA is.

Many things. It's an umbrella marketing term for all the work MS are doing to make developer tools for games.

That include stuff around build systems for game content ("XNA Build"), and Visual Studio customization for managing game assets ("XNA Studio"), and depending on who you talk to, might also include DirectX and the Xbox SDK. It also includes making managed code work for writing games (the "XNA Framework"), which is the part I'm working on.

Marcello
Member #1,860
January 2002
avatar

Will it be free to use? :D

Shawn Hargreaves
The Progenitor
April 2000
avatar

Afraid that's one of the things they haven't announced yet...

axilmar
Member #1,204
April 2001

Quote:

For example, gl4java is a native library, and hardly recommended for production stuff.

Both the THALES RCMD console and VISU radar system are made with it, and they are quite fast. They could have been better if C++ was used, but the program manager insisted on Java, 4 years ago. But they had to double the specs to make it work.

Disclaimer : I worked in those projects.

Quote:

In Java 1.5 you do not need to create new Integer objects, as it's all transparent in the language. It does not create a new Integer object for each cast, but instead uses Integer.valueOf which has a bit more intelligent mapping.

Any object allocation is Java is not going to be as efficient as stack-based allocation. I challenge you to prove me wrong.

Furthermore, in Java 1.5 when you put an int in a list, an Integer object will be created automatically. It is the same as before, and generics is nothing more than syntactic sugar.

Marcello said:

The standard Java libraries are far better/easier to use than STL and boost.

You are comparing apples with oranges. The Java SDK contains a lot of things...STL is about algorithms and collections.

Compare java.utils with STL...STL is much better, both in performance and in usage.

Or compare Java SDK with Qt.

Quote:

Templates in C++ are evil.

Opinions are like asses nowadays: everybody has one. At least when I right down mine I try to justify it.

Quote:

C++ has to be compiled separately for each platform (windows/mac/linux/etc.).

Hardly a problem. Usually a product is compiled for Windows, Linux and Mac. With the proper libraries, no source code special to each O/S has to be written. Qt is the example here.

Quote:

Dynamic/reflective coding is near-impossible in C++.

Hardly ever needed.

Quote:

C++ cannot be run in a sandbox/secure "jail".

And why should it need to? security is not a function of jailing, but of design.

Quote:

DLL hell.

And you blame C++ for that??? if I made my dlls with Haskell, you would blame haskell as well?

Quote:

bloody. fucking. segmentation faults.

...which you would't have most of them if C++ had garbage collection.

Quote:

There's a lot of repeated code to write classes in C++ (.hpp/.cpp)

That's the only thing I agree with you. But a decent IDE can take care of that.

Quote:

Griping aside ;), doesn't managed C++ with .NET or whatever have garbage collection?

If you haven't heard, there are other O/Ses around, other than Windows.

Steve++ said:

I could go on and on... It would be better just to write a new language that takes the best aspects of C++ and Java. D doesn't qualify. I've looked at it a number of times and each time realised why I don't use it. It's got too much ugly syntax. The language itself is a bit bloated.

The cost of writing and verifying a new compiler (not for a toy language) is in the range of billion $$$.

Quote:

There's no perfect languages.

Nothing is perfect, but C++ with GC comes damn near closer.

Shawn Hargreaves said:

C# 3.0 fixes the anonymous delegate syntax to allow really nice lambda expressions, and adds a whole bunch more functional style goodness. For me it really does combine the best of C++, Java, and ML (yes, ML: it's about time some of those cool functional ideas made their way into a mainstream production language, and I'm very happy this is finally starting to happen).

Indeed, functional programming languages have some very good features: combinators, lambda functions etc.

But I won't touch C# as long as it is not open source...not free as in beer, but free as in speech, and available for other O/Ses as well...and not only the compiler, but the libraries as well (because the compiler alone is worthless).

Archon
Member #4,195
January 2004
avatar

Quote:

But I won't touch C# as long as it is not open source...not free as in beer, but free as in speech, and available for other O/Ses as well...and not only the compiler, but the libraries as well (because the compiler alone is worthless).

.GNU and Mono are free and cross-platform. They're not exactly the cross-compatible and feature-filled equivilent of .NET 3.0 since they don't exactly have the resources, but they'll get there sometime.

nonnus29
Member #2,606
August 2002
avatar

Quote:

Is it free to develop in C# though? For me, I see Java and C# as fairly similar, C# having the advantage of being newer and learning from things like Java (though I don't really see operator overloading as a good thing).

The bad thing about sun's control of java is (in particular) the java generics fiasco: Sun would not change the vm AT ALL to provide features to support generics. By association, it's just as unquestionable for sun to change the vm to allow ways to simplify the implementation of ML style constructs (it's possible to do ML in java bytecode; google for 'mlj' - I think they ported this to .net as well).

MS apparently has no such problem making changes to the clr.

Shawn Hargreaves
The Progenitor
April 2000
avatar

Quote:

Any object allocation is Java is not going to be as efficient as stack-based allocation. I challenge you to prove me wrong.

I don't know about Java, but in the desktop version of the .NET CLR the implementation of allocating a new object on the heap is literally as simple as:

void *addr = gHeapPtr;
gHeapPtr += sizeof(typeBeingAllocated);
if (gHeapPtr > gHeapEnd)
    CollectGarbage();
return addr;

In the case where no GC is triggered, this is exactly the same cycle count as a stack allocation! (assuming that your compiler switches are set to check for stack overflows, which almost all modern apps are built with for security reasons).

Of course it's not as fast as stack allocation when a GC is triggered, but even then it is pretty fast. This is one of those things that in theory sounds like it could be slow, but in practice I've never seen GC overhead even show up on a profiler for well written code. In fact I find myself spending way less time optimising C# to avoid GC overhead than I did in C++ to avoid malloc() overhead. It pretty much "just works" and runs fast. Heap allocating short lived objects (things that don't last long enough to get promoted out of generation 0) is really very similar to the performance of stack allocation in C++. But with stronger correctness guarantees.

Quote:

Furthermore, in Java 1.5 when you put an int in a list, an Integer object will be created automatically. It is the same as before, and generics is nothing more than syntactic sugar.

Yeah, Java sucks :-) C# on the other hand has true generics built into the runtime, not just as compiler trickery, so a strongly typed list of ints does not require any boxing. Which is as it should be.

Quote:

Quote:

Dynamic/reflective coding is near-impossible in C++.

Hardly ever needed.

Really? I find myself using reflection all the time. It is an immensely powerful way to step outside the statically typed universe and do cool Pythonic tricks: gives you a big chunk of the goodness of dynamically typed languages while still keeping static typing for all the places where that makes sense.

Reflection is particularly invaluable for writing unit tests. We have very high automated test coverage for all the code in my current project (probably more test code than actual production code), and this would be almost impossible to achieve without reflection. How else could you poke around in the guts of a running system to check everything is working as expected, or to simulate obscure internal error cases?

Quote:

.GNU and Mono are free and cross-platform. They're not exactly the cross-compatible and feature-filled equivilent of .NET 3.0 since they don't exactly have the resources, but they'll get there sometime.

I'm actually really impressed with Mono - it works great and is surprisingly close to the MS feature set. I don't know when they'll get the .NET 3.0 features online, but after .NET 2.0 was announced, they actually had generics working in Mono way before MS got around to releasing a beta of their implementation!

Zaphos
Member #1,468
August 2001

Quote:

But a decent IDE can take care of that.

That's another issue with C/C++ -- seems that because of all the preprocessor support, it's a lot harder to find an IDE which refactors & which compiles (and underlines errors / warnings) as you type/save. Does such exist?
I find I edit Java in Eclipse, and C++ in SciTE, so writing Java code is a lot nicer.

Quote:

And why should it need to? security is not a function of jailing, but of design.

Isn't jailing a design? It seems like the only way to provide gaurantees about the code, short of having it carry proofs ... I'm not sure why you would dismiss this as worthless out-of-hand.

The 'niceness' of Java also seems to mean it gets neat things like the omniscient debugger first and more freely ...

edit:

Quote:

...which you would't have most of them if C++ had garbage collection.

You'd could still access arrays out of bounds, deference null pointers, overwrite memory, etc ... and segfaults are really quite a liability, security-wise ... It still seems like a real advantage to get rid of them completely.

HoHo
Member #4,534
April 2004
avatar

How would you eliminate pointer calculations? Would you cut out inline assembly also because that would allow modifying pointers and data on lower level than the language might.

__________
In theory, there is no difference between theory and practice. But, in practice, there is - Jan L.A. van de Snepscheut
MMORPG's...Many Men Online Role Playing Girls - Radagar
"Is Java REALLY slower? Does STL really bloat your exes? Find out with your friendly host, HoHo, and his benchmarking machine!" - Jakub Wasilewski

Zaphos
Member #1,468
August 2001

Quote:

How would you eliminate pointer calculations?

Was that question aimed at me? I wasn't talking about changing C++, I was talking about using Java ... merely claiming that the lack of segfaults in Java is still a benefit to some extent.

Shawn Hargreaves
The Progenitor
April 2000
avatar

Quote:

How would you eliminate pointer calculations

There are various schools of thought on pointers.

1: The C++ approach. If you do it right it will work. If not, it won't. It's your problem.

2: The Java approach. Pointers are unsafe, therefore don't allow them.

3: The academic approach. Figure out some kind of code analysis algorithm that can verify whether pointers are being used correctly. Nice idea but unfortunately nobody has figured out how to actually do it yet :-)

4: The C# approach. Pointers are unsafe, therefore you shouldn't use them very much. It should be possible to write the vast majority of day to day code using constructs that are guaranteed typesafe and cannot corrupt memory. But sometimes you just need to do something low level and icky, or you are writing performance critical code, so you should still be able to use pointers when you really need them. Code that uses pointers will have less safety guarantees than code which does not, so it needs to be clearly labelled, making sure you can spend extra time reviewing these few risky areas. The language should encourage gathering up the unsafe pointer usage into just a few reusable functions, rather than scattering it all over the main body of the code.

How this works in practice:

1// Array indexing using integers (does overflow checks every time you index into the array)
2for (int i=0; i<array.Length; i++)
3 Console.WriteLine(array<i>);
4 
5// Array indexing using enumerators (usually faster because the enumerator can be optimized to avoid repeated overflow checks)
6foreach (string value in array)
7 Console.WriteLine(value);
8 
9// If I want to be unsafe I can. But I usually don't want to or need to.
10unsafe {
11 fixed (string* ptr = array) {
12 string* end = ptr + array.Length;
13 
14 while (ptr != end)
15 Console.WriteLine(*(ptr++));
16 }
17}



Go to: