DEV Community

Cover image for GearLang - A Systems Programming Language For Flexibility, Control, and Interoperability
kwphil
kwphil

Posted on

GearLang - A Systems Programming Language For Flexibility, Control, and Interoperability

Systems programming can be difficult and verbose. Just take a single function from my current project:

virtual auto iterate_parsers(
    std::span<std::shared_ptr<token::Base>>& list,
    std::vector<std::function<Node*(std::weak_ptr<Node>)>>& types,
    std::weak_ptr<Node>& parent
) -> std::optional<std::shared_ptr<Node>> const;
Enter fullscreen mode Exit fullscreen mode

I know it's a lot, right?

What if we wanted something cleaner, but more importantly, something faster and less error prone? Well, I introduce you to GearLang, a proposed programming language with the benefits of Zig's comptime, Rust's enums, C++'s classes, and the full use of C/C++ ecosystems!

Clean Syntax

GearLang prioritizes minimal syntax to increase visibility, where we need it most!

fn main {
  greet "bob";
  exit 0;
}

fn greet name:string => f"Hello, {name}!";
Enter fullscreen mode Exit fullscreen mode

Comptime calculations and checks

One of the big things about Zig is the comptime, but I feel like we can do a little more with it. Introducing Comptime checks! A way to assert valid code each time the program runs!

fn main {
  let num1, num2 = 4, 6;

  comptime assert num1 > num2; // "Comptime Test Error! Tried num1 (4) > num2 (6)"

  exit 0;
}
Enter fullscreen mode Exit fullscreen mode

Integrated Tests

However, lots of tests can make the build process take waaaaaaay too long. To fix that, I propose seperate integrated test functions, to ensure that everything is according to plan.

fn main {
  let num1, num2 = 4, 6;

  test my_test num1, num2;
}

test my_test num1:i32, num2:i32 {
  assert num1 < num2;
}
Enter fullscreen mode Exit fullscreen mode

Interoperability

What's the point of implementing a new language if it takes too long and is too hard to implement it into your program? I suggest interoperability between C/C++ of course, and maybe soon, Rust!

!include {
  C::printf,
  C++::std::{
    allocator,
    vector<T, A=allocator>
  },
  Rust::std::{
    Result<T,E>
  },
}
Enter fullscreen mode Exit fullscreen mode

Conclusion

With all of these added together, it is a really big ask for one person to make this language. If you see the same potential as I do, I could really appreciate any help I could get! You can view the GitHub repo here

Top comments (0)