This is the website of SharpBASIC.

SharpBASIC is a new programming language that is currently in development. As the name suggests it is intended that the language will have similarities with BASIC, but more powerful, less verbose and with a clear structure. The compiler is aimed to produce 32 and 64 bits native code for Linux and Windows. Mac support may be added later.

news 30 April 2020

The last few weeks have been demanding with the attempt to create a firm code base for the SharpBASIC compiler. A lot of work went into the expression parser to have its return types accepted, both with and without option strict enabled. This also naturally led to a differentiation between logical and bitwise operators, while traditionally BASIC languages use the same keywords for both. SharpBASIC now supports the logical operators and, or, nor, xor, eqv and imp, which all return type boolean. In addition the bitwise operators & (and), ? (or), ! (xor), << (shift left) and >> (shift right) are supported.

An immediate table has been added in order to reference (and prevent duplication of) numeric and alphanumeric literals. This means that e.g.any occurrence of number 255 in a program will be replaced by one and the same immediate constant reference. Additionally, constant declarations like const a = 255; can optionally be given a specific type such as const a: uint16 = 255, thereby overriding the default type, in this case uint8.

The illustration below demonstrates what a C example on Wikipedia looks like in SharpBASIC.

Time for a break!

SharpBASIC example algorithm
sum /carry example in SharpBASIC (stage 0056)

news 21 April 2020

Progress is being made with sealing the holes around type handling and parameter passing. For example, taking the pointer from a parameter passed by value is not the same as from a parameter passed by reference, even though the same function (aof) is used for both methods. And while we're at it, a constant can be passed as a parameter to a procedure, but not by reference, as the example shows. There are many things to consider before taking the next step: full string-implementation!

constant passed by reference error (stage 0043)

news 19 April 2020

Stage 40 introduced the pointer type. Unlike some other (BASIC) languages, pointers in SharpBASIC are not type-bound; they simply point to an address, whatever (type) the address holds. However, pointers are protected, just as booleans, in that they cannot be mixed with other datatypes.

In the example below, with aof() the address of b is taken. With bya() the value (65) is then returned from the address and automatically converted to integer. Next, the value 65 is shifted to the 'high' byte and 97 is added to the 'low' byte. Then, if bya() reads the address for b the 'low' byte is automatically returned because b is of type 'byte'. So the result for b is 97.

example of pointer datatype in SharpBASIC
pointer type (stage 0040)

news 17 April 2020

It wouldn't be BASIC-like without a pure swap statement. SharpBASIC supports basic swapping between numerical types. Without 'option strict' directive, different types can be swapped freely, but mixing with booleans and pointers is not allowed. With 'option strict' enabled, the types must match. Note that this is a statement that starts with the keyword 'swap'. It is not a function. Enclosing the arguments with parentheses will raise an 'invalid identifier' error.

swap statement in SharpBASIC
swap statement (stage 0038)

news 11 April 2020

Although SharpBASIC is a 'medium' typed language by default, strictly typed can be enforced with the option strict directive. If this directive is added at the beginning of the code, the compiler will complain when types do not match, even int with uint.

option strict in SharpBASIC
option strict (stage 0033)

news 8 April 2020

String functionality has not been fully implemented yet. One of the tests is the famous 'Hello world!'

'Hello world' in SharpBASIC
'Hello world' (stage 0031)

news 6 April 2020

In the last few weeks, while developing the first library for SharpBASIC, it became obvious that in-line assembler support would be very convenient. So it was decided to give this feature precedence over basic features that have not yet been implemented.

in-line assembler in SharpBASIC
in-line assembler support (stage 0029)

news 20 March 2020

On 20 March 2020, after several months of development, the first source code was successfully compiled and run. See image below. Compilation was in 32 bits mode on Manjaro Linux x64. The NASM compiler and LD linker were used as back-end. See image below. This is a huge milestone in the development of SharpBASIC because up until this point only code generation was tested, not the actual outcome of a computation. From here on it will be easier to test and further develop the language.

first successful compilation
first successful compilation (stage 0020)

code generation tests February - March 2020

code generation with warning
warnings during code generation (stage 0016)

code generation with hints
hints during code generation (stage 0015)

assembler code generation sample
assembler code generation (stage 0010)