Sign in to follow this  

Programming Language

This topic is 4850 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys, i dont want this to be a language war of any kind, but i truely dont get it, why anybody would start writing an engine in c++ (beside your boss insisting on it). My Background: I study computer science and have been programming since more than 6 years, and for the last 3 years as a part-time profession (started with basic *g*, java, c, c++ strange stuff like prolog, haskell and finally: python). I made two opengl-engines. One of them can be downloaded her "Tu-Wan'Hudan - Looking Like Ghosts" http://www.cg.tuwien.ac.at/courses/CG23/HallOfFame/2004/index.html Okay, so lets try to stay calm and discuss this seriously :-) Even in my personal surrounding I stand relativly lonley with my opinion that languages like Python should be used for everything (i hear stuff like "no serious computer scientist would code in a 'scripting language' ", etc..) C++ Pros: - Lots of examples/tutorials - Full control over computer (memory, etc.) - Very Fast Programms C++ Cons: - full controll over computer (do your own mem-managment, etc.) - no high-level-datastructures.. even with STD you're far away from the possibilites for example python gives you... In my opinion these Cons are enough reason to forget C++ instantly.. if there is something that helps me get the programm done fast: LETS USE THAT! even if the programm is 10x slower... you can always code the 1% of performance critical stuff in C++, but why the hell would i do the WHOLE project in such a low level, time-consuming language as C++. Okay, so to finally ask a question: Why are YOU coding in C++ and not in some higher level language? Don't try to convince my or anybody.. just tell me, what you think is so very best about C++ that you would never want to miss even if that means more work. Or is this a controversial point? I think its obvious that the coding time gets less, if the language gets higher. Bye bye

Share this post


Link to post
Share on other sites
I'm coding in several languages these days. C++, VB.NET, D, C# and javascript (if you want to count that). I use C++ as my 'main' language - why? I have no real reason other than it's the one I know best and feel most confortable with. I agree that there's an illusion that "all games should be written in C++!" as I see many people saying these days - I don't think it's necessarily true. I think it's really down to the fact that C++ is the industry standard language for games and that many programmers don't really feel inclined to change language.

Share this post


Link to post
Share on other sites
I've personally used python a little bit, but mostly use C++ for games. I principally use C++ because of speed I guess, though for all I know I'm probably loosing that advantage through sloppy coding :p

If you look at the CPUtime/memory comparisons of languages, python doesn't fare very well. So unless you're coding all your time critical stuff as python modules, you might get significant slowdown. (Yeah, now someone just needs to point to some python rendering engine that handles half a million polygons a frame with shaders)

Share this post


Link to post
Share on other sites
Quote:
Original post by evolutional
I use C++ as my 'main' language - why? I have no real reason other than it's the one I know best and feel most confortable with.


I can see your point - men like the stuff best the're good in :-)
But what stops you from trying some high-level language.. just to get a taste of it. I would say for a C++-coder python.org (interpreted, truely OO, very highlevel) for example is a "no-brainer"... after reading 2 pages of tutorial you can instantly start prototyping a game-engine.

do you agree on the point that this will get you more work done faster? if so... why not try it?

Quote:

I think it's really down to the fact that C++ is the industry standard language for games and that many programmers don't really feel inclined to change language.


okay... that might very well be the reason. But i feel like this is limiting our possibilites as freelancers and small-team-game-programmers.

Or to see this from a different perspective: Carmack has always included some "scripting-language" in his games: write the gfx-engine (everyting in this area performance critical if we're talking carmack-style) as a scriptable, interpreted C++ thingy, all the rest (ki, content, whatever...) in the so produced higher-level language. I guess none of us is trying to compete with doom3... so lets do everything with a fast-coding-prototype language and optimize we're its necessary.

another thing: i believe most "real games" (battlefield, doom3, c&c) have been coded like that.. be it a scriptable-c++-engine or a data-driven-engine.

no one does game-content in c++. and instead of thinking "because they have enough time to make a flexible-engine" i think the reason is, programming too much in c++ takes too long ;)

Share this post


Link to post
Share on other sites
There is a miss conception about Python.

When running py or pyc files it can be slower than a C(++) equilivant. But it is easier in most respects.

But you can convert your py(c) file to a executable. Fully machine code! aka fast.

It's called py2exe.

There is one really big pro for Python.
You can update without editing the script directly. :)

Share this post


Link to post
Share on other sites
Quote:
Original post by ch1pz
I principally use C++ because of speed I guess, though for all I know I'm probably loosing that advantage through sloppy coding :p


