svalente@mit.edu
Sanka is a general purpose programming language. It is compiled, strongly typed, and imperative. Its philosophy is defined as much by what it rejects then by what it provides. The tenets are:
I like this language.
I wrote this language because: After using C++ and Java, I wanted a language that was as easy to use as Java, and as close to the hardware as C++. I wanted the best of both worlds. And I thought that designing and implementing my own language would be fun. And I was right about that.
Sanka is in the same class of languages as Go, Rust, C++, and [insert your favorite compiled language here]. All of those languages are fine. I doubt that I could convince you that Sanka is the best of the bunch. But personally, I like this language a lot. The syntax and the details and the philosophy all work for me. If you like it too, that's great. If not, that's fine too.
Sanka's syntax is based strongly on Java's syntax. For example, here is a Sanka program which looks like a Java program:
class Hello {
static void main(String[] argv) {
System.println("Hello, world!");
}
}
Sanka has the following things in common with Java:
if
, for
, while
,
break
, continue
, case
.var
keyword defines local variables, as introduced in Java 10.Here are the Java constructs that Sanka does not provide:
Foo
, but there is no Foo.class
object accessable at runtime.static {}
blocks.foo
field, explicitly write this.foo
.That's what Sanka takes away. Here's what it adds:
Fast
Sanka is basically just a set of simple translations on top of C. And C, of course, is basically just a set of simple translations on top of machine code. There's no hidden complexity anywhere. Sanka code knows at compile-time exactly where to find all fields, exactly how to call all methods, etc. So it should be possible to write blazingly fast, optimized Sanka programs.
Dynamic Arrays and Maps
In Sanka, you can change the size of an array after you create it. So
you can use an array where Java would force you to use a List
class.
For example:
arr = {17, 34};
arr.add(51);
Arrays have two advantages over List
classes. (1) The array syntax
is nicer. (2) You can create an array of a primitive type like int
without promoting it to a class like Integer
.
Also, Sanka supports sorted maps as a built-in type. The maps use an array-like syntax. For example:
map = new map[int]String;
map[2018] = "Hello, world!";
For more information on all Sanka types, including arrays and maps, see docs/Builtin-Types.md.
Implicit Interfaces
When you declare a class, you do not need to explicitly specify what interfaces it implements. The compiler determines whether a class implements an interface.
Other Features
Sanka supports several other syntax constructs that Java does not. They are documented in docs/Other-Features.md.
Since Sanka is intended for server-side development, the first Sanka project is an infrastructure for creating micro web services: Restful Sanka