57 lines
1.4 KiB
Markdown
57 lines
1.4 KiB
Markdown
# Embedded Language Ideas
|
|
|
|
I would like a scripting language to be able to easily embed in a host application with the following features:
|
|
|
|
* Sandboxed for secure execution of untrusted code
|
|
|
|
For example, the language should not automatically make available functionality that allows scripts to arbitrarily read or write files in the host filesystem, or spawn processes, or establish network connections.
|
|
|
|
* Dynamically typed
|
|
|
|
* Multi-paradigm
|
|
|
|
The language should support imperative, object-oriented, and some functional aspects.
|
|
|
|
* Supports nil, Boolean, Integer, Float, String, Array, Hash, and Class types
|
|
|
|
* Supports closures
|
|
|
|
# Features of Other Languages to Use or Avoid
|
|
|
|
* Lua
|
|
* Good:
|
|
* Great C API documentation
|
|
* Not so good:
|
|
* 1-based array indexing
|
|
* The '#' operator not handling `nil` values within an array
|
|
|
|
* Javascript
|
|
* Not so good:
|
|
* Having both a `null` and `undefined` value is overcomplicated.
|
|
* Classes/types are not types, so `typeof` returns a string.
|
|
|
|
* Ruby
|
|
* Good:
|
|
* One `nil` value
|
|
* Clear definition of which objects are "falsey"
|
|
* Functional blocks
|
|
|
|
# Syntax Ideas
|
|
|
|
## Declare a variable
|
|
|
|
var foo := 42;
|
|
|
|
## Declare a function
|
|
|
|
function foo(a, b)
|
|
{
|
|
a + b;
|
|
}
|
|
|
|
Similar to Ruby, the result of the last expression is returned from a function, so an explicit `return` is not needed.
|
|
|
|
## Anonymous Function
|
|
|
|
var f = function(x) { x * x; }
|