Statically typed, high-performance, systems programming language. Panther is an alternative to programming languages like C++, Rust, and Zig.
Here are some examples to give a taste of the Panther programming language.
1 2 3 4 5 6 7 8 9 10 11 12func divide = (lhs: Int, rhs: Int) -> Int <Void> { if(rhs == 0){ error; } return lhs / rhs; } func entry = () #entry -> UI8 { const division_result: Int = try divide(12, 0) else 0; return division_result as UI8; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76interface Shape = #polymorphic { func area = (this) -> F32; func num_sides = () -> UInt { return 0; } // method with default } type Quad = struct { var width: F32; var height: F32; func area = (this) -> F32 { return this.width * this.height; } func num_sides = () -> UInt { return 4; } // implementation of Shape for Quad impl Shape{ area = area, // defining with an existing method num_sides = () -> UInt { return 4; }, // defining with an inline method } } type Circle = struct { var radius: F32; func get_area = (this) -> F32 { return 3.14 * this.radius * this.radius; } func get_num_sides = () -> UInt { return 0; } // Implementation of Shape for Circle impl Shape{ area = get_area, // method names don't have to be the same // using default for Shape.num_sides } } // this function becomes a template on the shape passed to it func get_shape_num_sides = (shape: Shape) -> UInt { return shape.num_sides(); } // runtime polymorphism (allowed becuase the interface has attribute `#polymorphic`) // `shape` is a struct of a pointer to the shape object and a pointer to a vtable func get_shape_area = (shape: Shape^) -> F32 { return shape.area(); } func entry = () #entry -> UI8 { const quad = new Quad{ width = 1.0, height = 2.0, }; const circle = new Circle{ radius = 2.0, }; const num_sides_of_quad: UInt = get_shape_num_sides(quad); const area_of_circle: F32 = get_shape_area(circle as Shape^); return 0; }
Interested in learning more? Check out the Panther tutorial.