Search Unity

ES6 standards in UnityScript?

Discussion in 'General Discussion' started by Kerihobo, Aug 10, 2015.

?

What does this mean to you?

  1. I'm hoping to switch to ES6 standards in Unity.

    72.5%
  2. I prefer the common standard functions in Unity.

    2.5%
  3. Go to C#.

    20.0%
  4. What is ES6?

    2.5%
  5. What's that weird arrow syntax?

    2.5%
Thread Status:
Not open for further replies.
  1. Kerihobo

    Kerihobo

    Joined:
    Jun 26, 2013
    Posts:
    65
    I'm just curious. Are we likely to see use of the arrow function being pushed for javascript in unity once ES6 walks on to the scene?

    For the people who say "Why don't you learn C#?". I never said I don't use C# :p

    This is not a question about which language is better. There are plenty of reasons to work in javascript, for example, perhaps you are working for a company that creates web utilities, and Unity is only a small part of the pipeline for a broader project. You would need some pretty good justification for why 4% of your project should be in a different language!

    See the following function that many of us are used to in UnityScript:
    Code (JavaScript):
    1. function SomeFunction () {
    2.   /*code*/
    3. }
    While I prefer the above, those who came to unity from a web developer background could be used to this way instead:
    Code (JavaScript):
    1. var SomeFunction = function () {
    2.   /*code*/
    3. };
    Those same people are probably looking forward to the changes coming in ES6 where the above is replaced by:
    Code (JavaScript):
    1. var SomeFunction = param => {
    2.   /*code*/
    3. };
    4.  
    5. //or
    6.  
    7. var SomeFunction = (param1, param2) => {
    8.   /*code*/
    9. };
    or simplified to anonymous functions:
    Code (CSharp):
    1. //parentheses not needed for single parameters
    2. //curly braces and semicolon not needed
    3. x => x + 1
    4. (x,y) => x + y
    What are people's expectations? Will unity be making changes to fit ES6 standards or will we remain old-school with our utilisation of JS in Unity?
     
    Last edited: Aug 10, 2015
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Unityscript is a custom language, only superficially similar to Javascript in a few ways. It won't be getting any changes like that, particularly since it hasn't had any development at all in years (unfortunately).

    --Eric
     
    elmar1028, Kerihobo and Kiwasi like this.
  3. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    UnityScript probably won't be updated. Ever.

    This change to the standard will simply add to the confusion of competent JavaScript developers trying to switch to UnityScript.

    Best to get used to C#. There is a decent chance we will get an update to the latest version within a year or two.
     
  4. Kerihobo

    Kerihobo

    Joined:
    Jun 26, 2013
    Posts:
    65
    Yeah that's all well and good. I updated original post though with better clarification on the topic of JS vs C# regarding this thread.

    As someone who works in the web world with Unity playing a small role in that, I look forward to some potential updates to unityScript. Though, like you, I am doubtful, like Eric5h5 said, it hasn't been updated in years. But it seems strange to me. Javascript in unity, or UnityScript is hardly javascript at all, but for javascripters to come in to unity, they will have a lot of assumptions that simply won't work. I learned UnityScript and C# long before I learned native JS, but I can see why experienced JS developers get really frustrated when coming in to Unity.

    It's fair enough to say they should just get used to C#, I agree. But sometimes you are working on a project that is not entirely built in Unity, and it doesnt make sense to have a small part of a project in a completely different language, for company standards and conventions.
     
  5. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Also, Unityscript already has had stuff like classes, inheritance, getters/setters etc. since forever.

    --Eric
     
    Kerihobo likes this.
  6. Kerihobo

    Kerihobo

    Joined:
    Jun 26, 2013
    Posts:
    65
    That's true, in web design I've only recently come into contact with TypeScript and really feel like UnityScript does it better... I suppose I see your point that UnityScript, despite not really being Javascript, is not necessarily "behind" Javascript.
     
  7. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    UnityScript is a different language to JavaScript. UnityScript has more in common with C# then it does with JavaScript. You've got the 4% in a different language anyway.
     
    Kerihobo likes this.
  8. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    4,044
    The big mistake here was naming the language javascript.
     
    angrypenguin, Kerihobo and Kiwasi like this.
  9. Kerihobo

    Kerihobo

    Joined:
    Jun 26, 2013
    Posts:
    65
    Seems like it xD
     
  10. Kerihobo

    Kerihobo

    Joined:
    Jun 26, 2013
    Posts:
    65
    good point!
     
  11. Xoduz

    Xoduz

    Joined:
    Apr 6, 2013
    Posts:
    135
    I wish Unity would take a clearer stand. Either get rid of UnityScript, or support it and continue to update it. I'd prefer the last, but I understand that I am in the minority.

    Edit: Oops, didn't look at the date. But, still.
     
    Kerihobo likes this.
  12. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    We can't drop it right now because a lot of projects have taken a dependency on it. But yes, UnityScript has no real future.
     
    Ryiah, Kerihobo and Xoduz like this.
  13. ProteanDev

    ProteanDev

    Joined:
    Apr 19, 2013
    Posts:
    1
    "Know your Roots!"

    While we are all aware JavaScript is pretty old, there's still the Open Source people who have yet to taste the Power of Unity. Legacy Code was written on the same pattern for a reason, this Ancient Beast can be tamed.

    No seriously I saw huge potential with ES6 when talking about code standards. Being able to write complex tasks in a few lines of code is a big time saver, especially for the mobile market.
     
  14. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,204
    Except it isn't real JavaScript. It's a bastardization of JavaScript. Regardless of who you are you're basically learning a new language when you pick up UnityScript. If it were real JavaScript there might have been reason to leave it in but UnityScript is a complete waste of time.

    Thankfully they're finally removing it.

    https://blogs.unity3d.com/2017/08/11/unityscripts-long-ride-off-into-the-sunset/
     
    elmar1028, hippocoder and mysticfall like this.
  15. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    What Ryiah said.
     
Thread Status:
Not open for further replies.