Jump to content
  • Advertisement
  • entries
    146
  • comments
    435
  • views
    198842

A Language Quandary

Sign in to follow this  
Washu

331 views

Now, I don't know about you, my readers, but I happen to know quite a few programming languages. I've spent many years learning them. Why? Because I've found that no language is perfect, no language is better than any of the others. Each has its domain of applicability.

So, it is quite consternating to see threads on these boards asking, essentially, "Language X vs Language Y". What on earth would make someone think that a particular language was "the best," or even "better." To me, and most professionals, this makes no sense. You use which ever language you are told to use, or whichever one you are most comfortable solving the problem in, if given a choice. More importantly, why would you think that you can get away with learning just a single language? You do realize that you are going to end up having to probably produce a scripting core for your game, which means at least one "scripting language." Heck, if you want to store your formats in an easily readable/testable format, then you will be using XML, which is another form of a language. Yes, yes, I know some people don't consider XML a language, but it has a syntax and a structure to it, hence it's a language.

So, here's some things you can think about:

Generics:
Ah yes, the great cornerstone of so many arguments. First of all, to clarify something: C++ Templates != Generics. Now, to get to the core of this: C# Generics vs Java Generics. On the surface, the two appear to be mostly identical. You define a type, passing it another type, and now it's methods take and return that type parameter instead of generic objects. There is a difference however. In C#, the generics are true generics. They are determined at runtime, and when the IL is generated, you get a type specialized for the input type. In Java, however, generics are just implicit casts. Thus Java generics give no inherit performance nor type safety1 bonuses. They just make your code prettier to look at. This is, in fact, one of my big disappointments with Java.

Templates:
Ah yes, the great cornerstone of C++, the gloriously hacked templates. There are so many dirty things one can do with templates that it's not even funny. That combined with the fact that most people don't really understand them (sure, you can use them, but do you understand why you need typename sometimes and why you don't other times?). Combine that with the fact that no compiler properly supports them (excepting one, and that one has other issues), and you have a royal mess of code that requires both preprocessor statements, template hacks, and generally bad coding habits just to get something to compile and build across two compilers.

Cross-Platform:
Heh, this seems to be the one big cornerstone of the Java world. To bad it's not true. I have yet to see any sufficiently complex Java application that didn't have hacks in it to get around operating system deficiencies. Even C# has these problems, and hence isn't cross-platform. For the most part, it's an issue of libraries. But, assuming you avoid such libraries (which can be very very difficult) you can presumably write applications which are "cross-platform", good luck though.

Standard Library:
Ever noticed how people will extol the virtues of the Java standard library, but yet will refuse to use the C++ standard library? Sounds kind of hypocritical, don't you think? Now, the library that comes with C++ is woefully small. But that still doesn't mean you shouldn't use it. But this is one of the advantages that C# and Java have over C++. Their standard libraries are huge. With .Net 2.0 coming out soon, the .Net Framework will nearly triple in size.

So what language would you use?
I like C#. I use C#. I love C#. I hate Java. I don't mind C++, but I'm not in love with it anymore. I will use which ever language provides the functionality I require. When a solution is better solved through the use of O'Caml, then that's what I will use. If on the other hand it would be better done in COBOL, then you can bet that that's what I will use.

Why should I learn multiple languages?
Because, to be frank, you are not a very desirable employee if you don't. In this industry, knowledge and the ability to learn and adapt to changing situations is much more valuable than knowing C++, or whatever this weeks favorite language is.

I should note, however, that esoteric languages do not count. No one really gives a damn if you know brainf*ck, whitespace, ook#, or YASOOL.

1The problem here is that since you can convert a List to an Object and then to the actual container type, you can completely sidestep the "type safety" afforded by the compiler. This is not possible with C# generics, as the container actually only holds T's, and not object's that are cast to a T.
Sign in to follow this  


7 Comments


Recommended Comments

I like your POV - seems like you're one of few people who's got their head screwed on the right way round [smile]



Do you ever end up forgetting bits of various languages that you "know" but haven't used for a while?

On paper I can probably list 5-6 languages I "know", but off the top of my head I'd probably struggle to write good code in several of them without a refresher first...

I'm employed to write Java code during the day, can't say it's my favourite language but I'll survive.

Anyway, so I've been lazy for a while and I pick up my C++ project again - a (currently) 35,000 line framework for a bigger project. Been a good couple of months since I've done any proper work with C++ and I've found that I'm making so many newbie mistakes [sad]

Same with dipping into some VBA for Excel - I used to be a really good VB6 programmer (close enough to VBA), yet I've forgotten so much stuff since I last used it...

Jack

Share this comment


Link to comment
Good commentary, especially the part about how you'd use COBOL if it best suited your purposes. I remember doing a bit of COBOL programming way back in the 80's, and I found it to be a dandy language for its purpose -- flat file heirarchical-style databases. After spending a year doing Pascal in college, I was quite impressed to see a language where you could very easily design datatypes that mirrored your database records exactly.

And now it supports .NET :)

