Jump to content
Sign in to follow this  
noubernou

Carma: A Object Oriented Language Extension for SQF

Recommended Posts

Carma is a object oriented programming extension to SQF, the scripting language of Arma. It uses a translator/compiler to parse additional syntax in SQF files and generate the requisite real SQF to implement objects.

An example is shown below.

// The carmaClassDef operator defines a class.
ClassA carmaClassDef {
   // The public code space defines all assignments inside
   // as being public members, accessible by anyone.
   public {
       _varA = "A";
   };
};

// The carmaClassDefExtends operator extends an
// existing class.
ClassB carmaClassDefExtends ClassA with {
   public {
       _varB = "B";
   };
};

// The carmaClass operator creates a new instance
// of a an object. Objects are stored as arrays, so
// they are always passed by reference and they go
// in and out of scope like any other SQF variable.
_objectB = carmaClass ClassB();

// The final operator is the "." (dot) operator, which 
// is used to access member variables.
hintSilent format["A: %1\nB: %2", _objectB._varA, _objectB._varB];

Carma supports public and protected members and methods, static members and methods, constructors, destructors (though they are as of 1.0 not currently called automatically), method chaining, inheritance, and C style array access for array members.

For more information please see the wiki page on DH: http://dev.withsix.com/projects/carma/wiki/

This is a side project from my normal ones (ACRE, ACE, etc) and is meant to mostly be experimental and designed to further SQF coding practices, techniques, and technology as well as serve as a useful distraction. I am looking for people that wish to develop and maintain the project further. If anyone is interested in applying please let me know.

You can find download links to the current version here: http://dev.withsix.com/projects/carma/files

If there are any immediate issues you can see please post tickets to the tracker here: http://dev.withsix.com/projects/carma/issues

Questions will be fielded in this thread.

Enjoy!

Edited by NouberNou

Share this post


Link to post
Share on other sites

Very impressive work, SQF is starting to become quite a mature language.

How does using this, instead of native SQF equivalents, affect performance? With the possible overhead in mind, what sort of scenarios would object-oriented SQF be best used in?

Edited by Goodson

Share this post


Link to post
Share on other sites

I've tried to minimize performance overhead as much as possible, but to maintain the same style as SQF, such as it being dynamically and loosely typed, there had to be some sacrifices. For example, all method/members require a look up. Static members/methods require a depth look up (searching the parent class definitions). Maintaining the _self variable requires call wrappers.

The nice thing though is there is tons of room for optimization still. Static analysis can lead to implementing hard coded method functions, direct set/getting of members, etc. There is room for dynamic optimization as well. Since all of this can be implemented in the library and compiler it means code can stay the same source wise and benefit from improved performance as releases are made.

At current the best scenarios are for things where near real time performance is not needed, things that can be done over many frames or (god forbid) in the scheduler. Administrative things, data systems, etc.

Share this post


Link to post
Share on other sites

This is very amazing work! Please keep it up. I am wondering about something though. Could this be used for multiplayer scripting? I'm new to the multiplayer side and it seems to me that every client would have to download and have carma loaded as an add-on first.

Share this post


Link to post
Share on other sites

I plan to make a static compiler in the future, also thinking about possibly suggesting integration with CBA (but we'll see).

Share this post


Link to post
Share on other sites

I just came across this again - is this still an active project? I looked up Naught's object-oriented stuff as well and that seems fairly dead/inactive, too.

Has anybody else continued working on creating a higher-level language on top of SQF?

Share this post


Link to post
Share on other sites

It is pretty dead at the moment. I might fork it over to github and let anyone take a crack at it. The code is really rough though and could use a good rewrite. The lexer/parser is ... not great.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×