tomprimozic / caya

a tiny useful simple language experiment

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Caya - a programming language experiment

Goals

  • a useful yet simple language
  • not aiming for performance per se, but choosing constructs and patterns that can be optimised
  • interactive, optionally statically typed, functional & imperative, simple & predictable syntax & semantics

current priorities

  1. implement enough features to stop using host language for library implementation
  2. bytecode interpreter (and overall refactor, e.g. a single immutable HashMap.empty object)
  3. performance improvements

Implementation

We use Java / JVM as the host platform.

Java has improved a lot in recent years - records, pattern matching, var type inference - so it's not terrible to use any more. In addition, bison (parser generator) can generate Java parsers.

JVM is one of the few runtimes with a sensible memory model (no undefined behaviour - the other being OCaml) and has great support for concurrency (threading) and memory management (garbage collection). It generates decently fast code and enables interesting optimisation strategies in the future (directly generating JVM bytecode, Truffle/Graal optimised interpreters). Finally, it makes available a plethora of third-party libraries.

Progress

  • keyword arguments, default arguments
  • exceptions
  • hashing, dict
  • iterators
  • modules
  • first-class types, typeof, instanceof (:?), cast (:)
  • inheritance (single)
  • equality, comparisons
  • has_attr, list_attrs, runtime services like call_function, invoke_method, typeof, int_to_str, plus_int32, get_field, set_item, eq, cmp, ...
  • classes
  • block if
  • while loop, for loop
  • break, continue
  • library: str, atom, dict, list, index, vector, set, json, requests, csv, plotting, regex, math, random, datetime, os functions, hashing, logging, print, urllib, serialization (pickling), HTML, xls, postgresql, sqlite, tqdm
  • block functions
  • whitespace syntax
  • loading modules
  • operators
  • rational numbers
  • float
  • logic operators
  • tuples, records
  • recursive functions
  • Java interop
  • underscore _ (implicit functions: _.x, _ * 2)
  • static modules
  • comparison operators
  • immutable data structures (vector, index)
  • mutable data structures (list, dict)
  • array (multi-dimensional, numeric, fixed size, mutable)
  • immutable & mutable literals
  • add tests for error messages
  • function overloading
  • custom operators
  • let and var declarations
  • destructuring assignment
  • pattern matching
  • "parent scope" declarations (function-level or toplevel)
  • spread arguments
  • list comprehensions
  • atoms
  • macros, attributes
  • bytecode, bytecode interpreter
  • tail calls
  • threads
  • type checking, type optimisations

About

a tiny useful simple language experiment


Languages

Language:Java 87.2%Language:Yacc 6.8%Language:Lex 5.7%Language:Cycript 0.2%