Skip to content

eantcal/nubasic

Repository files navigation

nuBASIC

nuBASIC is a modern, open-source BASIC interpreter written in modern C++, available for Windows, Linux, and macOS. It is designed to be both approachable for beginners and capable enough for real programs.

Features

  • Structured programmingSub, Function, For, While, Do…Loop While, If/ElIf/Else, Select Case; Call keyword; ByRef / ByVal parameter passing; open-ended array parameters (param() As Type); Include / #Include for multi-file programs
  • Classes with static methodsClass/End Class with instance fields, instance methods (Me), and Static Function/Static Sub callable as ClassName.Method() without an instance
  • main() entry point — if a Function main(...) is defined, execution starts there; CLI arguments are available via argc and argv() As String
  • Namespaced modulesSyntax Modern activates qualified names (math::sin, string::left$); Using Module imports a module for unqualified access; Syntax Legacy restores classic mode
  • Rich type system — Integer, Double, Boolean, Long64, String, Byte, Any, user-defined Struct
  • Arrays and hash tables built into the language
  • Full file I/O — sequential, binary, and random access
  • Graphics — lines, rectangles, ellipses, filled shapes, text, bitmaps, pixel access (Windows GDI / Linux X11)
  • Screen mode switchingScreen 0 (text/headless) / Screen 1 (GDI graphics), like GW-BASIC SCREEN; -t CLI flag for CI/scripting
  • Flicker-free renderingScreenLock / ScreenUnlock / Refresh for double-buffered animation
  • Mouse and keyboard inputGetMouse() returns a Mouse struct (x, y, btn) in one call
  • Date/timeGetDateTime() returns a DateTime struct with all fields in one call
  • UTF-8 string literals and console output
  • Built-in helpHelp <keyword> and Apropos <topic> accessible from the REPL
  • IDE for Windows and Linux (GTK+2) with syntax highlighting, auto-completion, and integrated debugger
  • Console build for headless/embedded systems (no graphics, no external dependencies)
  • MIT License

Documentation

  • Wiki — full language reference, graphics API, IDE guide, interpreter internals, and build instructions
  • User Guide — complete guide in a single document (v2.0)
  • Examples — ready-to-run .bas programs covering games, graphics, fractals, animations, and more

Quick Start

# Interactive REPL
nubasic

# Run a program file
nubasic myprogram.bas
Print "Hello, world!"

Building from Source

nuBASIC builds with CMake 3.14+ and a C++20 compiler.

Windows (Visual Studio 2022):

git clone https://github.com/eantcal/nubasic.git
cd nubasic
mkdir build && cd build
cmake -G "Visual Studio 17 2022" ..
cmake --build . --config Release

Linux:

git clone https://github.com/eantcal/nubasic.git
cd nubasic
mkdir build && cd build
cmake ..
make -j$(nproc)
sudo make install

Console build (no graphics, no IDE):

cmake .. -DWITH_X11=OFF -DWITH_IDE=OFF
make -j$(nproc)

See the Building from Source wiki page for full details including macOS, iOS/iSH, CMake options, and installer creation.

Running the Test Suite

Tests live in the tests/ directory as test_*.bas files. They use Screen 0 (text mode) so output goes to stdout without needing a GUI.

Windows (PowerShell):

.\tests\run_tests.ps1 -Interpreter .\build\release\Release\nubasic.exe

From Visual Studio: right-click the RunTests target → Build.

Linux / macOS (Bash):

./tests/run_tests.sh --interpreter ./build/release/nubasic

Or via CMake:

cmake --build build/release --target RunTests

Platforms

Platform Interpreter IDE
Windows nubasic.exe NuBasicIDE.exe (GDI console + Scintilla editor)
Linux nubasic nubasicide (GTK+2 + Scintilla editor)
macOS nubasic
iOS (iSH) nubasic (console build)

License

nuBASIC is open source under the MIT License.

Bug reports and feature requests: [email protected]

nuBASIC IDE for Windows

nuBASIC IDE on Linux/GTK

Visual Code extension