Bridges
The Language Bridges are for programmers who know another language and want to write JaiScript. The Code Migrations are for C++ code that uses a library JaiScript replaces.
Language Bridges
Each bridge sets a language beside JaiScript idiom by idiom, then lists where a habit from it gets a different answer, with a sample of what JaiScript does. To run a sample, save it as try.jai and run jaiscript try.jai (Hello & Basics has the setup). Every bridge points first to Value Semantics & References, where the Language Guide takes over.
- From JavaScript
var,function, template strings and?.carry over, withlet, arrow functions,??,do...whileand the array helpers (map,reduce,find, ...). Assignment copies arrays and objects,==compares contents and never converts,7 / 2is3, lambdas name what they capture. - From C++
Value classes, references, destructors, operators and capture lists mean what they mean in C++. No pointers or templates, a narrow
const; a defined evaluation order, checked overflow, no slicing, and aswitchthat never falls through. - From C#
Classes,
override, statics andyieldlook familiar, but a class is a value type:newmakes the shared reference.varisdynamicandautois C#'svar; properties are accessor methods, and coroutines replaceasync.
Code Migrations
Each migration maps a C++ library's types and calls to their JaiScript spelling, converts an example, and lists what has no counterpart and where a straight translation gives another result.
- From Cereal
Archives, names, save/load splits, versions, polymorphic registration and pointer identity; the
JAI_PROPERTYroute that deletes the serialize functions; both libraries in one function during the transition; converting existing files once. Boost.Serialization spellings included. - From Boost.Signals2
signal,connection,scoped_connection,track, blocks and combiners mapped tojai::signal, and what behaves differently: the private emitter, a handle that is the connection, the per-signal lock. Notes for Qt and sigslot code. - From ChaiScript Bindings
fun,user_type,constructor,base_class, modules, globals,evalandeval_errormapped to the engine anddynamic_binder; then the script habits that change: arguments copy, interpolation uses backticks, integers are 64-bit and checked. - From sol2 (Lua) Bindings
new_usertype,constructors,property,overload,bases, meta functions, tables and protected calls; then the Lua habits that change: tables become values, indexes start at 0,/truncates between integers,0is false. - From Squirrel Bindings
The stack-based C API (
sq_newclosure,sq_newclasswith type tags,sq_call,sq_getlasterror); then the Squirrel habits that change: instances, arrays and tables copy, the empty string is false, generators become coroutines. - From pybind11 and Boost.Python
class_,init,def_readwrite,def_property,overload_cast, holders,error_already_setand calls into Python, and what has no counterpart: keyword arguments, trampolines, the GIL. - From nlohmann::json
NLOHMANN_DEFINE_TYPE_*,dumpandget<T>mapped to the archives and the record format they write; plain JSON documents through the script'sfrom_jsonandto_json. - From Qt Properties, RTTR and refl-cpp
Q_PROPERTY, RTTR registration andREFL_AUTOmapped toJAI_PROPERTY: declaring, walking, reading and writing by name,NOTIFYas an observable property, and what has no counterpart: metadata, compile-time iteration, dynamic properties. - From Lua Coroutines and C++20 Schedulers
coroutine.create,yield,resumeandstatus, and C++20 promise types and schedulers, mapped tocoroutinefunctions withnext(),next(n)anddone(); hosting handles from C++, budgets and hot reload.