Well.. and I say speed is never an issue :-) If you're doing a game yourself you probably won't ever have millions of polys on the screen nor will the A.I. be eating all the CPU-power and how many objects do you have on the screen for coll-detection? what else can eat your cpu-power? md3-animation stuff.. okay... that and other game-content-specific stuff would be something definitly faster in a c-module for python (and would be logical as well... there are thousunds of ready-to-use tutorials out there... copy&paste, precompile and use as python-function).

most graphics stuff can be handled on the GFX, and in the near future none of us will really make the GPU hot.

Quote:

If you look at the CPUtime/memory comparisons of languages, python doesn't fare very well.


you're right... but the game-content (textures, vertex-lists, etc.) always takes 90% of the memory and stuff like linked-lists, or the heap and programming-stuff in generally is neglectible... lets say it takes: 128 MB. and i wouldn't know how to produce so much stuff to fill these 128 MB.


Quote:
(Yeah, now someone just needs to point to some python rendering engine that handles half a million polygons a frame with shaders)


there is no such thing :))

Share this post


Link to post
Share on other sites
Quote:
Original post by mldaalder
There is a miss conception about Python.
(...)
But you can convert your py(c) file to a executable. Fully machine code! aka fast.

It's called py2exe.



Ah.. NO NO NO!!
py2exe only wraps your py-code, the python-interpreter and all needed modules into a lot of strange files and makes an exe that you can use to start the wrapped thing. but it's still interpreted python-code... no change in speed. only difference / advantage is, that you obviously dont need a python-interpreter installed because it wraps it within some dll...

the homepage says so too...
http://py2exe.sourceforge.net/


BUT: there is psyco, which convertes python-interpreted-code into machinecode on the fly during execution and without any need to do something special with your code:

Quote:

Think of Psyco as a kind of just-in-time (JIT) compiler, a little bit like Java's, that emit machine code on the fly instead of interpreting your Python program step by step. The difference is that Psyco writes several version of the same blocks (a block is a bit of a function), which are optimized by being specialized to some kinds of variables (a "kind" can mean a type, but it is more general). The result is that your unmodified Python programs run faster.
http://psyco.sourceforge.net/


worked very well for me... but eats a lot of memory.

Share this post


Link to post
Share on other sites
Quote:
Original post by sim27

But what stops you from trying some high-level language.. just to get a taste of it.

do you agree on the point that this will get you more work done faster? if so... why not try it?



Funny you should say this, I do most of my work in script these days. I write the game shell with a scripting interface and do a lot of the game work in scripts - why? Because as you said, it's quicker and easier [smile]

Share this post


Link to post
Share on other sites
Quote:
Original post by evolutional
Quote:
Original post by sim27

But what stops you from trying some high-level language.. just to get a taste of it.

do you agree on the point that this will get you more work done faster? if so... why not try it?



Funny you should say this, I do most of my work in script these days. I write the game shell with a scripting interface and do a lot of the game work in scripts - why? Because as you said, it's quicker and easier [smile]



nice :-) so another believer

Share this post


Link to post
Share on other sites
I see a lot of generalistic points of view, and i think that's a wrong way to start arguing about this.

My point is, there is a tool for each job.

For small programs, or even big ones, where speed is a non issue, high level programming languages are the best choice because they allow very fast development, with readable, stable, sometimes portable and fast enough code. When speed becomes a issue, it's also possible to leave most of the program as it is, and just code some core funtion in a low level language to meet the specs.

But, to say something like "forget C++ instantly" is absolutely futuristic. The same goes for C and assembly code.

For applications where speed is important a low level language is a must, along with skill to bend it to one's will. You don't see good fast games in Java, in Python, in Visual Basic, they are coded in C++, with c/asm cores.

There's a reason for that, speed.

Map editors, user interfaces, loading sequences, and more, might be coded in high level languages, but AI, graphics, sound, networking, and more, need speed.

Like i said, a tool for each job.

Until high level languages match that speed, or cpu processing power makes the speed diference insignificant, low level programming languages will have a, not so easy to forget, place in many programmers lifes.

Share this post


Link to post
Share on other sites
Quote:
Original post by sim27
C++ Cons:
- full controll over computer (do your own mem-managment, etc.)
- no high-level-datastructures.. even with STD you're far away from the possibilites for example python gives you...

In my opinion these Cons are enough reason to forget C++ instantly..


I believe its speed that outdoes the cons.

Otherwise if you use a slower language, you will spend half your time trying work arounds to speed things up.
So that might counter the fast production speed of higher level languages.

But c++ isn't really that low level, its just slightly lower than java,

