elang Future Proposals

Purpose

Deciding on the future of elang - establishing a vision and bringing it into a world all its own. elang is a systems language, and gets its power from C, so the primary goal should be focusing on C interop. This means everything from a C Foreign Function Interface to the build chain, so the compiler needs to be reworked from the ground up to focus on a new compilation toolchain. Next is adding improved language constructs that create a focus on memory safety and rapid development; in order to improve programmer experience writing C software, elang can make working with memory easier and allow for less boilerplate. It is for these reasons that the language grammar should be reworked with these principles in mind.


New Build Tool - eMake

eMake is a proposed replacement for elangc - as a 2in1 Make extension and transpiler for elang, eMake will allow for easily interfacing elang output with a pre-existing C build tool. Because of this, it will make writing hybrid elang/C projects that much easier, and can be an extension of the overall compiler. Using similar syntax to Make, eMake will do a compilation pass first through elang files, then compile existing C files, and will then compile them together into a single binary.


Reworked Syntax

elang has the potential to be a powerful systems language alongside C. However, a current drawback is the similarities to C, and the restrictions to the current grammar as a result. This is why it is proposed to "go back to the drawing board", and to reformat the core syntax in such a way that empowers developers to write their code hassle free - or, at least, much easier. Below is an example of what is proposed for elang's legitimate alpha, which is still missing constructs for threading and async tasks.

// Using the C stdlib
use <stdio>
// Importing elang code
use "filename.e"
// Using external C libs
extern "libname.h"

// Declaring structs
struct Person {
  int age;
  string name;
}

// Declaring Objects (structs with bound methods)
// -> Would expand to structs with methods that accept structs under the hood
// Still unsure if necessary
object Dog {
  int age;
  string name;
  Person owner;

  // Possible way to define constructor?
  #init(int i, string s, Person o) {
    self.age = age;
    self.name = s;
    self.owner = o;
  }

  // Would be expanded to: int getYearBorn(Dog self, int currentYear)
  int getYearBorn(int currentYear) {
      return (currentYear - self.age);
  }

}

int main() {
  // declaring arrays
  Person[] people = new Person[3];
  // Array access + defining structs
  people[0] = {age: 10, name: "Billy"};
  people[1] = {age: 12, name: "Bobby"};
  people[2] = {age: 11, name: "Barry"};

  // For loops are for iteration
  for(p in people) {
    puts(p.name);
  }

  // Loop construct as replacement for 'while'
  loop {
    // Initializing Objects
    Dog d = new Dog(4, "Woofers", people[2]);
    printf("%s says woof!\n", d.name);

    break;
  }

  return 0;
}