Plato is a high-performance cross-platform programming language inspired by JavaScript and C#.
Plato is a statically typed functional language that looks and behaves like an object-oriented scripting language, but with a lot less complexity.
The most notable features of Plato are that all types are immutable, and there are no implicit this
parameters.
There is no distinction between methods and functions, no visibility modifiers (e.g., public, private, protected, internal),
and no virtual or abstract methods.
Plato is being used to develop cross-platform libraries that form the basis for software we are developing at Ara 3D. We do a lot of computational geometry work in different languages and recreating and maintaining high-performance code for multiple platforms and languages was too costly and burdensome for a small company.
No existing language provides the appropriate mix of simplicity, abstraction, and performance.
Plato is being designed to allow multiple implementations. We are actively developing and using a Plato to C# compiler.
The Plato to C# compiler is all open-source, and was built in tandem with the Parakeet parsing library.
Using Plato instead of C# has the following advantages:
- Code can be reused in other contexts (e.g., JavaScript)
- Significantly reduces the amount of boilerplate code a user has to write
- Code is easier to read and maintain
- WIP: Code will be faster
Currently the Plato compiler produces code which is comparable to well-written code in C# in terms of performance.
In the future we will be leveraging the fact that Plato code:
- Is immutable
- Does not support reflection
This enables a set of interesting and powerful optimizations that can be performed on the AST before code generation occurs.
The top-level abstractions in Plato are:
- Libraries - collections of functions
- Types - data structures
- Concepts - abstract data types
A Plato library contains only functions. It is similar to a static class with extension methods in C#. Library functions can be called using a dot syntax using the first parameter on the left of a dot. Furthermore, any function with no arguments, can be invoked as if it was a parameter. Function parameters can be a mix of either types or concepts.
For example:
library MyLibrary
{
Square(x: Number): Number
=> x * x;
SumSquares(v: Vector): Number
{
var r = v[0].Square;
for (var i=1; i < v.Count; ++i)
r += v[i].Square;
return r;
}
Magnitude(v: Vector): Number
=> v.SumSquares.Sqrt;
}
A type is a concrete data structure. It is similar to a record, struct, or class in other languages. It contain fields, and decares the concepts that it implements. Unlike traditional object-oriented languages, it does not have member functions (aka methods).
type Vector2D
implements Vector
{
X: Number;
Y: Number;
}
A concept is an abstract data type.
It declares a list of functions that can be called on any type implementing the concept.
In the context of the concept, the implementing type is called Self
.
Concepts are similar to an interface, mixin, or trait in other languages. Concepts can inherit from other concepts.
concept Array<T>
{
Count(xs: Self): Integer;
At(xs: Self, n: Integer): T;
}
concept Vector
inherits Array<Number>, Numerical, Magnitudinal, Equatable, Coordinate
{
}
The Plato standard library is the best place to start for Plato examples:
Plato tools and libraries are not intended for general usage yet. This repository currently compiles only when used as a submodule from within the Ara3D main repository.
While the language design is still undergoing a few minor tweaks, it is starting to reach a stable equilibrium.
Some ideas for highly motivated and patient people who are interested in contributing to the Plato project:
- Optimizers - in particular Plato to Plato rewriting tools
- Type checking and inference tools
- Transpilers to other languages (e.g., JavaScript, GO, Rust, Dart, Java, C++, GLSL, etc.)
- Support for Plato syntax in popular coding tools (e.g., VS Code, Visual Studio, Avalon Edit, Scintilla, etc.)
I am always interested in feedback in any form. You can find me on twitter as @cdiggins or mail me at [email protected].