Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Thoughts on UnityScript's Farewell

Discussion in 'General Discussion' started by skauth, Feb 14, 2018.

  1. skauth

    skauth

    Joined:
    Jun 4, 2017
    Posts:
    16
    I am so glad that UnityScript is going bye bye.

    === Edit ===

    tl;dr:
    • BAIT AND SWITCH
    • UnityScript is nothing like JavaScript.
    • C# is actually easier to learn and use than UnityScript. (I've been using JS since I was 8, know a bunch of langauges, never really used C# before Unity)
    • We need to find some way to show how easy C# is and make it less intimidating.
    UnityScript works nothing like JavaScript, does everything like C# does.
    • Syntax is unique, not like real JS or C#.
    • Semantics is made to match C#.
    • Brand new language, exclusive to Unity. Which means NO answers on StackOverflow, NO documentation outside of Unity manuals, NO articles on random blogs.
    • Far easier to learn about classes, inheritance, enums, and more, in C#, where there's a million non-Unity articles and docs regarding how C# works.
    • Still very verbose, maybe even moreso than C# or Java.
    • Still compiled. (I debug javascript by running typed-in functions at runtime).
    However, Intellisense and Compilation show you errors in your code before you encounter them at runtime. It makes strictly typed languages actually make sense. I've been using JS since I was 8. I am an expert in it. And now I don't think I can ever go back to trying to make complex games in pure JS.

    === End Edit ===

    Honestly, it felt like a bait & switch when I first started using Unity. I come from a web development background, and I had recently started making simple games from scratch with HTML5 Canvas, JQuery, and Pure JavaScript. I ran into a lot of roadblocks with boilerplating the drawing and positioning of things, and I wanted to make more complicated games. So when I saw "With Unity, you can program in C# or JavaScript," I got super excited and jumped on board, downloaded stuff, downloaded the assets for the 2D RogueLike Tutorial, and started following the video tutorial. (btw, I hate video tutorials in general; I usually like text tutorials, but this one was well done. The Live Training videos are a nightmare to follow.) Anywho. The tutorial had everything in C#, and I was like, "I don't know C#. I'm going to do this is JavaScript instead." So where he says to create .cs files, I created .js files. And I tried writing js to the same effect. I failed. Miserably. Errors at every turn. I had to look up new syntax for every single line of code I wrote. After several hours of struggling uphill to get through this, I finally found that it was easier to rewrite my code as .cs, without even looking at the tutorial, than to continue to write another line of .js UnityScript.

    UnityScript is NOT JavaScript, nor has it ever been. I keep hearing "Though they resemble each other syntactically, they have very different semantics." Well no. They do not resemble each other syntactically, either. I'd go so far to say that JavaScript is more similar to C# than it is to UnityScript, in terms of pure syntax. I have never once written `var variableName : string;` in JavaScript, nor `function DoSomething(variableName : string){}` Colons are for writing JSON and Ternary Operators. It is far easier to go from `var name = "blah"` to `string name = "blah"`

    The precise reason I like JavaScript over other languages is primarily the loose typing. A function can have properties attached to it. Namespacing is as simple as making an arbitrary object. You may call me a classless fool (pun intended), but that was what I was expecting out of something people call "JavaScript".

    Now granted... now that I know the wonders of strictly typed languages and intellisense, I doubt that I'll ever be able to go back to the way I was trying to program before. Without intellisense and compilation errors, you have to keep in your head anyways that "You can't call .Push() or .Add() on an integer." If your program doesn't tell you that anyways, and you have to figure that out on an object-to-object basis, then dynamic typing makes a lot of sense. It's only once something else is stepping in to remind you of what your previous code says that it makes sense to have strongly typed languages and non-arbitrary classes so the compiler/editor can tell you when that variable named "Horse" is an Enum, an integer id, a string id, a string name, or an object of the class Horse, and so it can tell you what methods and properties are available.

    The same applies to having multiple script files. When making three simple games in JavaScript that were meant to run in the same setting, I would put them all in one file, which I could call once. The common advice is to separate it into different scripts. I currently have over 30 .cs scripts for a game which, when I was making it in JavaScript for web browsers only, was all in one file. Because those files are very easy to lose when you copy and paste the code to work in a new site (of course it was modular, though. So it would work anywhere. So long as you got the entire file set.). And if your error is in blah file, there was no neat little IDE thing to transport you to just the right part of just the right page. No, ctrl-F in a single file was way faster than 30 ctrl-F's to find the right place. But with MonoDevelop, Shift-F12 will bring up every single time that identifier is referenced.

    So yeah... UnityScript is nothing like JavaScript, and it is shameful to pretend it is. But I understand why they marketed Unity towards JS programmers that way. I'd like to argue that instead of saying "You can use JS with this!", that they should show how easy the C# code is. There are a million Unity tutorials out there that make C# almost as easy to learn as true JavaScript. Maybe I'm a bit off base. I've been using JavaScript since I was eight years old (I'm almost 23 now). I've been using Unity since last year. I fall into new languages extremely easily. (I always helped debug PHP, Perl, Lua, ASP.net, VB.net, and many others without knowing what language was up on the screen. Like knowing if a semicolon should be there, based on if other lines had semicolons.) So maybe it's just me. But C# seems a lot easier than advertisements make it out to be. UnityScript is 10x more difficult than the advertisements. JavaScript is about 2x more difficult (though 10x more difficult than snobby college boys, who think JS isn't actually a programming language, make it out to be).
     
    Last edited: Feb 15, 2018
  2. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    6,436
    Can you add a tl;dr version?
     
    hippocoder, FMark92 and theANMATOR2b like this.
  3. Ony

    Ony

    Joined:
    Apr 26, 2009
    Posts:
    1,847
    Pretty sure that would be...

     
  4. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    6,436
    Sweet. Cool story.
     
    theANMATOR2b and Peter77 like this.
  5. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    6,525
    I'm happy to see it go as well, but in defense of getting started in Unity with UnityScript, when I started in Unity in the early 4.x versions a large portion of the tutorials, example code, and assets available were written in UnityScript, not C#. A good number of the standard assets were js files as well. This was problematic for me, as I jumped in with C# and there are issues talking back and forth between C# and js scripts. The landscape drastically changed by the time 4.6 came out, apparently just by the community moving to C#.
     
  6. FMark92

    FMark92

    Joined:
    May 18, 2017
    Posts:
    1,238
    Nice.
     
  7. Whippets

    Whippets

    Joined:
    Feb 28, 2013
    Posts:
    1,775
    Bye bye UnityScript... Can I has your stuff?
     
    AntoineDesbiens likes this.
  8. elmar1028

    elmar1028

    Joined:
    Nov 21, 2013
    Posts:
    2,183
    When I was starting out (no C#/C++ background), I finished the course for Javascript through Codecademy (it was completetly free back then). Knowing that Unity supported Javascript, it gave me confidence and courage in familiarizing with the engine.

    I made my first mobile game with it (Death Race, some people here might recall it)

    So as much as I am happy seeing Unityscript go, I am also a bit sad. I am not sure if I would've started learning Unity properly without it. :p
     
  9. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,628
    I found it easier to learn unity script initially, I'm a bit disappointed that it is being removed, though I have necessarily had to transition to C#. I just don't like how 'formal' and finnicky C# is syntax-wise.
     
  10. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    25,604
    What's the biggest thing you've made in UnityScript? the most ambitious working project? I'm going to call it now and say "not that big" or "under 6 months of code"

    I mention this not because I want to attack, but to illustrate that the formal and finnicky bits are really there to help you, not C#. C# doesn't really need to have them, but it prevents programmers from causing more bugs than they need to. UnityScript in large projects tends to run a bit riot and become a mess.

    Humans are the weakest link in the compiler chain.
     
  11. skauth

    skauth

    Joined:
    Jun 4, 2017
    Posts:
    16
    I'd like to argue that I'm one of the strongest human links in the compiler chain, given that I've used JS since I was 8, and I've made some mildly complex games in JS (Mastermind clone). I'm pretty darn good at remembering what functions and properties are available on the objects returned from each function. That said... After finding the wonders of intellisense, strictly typed languages finally make sense. I don't think I can ever go back... At least not for anything more complicated than a webpage (though those can get pretty darn complicated...)
     
  12. ShilohGames

    ShilohGames

    Joined:
    Mar 24, 2014
    Posts:
    2,468
    I personally love strictly typed languages, and I hate using loosing typed ones. C# is massively better than UnityScript (and JavaScript), especially on large projects. By large projects, I am referring to projects that take years to build and/or a large group of people to build. Loosely typed languages are ok for tiny projects that get slammed together in a few hours or days, but loosely typed languages allow for frequent subtle coding mistakes that can be very hard to track down in large projects.
     
  13. Ony

    Ony

    Joined:
    Apr 26, 2009
    Posts:
    1,847
    In the hands of a determined developer, the language doesn't matter as much as the execution.

    When I first learned Unity (2009) they heavily pushed UnityScript (they were also using Boo back then). As far as I recall, almost every tutorial was using UnityScript. I was coming from the A6 engine, which used their own proprietary C-Script language. Since I'd never used C# at that point, and Unity didn't seem to be pushing it, I learned UnityScript and started on our first Unity project.

    The game we released (two of us) was a big project. It came out in 2010 and is still being purchased and used today, with just under 500,000 users. Roughly 250 people still log in every day. It was written entirely in UnityScript.

    It wasn't until about 2014 that I decided to switch to C#. We were already in the middle of a project so I did the conversion from UnityScript to C#, and have been using it since.

    Figured I'd throw that out there as a counterpoint to the "UnityScript" sucks idea. Maybe it does these days, I don't know, but back then it did what it did and it worked, and that was good enough for me. I'm curious myself about how many other people released larger projects that were made with UnityScript.
     
  14. Ony

    Ony

    Joined:
    Apr 26, 2009
    Posts:
    1,847
    erk... I've never liked Intellisense. I wish I did, because it seems for a lot of people to make things easier. For me it just makes things more annoyingly complex on screen and ends up being frustrating. I code in Notepad++ and I like very little visual distraction. I've tried to use several of the "helpful" tools people use these days but it just doesn't work for me.
     
    moonjump likes this.
  15. skauth

    skauth

    Joined:
    Jun 4, 2017
    Posts:
    16
    I love Notepad++. In the past, I loved loosely typed languages and hated strictly typed languages.

    I didn't like intellisense at first, either. It's not quite as bad as Notepad++'s habit of, when I type "<?php" enter, it turns it into phpEgg or whatever it was. (it doesn't happen anymore). But intellisense was really distracting at first. But then I started actually reading the tips that popped up. I think I may have changed some settings to make it work the way I wanted, but I can't remember. Either way. I don't have to go to the docs to find out that Vector3() can accept x and y, or x, y, and z, or another vector3, or a vector2, etc. I hit comma, down arrow, and I can scroll through the entire list of parameter sets. It will tell me if something is a struct or a class (very important distinction). I can set C# comment summaries on a list of enum names, and even if the names themselves don't quite make sense, or I last worked on the project last year, or it's someone else's code, I can know exactly what they meant. It may not mean much with simple classes like Mathf, Vectors, stuff I've written, or stuff I'm actually familiar with. But when I started using Colors in my code, I relied entirely on Intellisense to tell me how to define colors using the Color class. (I was used to colors being "#f9f9d3", and not including Alpha.) Intellisense will remind me that I've declared something as a Sprite instead of a SpriteRenderer, because I can't use "theSprite.sprite", it doesn't exist. Hover over "theSprite", and I realize that it was declared wrong.

    I cannot go back to working on big projects without Intellisense. And I've only been using it for a year.
     
    Ony likes this.
  16. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    14,531
    For me it wasn't that other people found it beneficial. It was that I had a problem that appeared to be RSI (and it may still be RSI but it doesn't seem to happen lately) and had no real alternatives but to learn it. After a while it became a normal part of development but that hasn't stopped it from messing with me on occasion.
     
    Ony likes this.
  17. ArachnidAnimal

    ArachnidAnimal

    Joined:
    Mar 3, 2015
    Posts:
    1,644
    Just think...in 10 years people will be creating threads entitled "I'm so glad C# is going bye-bye".
    Also, Valve might be finishing up Half-Life 3 by then.

    The people who are most sad to see Unity Script go are:
    1. Asset store sellers who have to convert their code to C#
    2. People who bought asset store items in UnityScript who have to convert the code to C# themselves because the Asset Store seller can't or won't.

    I'm lucky enough to be using only a couple of assets that were done in UnityScript, and the asset store seller converted the code to C#. So I'm fortunate.
     
    Socrates, firejerm and Jamster like this.
  18. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    25,604
    Unity is 13 years old with a made up language (UnityScript) and C# is a microsoft invention backed by billions of dollars, and one of the most popular languages in the world and it's 18 years old. So far C# is proving it can stick around.

    Unity Script is not a bad language, it is great actually - shipped a few titles in it - but after switching to a stricter language, I was able to see that the quality of my work went up but the code largely remained my own and aside from a few very minor syntax differences, I struggled to understand the purpose for Unity Script's existence.

    Especially with hundreds of thousands of pieces of code on the web I could use vs a tiny handful of scripts for UnityScript. It was no contest.

    Honestly I don't see why C# would suddenly be replaced. Much more likely, AI + Voice + graphs, those will be the mainstay of future game development.
     
  19. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,481
    I'm not sure we are talking about the same thing here. UnityScript was not JavaScript.

    The biggest issue with UnityScript was that it was a strictly typed language that pretended to be a dynamically typed language. It still compiled down to strictly typed IL.

    In practice that meant that you could assign any value to any variable. If you assigned incompatible types, UnityScript would just make the variable type System.object. Which then meant that you couldn't call any methods on it without casting.

    Ultimately this pretend dynamic typing made UnityScript a harder language to learn and master then C#.

    I for one am glad it's gone. I could use it, but it was a major pain to get anything done with.
     
  20. sicga123

    sicga123

    Joined:
    Jan 26, 2011
    Posts:
    780
    Clearly it is a fait accompli as Unityscript has now been dumped. For people without a C# and :net background, C# code can be opaque. By this I mean if I am using a toolkit written in C# by an experienced C# coder then pretty much there will be numerous class calls to the .Net framework and the C class core, sometimes coming across a line like dothis() and then no reference within the scripts anywhere to dothis() can result in a WTF?

    This can often mean that what would have been a trivial change in someones code had that code been written in C++ suddenly becomes this whole rigmarole of tracing through all sorts of stuff that is external to the assets scripts. If I write my own scripts then yes C# is better then Unityscript, but at least assets that had both C# and Unityscript meant that one could dump the C# scripts and make changes to the Unityscript which always were trivial changes because everything was in those scripts I didn't need to have an understanding of an underlying framework.

    Will removing Unityscript have an impact on using Unity? Well, the real success of Unity lies in the object/component system and not in whether one uses C# or Unityscript, so it likely won't, but would anyone know really, how many people look at an engine that uses C# and would go searching elsewhere, I know Unityscript finally got me into Unity and I paid for unity pro from versions 3 - 5, if I was having to make the same decision now, without an understanding of how good an object/component system is, then no, I would go to Unreal or I would use phaser or marmelade depending on what I wanted to do, or even gamemaker. There are other game engines that have started using that object/component architecture, if Epic switched over to a fully object/component system then no-one that migrates over there would migrate back here. To me it seems like a step in the wrong direction in terms of accessibility for non-coders. A great many assets don't play nice with each other and assets scripted in Unityscript were always easier to bend to one's will than those scripted in C#.

    Again, to re-iterate - I don't think people have problems writing their own C# scripts, the problems are more in deciphering other code from scripting assets and plugins bought on the store, and over time asset providers have stopped giving Unitscript versions anyway so its a moot point really: Even if the idea of democratising game development was really just a nonsense blurb (well there was a time with Unity it seemed genuine) removing Unityscript seems like the end of an ideal when a few guys from Europe really did have a vision. I don't really care so much about Unityscript as I do about the loss of the Ideal. This is why we can't have nice things.
     
  21. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    14,531
    What are you referring to when you say "the C class core"? Are you referring to native code? Because if you are then let me tell you as an experienced C# coder who has worked with code written by other experienced C# coders that unless you have a native code library that is important to the project you simply won't be making calls to C from C#.

    That aside though the whole "there will be numerous class calls to the .Net framework" is a real oddball statement and my only conclusion that you would say that this has to do with C# is that you have never written a complex script.

    UnityScript may not have the "using" statements at the top of a script, but it's most definitely using the .Net framework. For starters, when you create an array you're actually creating an object of type System.Array. Lists are another common example of a class from the framework that is commonly used. It's found in the System.Collections.Generic namespace.

    https://msdn.microsoft.com/en-us/library/system.array(v=vs.110).aspx
    https://msdn.microsoft.com/en-us/library/system.collections.generic(v=vs.110).aspx
     
    Last edited: Feb 18, 2018
  22. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,481
    I'm a little confused by this. When you get down to it, UnityScript was C# with a bunch of syntactic sugar. Some of it was nice, like not having to worry about explicitly declaring classes or typing every single variable. But ultimately you were still sitting on top of .NET.
     
    angrypenguin likes this.
  23. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    5,866
    Yes, but what if I'm the rebellious kind of developer and all for riots?
     
    Kiwasi and hippocoder like this.
  24. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    25,604
    You can have your own personal riot, just not at the expense of everyone else :)
     
    AcidArrow likes this.
  25. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    5,933
    I don't have a C# background at all, but it's all I use. My background? I'm an archaeology major. I got started in Unity converting example scripts I found around into Unityscript. I never found it opaque at all.
     
    Kiwasi likes this.
  26. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    5,866
    Well, just today I replaced the last .js file in our project with a .cs version.

    It has been there since the beginning and has seen us through good and bad. It was there for legacy reasons, to remind us where we came from.

    Now it's been replaced by the new and improved .cs, but I already feel like more of a conformist. I can no longer be a rebel and dynamically type all my variables, but maybe it's time to accept that I'm older now, my head having less and less hair each day is proof of this, and doing riots is something for the younger kids.

    UnityScript is dead, long live UnityScript.

    (-ω-)ゝ

    (in case it's not super clear, I'm having a bit of fun with the subject matter, if I'm derailing the thread too much, please delete this post)
     
    superpig, Kiwasi and Ryiah like this.
  27. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    25,604
  28. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    12,042
    I don't understand this, for two reasons.

    First of all, is UnityScript honestly any easier than C#? I know the marketing department told us it is, but they also called it JavaScript, which it is not and never was. Still, that's a genuine question. C# is more verbose in some areas and it has "C" in the name, both of which make it far more scary for newcomers, but is it actually harder?

    Secondly, I'd have thought that unifying to one scripting language would support democratisation, because it solves a bunch of issues like the compile order impacting what scripts can talk to each other, and unifies the community around a single tool rather than separating them across multiple. Plus, as has already been pointed out, many many people have prior C# experience, where nobody new to Unity has prior experience in their custom-language-masquerading-as-JavaScript.
     
  29. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,481
    Very interesting question. We discussed this a lot back in the day when both languages were legitimate choices.

    UnityScript was easier to get started in. You didn't have to know about classes and instances. You didn't have to know a thing about data types. The trouble was, these are both fundamental programming concepts for programming with Unity. So within a few weeks of getting started, you would run hard up against them anyway. And by this time you had a bunch of scripts running around built without consideration for these. Then you had to contend with the languages dismal documentation. And the fact that every time you searched google, you got useless answers about real JavaScript.

    Ultimately when it came to learning, UnityScript was no easier then C#. It just delayed some of the learning a little bit. C# had a slightly more difficult first few weeks. But after that it was much easier to learn.
     
    zombiegorilla, angrypenguin and Ryiah like this.
  30. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    25,604
    Really, it increased access to Unity, so that was mission accomplished for Unity at a specific period of growth. I'm going to assume it's all about having the latest C# version nowadays, since accessibility is going to be served with visual scripting and templates.
     
    Ryiah likes this.
  31. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    12,042
    Well, getting those wrong might not throw errors, but stuff still won't work as intended, and by default things are less clear.*

    I remember helping a fellow who's character had stopped moving until speeds were cranked to ridiculously high values. It turned out that he had changed how a number was written so that the compiler interpreted it as an int instead of a float, so it was getting truncated to 0 most of the time. Deferring the learning about data types just made it a bigger, harder-to-learn lesson later.

    Playing Devil's Advocate for a moment, though, it takes a bit of experience as a coder before you realise that error messages aren't evil, mean, cranky things - they're guard rails that help you get things right by flagging errors early. But by sweeping them under the rug Unity did help this guy get pretty invested in the task at hand before they might have managed to scare him off. So I guess there's that?

    * Note that you can use implied types in C#, too. It's just not the default, encouraged way to do things.
     
    Kiwasi and Ryiah like this.
  32. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,481
    That was kind of my point. You could get started quickly. But you soon hit a wall when you actually needed to know about data types. Which was normally pretty soon after you started. Getting a running start into a pit of spikes wasnt really super helpful.

    The number of times I helped resolve "xxx is not a member of System.Object". Its an error peculiar to the UnityScript typing system. Its pretty obtuse, and never pointed at the right location in script. I would prefer "Cannot implicitly convert type xxx to type yyy" every time.

    I know you can do it at the method scope level, but I didn't think it worked at the class level?
     
    angrypenguin likes this.
  33. superpig

    superpig

    Quis aedificabit ipsos aedificatores? Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,194
    I'm curious to see how people will feel about the loss of UnityScript once we ship Visual Scripting.
     
    Ryiah and hippocoder like this.
  34. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    14,531
    About the same way once you ship the new terrain and input systems. :p
     
  35. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,481
    Don't worry. We will complain about that too. We have an endless capacity for complaining! :p

    (Actually tentatively excited to see the visual scripting solution.)
     
  36. ippdev

    ippdev

    Joined:
    Feb 7, 2010
    Posts:
    2,640
    Ummm. You could specify the type you used in .us. Just because you didn't have to did not mean _everybody_ using .us was using untyped vars. Yet another mythic misconception around here with the C sharpers. I came into Unity as a very advanced AS3 programmer so .us was a breeze to pick up and use correctly with #pragma strict. C# is just as easy if you understand programming.
     
    Ryiah likes this.
  37. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    25,604
    Well with C# you can use var if you want to let the compiler figure things out.
     
    angrypenguin and Ryiah like this.
  38. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    12,042
    Indeed. The difference @Kiwasi/I were talking about is how newbies approach, or are encouraged to approach, the language.
     
    Ryiah and Kiwasi like this.
  39. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,481
    For experienced programmers, typing wasn't a big problem. My comments about typing were mainly directed around beginners trying to pick up UnityScript as a first language. Which is mainly what UnityScript was sold as (at least when I started with Unity).

    The problem I encountered as an experienced programmer with UnityScript was the general lack of documentation. I never did find out how to use generics in the language. Admittedly, I didn't try very hard. By the time I started with Unity, it was already fairly obvious that UnityScript was going to die eventually, and everyone was being pushed to C#.
     
    angrypenguin and Ryiah like this.
  40. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    14,531
    It's almost identical to C# except there is one minor difference. You need to insert a period between the container class name and the generics tag. It's completely bizarre in my opinion but it's likely a side effect of how something works.

    Code (csharp):
    1. var list : List.<String>;
    2. list = new List.<String>();
     
    Kiwasi likes this.
  41. ippdev

    ippdev

    Joined:
    Feb 7, 2010
    Posts:
    2,640
    Another issue folks had was delegates but you could declare a function as a var.
     
    Kiwasi likes this.
  42. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,481
    Has this changed recently? I was under the impression this could only be done on locally scoped variables, and not fields at the class level.

    Nice. Never figured that one out. How did you go about creating a generic class? What would be the equivalent to this?

    Code (CSharp):
    1. public class MyGeneric<T> {
    2.     public T someValue;
    3. }
    I suppose it doesn't really matter anymore, but I still hate having gaps in my knowledge.
     
  43. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    14,531
    You can't create one with it. Quoted from the UnityScript sample code box at the link below.
    Code (csharp):
    1. //JavaScript does not allow generics to be defined. To utilize
    2. //this functionality you will need to use C#
    https://unity3d.com/learn/tutorials/topics/scripting/generics
     
    Kiwasi likes this.
  44. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    1,147
    It would have been better if Unity had focused on C# from the beginning instead of having all their examples in Unityscript in the beginning which lead many to use it instead - then having to change to (the better) C# later..
    But what has made unityscript unusable for a while is the lack of tool support (intellisense, VS code checking pre-compile, things that make coding much faster/easier/less error-prone) and also compile times for unityscript were minutes vs seconds for C# for large projects, a rarely mentioned issue.
     
  45. Jingle-Fett

    Jingle-Fett

    Joined:
    Oct 18, 2009
    Posts:
    548
    Unityscript was easier and more convenient for me coming at it as an artist with little/no prior programming experience. It also helped that I didn't (and still don't) have any interest in programming stuff outside of Unity. 98% of BHB: BioHazard Bot is in Unityscript, it wasn't until roughly the last year of development that I started using C# in other projects and bringing in some C# scripts here and there. When I first started using Unity, the tutorials and examples were overwhelmingly in Unityscript, and that was also a big factor.

    It's only now that I'm more experienced as a programmer that I've come to prefer the more "strict" nature of C#. For future projects I'd probably use C# even if Unityscript wasn't being discontinued. But looking back at the time in Unityscript, I can say that for me personally it was definitely the better beginner's language.
     
  46. recursive

    recursive

    Joined:
    Jul 12, 2012
    Posts:
    598
    As someone coming from a C/C++/Obj-C/Java + (TorqueScript/UnrealScript/ActionScript) background with very light experience with .NET, C# just seemed like the obvious choice, on top of having more standardized packages written in C#. UnityScript always seemed like an EcmaScript dialect that couldn't decide what it wanted to be (it's the same problem I have with Objective-C, does it want to be C or does it want to be Smalltalk?).

    I understand the appeal for a lot of artists I worked with really wanted to keep using UnityScript on projects as far back as 3 years ago. Most of them moved on to C# when it became clear they couldn't do everything they wanted to do for editor scripting and getting the most of out of UnityScript meant using the stricter typing, which just made it more like C# anyway. Compound this with more and more tutorials and plugins focusing on C# (since it was more standardized and had more inbound developer knowledge), it makes perfect sense.

    Who knows though, maybe someday someone'll make a nice TypeScript adapter plugin that hooks right into unity's compiler pipeline, and UnityScript will have it's revenge.
     
    Kiwasi likes this.