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

What Language?

Discussion in 'Scripting' started by MattDAndre, Jul 21, 2012.

Thread Status:
Not open for further replies.
  1. MattDAndre

    MattDAndre

    Joined:
    Jul 21, 2012
    Posts:
    17
    Hey all!

    I've just recently downloaded the free version of Unity and I'm excited to get going with it, but I have a question.

    I assume there has to be some level of coding involved to make a good game, so what programming language should I learn for use in Unity? I've read Javascript somewhere, but I wanted to ask around on the forums to get a more solid answer :)

    Thanks!
     
  2. ippdev

    ippdev

    Joined:
    Feb 7, 2010
    Posts:
    3,793
    Both UnityScript/JavaScript and C# both have their advantages and really depend on what kind of headspace you have as to whether you prefer one or the other. You can do most things in both and some in one and some in the other. Sometimes .js is more verbose and others it is C#. If I was tutoring someone from scratch and wasn't there to hold their hand along the way I would suggest UnityScript as most of the docs have good examples which can be cut, pasted and altered to suit your purpose. I would learn C# too as many of the helper scripts, plugins and code examples from research and dev by forum members and scattered around the web are in C#. When it comes down to it they are both about the same with some flipping of syntax and changing of words..void versus function for example.

    hth
     
  3. MattDAndre

    MattDAndre

    Joined:
    Jul 21, 2012
    Posts:
    17
    Thanks for getting back to me ippdev!

    If I really have no previous coding experience what language do you suggest I learn first.

    If say, it was C# how much knowledge of the language does one need to use it effectively in Unity?

    I've found a C# tutorial website and it has a load of tutorials on different things. I don't really know where to start because it's not like I'm programming C# for windows programs, so I don't know what to skip and what not to skip.

    I guess I'm just a little lost, and looking for some direction.
     
  4. AnthonyPaulO

    AnthonyPaulO

    Joined:
    Nov 5, 2010
    Posts:
    110
    You need to learn the core language itself, so ignore anything that is windows specific. Look for tutorials that only deal with the console.
     
  5. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    I would suggest to do a forum search for the topic what language is better.

    There are already several excellent flamewar threads here that covers this issue. All with no result, because it is more a thing of personal flavour. So i suggest to have a look what looks more comfortable for you. And start with that.
     
  6. ippdev

    ippdev

    Joined:
    Feb 7, 2010
    Posts:
    3,793
    Ah yes.. You will run into tons of non game related C# examples. If you have never programmed then use the docs which use JavaScript/UnityScript. Most of the game specific code you seek will then pop up on google searches IME.

    This is a primer on it's proper usage.

    http://forum.unity3d.com/threads/34015-Newbie-guide-to-Unity-Javascript-(long)

    Start simple. Your script end up being easier to manage anyways. Write out your psuedocode first to get the gist of what you are trying to do. Then look at it like a stupid genius that will only do exactly and precisely what you tell it to do. If it looks solid then start matching functions and methods and arrays to store and retrieve in the docs. Cut and paste and alter a line or two at a time and keep your console open to keep you abreast of errors and where they are. Always fix your errors before ploughing ahead.

    hth
     
  7. ippdev

    ippdev

    Joined:
    Feb 7, 2010
    Posts:
    3,793
    Way to insert another flame war vector pal. Jeesh..this forum never ceases with this stuff. It makes it uncomfortable to post.
     
  8. venhip

    venhip

    Joined:
    Jul 7, 2012
    Posts:
    6
  9. MattDAndre

    MattDAndre

    Joined:
    Jul 21, 2012
    Posts:
    17
    From what I've read here it seems like Javascript would be the best starting language due to the fact that it's a bit easier to understand and more examples and tutorials are based on JS.

    @Venhip: I'm watching that video now and I think it'll be very helpful :) Thanks for pointing me in that direction!
     
  10. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    6,171
    C# is faster (yes, I know it's all .Net, but there are a lot of hidden slowdowns in UnityScript), better documented, and more powerful. I suggest you use it. There are millions of C# developers, and millions of pages of help on the internet, and quite a bit of it is applicable to Unity. Also, you can use Visual Studio to edit, and it's way way better than Monodevelop. It's a widely used language, you will get more help with it.
     
  11. AnthonyPaulO

    AnthonyPaulO

    Joined:
    Nov 5, 2010
    Posts:
    110
    I taught myself programming at age 10 and have been doing it ever since (I'm almost 39 now). I have programmed in a professional capacity with both Javascript and C# over numerous platforms (web, desktop, mobile, embedded, etc...) and I would *not* recommend Javascript as a starting language. All the flame-wars on this topic are absolute nonsense and people treat their languages like a religion instead of as the tools that they are. Javascript is a language whose primary focus was to appeal to beginner web-programmers in pretty much the same manner VB is the beginner programming language for application developers. It acts as a "lite" Java substitute and has been primarily used for manipulating HTML elements in a browser, so all your examples and tutorials are going to involve dealing with the DOM (Document Object Model, a nasty piece of work, save yourself time by not looking it up). You have my advanced condolences if you think learning via Javascript DOM manipulation examples and tutorials is going to be easier than learning C#. C#'s primary focus was to appeal to professional programmers and acts as a full-fledged Java substitute on both the application and web development fronts. You will find examples and tutorials in C# that deal with manipulating different User Interfaces such as WinForms, WPF, and Silverlight; don't do that. Instead, look for examples and tutorials that teach you C# using the console, which is just plain Jane text output without any UI whatsoever. This is how you learn, and this is the language I recommend you start with since it gives you the structure and rigor you need to understand what to do and what not to do when you encounter other languages that are not as rigid, such as Javascript. Don't believe the hype that Javascript is easier to learn, it's simply not true. Both languages, taught properly, are "easy" to learn, it all depends on you.
     
  12. ImogenPoot

    ImogenPoot

    Joined:
    Jul 2, 2012
    Posts:
    214
    If you don't wanna learn programming, and just create some game scripts, stick with a script language like JavaScript or Boo. C# is already very generous, but still requires an advanced skill level and understanding of how programming works.
     
  13. ImogenPoot

    ImogenPoot

    Joined:
    Jul 2, 2012
    Posts:
    214
    Well same here, even though I think I started even earlier. Just with TurboPascal, then Delphi, C++, Java, C#, Assembler ^^, Haskell, Scala, and then I tried some scripting languages like JavaScript and PHP and barfed...

    But you have to understand that especially for older people who just want to get something done, learning a real programming language might raise the bar too high. That is why script languages are so popular, because you can just hack somethign together without having to care much about what you write.
     
  14. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    Not true. All three languages gets compiled into a fourth language when building the exe ( I always forget the name of this language, sorry) . Means the execution time of the available languages are equal fast. Or at least unequal fast in a range where it doesn`t matter at all.

    Unity pormises to provide the same functionality and speed for all three available languages within Unity. And this promise is still valid. You miss nothing with either of the languages.

    And just in case you find something that you can do in one language and you can`t in another, that`s a bug then. Please report so that it gets fixed.
     
  15. npsf3000

    npsf3000

    Joined:
    Sep 19, 2010
    Posts:
    3,830
    Sorry Dude, but that's Bollocks (TM)

    I just wrote a script in C# that took ~20s.
    Same script, written in F# took ~4s.

    Different languages have different compilers [to the IL], and different languages have different paradigms.

    Do not confuse the Unity API with the language, and do not forget about the vast bodies of work that exist outside of the Unity API but are still useful from a unity dev PoV.

    Yes, I know you like US and that's fine - but make sure you keep your arguments factual.

    -----

    @OP

    There are 3 supported languages - Boo, US, C#

    Boo is cool - but it's kinda a niche language - very few people know it. As such it's not a language I'd pick as a beginner.

    US is fairly cool, but it's got limited resources. For example - there's no official language reference - you sort of have to guess at what you can and cannot do - or try reading the compiler.

    C# is similar to US [they share similar syntax/paradigms] but on steroids. There's an absolute ton more resources [books, documentation, video's, blog posts, stack-overflow etc] available, it's got a whole bunch more functionality, supported by Visual Studio and you can use it for far more than just unity.

    TBH, as someone that started U3D with US, and has learnt half a dozen or so languages for fun... go with C#. It's the easiest to learn thanks to the incredible amount of resources available, and it'll take you further than any of the others IMO.
     
    Last edited: Jul 22, 2012
  16. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    Again at your insane C# mission, fanboy? What comes next, forbid me the useage of my mother tongue, because english is the only true language? :)

    F# is not supported by Unity. That for your example ...

    Same here my friend, same here.
     
    Last edited: Jul 22, 2012
  17. npsf3000

    npsf3000

    Joined:
    Sep 19, 2010
    Posts:
    3,830
    Yep. Posting that F# was 400% faster surely shows my intentions of being a C# fanboi doesn't it.

    http://stackoverflow.com/questions/...parallel-for-on-a-dual-core/11599585#11599585

    Look, I think reporting it to Unity is going to be a waste of time, but if you really want to - go ahead.

    Feel free to correct my errors.
     
  18. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    Sure, no problem.

    And now do the same for C# and JS inside Unity, with a significant time difference, then we may talk again.

    Again, F# does not belong as a valid example because F# is not supported by Unity. This is no valid example. But a good example how your arguments always looks like. Post bullock that nobody can really follow. Chances are big that nobody even notices that it is bullock because nobody can follow it anyways.

    You were faster with your answer than i with my edit i would say.

    To make this point valid again, in case you find a REAL, a PRACTICAL example where there are significant differences, and not just some chimera examples as usual, then you have found a bug. Unity still promises same functionality with all three languages.

    If a bug report towards Unity makes sense or not (and unfortunately i tend to agree with you here because of some experiences in the past) is another chapter.
     
  19. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Please don't muddy the waters with languages that are not supported by Unity.

    Don't forget the Unity's JavaScript is definitely not the JavaScript used to code web-pages.

    Unity's JavaScript is a custom language for coding in the Unity environment.

    Think of Unity's JavaScript as C# in JavaScript clothing.

    F# is not supported by Unity.
     
  20. hellcaller

    hellcaller

    Joined:
    May 19, 2010
    Posts:
    381
    pick C# if u're planning to program outside unity, also check burgzergarcade.com tuts
     
  21. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
  22. npsf3000

    npsf3000

    Joined:
    Sep 19, 2010
    Posts:
    3,830
    Why? You claimed the compilation of Languages A and B and C to Language D means that languages A, B and C are going to perform the same - this is not true - that's a real world example. Hell, even the semantically same code in C# improved by 5x simply by some manual in-lining, feel free to test on mono and prove this is not the case.

    Correct, F# is not one of the supported languages by unity - please refer to the following:

    There are 3 supported languages - Boo, US, C# - NPSF3000
    C# is similar to US [they share similar syntax/paradigms] - NPSF3000

    However, the case is valid for two reasons:

    1. The code is an exagerated, but valid example of how languages compilers and paradigms can drastically change performance characteristics.
    2. This code, while no being run in Unity, was built as part of an R&D process to generate textures for a Unity3d application. I managed to bring the the time from 30 HOURS down to around 4 seconds. http://forum.unity3d.com/threads/144235-A-Fast-KD-Tree-or-Unity-Alternative

    The last one is important - a substantial part of my U3D development exists outside of unity - whether it be R&D, Webservices, Tools etc. As such it's false to reason that just because something is outside of unity it cannot be useful to a programmer working with Unity.

    I'm dreadfully sorry that nobody can follow my reasoning... which is exactly why a people at stack overflow, this forum and my work all follow the scenario with interest and several have written test code of their own.

    While I invited you to find errors in my arguments, and still do, I think it would be good for you to first reexamine your assumptions.

    Please, can you find a quote for that? You repeat it ad nausam, but I don't think it means what you think it does.
     
    Last edited: Jul 22, 2012
  23. Tseng

    Tseng

    Joined:
    Nov 29, 2010
    Posts:
    1,217
    C# itself doesn't need much to learn and most of the stuff you learn is applicable to other languages too (i.e. inheritance, accessors, interfaces, if/do/while/for-statements etc.). That + the syntax. That's all. If you are a good learner, it takes around less than a week to read it up all and understanding it.

    Though getting a good design (having inheritances applied correctly, designing of classes etc.) takes some time, it's called experience and can't be learned, only experienced.

    Everything else is NOT C# language anymore. 99% of all tutorials you find in the internet do not show you how to learn C#, they show you how to learn .NET programming in C#, which is a huge difference. C# is just a language, while .NET programming mostly (99.5%) involves using of .NET Api. The .NET API is same for all .NET compatible languages, be it VB.NET, UnityScript, Boo, C#, IronPython, IronRuby or F# or whatever else.

    Simply ignore noobs like Arunderan, they have no clues about programing.

    What will takes you most is to learn what API is available in .NET/Mono and in Unity and correctly apply this API calls, and this is mainly same in all, because the API doesn't change when you change a language.

    Also to note, UnityScript is just a language loosely based on ECMA Script, but other than the similar syntax it has nothing in common with JavaScript/EcmaScript, because EcmaScript paradigms can't be applied to .NET/CIL.


    I disagree. The first few chapters of every beginners programming book usually don't handle any API calls but the language and the basics itself, like inheritance, interfaces etc. and they are very similar for OOP oriented languages.

    Also it's pretty much a rumor that you don't need to understand how programming works when working with UnityScript. You need as much knowledge as for C#. If you do inheritance in UnityScript you must understand how inheritance works. Same is true for C#. If you don't understand it, you can't utilize it, simple as that.

    I think most of you people confuse many things. You seem to confuse become a professional programmer vs able to learn a language. Learning C# is easy, it's language properties can be learned very quickly by most persons who spent a little time learning it.

    However, becoming a professional programmer requires more than knowing a language. You have to know common patterns (they are not language specific) or learning and applying algorithms or designing and proper interaction of 1000's of classes of a big project. But this has nothing to do with the language itself, they are general, language independent, skills.

    i.e. Learning C# is like driving a car. It's easy for everyone to learn it, no matter if you are young, middle-aged or retiree. But becoming a professional programmer is similar to being a car engineer who constructs new type of cars and understand how they work, how to improve the security and performance of the car, make it use less fuel, how aerodynamics affect the car etc.

    People who can't even remember 3 letters, shouldn't be called themselves programmers or giving others advices when they themselves lack of enough programming understanding.
     
  24. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    So you better shut up then.
     
  25. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    And again no real example. Thanks for all the fish.
     
  26. Tseng

    Tseng

    Joined:
    Nov 29, 2010
    Posts:
    1,217
    It wouldn't be even necessary to step in, wouldn't inepts like you spreading wrong facts and confusing people with their wrong understanding of the subject
     
  27. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    You have your understanding, i have mine.
     
  28. Tseng

    Tseng

    Joined:
    Nov 29, 2010
    Posts:
    1,217
    Then stop spreading your ignorance, other people may read it and continue spreading this rubbish themselves
     
  29. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    That`s more what i think about you. Stop posting bullshit please.
     
  30. Tseng

    Tseng

    Joined:
    Nov 29, 2010
    Posts:
    1,217
    Just trying to have the last word won't make your nonsense more true. Just get it, you are mediocre programmer at best. It's not bad to admit that you suck in something. I such at 3D modeling and arts and I have no problem with. I'm no ignorant jerk like others are.
     
  31. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    Well, the problem is, my programming skills have absolutely nothing to do with this discussion here. But is just your usual way to discuss. Discrediting the opponent. Must be a C# disease. Noo, i am right, look the other one is a moron!
     
  32. Tseng

    Tseng

    Joined:
    Nov 29, 2010
    Posts:
    1,217
    They have something to do with it. You got examples that proved you wrong, yet you still decided to ignore it. Performance of compiled code depends on a few facts, the compiler and compiler optimizations being one. .NET C# compiler will apply different optimizations than Mono one. Boo uses it's own compiler, UniyScript basically gets turned into Boo first before getting compiled (see UnityScript on GitHub).

    And you got your prove in the previous post of npsf3000 that different languages (who all compile into CIL code) can have different results. Microsoft has 100s of people working on their compiler and framework, Mono has less. Unity has like what? one guy working on Boo and UnityScript? How likely is it that one single guy can write a compiler which generates better and more optimized code than one where many people are working on it?

    It's just that in 90-95% of the situations you won't deal with time critical code anyway, where optimizations (both compiler and manual one) could make performance differences that are >50%, that's where the compilers (and/or JITers) show their real strength and not in the simple code.
     
  33. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    I think this thread has it's pearls of wisdom.

    As such, I invite users to pry open this oyster and dig around to find them.

    That being said, however, I feel that this oyster bed should be closed from further growth and be left in it's current state for the language archaeologist of the future.
     
Thread Status:
Not open for further replies.