I like java, but I cannot not stand the slowness of it. It has heaps of useful libraries, so I would still use it for many things, but not when speed is most important.

Share this post


Link to post
Share on other sites
I personally use C/C++ (a mix of the two) because I'm a hobbyist programmer. For that reason, I'm not interested in finishing my current project as fast as it is possible to do. I'm not interested in getting excellent development times. I prefer to enjoy the coding, and I use C/C++ for that because I'm most familiar with that language and I like having to do so much myself.

I've tried higher level languages, and I really dislike the loss of control. It took me a while to get used to using regexps for text parsing as opposed to treating strings as character arrays.

Share this post


Link to post
Share on other sites
first of all thanks for your opinions. i must admit that maybe may original post was a bit harsh.. especialy the "forget c instantly" part.

i obviously have a very different view on what is "fun" about programming than some of you have... and your posts made that more clear to me.


Quote:
white rabbit
My point is, there is a tool for each job.


very true.

Quote:

You don't see good fast games in Java, in Python, in Visual Basic, they are coded in C++, with c/asm cores.


well.. my opinion stands that those fast (professional, big, ..) games have an underlying framework in c++ (which might take most of the dev-time) but most of the specific coding (non engine stuff) is done on top of this. via data-driven design or an implemented scripting engine.

I am mostly interested in getting something up&running .. so no matter how hackisch and slow it might be, my (!) fun time starts when i get away from coding terrain-engines, loaders, shaders and that kind of stuff towards the game-logic side.

i think its like that:
- good thing, that a lot of you like coding in c++ to get most out of available hardware and make a game look great
- good thing that i enjoy not being touched by these issues but plainly get something playable.. make the game-logic work

having said that.. i think its easier for "you others" to get a job in the game-biz, but my chances for ever finishing a "nice", playable game are better :-)

Quote:

Until high level languages match that speed, or cpu processing power makes the speed diference insignificant


my personal view on this is, that SOMETIME the cpu-speed will be fast enough to do in real time what i code in python... but my coding-speed wont get faster any time soon. so why spend time with optimization (.. because i need a fast terrain-engine, smooth animations.. i know.. but thats just "polish" for the game.. imho. once the game is up and running and maybe a great thing.. people will come and do the trick for me)

if i could rephrase my question "why do you use c", i'd go like this:

is it more important to have a AAA-title or to proof that the inherent game mechanics are worth playing?

Share this post


Link to post
Share on other sites
to make something else clear:

i understand that the optics of a game are vital to its success.. and i thought (and worried) a lot about having to start to seriously code c++, because i saw no other way to get a 3d-engine running (if it's not 3d.. forget it.. imho).

until i found the combination of plain opengl and python. that did the trick for me.

I think (!) of all the real-world languages python is the most high-level, fastest prototyping i know of.

Share this post


Link to post
Share on other sites
Nobody does an entire game in C++. Everybody I know in the industry uses some dynamic language (Lua, Python, Perl, Java, Lisp, ...) for the soft-and-gooey stuff, and C++ for the hard-and-performance-sensitive stuff. It's not even controversial to say this: it's the accepted norm.

Note that a "struct" will take significantly less memory in C++ than the equivalent table/hash in a scripting language; this matters to people on constrained platforms like consoles, but not as much on a PC. Unless your game is all about cramming 2000 minutes of custom character animation into a minimum spec machine of 128 MB, or something along those lines.

Share this post


Link to post
Share on other sites
Quote:
Original post by sim27
C++ Cons:
- full controll over computer (do your own mem-managment, etc.)
- no high-level-datastructures.. even with STD you're far away from the possibilites for example python gives you...


These are some interesting cons, as the first isn't a con in a lot of situations, and I don't believe the second is anywhere close to true.

I don't use Python because Python seems to attract a lot of pricks, in my experience. I don't use Perl because no person with half a brain would write anything larger than 100 lines in Perl. I have used Lua and I like it very much because it is clean and fast.

The higher up you go in the language chain, the more control and speed you lose and the more cruft you gain. The trick is to find a balance, and the fact that you aren't limited to one language for any given project makes your balance different for every component of the game. Also in the mix is your target platform.

C# is a good choice on PC, a better choice for a console is C or C++ for the engine and a scripting language for the logic. A goo d choice on a handheld is straight C, possibly C++, or J2ME if the device supports it.

This assumes that you're never going to accept an app that runs slow just because it runs "fast enough", and I don't have any faith in the next generation of programmers to do that.

[Edit] I just noticed that the OP put full control over the computer as a Pro too... this makes my post much less necessary. Sorry for the oversight.

[Edited by - bobstevens on August 21, 2004 11:12:08 PM]

Share this post


Link to post
Share on other sites
To continue on bobstevens' idea :

Quote:
Original post by sim27
C++ Cons:
- full controll over computer (do your own mem-managment, etc.)


In my opinion, this is not a real Con - instead, I found it to be a Pro.

When you have an application which can eat up to 1 GB or RAM (yes... we do, and this is the memory friendly version of our product :P), then you are happy to be able to control the way the memory is managed. Garbage collectors are generally a big black box. You know that some time you are enteninr the garbage collector. You know that it perform well. The problem is : when, how, what. I do not want my program to eat 1.5 GB because the gc has not been called yet.

Programming is still about controling :)

