Next Scripting Framework - The next generation OOP

Next Scripting Framework - The next generation OOP

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.

A tutorial that scratches the surface of the powerful NX/NSF will help you in getting started.

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.

Read more about the dynamic nature of NSF and NX at it's homepage.

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 abc
obj 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.

Container
Simple Traits
Composite Traits
Attributes

Abstract Type
Add variable
Classes
Constraint Genericity
Delegates
Multiple Distinct Objects
Polymorphic Copy
Polymorphism
Object Serialization
Single Inheritance
Singleton
Tokenizer
Tree

Conclusion

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

You might enjoy these similar articles:

Be the first to comment!

Add a new comment

All comments are moderated and must adhere to the terms of service.

Subscribe to my awesome newsletter!








What to expect: Ultimate Knowledge regarding Business Efficiency, Personalized Marketing Experience, Software Development and Cyber Security tips and tricks. 1-3 mails per month. Unsubscribe any time. See the privacy policy to learn how we take care of your information.