Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Which program language to learn first?

Discussion in 'General Discussion' started by Javafuel, May 31, 2015.

  1. Javafuel

    Javafuel

    Joined:
    May 30, 2015
    Posts:
    4
    Hi all,

    I am a product designer with next to zero programing experience, but I've read and played with C++ for a few weeks when I was experimenting with Arduino. Now my goal is to become an indie app developer for Android & iOS. The plan is to learn Java, since the Android OS will be integrated into consumer products other than mobile devices in the near future. Java would be a good addition to my product design skills.

    Now I'm thinking that I should learn C# first, so I can take a full advantage of multiple platform development in Unity. Once I'm comfortable with C#, then I can learn Java. My understanding is that C#, Java and C++ are quite similar. Once you know one , the other two languages are fairly easy to learn.

    If I am to developing apps with Unity only, how much Java and Objective-C I need to know? Thanks in advance.
     
  2. jpthek9

    jpthek9

    Joined:
    Nov 28, 2013
    Posts:
    944
  3. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    To expand on jpthek9, C# is most likely the best option:
    1. It's most likely the easiest to learn out of C#, Java and C++.
    2. It's the only one of those three that is applicable for doing Unity development.
    Regarding Java and Objective-C required for Unity dev - I'd say that typically VERY LITTLE will be needed - typically you only need to use Java if you need to write some code to access Android specific features that are not provided by the Unity API, and likewise Objective-C is typically only used to access iOS specific features that are not provided by the Unity API.

    Even saying this, most (if not all) iOS/Android features that are not already covered by the Unity API can usually be access through some of the (often free) Mobile platform native Asset Store packages like: https://www.assetstore.unity3d.com/en/#!/content/9555
     
    Javafuel, NomadKing, jpthek9 and 2 others like this.
  4. Tomnnn

    Tomnnn

    Joined:
    May 23, 2013
    Posts:
    4,148
    And the same for C++, right? You can't code straight C++ in the editor but you can write native plugins?
     
  5. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,555
    Java was about 90% the same as C# until C# .NET 2.5. Then they added LINQ to C# and some other cool stuff. If you learn Java OR C#, it's quite easy to pick up the other one. C++ is of limited usefulness these days, I wouldn't waste my time learning that one. It's quite an old language. Something like Python would be more useful IMO.

    Objective-C is useful if you want to code just for iOS and not use Unity.

    But yeah if you're in Unity, C# is the only one you reallly need to know.
     
  6. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    There's a few ways to use C++. You can use managed C++ compiled to a DLL and use that on all platforms (I believe) you can also use unmanaged native c++ but this typically needs (correct me if I'm wrong) to be build for each platform you want to deploy to (and that typically means maintaining multiple build environments for the native lib for each platform).

    There is also other limitations you may hit using c++ native code - some features are not usable on WebGL (posix threads, posix sockets, etc) some posix thread features are also not available on Android (I think pthread_cancel is not available).

    I've made significant use of c++ native libraries for some custom physics and while this give a massive performance benefit for my actual problem, it causes a myriad of other maintainability and portability issues (from a Unity perspective).

    But yes you an use C++ in various forms from Unity :)
     
  7. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    I think that's VERY subjective - probably not an argument for me to start here, but I strongly disagree.

    C++ has a lot of practical uses that Python is not overly well suited to, it may be 'old' but it's not about to disappear any time soon, and Python certainly does not fill the gap of C++ - it's a totally different beast IMO.
     
    jpthek9 likes this.
  8. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,555
    That's cool larku. I hear that a lot of people have memory leaks when coding in C++ unless they're very very experienced so that kind of makes me feel like the language is not worth the trouble. I like how C# an Java protect against this automatically.
     
  9. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Sure you can. But the real question is should you. Unless you have a special case the answer is no.
     
  10. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,555
    Yeah I'm not saying C++ is replaced by Python.
     
  11. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    Indeed and that's a fair call - but that 'safety net' often comes at a significant performance cost - this cost is often not a concern, but it often is also :)
     
    jerotas likes this.
  12. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    Which is pretty much what I was saying (in a long winded way). If you have an absolute performance need, it's a useful tool, but if it can be done using C# and is performs well enough then that's nearly always the better option.
     
    Kiwasi likes this.
  13. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,555
    I hear that compilers are so good at optimizing these days that the performance difference isn't very much any more. Although on certain platforms a little can go a long way (mobile). I have no experience in the matter though lol, do I don't know how true that really is.
     
  14. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    Having implemented a custom physics solution in native C++ and the same solution in C#, in my case the C# code was fine for desktop but absolutely unworkable on mobile (orders of magnitude slower).

    The actual implementation did not lend its self well to a C# solution and is not representative of most problems - which is mostly my point. C++ is there (and C for that matter) when there is an absolute need, but should be avoided if possible due to the other complications it can bring.

    For context, my custom physics is not the typical frame based physics used in games - it needs to execute an entire simulation within < 0.05s (or at least fast enough that it seems instant for the user).
     
    jpthek9 and jerotas like this.
  15. Tomnnn

    Tomnnn

    Joined:
    May 23, 2013
    Posts:
    4,148
    @larku not to mention that python has it's own version of a < b < c. My c++ instructor hated python with a passion for many reasons, but that one seemed to bother him the most.

    All other languages ever - ((a < b) < c)
    python - (a < b < c)
     
    jpthek9 and larku like this.
  16. jpthek9

    jpthek9

    Joined:
    Nov 28, 2013
    Posts:
    944
    I don't know how C# or Python even have arguments here for low-level use over C++. It gives you so much more control which means more optimizations and better design. C++ has a niche yet to be rivaled for a while.

    With that said, C# does 99% of everything well enough in a simpler fashion.

    @Iarku Just curious, is this custom physics for a synchronous game?
     
  17. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    Yes, and I needed 100% deterministic simulations. I also use the same physics engine to perform AI where the AI can simulate thousands of possible 'turns' and then select a course of action from those simulations.

    Though the synchronous nature of the game does not really feed the requirement to have it be deterministic or computationally fast. It's actually a turn based game but each player observes the actions of the opponent. So it's not synchronous in the classic sense of the term, and the physics calculations do not need to occur synchronously on each device (and hence, no lock step required) there can be some minor delay in execution of the simulation (where the delay is palatable in keeping it feeling realtime - if that makes sense).
     
  18. Javafuel

    Javafuel

    Joined:
    May 30, 2015
    Posts:
    4
    Thank you all very much for your inputs. So C# it is. I'm very excited about join Unity community.
     
  19. jpthek9

    jpthek9

    Joined:
    Nov 28, 2013
    Posts:
    944
    Shameless self-plug here.... but http://forum.unity3d.com/threads/dphysics-deterministic-2d-physics-engine.315553/. Do you still need a deterministic physics engine?
     
  20. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    [apologies OP - we seem to have hijacked your thread here]

    Ha, yes I've seen your work there (I tend to follow all physics stuff here :) ) and it's excellent - but no, my physics is not general purpose and is designed to simulate a very specific scenario and needs to model the real world interaction of 3D objects moving at high velocities very accurately and needs to be able to execute entire simulations (of about 15 seconds wall-clock-time of around 50-100 objects) in around 0.01s on mobile. The physics needs to accurately simulate sliding friction, rolling friction, collision elasticity/restitution, etc) and each execution of the simulation must produce identical results given identical inputs.

    I had originally attempted to solve this with both Box2D and Physx, but neither could come close to what I needed in terms of execution speed and realistic simulation of said properties. They could get close in terms of realism, but not close enough.
     
  21. Gigiwoo

    Gigiwoo

    Joined:
    Mar 16, 2011
    Posts:
    2,981
    There is no right answer. I used Java for my first Unity app, before I realized it made my life complicated. Tutorials were usually in C#, plugins were in C#, and sometimes, the simplicity of Java added challenges (ex delegates). It took me about 4 hours to get used to C#. That was nine releases ago. <3 to C#.

    Gigi
     
    Ryiah and Tomnnn like this.
  22. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    Java?? Perhaps you mean JavaScript (which in Unity is really Unity Script which is Unity's take on Java Script).
     
    Ryiah and Gigiwoo like this.
  23. krazyhamad

    krazyhamad

    Joined:
    May 25, 2015
    Posts:
    12
    Well Sire,

    Start with learning basics first. Make your BASE strong and then start with any language you wants ..
    well I learnt the basics in C++ and it was good experience .. well you can do it in any language but the focus should be some key principles of Programming ...

    Regards :D
     
  24. Tomnnn

    Tomnnn

    Joined:
    May 23, 2013
    Posts:
    4,148
    Are you excited for java 8? We get a sort-of delegate function capability!
     
  25. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,555
    Yeah. C++ isn't very readable IMO, especially if you didn't write the code. Also (may be different per area), there seems to be way, way more jobs in C# vs C++. I live by Microsoft so of course that's the case here haha.

    I never used Python, but I read that it's a language with "no weaknesses" vs all the others, which did have certain weaknesses. That made an impression on me.
     
  26. Tomnnn

    Tomnnn

    Joined:
    May 23, 2013
    Posts:
    4,148
    Greed believes that time is money. The higher level your language is, the less time you pay a programmer to work. Any performance issues just mean you get to service your customers again in the future.

    --edit

    I use livestreamer to watch long videos and streams because chrome+flash+streaming = 400-800% cpu usage & fan stress test. Livestreamer is written in python and performs better than flash. Streams video right to vlc.
     
    Last edited: Jun 1, 2015
  27. tiggus

    tiggus

    Joined:
    Sep 2, 2010
    Posts:
    1,240
    Woah that's crazy talk. Also for Python all you have to google is "GIL (Global Interpreter Lock)" for weaknesses.

    I agree with Jpthek there's absolutely tons of stuff written in C++ and will be for the longterm future as with C++11/14 it is quite modern now. Not necessarily as pleasant as other languages but I can't ever see it going away in next few decades with how much is written in it.