My own experience tends to prove me than every language has its own target application. Scripting languages are ok for things that need to be scripted. C# seems ok for high level system manipulation (just as current java in fact but java was originally aimed at low level development). Fortran is good for math because of its syntax and its big math libraries. perl is good for showing to your friend how obfuscated code can be (and therefore telling them that you're that 133t c0d3r everyone is talking about (yup... just joking :)).

And C/C++ is good for low level, system programming stuff. But he also proved to be good in a lot of other fields : UI, algorithms and so on. C++ is a very versatile language which can be adapted to nearly all situations whre a compiled program is required.

Now, speaking of the industry (whatever this industry is. I have been involved in the game industry some years ago but it is not the case for the moment). Rapid prototyping is a good thing. But rapid prototyping must evolve to a fully functional product. Obviously, I will not code a big system in python (nor in lua, nor in any scripting language). So why should I code my prototype using this language ? This will be a complete loss of time because I won't be able to reuse any part of that prototype code. Given the price we (me and my 4 people team) are selled to other companies, if I work during 3 month on a prototype product in a way which cannot be reused after that, I will be responsible of a net loss of nearly 150.000 USD.

Hope I'm clear (I'm somewhat tired :/).

Regards,

Share this post


Link to post
Share on other sites
Quake1 uses scripts. Quake2 uses dlls. Quake3 uses scripts? Doom3 uses dlls. The reason for dlls is speed. But it really depends on what you're making and how much cpu you have to burn. C++ is popular because it's both fast and high level and there are lots of middleware libs using it. Opengl and DX for example. Asm is probably too low level for most but can speed things considerably so it's something to keep in mind. I don't believe in the common belief that once we got fast cpus we can afford slower langs. This is because we always needed fast cpus in the past because we found new things to suck up cpu cycles. We evolve as human beings and so do our needs.

Share this post


Link to post
Share on other sites
Thinks I like about C/C++:

- great IDE VC 6/7 (win), KDevelop (lin)
- easy debuging
- very good help (MSDN)
- easy integration (libs[fmod, gui, maya, ...])
- multiplaform (Win/Lin/Mac/Unix)
- full control of memory
- fast and can use CPU specific futures
- that code you make now can be good for a cople of years
- standart api

When you are developing a game on a P4-1GHz maybe it will be good for that game to work on CPU (500MHz - 2GHz). (C/C++ will do this for you)

Share this post


Link to post
Share on other sites
Quote:
Original post by tibi
Thinks I like about C/C++:

- great IDE VC 6/7 (win), KDevelop (lin)
- easy debuging
- very good help (MSDN)
- easy integration (libs[fmod, gui, maya, ...])
- multiplaform (Win/Lin/Mac/Unix)
- full control of memory
- fast and can use CPU specific futures
- that code you make now can be good for a cople of years
- standart api

I don't know about Python, but it's ironic that most of these things are done better by Java and C#:

- Great IDE:
After using Eclipse, Visual Studio seems primitive. Eclipse offers:
- Refactoring: for example, rename a variable, method or class, and all references to it with a 3 keystrokes. Or, select a bunch of statements and automatically Extract Method from them (replaces sequences of similar statements with the method call).
- Incremental compile: finds and highlights syntax and semantic errors as you type; you'll never have to press Build, wait for it, and then go through 20 errors - if there are no errors marked, you can just save and instantly run the program.
- Code generation tools: generate getters and setters, create constructor from fields, create stubs for unimplemented abstract methods, etc.
- "Local History" automatically stores diffs of each file from the past X versions; you can compare and replace a whole class or just one particular method with a previous version from local history with a couple of clicks.
The only thing that I miss from Visual Studio is the form editor, but how many forms will you make for each project? And anyway there is a free plugin in development for that, it's just a bit slow and buggy right now. I think Visual Studio 2005 will add in some of these features, but even then, a C++ IDE can't give you as much help as a Java IDE because C++ is a more complicated language. In C++ you have #includes that simply paste in a file's contents, macros that can change the meaning of a common piece of syntax, #ifdefs, etc. It's a lot harder for the IDE to parse this in real time and give you meaningful information. It's nigh-on impossible to have it compile-as-you-type.

