Jump to content

  • Log In with Google      Sign In   
  • Create Account


C++, should I switch?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
28 replies to this topic

#1 superman3275   Crossbones+   -  Reputation: 2011

Like
0Likes
Like

Posted 14 September 2012 - 02:31 PM

I started learning C++ some time ago, and feel I am a competent programmer. However I've read using C# and Java makes developing applications and games much quicker, and theres a less steep learning curve. I know about how dealing with bugs is easier in those languages, however that doesn't make me want to switch. Essentially, I am asking if I should switch to C#. I've succeeded in making a tic tac toe game and Simple R.P.G. in C++, and know a lot about the language. I really like C++ and so far have had fun learning how to program with it. So should I give up on C++ and switch to C# now that I'm a few months in. (For clarification, C++ is my first language.

I'm a game programmer and computer science ninja ph34r.png!

Here's my 2D RPG-Ish Platformer Programmed in Python + Pygame, with a Custom Level Editor and Rendering System!

 

Here's my Custom IDE / Debugger Programmed in Pure Python and Designed from the Ground Up for Programming Education!

Want to ask about Python, Flask, wxPython, Pygame, C++, HTML5, CSS3, Javascript, jQuery, C++, Vimscript, SFML 1.6 / 2.0, or anything else? Recruiting for a game development team and need a passionate programmer? Just want to talk about programming? Email me here:

hobohm.business@gmail.com

or Personal-Message me on here smile.png!


Sponsor:

#2 Telastyn   Crossbones+   -  Reputation: 3726

Like
23Likes
Like

Posted 14 September 2012 - 02:38 PM

Don't switch.

Experiment.

Edited by Telastyn, 14 September 2012 - 02:38 PM.


#3 Serapth   Crossbones+   -  Reputation: 5313

Like
13Likes
Like

Posted 14 September 2012 - 08:33 PM

There is one major downside to switching...

Once you've programmed in a sane language, C++ feels SOOOOOOO much *more* painful. I need to make my own ??what??, to do what?? Really..... sheeesh.


Telestyn pretty much got it in one. You are going to be picking up many different languages over your career; dont look at it as leaving one behind, but learning a new one. Your knowledge doesn't magically go away. In fact, learning a second language will generally make you better at your first language.


If I can give you a tip though, learn the new language. Don't try to turn program the new language in the style of your old language. This is a trap far too many people fall into.

#4 ic0de   Members   -  Reputation: 804

Like
-16Likes
Like

Posted 14 September 2012 - 10:56 PM

Once you've programmed in a sane language, C++ feels SOOOOOOO much *more* painful. I need to make my own ??what??, to do what?? Really..... sheeesh.


C++ is the only sane language.

Once you know c++ there is no reason to use anything else. Unless of course you want the best speed possible in that case you would use assembly (sometimes I use it inline with c++ just for speed). As for making your own code for complicated things you can either have fun and do it yourself or use a third party library.

I tried learning JAVA, I decided it was just like c++ but slower and with too many rules.

Edited by ic0de, 14 September 2012 - 10:58 PM.

you know you program too much when you start ending sentences with semicolons;


#5 Hodgman   Moderators   -  Reputation: 29302

Like
21Likes
Like

Posted 15 September 2012 - 12:02 AM

C++ is the only sane language.

Once you know c++ there is no reason to use anything else. Unless of course you want the best speed possible in that case you would use assembly (sometimes I use it inline with c++ just for speed). As for making your own code for complicated things you can either have fun and do it yourself or use a third party library.

I tried learning JAVA, I decided it was just like c++ but slower and with too many rules.

C++ is by far my favorite language, but there's a lot of reasons to use other languages. It's incredibly self-harming to restrict yourself to a single language.

