0 Favourites

[Feature Request] First class functions

  • Overall I am a little bit disappointed how Construct 3 is THE SAME as Construct 2, concerning "langugage" features (not development utilities, where it gets much better). Not to belittle the huge amount of work done to rewrite the whole editor to browser, that is HUGE and I am amazed how little bugs are in the beta. (I imported a project with aroung 1000 events and no problem, runs very nice).

    But I suggest also adding a new feature to the "language" - better support for functions.

    Problem statement / motivation

    Readability of code: Function created with Function plugin are second class. They do not provide comparable aids during development as "first class" system functions, such as lerp, choose, etc. - no parameter and type hinting, they must be called specially by Function.Call (xxx) expressions. Moreover they can be placed anywhere in any event sheet (even not included ones), they are hard to find in large projects.

    Performance: Function calling carries currently relatively huge overhead. I am able to do approx. 70.000 actions per frame (with 60 fps) on my hardware, but only approx. 6.000 function calls. The overhead of a function call is BIG - 10x simple action, such as manipulating a variable.

    Edit2: I just performed similar measurement in App Game Kit (AGK) engine, and just for comparison (and how much we pay for visual development / javascript backend in Construct) - results are 7.200.000 simple actions per frame (manipulating instance variables), 3.150.000 function calls per frame when keeping 60 fps.

    Suggested behaviour: Lets have them as a members of Object Type and Family. The same way these objects can have instance variables, let them also have functions. When adding a function, one must specify the names and types of parameters, possibly also function and parameter descriptions, that can be shown in editor and expressions. The parameter types also allow for typechecking of calls in editor.

    Such functions can be directly called by Object type.Function name (Param 0, Param 1, ...) notation in expression. New action on Object type / Family - Call function - allowing call only their specific functions (hiding the need to "pick by unique ID" of that specific object type or family).

    That would most likely involve:

    Creating new set of properties for Object types and Families - Functions

    Creating new dialog to create new function - name, parameters, types, descriptions (and some complications such as variadic parameters)

    New way to edit functions - outside event sheets - new event sheet per Object type / family, or some way to do in Event sheets without making mess (that includes some more complications, such as Copying / Pasting functions ...)

    New actions to call such functions

    Optionally - better internal support of calling functions without imposing existing overhead

    Edit1: Actually it would be best, if these functions could appear as Actions of that particular Object Type / Family in the list of Actions in Add Action dialog ... (in addition to being called in expressions). Maybe the name "Custom Actions" could be better to disambiguate Function plugin functions and these Object Type / Family functions.

  • +1 I pretty much always use functions in any project of meaningful complexity and having the editor help with that would be a great feature.

  • Great suggestion. I'd love to hear Scirra's opinion on this.

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • I'd love to see more function support. It is pretty crucial for reusability, scalability, modifiability, etc.

  • You should do an example capx showing the overhead.

  • Fair enough newt, try for yourself (in C3).


    Edit1: Modified to wait for 5 seconds before measurement starts. If it is not enough, feel free to modify REQUIRED_FRAMES_BELOW_LIMIT to higher value. Or the initial delay for that matter.

  • Needs a better trigger than fps from the start of layout.

    The engine, sputters a bit.

    System wait 5 seconds, enable group

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)