- Easy debugging: Same thing is true with Eclipse, or with Visual C#. Debugging managed code that runs in a VM is probably easier because there are fewer unexpected things it can do.

- Very good help: Java API reference for Java, or MSDN for C#.

- Easy integration/libs: Sure.. In C++, every library seems to declare its own type of int, float, and string, and sometimes even writing code to convert from one data type to another is time-consuming. Furthermore, you must link all these libraries into your project. In constrast, the Java standard library provides GUIs, regular expressions, image I/O (including JPEG, PNG, GIF), GZIP or ZIP compression, easy to use networking, XML, database access, and many other useful API's, all very tightly integrated, well designed, regularly updated (since they come with the JVM), and easy to use. If you want to use an external library, it's easy to add a JAR file to your classpath or just drop it in the /lib/ext folder of the JRE.

- Multiplatform: C++ is only multiplatform in that there are compilers for it on different platforms, and there are libraries which have been ported to all these platforms. Almost any programming language is "multiplatform" in this way. With C# or Java or Python, you just copy a file from one computer to the other and it works. Furthermore, C# and Java declare sizes and signedness for their primitive data types (int, etc), as well as other behaviour such as the meaning of "i += i++", whereas in C++ there are many things left "unspecified" by the standard, and you must write code defensively to deal with this.

- Fast and can use CPU specific futures
It's true that C++ lets you do a lot by adding assembly code, but with Java, you can run an old program on a new Java Virtual Machine and take advantage of CPU instrictions that weren't even around when the program was written. How often this will really be useful is a different question though.

- That code you make now can be good for a cople of years
In Java, the code you make now will likely work better in a couple of years because of bug fixes in the standard library, updates to the JVM, etc.

- Standard API
The only standard API in C++ is the STL, for console and file I/O, memory management, math and some data structures. The .NET Framework API and the Java API cover many more things (see "easy integration").

I think the main reason that game companies stick with C++ is that they have existing code in it. Once you've written your graphics wrapper, I/O wrapper, networking wrapper, window framework wrapper, image loader, memory manager, RTTI system, etc, you can easily use C++ as a high level language. So you reuse your engine in future games, adding extra code to each part as required. If you are starting from scratch, however, as most people on gamedev.net are, you'd be a lot better off choosing a language and framework that already provides this functionality for you, so you can get on with the really interesting things that make your game idea unique.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
C++ pro

We have nearly 2 decades worth of source code from our previous games, libraries and utilities on our computers written in it.

Share this post


Link to post
Share on other sites
Java and C# are 2 great languages but they are framwork dep. ,slow and eat a lot of memory.

I like NetBeans for Java IDE (it's so great) but it's so slow. (It's not going very good on a P4-2.6GHz).

Java don't have native support for OpenGL/DirectX (it's working on this :: can't make a hardware opengl applet)

C# is great but it's close related to MS tech. (C# is my next option after C/C++ and maybe with LUA for scripting)

what about python?

Share this post


Link to post
Share on other sites
Quote:
Hi guys, i dont want this to be a language war of any kind


You know, I can't remember the last time someone started a language war (deliberately or not) and *didn't* say something like that. And I'm not even limiting myself to the GD.net forums when I say that! ;)

So, here is my bitter, whiny, and probably flame-inducing input on the subject.

Why is everyone talking about Java like it's such a high-level language? :( "gomgom it does teh GC it r for scripting!!!11"

Java provides primitive types, static typing, the ability to make as much stuff static as you like, and JIT optimization of the compiled bytecode. Plenty of opportunity to escape the overhead that is stereotypically associated with the language. Real high-level languages don't really give you that escape. In Python, there is no way to express the equivalent of 'float' because every floating-point value is represented in a double - and then wrapped in all of Python's object overhead. The relative size of which is their justification for not providing access to floats in the first place (the 4 byte savings would be more or less pissing in the wind).

My judgement of things based on experience to date is that it's easier to treat Java as a "stererotypical C++"-level language as the other way around. Yes, there are very powerful things like Boost available for C++, but when something goes wrong even with a simple STL container, the compiler output can be very intimidating - you are shocked right back out of the illusion of working at a high level. Plus, there are limits to how prettily you can express those powerful concepts. (Consider weird hacks in Boost like the _1 variable.)

Share this post


Link to post
Share on other sites

This topic is 4850 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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

Sign in to follow this