DEV Community

Discussion on: Gaming JavaScript

homerdalords profile image

A lot of people like to call UnityScript by the name "JavaScript." I believe this is wrong on several levels.

While "JavaScript" could refer to any one of the ECMAScript specs, Unity's ".js" language doesn't even come close to conforming to that specification — nor does it try to. UnityScript is a proprietary language, and it doesn't follow any concrete specification; it is modified at the will of the Unity developers.
The vast majority of JavaScript libraries you find will not work just by copying them into Unity. Unity's "JavaScript" is most similar to Microsoft's JScript.NET, although it is not quite identical.

  • JS is class-free, UnityScript have them, and that once defined are fixed for the duration of the runtime.
  • File name matters in UnityScript, where most files represent a single class.
  • UnityScript supports .NET OOP features like classes,"protection levels" (public, private, protected) and "static" keyword options. Since it also supports explicit typing, it also has support for "generics" (runtime type enforcement), which JavaScript has no notion of.
  • And unlike the popularity of Javascript, UnityScript should be buried deep and nobody should be allowed to use it, at all.