Javascript Version?

  • So, time to start making things in HISE. First question what version of Javascript are we using ECMA 6? 5?

    Sorry if this is answered elsewhere, I couldn't find it in the documentation, in the forum or over on the JUCE site.

  • From what I've gathered through my use of JavaScript in HISE it doesn't seem to be a standard web type implementation but more a pick n mix of the most suitable bits with a lot of additional stuff specifically for HISE - I'm probably not 100% correct about this though.

  • Hmm, I sorta guessed this, but I was hoping for (at least some of) ECMA 6, so I can at least have "real" classes.

  • I experimented with a few different ways of doing classes with HISE, there are some posts (probably in the scripting forum) about this. Basically I started with the usual self invoking functions and this worked for simple situations but had problems when used in more complex contexts, it also had problems with private variables, this may work now though. The solution I use now was suggested by Christoph and to me it makes a lot of sense and works really well with HISE's namespace system.

    So to create a class I would do this

    namespace myClass
        reg _privateVariable; //Use underscore for variables that should be private
        reg publicVariable;
        inline function createInstanceOfClass(id, someParameter)
            local obj = {};
   = id;
            obj.someParameter = someParameter;
            return obj;
        inline function changeParameter(obj, parameter, value) //Pass in the instance of the object
            obj[parameter] = value;

    This setup is very efficient because each object doesn't need to contain all of the class functions it is just a standalone object that can make use of the functions within the namespace. It provides all the flexibility of true classes without the overhead.

  • Actually I am thinking about renaming the script language to something like HiseScript, since there are many language differences to traditional Javascript (reg, namespace, include, inline function, local just to name the most important ones). On the other hand it's a valid superset of Javascript (so almost every Javascript construct should work in the HISE implementation so it's not "Yet Another Script Language".

    About the classes thing, most encapsulation needs can be satisfied with the namespace concept that David sketched above, however if you are looking for any kind of inheritance or even polymorphism you're out of luck (to be honest, I don't know ECMA 6 well enough to know what's going on there).

    Could you describe what kind of thing you want to achieve using classes? I am positive there's a solution in the current HISE implementation.

Log in to reply