boltlang / Bolt

A programming language for rapid application development
35 stars 1 forks source link
experimental productivity programming-language scalability security web-development

Bolt

[!WARNING]

This compiler is experimental and might have breaking changes with each update.

💬 Got some questions or feedback? Just open an issue and we'll be glad to respond!

fn fac = match.
  0 | 1 => 1
  k => k * fac (k-1)

Bolt is a new strictly-evaluated functional programming language in the making that aims to make writing complex applications dead-simple. It ships with some nice goodies, including:

Examples

Note that these examples are stil in the design phase and not able to compile.

Here are some records we define in Bolt:

struct Dog.
  name: String
  age: i32

let spike = Dog {
    name = "Spike",
    age = 5
  }

# Shorthand
let sadie = Dog "Sadie" 12

print f"Hey look! {spike.name} and {sadie.name} are playing together!"

Records are extensible, meaning that you can do things like this:

fn greet { name, .. } = print f"Hello, {name}!"

greet sadie
greet spike
greet { name = "Sam", company = "Accelera" }

Bolt will also support traits/type classes, like in Rust and Haskell:

trait Shout.
  let shout : String

impl Shout for Dog.
    let shout = "Bark, bark!"

# Imagine somewhere in another library Cat is defined ...

impl Shout for Cat.
    let shout = "Miau! Miau!"

Here's an example of a React-like framework in Bolt:

Note that this example is very experimental.

import "html" ( Html )

fn app : Html.

  let user = perform get_state

  return match user.
    None => do
      Future.when_done (fetch "/api/login") \data -> do
        perform set_state data
      h1 [ "Please log in." ]
    Some { name, .. } => h1 [ f"Welcome Back, {fullname}" ]

Core Principles

Bolt has a few fundamental design principles that we hope in time will make it stand out from other programming languages.

FAQ

When will the compiler be ready to use?

It is really difficult to say when the compiler will be ready. This project is made exclusively in people their spare time. Depending on the availability of the programmers making this project possible, this might take a lot of months or even years.

Currently, we are working hard to get the type-checker fully operational. After that work will continue on the code generator and garbage collector. A small part of the code generator is already done: the first bindings to LLVM are operational and will be expanded in the future. Stay tuned!

Why yet another programming language?

Granted, there are a lot of programming languages, but oddly enough I found myself in the situation where I was still not completely satisfied. For example, Rust is a fantastic programming language, but writing web applications in it feels a little cumbersome due to its manual memory management. On the other hand, functional programming languages like Haskell and Idris look like they come straight out of the future, but sometimes have unpredictable run-time performance and force you to do weird things when all you want to do is mutate a variable. Bolt aims to solve these two issues, while not giving in on performance or correctness.

Why should I choose Bolt over JavaScript?

First of all, let me tell you that if you've never heard of a functional programming language, learning Bolt will take some time. However, I assure you that it is worth it.

What happened to the old compiler?

The old repository has been archived and has been replaced with this one. I doubt there will be much interest in this older software artifact. If you want to check it out nonetheless, you can still do it by following this link.

What's the difference between the old Bolt programming language and this language?

I redesigned the language from the ground up to be more functional, terser, and with very straightforward extensions for writing complex HTML. It is by no means done, but I do hope to have struck a good balance between readability and ease of use.

License

Bolt was initially licensed under the GNU GPL, version 3. I decided to release this new version under the more permissive MIT license. In the end, I hope that this piece of software may inspire other projects and may improve the quality of new and existing software.