@bitloops/bitloops-language-cli

Bitloops Language CLI


Keywords
bdd, bdd-tests, behavior-driven-development, bitloops, bitloops-language, clean-architecture, contributions-welcome, ddd, ddd-architecture, ddd-example, developer-tools, domain-driven-design, domain-model, open-source, opensource, programming-language, test-driven-development, transpiler, typescript, ubiquitous-language
License
GPL-3.0
Install
npm install @bitloops/bitloops-language-cli@0.0.18

Documentation

Bitloops FOSSA Status

Quick Start | Discord | GitHub Discussions | GitHub Issues | Contributing


Build scalable, maintainable & reliable software (faster, much faster)

Bitloops Language (BL) is a transpiled, high-productivity, fourth generation, DDD/BDD focused programming language. BL has been built to empower any software developer to build high-quality and well designed software, particularly applications that have complex, and frequently changing, business requirements.

⚠️ Please keep in mind that the Bitloops Language is in its early stages and under very active development. Expect bugs and limitations. Full backward compatibility is not guaranteed before reaching v1.0.0.

Quick Start

The fastest way to see how the Bitloops Language works is to run our Todo example.

Transpiler Installation

Until we create binaries, the best way to install and run the transpiler is to install the Bitloops Language CLI as a global npm package:

npm install -g @bitloops/bitloops-language-cli

or

yarn global add @bitloops/bitloops-language-cli

Transpiling the example Todo application

  1. Clone this repo
git clone https://github.com/bitloops/bitloops-language.git
  1. Run the transpiler
bl transpile -s bitloops-language/examples/todo/bl-source/ -t output

or

bitloops-language transpile
  1. After the transpilation finishes, go into the output dir
cd output
  1. Install the npm packages
npm install

or

yarn install
  1. Make sure you have a running instance of MongoDB

5.1 If you don't have MongoDB already installed on your system, the easiest and "cleaner" way is to run MongoDB through Docker so install it and launch it

5.1.1 Install MongoDB in Docker

docker pull mongo

5.1.2 Start the MongoDB container

docker run -d --name mongo -p 27017:27017 mongo
  1. Start your TypeScript Todo backend
yarn start:dev
  1. Start sending requests to the Todo app using Postman or curl (or any other way you like)

    7.1. Example using curl

    curl -X POST localhost:5001/api/todo/ -H "Content-Type: application/json" -d '{"title": "My first todo"}'

