User Tools

Site Tools


introduction

Table of Contents

Introduction

SharpBASIC is a new procedural programming language that is currently in development. As the name suggests, the language should be considered a sharper BASIC, more powerful, less verbose but with a clear structure. The compiler is aimed to produce 32 and 64 bits native code, first for Linux and later also for Windows and Mac.

Development started in early 2020 by Frank Hoogerbeets, but was halted soon after the corona crisis began. Development resumed in late 2021. No time has been set yet for the release of the first compiler version.

The compiler uses a recursive descent or 'top-down' predictive technique. As such, it doesn't do any backtracking or left-recursion. This requires the grammar to be clear and without ambiguity, which is what the SharpBASIC language aims to be, to make it pleasant for the programmer to use and for the compiler to process.

Perhaps the most characteristic feature of the language is its block structure, both for declarations / definitions (marked by is..end blocks) and control flow (marked by do..end blocks). This feature sets the SharpBASIC language apart from the more traditional BASIC and most other languages.

' "Hello World" program in SharpBASIC
main do
  print("Hello World");
end

SharpBASIC has everything a programming language should have: a variety of data types, logical and bit-wise operators, control statements, subroutines and functions, but also less common features, such as non-null terminated fixed-length strings, data buffer types and anonymous functions.

Why a new language?

Some very popular languages are old and date back to the early 1970s, while many other languages are modeled after them. Some can be hard to debug while others leave (much) room for ambiguity. Furthermore, SharpBASIC philosophy dictates that it should always be clear what code does, even for beginners. Take a simple example as a for-loop. Many popular languages use a syntax similar to:

for (i = 1; i < 11; ++i)

The problem here is that without fore-knowledge of the language, there is no way to know what it means. What happens when i = 1 or when i < 11 and what does ++i mean? By comparison, SharpBASIC makes it clear what the code does:

for i = 1 to 10 :++

The syntax is consistent with SharpBASIC's increment operator and it eliminates additional constructs such as by or step, which are often mandatory in other languages to indicate downward iteration. In SharpBASIC the same operators are applied:

for i = 10 to 1 :--

Another reason for a new language is that most languages today support some form of object oriented programming, which has been dominating the industry for many years. In recent years however, more and more programmers have come to the conclusion that OOP, in particular inheritance is bad. While functional programming has been suggested as the best alternative to OOP, we at SharpBASIC believe that imperative and procedural programming, perhaps with extended function support, such as anonymous functions, is a valued middle path.

' example of anonymous function
dim a, n: int;

main do
  n = 7;
  ' create scope and use copy of n
  a = afunc(n)
    dim i:itr;
    dim r:int=0;
  do
    for i = 1 to n :++ do
      r:+i;
    end
    return r;
  end
  print(a);   ' output: 28
end

Last but not least, creating a new programming language with new syntax and keywords is more than just fun; it is in one word exciting!

For the latest development news, check out the forum.

introduction.txt · Last modified: 2023/06/19 10:47 by admin