I'm currently using ActionScript, which is based on ECMAScript, which is the same root as javascript/JScript. I'm actually quite impressed with it. I'd always liked the nature of Lisp but was never a big fan of its structure. Since ECMAScript is essentially OO Lisp with a C++/C#/Java-ish front end glued on, I'm quite enjoying using it.

Share this comment


Link to comment
Quote:

There is a difference however. In C#, the generics are true generics. They are determined at runtime, and when the IL is generated, you get a type specialized for the input type. In Java, however, generics are just implicit casts. Thus Java generics give no inherit performance nor type safety1 bonuses.


That superscript 1 suggests a footnote, but I cannot find one.

In any case. I have heard this mentioned before, but I do not see what the practical difference is. Could you provide a minimal example?

Quote:

Cross-Platform:
Heh, this seems to be the one big cornerstone of the Java world. To bad it's not true. I have yet to see any sufficiently complex Java application that didn't have hacks in it to get around operating system deficiencies. Even C# has these problems, and hence isn't cross-platform. For the most part, it's an issue of libraries. But, assuming you avoid such libraries (which can be very very difficult) you can presumably write applications which are “cross-platform”, good luck though.


There are some interesting comments about this on Wiki: here and here. In particular, I draw attention to the following, which I believe as well:

Quote:
And just because the portability of Java (or anything else) isn't 100% perfect; doesn't mean we should abandon attempts to be portable. Where portability is important, code that is 99% portable is far better than code that is 50% or 20% or 0% portable.

Share this comment


Link to comment
Zahlman, yes, I forgot to write up the footnote, I've added it now.

The basic problem is: If the container holds objects, then I can insert anything I like into it (except primitives since in Java those are not of object type). This inheritly eliminates the ability for the compiler to check you, and hence you have to wait till runtime in order to find out your mistake.

Now, runtime is bad. It is bad because the bug may happen after only one particular method is called, and that method may not be called very frequently. So it might not be easy to replicate, and hence fix. The whole point of generics is type safety. There is no other reason to use them. If your containers can't guarantee that, then why bother adding the extra complexity of supporting them?

Writing for portability has more issues than just the library one I mentioned. A particular pattern may meet the performance constraints on one platform, and might not on another. So, even if the application CAN run on the platform, it might not run at an acceptable pace (this is a real problem in RT computing). That's not to say that you shouldn't write for portability. Applying the appropriate abstractions can make your job of porting to another platform easier. However, if there are no plans to port it, don't write for it. Instead write your code and refactor it. If you need to make it portable, then the refactoring that you have done will make it easy to add an extra layer of abstraction to enable you to support multiple platforms.

Share this comment


Link to comment
"Yes, yes, I know some people don't consider XML a language, but it has a syntax and a structure to it, hence it's a language."

Also the L in XML kinda gives it away... :P

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!