Introducing Jancy

What?! Yet another programming language? Like, there isn't enough of them already?

Well, yes and no. New languages keep emerging, because there are and always will be domains uncovered by existing tools — and Jancy covers a few of important ones.

The main motivation in our case was IO Ninja. We were looking for a scripting language with C-like structures and safe pointer arithmetic — something like a safe dialect of C suitable for employment as a scripting engine in a C/C++ application. Surprisingly enough, we couldn't find such a thing! So we created it.


Main design goals

Open-source

Jancy is an open-source project hosted on GitHub under the MIT license — one of the most permissive licenses in existence. Visit Jancy GitHub page for more details.

Killer Features

Source and ABI-compatibility with C

Jancy scripts are JIT-compiled and can be called directly from the host C/C++ application. Jancy supports all of the major calling conventions and is compatible with C/C++ compilers with respect to struct/union layouts with arbitrary packing factors.

Safe Pointers

Jancy provides all the colors and flavors of pointers such as safe pointers and safe pointer arithmetic, unsafe thin pointers for interoperability with existing C/C++ libraries, weak pointers which do not retain objects, function pointers with partial application, scheduled function pointers and even property pointers!

Reactive Programming

Ever used Microsoft Excel before? Then you know the concept of writing a "formula" which will be automatically re-evaluated when the referenced cells change. With Jancy you can do the same in your code — and with full control of where and when to use this reactive paradigm. This is perfect for UI programming!

Regex Switches

Jancy provides a convenient way of tokenizing input streams — that is, splitting a stream of characters into a token sequence. Specify regular expressions to define recognized lexemes and then simply write actions to execute when these lexemes are matched in the input stream!

Dynamic Structs

If you ever wrote a parser for a binary protocol, then you know how often the length of a field is dynamically calculated from the values of others. Jancy allows declaring structs with non-const sized array fields. Use these dynamic structs for packet parsing/generating — the same way you do with regular C-structs!

Dual Error Handling

Both error code checks and exceptions have their preferred domains of applications. Jancy allows you to create APIs which support both! Define a function once, and then choose whether it's more convenient to error-check or use exception semantics at each particular call-site!

Other Notable Features

Properties

Jancy features the most comprehensive implementation of properties. Along with the natural syntax for simple properties there is support for properties with overloaded setters, indexed properties, bindable properties, auto-get properties, and property pointers.

Multicasts & Events

Jancy supports multicasts and events which allow accumulating function pointers and then calling them all at once. Weak multicasts and events which do not require explicit unsubscribing are also supported, thus providing an out-of-the-box solution for the publisher-subscriber pattern.

Schedulers

This function pointer-related feature simplifies the development of asynchronous multi-threaded applications. Jancy provides a natural syntax for creating callback function pointers, which are guaranteed to be executed in the proper context (e.g. in a worker thread, with a lock held, as a Windows message handler, etc.)

Deterministic Resource Release

Jancy provides a very intuitive approach for ensuring the deterministic resource release in an inherently non-deterministic GC-world. Local variables declared with disposable storage specifier will have their dispose () method called upon exiting the scope — no matter which exit route was taken!

Classes With Multiple Inheritance

Besides standard class features such as constructors, destructors, virtual methods, and namespace member access control, Jancy also supports multiple inheritance, in- and out-of-class method implementation, operator overloading, in-place field initialization and preconstructors.

Const-correctness

Const-correctness is a yin to the yang of data pointers. It is a great feature, which not only detects a whole range of logical errors at compilation time but also helps to design better and more foolproof libraries and APIs. Const-correctness is left behind in way too many languages. Jancy restores justice by bringing it back.

Dual Modifiers

Jancy features special "dual" modifiers, the meaning of which depends on the call-site. They allow natural declarations for such common design patterns as read-only fields and events. No more writing dummy public getters for private fields!

Special Literals

Beside traditional C character literals, Jancy features new kinds thereof. There are binary literals for a convenient HEX-view definition of in-program binary blobs. There are formatting literals (as in perl-style formatting). There are raw literals which do not process escape-sequences. And there are multi-line literals! All kinds of literals can be concatenated in any combinations.

Bitflag Enums

Bitflag enums are just like enums... but for flag constants. Bitflag enums are missing in most modern languages and usually require some not-so-trivial workarounds. Jancy provides a solution for flag enums out-of-the-box.

Extension Namespaces

Jancy allows you to extend functionality of existing classes without subclassing. Create an extension namespace for a class, implement necessary methods/properties (in which you can access all the protected members of the class), and then "turn it on" with the using directive — now you can access the new methods just as if they were part of the original class!