The main parts of Suneido are:
- base components – memory manager, data types
Suneido can be run either standalone or client-server. The same executable (suneido.exe) can act as a server, a client, or in standalone mode. Although individual executables for each of these functions could be slightly smaller, it is easier to maintain and deploy a single version. Currently the combined executable is about 1 mb in size.
- custom versions of malloc and operator new
- null versions of free and operator delete (not needed with garbage collection)
- garbage collected (both at the application level and at the C++ level)
custom gcstring class that takes advantage of having garbage collection
strings are immutable
strings have a separate length rather than being nul terminated, so they can contain arbitrary binary data
- STL-like HashMap template class
Single Linked List
- Lisp-like single linked list template class
Suneido compiles to byte-code that is then interpreted, similar to Smalltalk or Java.
Uses a hand written lexical scanner and recursive descent parser / code generator. For speed, parsing and code generation are done in a single pass, with no intermediate representation. Although tools like Lex and Yacc (or Flex and Bison) could have been used to write the scanner and parser, Suneido’s language is simple enough that it was almost as easy to write them by hand. This has the advantage of eliminating a dependency on other tools. Currently, source code is stored in the database and is automatically compiled when needed. interpreterBasically a big switch with cases to execute each type of byte code.primitivesSuneido provides a number of built-in classes and functions that are implemented in C++ code.platform interfaceThis is a facility for calling DLL’s, including the Windows API.
Suneido incorporates a client-server relational database, accessed via a relational algebra query language (not SQL).
The lexical scanner is derived from the language one. The hand written recursive descent parser produces a syntax tree. This syntax tree is transformed and execution strategies are chosen using a cost-based query optimizer. The syntax tree is then used to directly execute the query.
concurrency & recovery
All database activity is done within atomic transactions, which either complete, or rollback. In the event of a crash, the database is automatically recovered to the last consistent state (any partial transactions are rolled back). Suneido uses an optimistic time-stamp based concurrency scheme.
A standalone or server instance of Suneido deals with a single database file (suneido.db). All schema information, table data, and indexes are stored in the database which is accessed as a memory mapped file. The database file also acts as a log for concurrency and recovery purposes.
NOTE: This document primarily applies to cSuneido. The newer jSuneido Java implementation has some differences.