Why? | Goals | Status


  • High-productivity, fourth generation (4GL) transpiled programming language
  • Easy to learn and get started with
  • Focused on Domain-Driven Design and Behavior-Driven Development (DDD/BDD)
  • Testing is treated as a 1st class citizen
  • Add different API controllers (REST, GraphQL, gRPC) with just a few lines of code
  • Modular Monolith or Microservices architecture? Both! Switch back and forth within minutes as all messages are moved through either in-memory or distributed message buses depending on your deployment choice
  • Significantly reduce the amount of boilerplate code you need to write and maintain
  • Ensure alignment between business and engineering with a natural ubiquitous language
  • Transpiles to widely used programming languages for maximum compatibility with existing code (currently only TypeScript support, Go, Java, C#, C++ or maybe even Rust or Carbon to follow in the future)

Why build the Bitloops Language?

There are numerous great programming languages out there with massive and growing codebases and investments. However, the most common problem faced by organizations that build and maintain systems, with teams of developers working on them, is good architecture and design; Designing a complex system so that it can last through time and that will allow developers (existing and new joiners) to work on its codebase with steady (or hopefully) increasing productivity. Good testing is an additional major requirement of long lasting products which is also made possible by good architecture and design. Unfortunately, there aren't enough knowledgeable and experienced senior engineers around the world to build and maintain great systems for all who need them. Even when a company is lucky enough to have some, it is unable to hire more junior engineers than the senior ones can review their work and guide in order to make sure the system does not degrade over time due to bad design decisions.

The Bitloops Language is the first programming language that aims to address these issues by making it much easier to adopt important software engineering principles and patterns such as Domain Driven Design and Behavior Driven Development, without requiring many years of experience to do so successfully. As a result, the work of senior engineers can be further leveraged and the contributions of junior engineers significantly boosted.

Language Goals

  • Reduce the learning curve needed to build and maintain great software using DDD and BDD, allowing many more software developers around the world to adopt these important principles
  • Allow organizations to have to rely less on developer discipline and more in a structured process
  • Make testing a more integral, collaborative, useful, and fun process
  • Put the focus on the domain and automate everything else as much as possible
  • Make domain logic timeless, platform & (target) language independent
  • Eliminate the need for boilerplate code
  • Allow software engineers to postpone the need for a microservices architecture until it is needed strictly from a infrastructure perspective to better manage computing resources and if eventually it is needed to be able to do so within hours and not months or years.
  • Allow for the reuse of existing packages writen in the target language
  • As a result of the above, significantly increase developer productivity

The Bitloops Language aims to define and retain a simplistic syntax that will be as close to human language and business logic as possible that will become timeless, helping adopt and use a ubiquitous language within each module or bounded context. Making the Bitloops Language a transpiled language was a core decision to achieve exactly this. By allowing oraganisations to write their business logic in a timeless language that can be transpiled to powerful but also changing target languages without burdening the users of the Bitloops Language with this task. The Bitloops Language will make sure it transpiles to optimized code of relevant, up-to-date, and right-for-the-task languages.

Project status

The Bitloops Language is currently in early stages. Its transpiler has been created as a proof of concept and is not meant to cover the full range of developer creative code writing at this stage.

We want to better understand whether we can build a language that meets your needs, and whether we can gather a critical mass of interest within the DDD community and outside of it.

Currently, we have fleshed out several core aspects of the project and the language:

  • The strategy of the Bitloops Language and project.
  • Critical and foundational aspects of the language design. This includes designs for:
    • Class types
    • Inheritance
    • Lexical and syntactic structure
    • Code organization and modular structure
  • A prototype transpiler that can run example projects is a few days away.
  • We are currently writing up documentation to release along with the first version of the transpiler.

There are many things we want to add in the future including

[ ] CQRS support [ ] Event Sourcing support [ ] Java target language [ ] gRPC support [ ] And many more...

If you're interested in contributing, we would love help

Bitloops -> TypeScript Transpilation

If you are already aware of the DDD concepts (Aggregates, Value Objects, Use Cases, Controller, etc.) and know how to code in any modern programming language, it should be really easy to pick up the Bitloops Language. It is built out of a consistent set of language constructs that should feel familiar and be easy to read and understand.

While Bitloops is an Object Oriented Language, it doesn't have a generic class. Specific Bitloops classes are build-in as follows: ValueObject, Entity, Root Entity, UseCase, RESTController, GraphQLController, GRPCController, DTO, Props, Config, OK, ApplicationError, DomainError, Error etc.

Bitloops Language code like this (11 lines):

// Bitloops Language:
Rule TitleOutOfBoundsRule(title: string) throws DomainErrors.TitleOutOfBoundsError {
  isBrokenIf(title.length > 150 OR title.length < 4);
}

Props TitleProps {
  string title;
}

ValueObject TitleVO {
  constructor(props: TitleProps): (OK(TitleVO), Errors(DomainErrors.TitleOutOfBoundsError)) {
    applyRules(TitleOutOfBoundsRule(props.title));
  }
}

transpiles to this TypeScript code (28 lines):

// TypeScript:
import { Domain, Either, ok, fail } from '@bitloops/bl-boilerplate-core';
import { DomainErrors } from './errors';

export class TitleOutOfBoundsRule implements Domain.IRule {
  constructor(private title: string) {}

  public Error = new DomainErrors.TitleOutOfBounds(this.title);

  public isBrokenIf(): boolean {
    return this.title.length > 150 || this.title.length < 4;
  }
}
                                                            
export namespace Rules {
    export class TitleOutOfBounds extends TitleOutOfBoundsRule {}                                             
}

interface TitleProps {
  title: string;
}

export class TitleVO extends Domain.ValueObject<TitleProps> {
  get title(): string {
    return this.props.title;
  }

  private constructor(props: TitleProps) {
    super(props);
  }

  public static create(props: TitleProps): Either<TitleVO, DomainErrors.TitleOutOfBounds> {
    const res = Domain.applyRules([new Rules.TitleOutOfBounds(props.title)]);
    if (res) return fail(res);
    return ok(new TitleVO(props));
  }
}

Are you liking what you are seeing? Don't forget to star our repo