e.g. Some personal experiences:
* I want a really simple program to copy certain files from Windows directory A to directory B -- C++ is overkill, I can write this program in 30 seconds with Batch.
* I want to do some basic analysis of some data and display it in a simple table for my own use only -- C++ requires me to build a GUI and write a lot of boilerplate code. Instead I could write 10 lines of JavaScript and spit out HTML to a web-browser.
* I want to write some non-performance-critical gameplay code without worrying about memory management, and would like to use modern features such as closures (on platforms that don't yet have C++11 compilers), and dynamic code reloading (for fast iteration) -- I'll just use Lua.
* I'm doing a bunch of data-processing work, which requires me to be able to quickly iterate on GUIs, load XML files and write out binary streams, while making use of a lot of "standard" data structures. I don't care about memory usage or performance that much, I just want quick development time -- I'll use C#.
* I'm targeting a GPU -- I'll use HLSL, for obvious enough reasons.

Every programmer should learn as many languages as they can and put them in their toolbox. A bigger toolbox gives you more options so you're not hitting nails with a screwdriver...

As for performance, algorithmic optimisation and memory-layout optimisation are much more important than reducing cycles by outsmarting the compiler with manually written assmebly. It should be very rare that there's a need to use inline assembly (and in many of those cases, intrinsics can be a better option).

Edited by Hodgman, 15 September 2012 - 12:14 AM.


#6 Bacterius   Crossbones+   -  Reputation: 8474

Like
8Likes
Like

Posted 15 September 2012 - 06:26 AM

Somebody is loving the new Language War tag Posted Image

I really like C++ and so far have had fun learning how to program with it. So should I give up on C++ and switch to C# now that I'm a few months in.

See, the green and red statements are contradictory. You're having fun with a language, and you want to stop developing in it? What is wrong with you???!11! Seriously though, there is no such thing as "switching" to another language. Your brain has space for more than one language, and just because you write a project in C# because C# is suited to a particular task doesn't mean you are "giving up C++" or "betraying your C++ roots" or some other nonsense - it just means you decided C# was a better language to use for such and such project than C++. Doesn't mean the next program you write will automatically be in C#, or that by opening up Visual Studio C# you've suddenly lost all knowledge of C++ and have to start from scratch again... It's not a crime to be proficient in multiple languages, it's actually a requirement if you want to be productive. Sticking to one language just doesn't cut it, unless your goal is to be known as "the guru".

Essentially, I am asking if I should switch to C#. I've succeeded in making a tic tac toe game and Simple R.P.G. in C++, and know a lot about the language.

How much do you really know in C++? I'm asking this because many people think they've "mastered a language" when in reality, they've barely scratched the surface. There may still be a lot for you to discover and have fun with. Anyway, my point is, sure, you can download Visual Studio C# 2010 Express for free, fire up a hello world template and start coding. It's a few minutes away if you've a decent internet connection. Try it out! Figure out the pros and cons of each language for yourself, find their strengths and weaknesses, see where C# can benefit you and when you'd rather use C++.

For example, just today, I wrote some low-level C library code (with some makefile scripting), then worked a bit on my FreePascal raytracer, did some Java for my university assignments later on, and also had some fun in my Python sandbox throughout the day with number theory algorithms. I would not have been able to accomplish any two of those tasks using only one language, so in this sense I was infinitely more productive knowing multiple languages than if I only knew one. Simple as that.

Once you know c++ there is no reason to use anything else.

Oh, really? Please, do enlighten us on how you write GPU shaders. Do you cobble them together from C++ macros? Or perhaps you write them directly in IL assembly, hardcore-style? Also, how long does it take you to write a tool that replaces sequences of bytes in a binary buffer? Still waiting, cause in Python I'm done: buf.replace(). Oh, yours is... what? Faster? Oh, but I was only going to use it for a 10kb file anyway.

The slowsort algorithm is a perfect illustration of the multiply and surrender paradigm, which is perhaps the single most important paradigm in the development of reluctant algorithms. The basic multiply and surrender strategy consists in replacing the problem at hand by two or more subproblems, each slightly simpler than the original, and continue multiplying subproblems and subsubproblems recursively in this fashion as long as possible. At some point the subproblems will all become so simple that their solution can no longer be postponed, and we will have to surrender. Experience shows that, in most cases, by the time this point is reached the total work will be substantially higher than what could have been wasted by a more direct approach.

 

- Pessimal Algorithms and Simplexity Analysis


#7 L. Spiro   Crossbones+   -  Reputation: 13168

Like
8Likes
Like

Posted 15 September 2012 - 07:14 AM

I started learning English some time ago, and feel I am a competent speaker. However I've read using Japanese and Chinese makes communication and business much quicker, and theres a less steep learning curve. I know about how dealing with people is easier in those languages, however that doesn't make me want to switch. Essentially, I am asking if I should switch to Japanese. I've succeeded in making a few essays and forum posts in English, and know a lot about the language. I really like English and so far have had fun learning how to speak with it. So should I give up on English and switch to Japanese now that I'm a few months in. (For clarification, English is my first language.

Fixed.

If you read that and thought it sounded strange, well, that just puts your question into perspective.
As has been said: You have the capacity to learn and use multiple languages at once.
本当に。


If you want to use another language, just start using it, in addition to the languages you currently use.


L. Spiro

Edited by L. Spiro, 15 September 2012 - 07:17 AM.

It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#8 ic0de   Members   -  Reputation: 804

Like
2Likes
Like

Posted 15 September 2012 - 07:22 AM

Oh, really? Please, do enlighten us on how you write GPU shaders. Do you cobble them together from C++ macros? Or perhaps you write them directly in IL assembly, hardcore-style? Also, how long does it take you to write a tool that replaces sequences of bytes in a binary buffer? Still waiting, cause in Python I'm done: buf.replace(). Oh, yours is... what? Faster? Oh, but I was only going to use it for a 10kb file anyway.


I'm sorry that came of so rudely but what I meant was for making games, yes scripting languages like python and javascript are great for doing small automation and I admit I use them from time to time, but if you are writing games the bulk of it is usually time critical and should be written in a fast language like c++, that said languages like GLSL are useful but they are incredibly application specific, they really just supplement other languages and not replace them.

More specifically c++ is in my opinion the best general purpose language for writing games.

you know you program too much when you start ending sentences with semicolons;


#9 Bacterius   Crossbones+   -  Reputation: 8474

Like
1Likes
Like

Posted 15 September 2012 - 07:36 AM

I'm sorry that came of so rudely but what I meant was for making games, yes scripting languages like python and javascript are great for doing small automation and I admit I use them from time to time, but if you are writing games the bulk of it is usually time critical and should be written in a fast language like c++, that said languages like GLSL are useful but they are incredibly application specific, they really just supplement other languages and not replace them.

More specifically c++ is in my opinion the best general purpose language for writing games.

That's a lot more defensible (and I'm sorry if I came off as rude, too - it wasn't my intention). I don't really agree too much on the "bulk of writing games is usually time critical" - from a graphics point of view it's all handled by the graphics API and driver so from that perspective C++ gives you no special speed advantage. From a game logic point of view, it is true that performance matters, but usually game logic isn't all that intensive (perhaps AI). Physics can be a bottleneck, but surely you are using an existing library which is already compiled in C++ and has bindings in your language (like bullet).

Of course it's very game specific, some games are more intensive than others. AAA games sure are time-critical, but I'm not so sure a tetris, tic-tac-toe, amateur FPS or hangman needs the full horsepower of a modern processor, so in this case I would happily trade some performance for faster development time, for instance.

I'm not sure I'd call GLSL or other shader languages "application-specific". If anything they're incredibly important since they are the *only* languages that can run on graphics cards, so if you ever want to use the GPU, you must learn them - there is no going around that (though note that OpenCL 1.2 has a stripped-down-C++ kernel compiler now! though you still need to learn the API and how to effectively program with it, no more inline assembly and pointer hacks)

The slowsort algorithm is a perfect illustration of the multiply and surrender paradigm, which is perhaps the single most important paradigm in the development of reluctant algorithms. The basic multiply and surrender strategy consists in replacing the problem at hand by two or more subproblems, each slightly simpler than the original, and continue multiplying subproblems and subsubproblems recursively in this fashion as long as possible. At some point the subproblems will all become so simple that their solution can no longer be postponed, and we will have to surrender. Experience shows that, in most cases, by the time this point is reached the total work will be substantially higher than what could have been wasted by a more direct approach.

 

- Pessimal Algorithms and Simplexity Analysis


#10 Shaquil   Members   -  Reputation: 815

Like
1Likes
Like

Posted 15 September 2012 - 01:50 PM

There is no right or wrong answer. As many have said, it's not like switching to C# as your main language will mean you can never program in C++ again, so it's completely fine. If you're asking this question, though, it probably means the answer is yes. If you're curious about another language, then do what a little kid would do: Check it out. Don't ask for permission from the guys on the forums. Maybe you won't like many of the other languages. So what? Just stick with C++. Maybe you'll realize C++ is a horrible nightmare. Great! Enjoy whatever new language you're using. As long as you're programming, I don't think it quite matters what language you're using.

#11 EddieV223   Members   -  Reputation: 1406

Like
0Likes
Like

Posted 15 September 2012 - 02:00 PM

Games programming is generally done is c++ especially the engine code. c++ is a fine language, though one of the hardest to use correctly.

Because it is such a low level language, you will learn more about computers in general programming in c++. Which is why it makes such a great starting language, when you decide to learn something like c# and java you will appreciate all the work they do for you. And learning them will be really easy.

If this post or signature was helpful and/or constructive please give rep.

 

// C++ Video tutorials

http://www.youtube.com/watch?v=Wo60USYV9Ik

 

// Easy to learn 2D Game Library c++

SFML2.1 Download http://www.sfml-dev.org/download.php

SFML2.1 Tutorials http://www.sfml-dev.org/tutorials/2.1/

 

// SFML 2 book

http://www.amazon.com/gp/product/1849696845/ref=as_li_ss_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=1849696845&linkCode=as2&tag=gamer2creator-20

 


#12 Pointer2APointer   Members   -  Reputation: 283

Like
0Likes
Like

Posted 15 September 2012 - 03:00 PM

Why would you completely transfer from the use of one language you already are competent in all to seek learning a new language, when you can be competent and use C++, and many other languages, libraries, engines, etc.

C++ is not perfect and no language will be, but knowing more languages is always a bonus.
Yes, this is red text.

#13 JamesTheNumberless   Members   -  Reputation: 129

Like
0Likes
Like

Posted 15 September 2012 - 03:42 PM

When I was a young lad in the early 90s - assembly code and C++ were still really the only things worth my time learning if I wanted to make games. But if I were starting today, C# would seem like the smart choice.

Right now, if you want to be a AAA console developer, you still need C++ and I wouldn't expect that to change for the next console cycle. But current gen consoles and handhelds already support (and feature) smaller scale games written in managed languages including C# and Java. Android games are written in Java. 10 years from now, console development could look a lot different.

I work for a PC developer that has had two games published in the last 2 years - one is built on a C++ engine and the other on a C# engine. When I started my current job a few years ago, I spent some time in the interview with the studio head looking at a demo video for Unity 3D, with him (a veteran programmer from the days when only assembly would cut the mustard for games) enthusing about it. Now we have two Unity projects in the pipeline.

IMO Java and C# are superior to C++. C/C++ has long since been shunted to the sidelines for commercial software development and is already being voted against by indie and AAA game devs alike. I wouldn't bet against managed languages taking the place currently occupied by C++ in the industry in the near future.

Performance already has a lot less to do with the language used than it did 5 years ago. The benefits of languages (like C#) that lend themselves better to software engineering principles, more rapid development, and fewer bugs, are getting more attractive to developers and producers alike.
James

#14 JamesTheNumberless   Members   -  Reputation: 129

Like
0Likes
Like

Posted 15 September 2012 - 04:24 PM

t if you are writing games the bulk of it is usually time critical and should be written in a fast language like c++,


Although, when you're writing a modern game, the stuff that's really time critical is the stuff that's running on dedicated hardware. A GPU shader (whatever language it's written in) looks the same in a C++ game as it does in a C# game as it does in a Java game as it does in a Python game. What you then become concerned with, more than the algorithms running on the CPU, are the overheads involved in making graphics API calls. The worst benchmark I have ever seen comparing C++ to Java is one that concluded Java was bad at OpenGL because it took much more time to make a single immediate mode call to the GPU. People still often cite this benchmark and others derived from it as a reason why managed languages would perform badly for games, despite the fact that no modern realtime game would be making a vast amount of API calls per frame (much less using immediate mode!).

In broader terms, all languages have their own pitfalls when used naively. Just as C++ programmers have to understand the platform their code will execute on, so Java programmers and C# programmers need to understand the JVM or the CLI to write well performing code. e.g. much the time when Java programs are a lot slower than their C++ equivalents, it isn't because of the overhead of the JRE per se, but because the way code is written is causing unnecessary extra work in that layer by invoking the garbage collector too often. Quite often, when C++ programs are less stable than their Java or C# counterparts, it's because the programmer is ignorant of the memory leaks they are causing, or of precisely what they're doing with pointers. etc, etc
James

#15 Sollum   Members   -  Reputation: 695

Like
5Likes
Like

Posted 15 September 2012 - 05:05 PM

@OP

Whilst i was studying first years in Uni, i was a mindless C++ zealot.

But as the tasks started becoming way more serious and time consuming, from time to time i used C# or Java.

At the moment i am working as a .NET developer (+whole MS package of happiness, like MS SQL).

Got back to hobby game development again, picked up Java.

Why am I telling you this? Simple!
Don't be a slave to one language or one platform - adjust! Learn!
Sure, Java or C# might be slower and you can write your own super fast XML parser with C, but how much time it will consume?
Is it just a hobby project? Are you developing alone? I highly doubt that you will bother writing Crysis engine of your own.

I am not against C++, but if you wan't to see actual result, without loads of hours of hard work, go for something less time consuming. Visible results drive you further, settings you into success flow.

If you're afraid picking other language, apart C++, just because it's "Not the standard", learn to say - "So what?". Experiment!

I will share a word of wisdom, one lecturer in uni shared with us - "Chose technology by needs, not wise verse". What it means - draw outlines for your project, set goals you want to achieve and choose ways to do so!

Edited by Sollum, 15 September 2012 - 05:07 PM.


#16 phantom   Moderators   -  Reputation: 7014

Like
2Likes
Like

Posted 16 September 2012 - 04:34 AM

I wouldn't bet against managed languages taking the place currently occupied by C++ in the industry in the near future.


I wouldn't be surprised if C#/.Net based languages took the place of C++ for many things, although I suspect you'll end up with a mixed mode of things. Some stuff, like the rendering backend, might well stay in C++ but higher level logic might well shift to C# and the like for ease of development with the option of pulling in C++/C/Unsafe code as an optimisation.
(I say this because as good as compilers are there are still times when you need to get in there and hand massage some intrinsic based vector code into the mix because it simply can't do it due to lack of context about the operations being performed.)

Maybe this will finally get game play programmers to think in terms of 'threads' and 'tasks'... *sigh*

Edited by phantom, 16 September 2012 - 04:36 AM.


#17 dejaime   Crossbones+   -  Reputation: 4002

Like
0Likes
Like

Posted 16 September 2012 - 07:12 PM

Well, I try not think of myself as a C++ programmer, but simply as a programmer, with C++ experience.
I've already gotten my hands dirty with Java, Asm, Pascal, C#, Lua, Phyton... Even some more 'alternative' languages like Prolog and Haskell for a couple of weeks each... The fact is, when I need a language for any reason, I'll learn it the best I can, and it is usually enough. If I need some reinforcement, my library will get an addition...

Try not to shackle yourself up to a language, or it will you down a lot when doing something. Sometimes you can learn a language and program your tool faster than you would if you were trying to do it with your favorite one. Ever tried combing your hair with a knife?

Edited by dejaime, 16 September 2012 - 07:14 PM.


#18 Kirkula   Members   -  Reputation: 141

Like
0Likes
Like

Posted 16 September 2012 - 07:37 PM

I don't see why there's a need to "switch" to a language from another one. From my limited knowledge, it's my understanding that once you've mastered a lower level language such as C++, you're able to accomplish MUCH more than you ever can from higher ones, such as C# or Java (which both require virtualization) Instead of "switching" you should be "adding".

The good thing about Java is that almost EVERYONE has the JVM, so programming in that will mean almost everyone will be able to run your programming. Also, you don't have to worry about optimization for every machine on the market. The bad thing is, being it's a higher level language, it will run slower, and you have less control over what the program can do.

The good thing about C# is that, with XNA, you can make games for the XBox. The bad thing is the craziness you have to deal with when trying to monetize said game. From what I understand, it's friggin nuts trying to deal with them. With java, you can make games and sell them on countless websites, even Steam. Then again, you can do the same with C#, I would imagine.

The moral is, don't SWITCH your language...add to your repertoire! Don't stop using C++ while you learn other languages, continue keeping it fresh in your mind and fingers, and when you start to feel like you've brought yourself up to par with your knowledge in another language as compared to your knowledge in C++, either learn more in C++, or add another language! From what I understand, every language can do everything, but some languages do some things better than others. If you know all these languages, you'll know what's good for what, and what you should avoid using for such and such!

#19 viper110110   Members   -  Reputation: 579

Like
0Likes
Like

Posted 16 September 2012 - 09:01 PM

My former roommate said that he could do in Java in 2 days what took him a month to do in c++

#20 jefferytitan   Crossbones+   -  Reputation: 1999

Like
0Likes
Like

Posted 16 September 2012 - 09:19 PM

Agreed with many posters. Different languages have different strengths. Learn other languages AS WELL. Looks good on the resume too. As far as high level vs low level... I like to view it as driving an automatic vs driving a manual. For the ultimate in performance, drive manual. But be warned, if you're a bad manual driver you'll leave your gearbox on the road if not crash and burn. Myself, I'm happy to drive auto these days, as most of the time I just want to get from point A to point B with the least effort.

C and C++ are great for learning how computers work (as is assembly), good for writing super-optimised functions, and they're good for accessing low level APIs. But trying to find/write the right library to do something I consider standard, dealing with memory allocation/deallocation, header files, pointer arithmetic, arcane parameters and return codes from Windows APIs? Yech. Not for me.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS