Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

C, C++ and C#

Discussion in 'Scripting' started by darkben, Aug 12, 2011.

  1. darkben

    darkben

    Joined:
    Jan 8, 2011
    Posts:
    405
    I'm currently looking into learning a programming language for personal use and for advances in different degree courses, and I want to make sure that I learn the right languages at the right time.

    Currently, my question is this: What is the difference between C, C++ and C#? The course I am looking at offers C or C++ and Unity uses C#, so I might learn C# first, but I don't actually know the differences.

    Can anyone explain these in simple-ish terms? (I haven't looked into programming specifics yet)

    Thanks
    Ben
     
  2. Blitzer

    Blitzer

    Joined:
    Jul 19, 2011
    Posts:
    31
    If your looking for learning the language just learn any language by taking proper classes and then watch tutorials of other languages online there is noo big difference in any language I mean just few differences if you know about any language you can just learn easliy by seeing guide or video tutorials online .. My point is to start learning langugage just take a proper class of any language then u will be able to learn any language easily
     
  3. Blitzer

    Blitzer

    Joined:
    Jul 19, 2011
    Posts:
    31
    Hey see this wrote script for you to see the difference

    C language

    Code (csharp):
    1. #include<stdio.h>
    2.  
    3. main()
    4. {
    5.     printf("I am blitz");
    6.  
    7. }
    8.  
    9.  


    C++

    Code (csharp):
    1. #include <iostream>
    2. using namespace std;
    3.  
    4. int main ()
    5. {
    6.   cout << "I am blitz!";
    7.   return 0;
    8. }
    9.  
    10.  
    C#

    Code (csharp):
    1. public class blitzprogram
    2. {
    3.    public static void Main()
    4.    {
    5.       System.Console.WriteLine("I am blitz");
    6.    }
    7. }
    8.  

    Java language

    Code (csharp):
    1. class blitzprogram
    2. {  
    3.         public static void main(String args[])
    4.         {
    5.            System.out.println("I am blitz");
    6.         }
    7. }
    8.  

    Javascript(unity)

    Code (csharp):
    1. function Update () {
    2.     print("I am blitz");
    3. }
     
    Last edited: Aug 12, 2011
  4. npsf3000

    npsf3000

    Joined:
    Sep 19, 2010
    Posts:
    3,830
    From what I've read:

    C (and C++) are very detailed... but they also have a huge ability to hurt you. Think of a surgeons scalpel.

    C++ is C with a whole lot of stuff added. It makes writing good code easier (e.g. OO), but is also insanely complicated.

    C# is like a butchers knife. Very powerful, and gets the job done. You don't need 12 years of schooling to become proficient (as a surgeon would) but it's not great at open heart surgery.

    Given your into making games with unity, C# is the obvious choice.
     
  5. Arcmage

    Arcmage

    Joined:
    Aug 8, 2011
    Posts:
    17
    C was the original language it is totally procedural and not object oriented. C++ (which was originally just called C with objects) is just that an object oriented version of C with a standard library thrown in. C# is a version of C developed by Microsoft to be more clean and modern than C++ while attempting to maintain the power of C and C++.

    Btw Object oriented basically means you have classes which are nice constructs used to manage code.

    C is the most low level (closest to actual binary) of the three languages and still has many uses notibly all current OS are written primarly in C.

    C++ is higher level than C and is a standard for writing game engines and other high performance applications where speed is a critical issue.

    C# is the highest level and has a multitude of uses it is slightly slower than the other two but is much easier to use (Imo) which is probably going to be more important for most of the things you are likely to do (assuming your using it for personal use).

    You have to do allot of lower level things in C and C++ like manage dynamic memory which is actually a bad idea all around considering that most modern garbage cleaners will do it more efficiently than human coders. (If you don't know managing dynamic memory is just think of it as a pain)

    This comes from someone who learned a little C first then C++ and finally C#. But if you know any of the three languages you will pick up the other two quite easily.
     
  6. zine92

    zine92

    Joined:
    Nov 13, 2010
    Posts:
    1,347
    Actually c/c++ is hard, c# is easier. C++ is industry's standard. It will never run out. Personally if you think you are going to write your own engine, and stuff, C++ is the way to go. C for gaming not so popular because it's not oop. C# is good but you have to stick to the .Net framework which can be troublesome when porting games from win to osx or linux or mobile or vice versa.

    To put in short. If you are going to stick with Unity for some time. Learn C#. It's faster than learning c++ but if you see yourself writing game engine, then use C++. :D

    But same rules still applies. The concept of OOP is the same. Only difference will be the workflow. Personally i am not so fond of writing a code, compile and write and compile. A little time consuming, And i prefer Unity's workflow. :D
     
  7. Arcmage

    Arcmage

    Joined:
    Aug 8, 2011
    Posts:
    17
    Yes C# is the easiest to use that is what I said. When I say low or high level I am referring to the amount of abstraction layers not the difficulty to code in. Higher level languages are generally easier to code in and less efficient to run.
     
  8. oneXwork

    oneXwork

    Joined:
    Mar 3, 2011
    Posts:
    266
    I will say start with C++ first then C#/Unity javascript

    Since C++ is harder than C#/Javascript when you had learnt the fundamental of C++.
    You will find it a lot easier learning C#/Javascript.......

    But if you want to get straight into developing game:
    C#/Unity javascirpt is the best to start with......
     
  9. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    There is no reason to learn C++ first if its not where you will spend the majority of time in, as you would learn a lot of stuff that was dropped in modern languages for multiple reasons (primary ones like more productive, saver, cleaner, clearer)

    I personally would recommend to learn C# as you can use it outside of unity and as you find hundreds of books and ten thousands of tutorials on it. UnityScript on the other hand stops to exist at the borders of unity
     
  10. Mr.Smart

    Mr.Smart

    Joined:
    Aug 5, 2011
    Posts:
    54
    C# rules, it easy to use easy to learn and used in many big projects.

    And i can help you with lessons
     
    Last edited: Aug 13, 2011
  11. darkben

    darkben

    Joined:
    Jan 8, 2011
    Posts:
    405
    Ok, thanks guys :D
    I'm going to stick with C# for now, considering the course I want teaches C++ but that's not for a couple of years yet, and I'm taking decision maths at A-level for the next year followed by further maths after, so I should be set up.

    Thanks
    Ben
     
  12. Headingwest

    Headingwest

    Joined:
    May 3, 2011
    Posts:
    153
    I would learn C++ myself. If you want to go into games programming as mentioned above it's the industry standard. If you become proficient in C++ and find yourself in a position where you are required to use c# you will find the transition very easy.

    As you mention the course teaches C++ then you will also giving yourself a head start.

    If you do some simple games in c++ and open GL you will be learning alot of fundamental stuff that will give you a solid understanding of whats going on under the hood that will serve you in good stead, especially if you plan on going into programming as a career.
     
  13. codinghero

    codinghero

    Joined:
    Mar 21, 2009
    Posts:
    450
    I agree. Learn C or C++ first. The benefit of starting with C/C++ is that they are very strict and very touchy. You have to learn the proper way to do things or it won't work. With C#, as with all languages, you can do something many ways. One might say, "You SHOULD do it THIS way." In C/C++ that SHOULD becomes a MUST. So if you learn C/C++ first, you will learn how to do things properly from the beginning, which makes coding well in any other language considerably easier.

    By the way, OOP is not a per language thing. It's one of the original design patterns. You can use C in an object oriented fashion. It's just that C++, et al were designed with OOP in mind which allowed their creators to add more features that built on the paradigm. And C is still very much an industry standard, especially in embedded systems. Its straightforward approach and light weight pretty much guarantee it's not going anywhere soon.
     
  14. npsf3000

    npsf3000

    Joined:
    Sep 19, 2010
    Posts:
    3,830
    Isn't that oxymoronic?
     
  15. bdev

    bdev

    Joined:
    Jan 4, 2011
    Posts:
    656
    haha. Yea, in any way what can be shared from C ( almost nothing with C++ expansion ) to C# is so basic it doesn't really matter which one your looking into. If your interested in programming go ahead and take the class. If your starting from no programming background it doesn't really matter what language your learning as much that you understand how to accomplish tasks.

    But i have to warn you people who know C# very well still cannot jump into unity. Your going to be taking on multiple tasks once you get started with unity and even more than the scripting language you choose the most important thing will end up being your understanding of mathematics and physics. While some games won't require you to know that much 3D math, like say you were doing a card game you'll still end up needing to understand it to say move a card around.

    C/C++ are valuable to learn if your going into games in general. While i love using unity, and its very fast for what it does you do loose a-lot using a managed/scripted language. And with .net seemingly falling apart with the vast support of HTML5 who knows how much longer having .net support will be viewed as a positive vs. alternatives.
     
    Last edited: Aug 14, 2011
  16. darkben

    darkben

    Joined:
    Jan 8, 2011
    Posts:
    405
    Don't worry, I'm proficient in maths and physics.

    I'm probably going into embedded systems, but I still need to learn the language.
     
  17. bdev

    bdev

    Joined:
    Jan 4, 2011
    Posts:
    656
    Then you'll be fine. I'd highly recommend just starting off in unity then, otherwise i'd say to do a console or window forms app because it can be frustrating to try and learn physics while programming.

    Try and see if you can use a tutorial or demo from unity, modifying something to work differently and you'll pick up on C# pretty quick. It can be valuable to go through some language tutorials though too.
     
  18. npsf3000

    npsf3000

    Joined:
    Sep 19, 2010
    Posts:
    3,830
    My Advice: Learn lots!

    I've taught myself the basics of a half dozen languages since I began coding (<3 years ago). Each one presented a completely different viewpoint, and gave me a better grounding in the concepts.

    Right now, stick with unity and C# - but learn BOTH!

    People often learn just enough C# for unity... but don't bother learning all the powerful aspects of C# (Or vice versa, people not using Cor-routines properly)!

    I do 50% of my R&D in unity3d, 50% in Console applications (VS).