Next Scripting Framework - The next generation OOP

/images/blog/old_uploads/next-scripting-framework-825x510.jpg
next scripting framework 825x510

NSF is a highly flexible Tcl based, object oriented scripting language which can be used to build other OOP languages like NX.
NX is the next generation object oriented programming system.
It;s one of the things that kept me going and developing software in Tcl an obscure yet powerful language.
It’s also per default supported with the NaviServer webserver and the OpenACS platform.
I’ve used TclOO for my Codru - LostMVC web framework and then switched and rewrote everything in NSF / NX.

It has some unique things which change the way you write OOP programs. It was built on the strengths of XOTcl.

We have nx::Class and nx::Object
Both are interconnected and form the power of the system.

NX’s power is drawn from the fact that you can create objects directly without having any class. It’s kind of what javascript does with objects but at an extraordinary level.
Those objects can then inherit certain functions via mixin
This is a simple and clean way to generate singletons for example.
We can create new objects dynamically and on the fly.
This means that we can dynamically change the structure of an object and a class while the code is running.
Hot code patching as we may call it.
The power of the system is that we can then pass an object around in a variable (passed by reference).
This way I was able to create some funky stuff.

One of the biggest powers of NX/NSF is it’s introspection functions which allows you to analyze filters, methos, mixins, slots, variables.. and precedence of functions.

Dynamic Code

NX/NSF support dynamic state changes. Dynamic behavior changes.
Dynamic changes of the class structure and dynamic software composition.
We can also dynamically inject code.

Parameters

NX presents us with again something unique. We can implement positional and non positional parameters.
This means we can pass paramters to a function without having to remember the exact position in the function.
Increasing productivity and decreasing bugs.

obj function -x 3 -y 134 abcobj function -y 3 -z "Oh yeah" -y 134 abc

 

We can easily make the non positional paramters optional.

Here are some examples of the beauty of NX.

Unknown Method Call
Whenever a command doesn’t exist you don’t want to give an error. You’d rather try to figure out what the user wants to do!
Or maybe log this somewhere? The possibilities are endless! Thank you Tcl for the unknown construct idea.

Conclusion

Having used NX and NSF in multiple projects for almost 2 years I can certainly say that it helped me write better software.

Subscribe to my Newsletter

Receive emails about Linux, Programming, Automation, Life tips & Tricks and information about projects I'm working on