c++? c#?

Discussion in 'Scripting' started by jman90, May 1, 2012.

  1. jman90

    jman90

    New Member

    Joined:
    Apr 29, 2012
    Messages:
    8
    Hello everybody,

    I am new to the Unity community and have a couple of questions. I have an Android phone that I would eventually like to upgrade Unity to, but for now I have to stick with Unity Free and do the web build.

    1. can you use c++ with Unity? I have virtually no programming skills but I have the option to take a c++ or c# college course. My college recommends I take c++ but I wanted to ask some real devs. which is better? why or why not? does c++ work for flash game development?

    2. I will be working alone with Unity, are there any pointers for a newbie, tutorials, hints tips etc for starting out?

    I really appreciate all the help. I have read some posts in this thread but not all of them. It looks like the community is doing some great things with Unity. Keep up the good work and Thank you all.
  2. OmniverseProduct

    OmniverseProduct

    New Member

    Joined:
    Feb 26, 2012
    Messages:
    1,569
    1) You sure can use c++ in unity, but that's only for native code plugins. If you have virtually no programming experience don't bother with C++. I had no programming experience when I tried learning it and I gave up. I found it a nightmare to use for a newbie. However, with C# I can at least remember some of what I program. Imo, use C++ if you understand basic programming concepts or if you know another language all together. As for if C++ works with with flash, I'm not sure I would assume so but I'll leave that to someone else.

    2) Check the various stickies out in the teaching section. Start as simple as you can and work your way up from there. Don't expect to be able to program an rpg or anything complicated for your first game.

    Edit: also, here is a link to the license comparison: http://unity3d.com/unity/licenses
  3. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Messages:
    24,687
    You don't really use C++ in Unity. You can in certain specialized cases, such as plugins, but not for scripting. And definitely not for Flash.

    --Eric
  4. AdrianC

    AdrianC

    Member

    Joined:
    Apr 22, 2012
    Messages:
    149
    Short answer is no, you can't use C++ with Unity. In Unity, you can code in C#, UnityScript or Boo. You then deploy the same code to all the platforms supported by Unity. It does the conversion for you.

    Flash games are coded in AS3.
  5. JamesLeeNZ

    JamesLeeNZ

    Member

    Joined:
    Nov 15, 2011
    Messages:
    3,191
    I would start with C# so you dont get scared off, especially while your just learning the basics of programming.

    C++ is a lot less mainstream than C# these days, therefore more programming jobs exist for it.

    If you want to end up being a game dev, you will need C++ unless youre using something like Unity.
  6. kablammyman

    kablammyman

    New Member

    Joined:
    Nov 22, 2010
    Messages:
    466
    Learn both. C# and C++ are from the same C programming language roots, so they have some similarities. However, C++ will put hair on your chest...C# is kind and gentle with a lot of basic code done for you in the .NET libs. Learning C# can help you learn the big picture when it comes to programming and its concepts, while C++ its easier to get lost in the details as a beginner.

    But, in the end, if you want to be a game programmer for a game studio, you will need to learn C++. Its still the industry standard because of its speed, flexibility, and large legacy code base that most dev houses have. In reality, there is very little that C++ cant do (it may not be easy to do, but i doubt there's anything you cant accomplish in C++)

    last thing, as others already said, you can only script Unity in C#, but unity itself was written in C++. think about that.
  7. jman90

    jman90

    New Member

    Joined:
    Apr 29, 2012
    Messages:
    8
    Thanks for the answers so far guys/gals.

    Basically what I am wanting to do is make my own game with a game engine. Indy games. I do not want to become strictly a "game programmer", I just want to know how to script my game with the prebuilt game engine when the time comes. I do not desire to build my own game engine.

    Does this mean go with c#? Also I just found out that I don't have the option to take a c# class because as of now it is not offered, (only intro to c++ and advanced c++) but maybe in the fall we will get a c# class... I am stressing a lot about this because I just want to be able to script a game that I build and don't want to build an engine.
  8. AdrianC

    AdrianC

    Member

    Joined:
    Apr 22, 2012
    Messages:
    149
    I'm guessing you've never programmed before, because if you did, you would already know this. Programming knowledge is transferable in between languages. Yes there are some things that some languages do a little differently (and Assembly is something else entirely) but the general ideas are the same. So take the C++ class, since that's the only one available and most of the stuff you learn will transfer over quite easily.

    For example, this:

    Code (csharp):
    1. int x = 5;
    2. int y = 10;
    3. if (x > y)
    4. {
    5.   //Do this
    6. }
    7. else
    8. {
    9.   //Do this
    10. }
    11.  
    Is perfectly valid C++ and C# code.
  9. johnnydj

    johnnydj

    Member

    Joined:
    Apr 20, 2012
    Messages:
    196
    if you're in the university, they usually teach C++ in the first year including simple graphicdraw mechanics, like drawing a cube and circles from code, and they teach C# in 2nd or 3rd year.
  10. jman90

    jman90

    New Member

    Joined:
    Apr 29, 2012
    Messages:
    8
    So should I wait to use Unity until I have learned some programming?
  11. DexRobinson

    DexRobinson

    Member

    Joined:
    Jul 26, 2011
    Messages:
    530
    I would take the steps now to learn programming before your classes so that way you can go in with a basic understanding of what programming is and how to think when writing in it. There is a lot of tutorials for C# programming aimed at beginners, just Google it lol, and I would learn C# if you plan on using Unity
  12. MADmarine

    MADmarine

    New Member

    Joined:
    Aug 31, 2010
    Messages:
    624
    Agreed, start learning the basics, do a few C# console applications and grasp the core concepts of programming. When you come to programming in Unity you'll then have a better understanding of how to design your code, and how to make things work the way you want.

    And I also agree on the point of learning C# over Unityscript and Boo, if you want to take your programming skills beyond Unity at any point, C# is the best way to go, much more support for it too.
  13. diablo

    diablo

    New Member

    Joined:
    Jan 3, 2011
    Messages:
    736
    I agree, you need to learn programming first, and that the language of choice should be C#. I would also like to add that programming is a pre-requisite to using Unity, so unless you have at least the basics you won't be able to get anything done, at least not without posting "help!" on the forums every 5 minutes and try to con others to do your work for you.
  14. znoey

    znoey

    New Member

    Joined:
    Oct 27, 2011
    Messages:
    174
    This is such a mixed thread Imo because although C# tries to handle A LOT of things for you, I frequently find it failing. Of course I'm coming from the experience of years with C++ before I ever looked into C# but when I'm just doing things for fun, I always use C#.
    I like to thing of this as a control scale for the languages. C# protects from your own mistakes quite often. C++ lets you make those mistakes and see the outcome. C is unforgiving and can wipe your hard disk on accident. Assembly is even worse than c but lets you have unmodified control o er memory.

    Evenrually you learn to make trade-offs of memory for speed. This is where I see most languages struggle because C# uses tons of memory for ease-of-use.

    Here's a quick note though. If you can master C++ pointers mixed with object-oriented and polymorphism, your pretty much invincible in C#. Oh and learn the STL like the back of your hand. In C# that's anything in System.Collection.

    That's probably far too much for a beginner. Just master object oriented. Its in almost every language.
  15. KelsoMRK

    KelsoMRK

    Member

    Joined:
    Jul 18, 2010
    Messages:
    2,773
    That's less a question of C++ versus C# and more a question of an un-managed language versus a managed one.
  16. XGundam05

    XGundam05

    Member

    Joined:
    Mar 29, 2012
    Messages:
    395
    If you know c++, you know c#. My first experience with c# was on the first day of my current job, where they said "Here, this isn't working, fix it." I had only really ever used C and C++ up to that point, C# was just a matter of picking up the syntax (and some of the quirks of managed code).

    That being said, I'm of the opinion that you should also learn at least one layer below your main area of work...so for programming that equals some basic assembly and the principles of how things are done in the hardware. Helps tremendously in the long run.
  17. jman90

    jman90

    New Member

    Joined:
    Apr 29, 2012
    Messages:
    8
    Thanks a lot guys. The Unity Community is a good one. It seems like c# and c++ have their ups and downs so it is hard for me to weigh them out. but what Im guna have to do is stick to the course and take c++ which kind of bothers me for the fact that you cant script in c++ correct?
    c++ = game engine builder
    c# = scripting language
    Right?
  18. jman90

    jman90

    New Member

    Joined:
    Apr 29, 2012
    Messages:
    8
    If this is the case I want to tell my college advisor that I do not ever plan to become strictly a game programmer and want to learn how to script my game instead
  19. znoey

    znoey

    New Member

    Joined:
    Oct 27, 2011
    Messages:
    174
    I whole-heartedly agree with this! I've had to jump around to obj-c and even though i don't know much of anything about obj-c, i'm able to get by because mostly programming is just syntax.
  20. mweldon

    mweldon

    Member

    Joined:
    Apr 19, 2010
    Messages:
    86
    I believe that if you are choosing to take a programming class, you should take the one that will help you the most in the short term. Once you know one language, it is much easier to learn others, especially in the case of C++ vs. C#. But it sounds like it is a moot point anyway since they aren't offering the C# class. Take the C++ class anyway. The syntax is really similar. If you know one, learning the other should be pretty easy.
  21. npsf3000

    npsf3000

    Member

    Joined:
    Sep 19, 2010
    Messages:
    3,671
    This is only partially true. Different languages [API's/frameworks etc.] often work with different paradigms so there are barriers to cross. I have spent over a year now 'learning' C# - and an awful lot of what I've learned does not directly map to other languages.

    For example, this:

    Code (csharp):
    1.  
    2. x = 3;
    3. y = 2;
    4. x += y;
    5.  
    Makes sense in most c based languages [C#, C, C++, Java, ECMAscript] as far as I can recall. However it would look like this in BF:

    Code (csharp):
    1.  
    2. +++>++[->+<<+>]>[-<+>] //run in debugger http://www.iamcal.com/misc/bf_debug/
    3.  
    And erlang would flip a lid [literally, as the above code goes against it's fundamental principles]. Instead, you'd want to do:

    Code (csharp):
    1.  
    2. X = 3;
    3. Y = 2;
    4. X2 = X+Y;
    5.  
    The thing to note is that neither of these are syntax differences, but fundamental paradigm differences. Brainfuck does not have Random Access Memory, nor does it have the ability to add two cells together [without doing it yourself of course]. Erlang, which unlike brainfuck is a practical language, does not have a concept of mutability.

    These differences are not trivial either, they are extremely important to nature of the language. Brainfuck is as the name suggests hard to read, but more importantly it's extremely easy to compile making it an excellent exercise in learning. Erlang uses the immutability of its data to enable itself to multi-thread incredibly well [Hundreds of thousands of processes anyone? How about millions?]. This enables it to have a fascinating approach to errors and upgrades - enabling scale-able systems with nine nines of uptime.
    Last edited: May 2, 2012
  22. T Spline

    T Spline

    New Member

    Joined:
    Mar 16, 2012
    Messages:
    6
    The real question is are you looking to be an engineer or more of a designer?

    If you are looking to be an engineer you will need to do what the career programmers on the board have suggested.

    If you are looking to be a designer, then in terms of Unity you will want to learn C# to write scripts for your game.

    What is the point of going through the trouble of learning a language like C++ if you never plan to develop anything with it? Why go through months of education learning a metric ton of junk you have no interest in and never going to use or benefit from? Honestly you don't need to know the intricacies of hardware or memory management unless you plan to make your own applications.

    It's like saying you are going to learn how to do 3-d character animation but first you are going to learn the language that was used program the application you are going to use. Completely unnecessary (unless you want to make robust tools). Not really sure how that's going to help or inspire you as a creative person. You seem like you are just interested in game design and want to make an indie game for web and mobile.

    Get on Amazon.com look for:
    "The Art of Game Design", "Level Design concept, Theory, practice", "David Perry on Game Design", "The Game Production HandBook", "Artificial Intelligence for games 2nd edition", "C# Object-Oriented Programming by Dan Clark", "C# pocket reference guide from Orielly", "Unity 3.x Game Development Essentials", " Universal Principles of Design (revised)", and optionally " Designing Mobile Interfaces from Orielly", and "Genius Android Marketing".

    Buy all these books and chalk it up as college book expenses. Take the C# class if you can. Take classes related to small business and/or freelancing if they exists. Or get some books on the topic. Taking classes that can help you with design, art, storytelling/creative writing, interface/interaction design, 3-d modeling and animation, will help you as an indie developer trying to do it all. It's a long and hard road and you need to be driven and multi-talented.

    I'd personally recommend that you focus on game design, the understanding of the entire pipeline of making a game application from a management perspective, and know how to write a design document that you can use to describe in detail to others what kind of game you want to make. Being able to market your design to others will be important, so learning how to do that would be a good thing.
  23. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Messages:
    24,687
    You really should though. Probably most bad code is written by people who don't understand how things actually work "behind the scenes".

    --Eric
  24. T Spline

    T Spline

    New Member

    Joined:
    Mar 16, 2012
    Messages:
    6
    I'm sorry I don't understand how this applies to game design and writing scripts for game logic in Unity. Are you saying anyone who fails to understand the gory details of what goes on behind the scenes such as manual memory management etc..., will fail to write proper code in the context of Unity scripting?

    Forgive me, but I just can't agree with that, due too numerous other users here and else where, that could show otherwise.

    I do agree that in the context of writing your own application/tools/plugins for Unity it would be required to have a detailed understanding of things "behind the scenes". However I really can't see how someone doing scripting would NEED to know what happens behind the scenes in gritty detail. Some understanding certainly, but detailed knowledge no.

    I'm not saying that he shouldn't seek knowledge of these things, but that it's not needed for him to be a game designer. It could be beneficial but it's no requirement. He should focus on a path that will help him most with reaching his goals as he inferred in his post. If at a later time he wishes to add on some extra education to round out his knowledge, great go ahead and take that C++ class. But I would think that the c# class would work fine for what he is after in regards to programming.
  25. T Spline

    T Spline

    New Member

    Joined:
    Mar 16, 2012
    Messages:
    6
    double post
  26. jman90

    jman90

    New Member

    Joined:
    Apr 29, 2012
    Messages:
    8
    Yes. I am mostly looking to do Indie games. In the future I wish to have my own company and expand by adding some extra people. If all goes well, some of those people will probably end up being programmers because this is my most insecure area of concern. So for now, what I really want is to just script, learn some animation, 3d modeling, etc. but programming will most definitely be my weak spot.

    I just took a game design class and read "Game Design, A Practical Approach" by Paul Schuytema. Very good read, and very informative. So, for now, I think you are right. I just want to learn c# because in the future I don't want to be a programmer.

    Now I just have to think about switching colleges... because my community college doesn't offer c#.
  27. Wraith

    Wraith

    New Member

    Joined:
    Feb 14, 2012
    Messages:
    8
    @OP
    I picked up C++ as my first language. lt's not as hard as most people say it is. Taking a class over it probably won't require racking your brains as long as the teacher knows what they are talking about(you might be supprised how often they don't)

    C++ will give you a good understanding of logic and will make learning other programming languages easy to understand.
  28. BrynP

    BrynP

    New Member

    Joined:
    Mar 7, 2012
    Messages:
    49
    C++ is the hardest of the 2, but if you're looking for a profession in programming C++ is the way to go, whatever you learn can just be transfered. C# has a very similar syntax because they're both based off of C and it really wouldn't not take you long to pick up C# after C++. However, C# is a good way of easing yourself into C++ because C++ might look kind of scary, particularly to somebody who has never programmed before, but saying that, it's not as bad as it seems. If you're being taught C++, it should make a lot more sense because you're likely going to have somebody who can explain it to you in terms and make it easier to digest.
  29. Dreamora

    Dreamora

    Member

    Joined:
    Apr 5, 2008
    Messages:
    26,586
    Thats no longer really true.
    If you want to go for a profession as low level programmer, then yes C++ is a must.

    But business programming is shifting to productive languages (thats why C++11 has been invinted to overcome at least a few of the productivity killers C++ has) like C#, Java or even VB.NET for visual applications. Web applications never were done with C++ at all and they will be more and more the focus of development.
    Also C# as Java will teach you object oriented development and other relevant aspects like parallelism in a clean, modern, intelligent way which allows you to understand and use it to then later apply it to dirty languages without any language level functionality like that like C++ where you best use Boost for parallelism


    So you might want to consider your background and target.
    If you want to write engines and similar, then yes C++ is great.
    If you don't want to go there, think about considering it a second priority thing thats not that relevant until you want to learn 'hard core optimization' as thats what you will really learn, what really makes C++ relevant, its low level existance and the hard and dirty lessons on optimization and non-optimization you will be forced to learn ;)

    If you want to learn a lower level language, learn C itself, not the mess put on top of it with C++. Its easier, clean and will teach you all those aspects too (there is a reason why core stuff is written in C not C++, like the whole Linux core). You will be able to make good use of that knowledge with ObjC if you want to go to iOS / Mac development and which you can rather easily expand with relevant C++ matters should you want to go there later on too.
  30. OmniverseProduct

    OmniverseProduct

    New Member

    Joined:
    Feb 26, 2012
    Messages:
    1,569
    Which one would be a better choice for audio software? More specifically synthesizers. I'm learning C# right now and while I love it, I eventually want to develop various audio software. I've heard conflicting stories on which language to learn out of the two. I asked this on the visual studio forums and while they said C# would be able to handle software audio synthesizers, they never really gave any specifics on why. On the opposite end I've heard that C++ is a better language all around if you can efficiently program in the language. I should revive my relatively new topic on the Visual C# forums and ask for specifics. Does anyone here have a specific answer for me?
  31. Integria

    Integria

    New Member

    Joined:
    May 12, 2012
    Messages:
    145
    Meh, this is honestly a tricky one. From a simple point of view, I absolutely prefer C#.
    From a learning perspective, I absolutely prefer C++, especielly combined with assembler.

    C++ is generally a must to know, if for no other reason than external dependencies. There's so much external functionality available to you through libraries.

    There are a ton of differences between the two, and I must admit that I feel the answer isn't quite as simple as learning one or the other; ideally, you should know both. Once you know one, the other will definately be easier, I'll guarantee.
  32. Integria

    Integria

    New Member

    Joined:
    May 12, 2012
    Messages:
    145
    It all depends. Which target are you intending to develop plug-ins for, to take an example.
    If you are developing from scratch, it won't matter all that much. If you intent on relying on external libraries, which you most likely will, I'd definately suggest C++.
  33. OmniverseProduct

    OmniverseProduct

    New Member

    Joined:
    Feb 26, 2012
    Messages:
    1,569
    I plan on developing this from scratch. I'll obviously have the option to plug in to various recording software via vst, au, rewire, pro tools plugin (can't remember the name), etc.
  34. Dreamora

    Dreamora

    Member

    Joined:
    Apr 5, 2008
    Messages:
    26,586
    In that case C++ is worthless generally though as DLLImport against C++ code is hell more complex (if possible at times) that clean simple CDECL from clean C code :)
    naturally you will need C++ if you want to write a wrapper to solve that problem
  35. meth0s_

    meth0s_

    New Member

    Joined:
    Dec 11, 2011
    Messages:
    60
    you will find learning C++ will open alot more doors than CSharp will as csharp isnt a very strong language compaired to Cpp. 1 Question is when you say collage (in new zealand collage isnt like what americans call collage ) its like year 9 to 13 or some thing. Any way back to what i was going to say. A collage class on Cpp or C# will not be a very well detailed class but you might get the jist of what you want to do.It also might make you think hell this is stupid ( gunna do 3d art instead ). Now for programming buy a book from amazon or ebay that will be the best easyest and fastest way to get the basics down pat before tackling a more complex idea of game programing.
  36. Dreamora

    Dreamora

    Member

    Joined:
    Apr 5, 2008
    Messages:
    26,586
    By what I've seen on the internet, even america university classes on Cpp and C# are not very detailed either or just are not understood.
    So that really shouldn't matter I think if you want to go there, the education is really irrelevant in being able to use a language normally.

    Programming in the end is learning by doing, not 'learning by sitting in a room listening', thats not give you anything at all as experience matters, not if you read 10 books more than the other applicant for the position.

    so if you want to learn a language, use it and get a book or two (or some good starter tuts) to support you going that path. Search for a meaningful application to develop so you can maintain your spirit and motivation. Thats gonna get you there.
    Don't waste time on reading 10 books on it even less if its C++ where you will soon realize that they added many concepts cluttered on top and next to each other that are basically replacable through other possibilities in the language due to the long overdue 'cleanout of the crap pilled up for over 20 years'
    Last edited: May 24, 2012
  37. Integria

    Integria

    New Member

    Joined:
    May 12, 2012
    Messages:
    145
    @dreamora - I should've possibly worded that differently. I was mainly thinking of DX / OpenGL functionality.

    There are indeed a lot of good references and tutorials available on either C++ or C#. Be vary which book you pick up, though. Some of them (Professional C++ 11, I'm looking at you) are more-so intended to cover new functionality, rather than giving a good overview.
  38. Endgame

    Endgame

    New Member

    Joined:
    Dec 9, 2011
    Messages:
    61
    Is C++ the only language offered? My university had first year Java programming, which i found helped me jump right into c#.
  39. techmage

    techmage

    Member

    Joined:
    Oct 31, 2009
    Messages:
    1,866
    Learn C/C++/ObjectiveC/ObjectiveC++/C#

    then you'll be covered

    and it does not matter which on you start with, just ask yourself what do you want to accomplish first? Get a degree in computer science? Then learn C++, Make a game in Unity? learn C#
  40. jman90

    jman90

    New Member

    Joined:
    Apr 29, 2012
    Messages:
    8
    I am taking classes for Game Development Concentration. so im taking marketing, programming logic, electronic color correction, flash game development, creative writing for games, Windows workstation Operating system, c++, advanced c++, Gaming Physics, Intro to game programming, Audio programming for games, AI for game programming, Advanced game programming. It seems that most of it has to do with programming but my goal is to be an Indie dev, so I need to know a little of everything. Later on down the road I would actually rather hire someone to program.

    What to do.... What to do...
  41. Drifter

    Drifter

    Member

    Joined:
    Mar 22, 2010
    Messages:
    284
    A lot of people tend to talk down Unity's flavour of Javascript, but in my opinion it is honestly the best way to get started in Unity. Most of the tutorials are in Javascript, and the language itself allows for some more organizational flexibility that c#, and especially c++ do not. If you have no programming experience, I would recommend starting with Unityscript and then moving into C# if you feel that it is necessary for your goals. If you understand programming logic well (and Javascript is a great way to get on that track), the only thing you'll really be learning when you switch to C# are the syntax (the physical grammar organization of the language) between the two languages. It isn't like learning to write code all over again.

    Also, the best thing you can do if you want to pursue the indie route is to honestly learn as much about everything under the game development umbrella as you can. It's a difficult path, and that's just how it goes.
    Last edited: May 31, 2012
  42. AlexanderLaheij

    AlexanderLaheij

    New Member

    Joined:
    Apr 29, 2013
    Messages:
    1
    As a 2th year student - Indie Game Developer (@NHTV) I could not agree more, that you should learn as much as you can around Indie Game Development. If you want to make games on your own, than you will have to go for it. I have some programming skills in AS3, C++, JAVA. I am planning to learn C# (C Sharp) so that I have a better understanding of programming.

    Also, keep making stuff!!!!! If you want to learn something good, make games or something interactive. I have not read much books, because all the information I need is always on the internet. I would recommend to read the book: "The Art Of Game Design" and maybe even the books "A Theory Of Fun" , "Rules Of Play" and "Level Design for Games". These books will not help much with programming, that is where the internet if for ;).

    Becoming better at something can be a difficult trail and error road, but once you learn from your mistakes you will be able to stick to the road and speed up. Just keep trying, good luck! ;)