BIPLAN Save

Byte coded Interpreted Programming language

Project README

BIPLAN CR.1

BIPLAN CR.1 (Byte-coded Interpreted Programming Language) is an experimental programming language that fits in less than 12KB of program memory and is implemented in less than 2000 lines of code. BIPLAN is a very compact language, even more compact than Wasm3, MicroPython or Lua.

Programming language Minimum requirements
TinyBasicPlus 11KB ROM, 1KB RAM
BIPLAN 12KB ROM, 1KB RAM
Wasm3 64kB ROM, 10kB RAM
MycroPython 256KB ROM, 16KB RAM
Lua 256KB ROM, 64kB RAM

The BIPLAN virtual machine implements the "fictional" BIP CR.1 computer architecture that operates with the BIP ASCII byte-code. It includes fixed-point arithmetics, serial interface, input-output ports, analog-to-digital and digital-to-analog converters, mono sound, text mode graphics and file handling.

Why?

In 2017 I built a couple of stand-alone computers using Arduino boards, I was forced to use BASIC because it was the only interpreted programming language that fitted in them. I asked myself: "How can BASIC, the first attempt to popularize programming, source of billions of lines of spaghetti code, now 57 years old, still be the only viable option?" . After some experiments I understood there was space for a new language: simple, portable, modern, but at the same time small enough to run on limited micro-controllers.

How?

The development of BIPLAN started in 2017, I wrote both the compiler and the interpreter from scratch avoiding external libraries, frameworks and the influence of compiler and interpreter design studies, learning by doing and evaluating results. In 5 years of experiments I wrote BCC, a pre-processor and multi-pass compiler capable of syntax and lexical analysis (576 lines of code), and BIPLAN, a register-based virtual machine implemented with a recursive descent parser (784 lines of code).

Code example

Fibonacci sequence computation in 166 bytes of BIPLAN code:

print fibonacci(40)
stop
function fibonacci($a, locals: $b)
  $b = 1
  for #r = 0 to $a
    $a = $b
    $b = result
    result = $a + $b
  next
return result

Compiled in 39 bytes of BIP byte-code by the BCC class:

p~$40)xf$}t}u)}u1@$0,}t}t}u}utt}t+}u;rt

Compiler output:

BCC (BIP Compiler Collection) Giovanni Blu Mitolo 2023
Source: fib.bpl 
Target: fib.bip 
Source length: 157B, BIP length: 39B, reduction: 75.159233% 
Compilation time: 239 microseconds 

Interpreted at run time by the BIPLAN_Interpreter class:

102334155

On my linux computer the biplan-interpreter needs around 30 microseconds to run the algorithm.

Performance

For now BIPLAN is around 1.43 times slower than python on my linux machine and orders of magnitude quicker than TinyBasicPlus when running on Arduino compatible boards.

Documentation

License

The license grants permission to use, copy, modify, merge, publish and distribute BIPLAN, only to individuals, for experimental purposes. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND. You are solely responsible for using, copying, modifying, merging, publishing or redistributing BIPLAN and assume any risks associated with your exercise of permissions under this License:

Definitions.

"You" (or "Your") shall mean an individual, human, exercising
permissions granted by this License.

"Software" shall mean the source code, associated documentation
and configuration files included in the BIPLAN directory.

"License" shall mean the conditions for use, copy, modify, merge, publish or
distribute the Software as defined by Section 1 through 3 of this document.

BIPLAN Experimenter's License

Copyright 2022 Giovanni Blu Mitolo

Permission is hereby granted to You, free of charge, the rights to use, copy,
modify, merge, publish or distribute copies of the Software, subject to the
following conditions:

1.Use, copy, modify, merge, publish or distribute the Software only for
  experimental or educational purposes.

2.Companies, institutions, organizations and corporations don't have the right
  to use, copy, modify, merge, publish or distribute the Software.

3.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  YOU ARE SOLELY RESPONSIBLE FOR USING, COPYING, MODIFYING, MERGING, PUBLISHING
  OR REDISTRIBUTING THE SOFTWARE AND ASSUME ANY RISKS ASSOCIATED WITH YOUR
  EXERCISE OF PERMISSIONS UNDER THIS LICENSE.

The version name CR.1 was chosen to honour the italian FIAT CR.1 biplane fighter aircraft. It was designed by Celestino Rosatelli, from whom it gained the 'CR' designation. The CR.1 was a Sesquiplane of Wood-and-fabric construction.

Open Source Agenda is not affiliated with "BIPLAN" Project. README Source: gioblu/BIPLAN
Stars
68
Open Issues
2
Last Commit
5 months ago
Repository

Open Source Agenda Badge

Open Source Agenda Rating