This is my dream language. Is it real?

Meghan (she/her) - Mar 21 '18 - - Dev Community

For a while, I've had a vision for my "dream" language. ((Sorry @mortoray , I don't think it's Leaf, still love your content))

The syntax I've come up with is inspired by JavaScript but with some added flair that would make it (best case scenario) compatible with ASM and WASM compilation.
I've left some sample code below, and I was wondering if anyone knew if a language similar to the snippet below exists.

import { sqrt, pow } from "math"

export class Point {
    struct {
        Int x,
        Int y
    }
    constructor(Int a, Int b) {
        this.x = a;
        this.y = b;
    }
    constructor(Int a) {
        this(a, a);
    }
    constructor() {
        this(0, 0);
    }
    distanceTo(Point pt) -> Float {
        return sqrt(pow(pt.x - this.x, 2) + pow(pt.y - this.y, 2));
    }
}

export class Circle {
    struct {
        Point center,
        Int radius
    }
    constructor(Point c, Int r) {
        this.center = c;
        this.radius = r;
    }
    constructor(Int r) {
        this(new Point(0, 0), r);
    }
    constructor() {
        this(1);
    }
    intersects(Point pt) -> Boolean {
        return pt.distanceTo(this.center) <= this.radius;
    }
}
Enter fullscreen mode Exit fullscreen mode

Thanks in advance for any help!


In hindsight this looks a lot like a real Java-Script like syntax but I was still curious if anyone knew if this existed before I went out and tried to start making a compiler for a project that's already been worked on :)

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .