Why nuBASIC

Ever since I started writing BASIC programs on my Commodore 64, I've always had a desire to develop a BASIC interpreter. In 2014, during a programming course in C++11 that I taught, I decided to take on the challenge of implementing an interpreter as a non-trivial coding example. I specifically chose BASIC, inspired by the fact that it had been fifty years since John G. Kemeny and Thomas E. Kurtz designed the original BASIC language. Despite Dijkstra's famous judgment that "It is practically impossible to teach good programming to students who have had prior exposure to BASIC," I believed that BASIC's simplicity made it one of the few languages that an 8-year-old kid could understand. It was this simplicity that made it an ideal choice for beginners to learn programming.

What does the prefix “nu” mean?

The prefix "nu" may not actually signify "new," but it originates from a namespace that I frequently utilize in my source code. Although it carries a different meaning within that context, it seemed suitable enough to be employed here and had an appealing sound to it.

What is the evolution strategy for the language?

Although nuBASIC is lacking several features that I would like to incorporate, my intention is to enhance the existing ones while maintaining the language's simplicity and the interpreter's portability. It is important to me to keep nuBASIC small and intuitive, ensuring that users can easily grasp its functionality.

I cannot predict when I'll find the time to work on improving nuBASIC since it's more of a hobby for me, and I don't receive any monetary compensation for it. However, I remain committed to the project and will continue to dedicate my efforts to enhancing it, just as I have been doing so far.

Why is nuBASIC designed to run as a console application?

The choice to run nuBASIC as a console application offers several advantages. It provides a convenient environment for experimenting with language features and makes the learning process simpler by eliminating the complexities of a graphical user interface. Users can interact with nuBASIC through a traditional command-line interface, allowing them to enter programs directly and execute them. However, it's important to note that a graphical IDE (available for Linux and Windows) is also provided for those who prefer a graphical programming environment.

What are the reasons behind using the console window (or the X-terminal in Linux) for drawing graphics? 

I must acknowledge that this is an unconventional choice. However, this approach enables the creation of simple applications that require graphics, despite having certain drawbacks like suboptimal control of window repainting. If time permits, I would love to expand nuBASIC to support a full GUI paradigm, including event-driven programming. Nevertheless, those who were accustomed to BASIC interpreters from the 80s might still appreciate this approach, particularly considering the nature of nuBASIC and its primary educational purpose.

Is nuBASIC compatible with other dialects of BASIC?

nuBASIC offers partial compatibility with GW-BASIC, QBASIC, and potentially other dialects of BASIC. It supports both classic BASIC programs that utilize line numbers and control structures like GoTo and GoSub, as well as procedure-oriented programs based on structured and procedural programming paradigms. The interpreter successfully runs the following two implementations of the Rosetta Code example, which showcases the Mandelbrot set, a fundamental concept in fractal geometry:

Implementation 1

5  Rem Rosetta.bas

10 For x0 = -2 To 2 Step .01

20 For y0 = -1.5 To 1.5 Step .01

30 x = 0

40 y = 0

50 iteration = 0

60 maxIteration = 223

70 xtemp = x*x-y*y+x0

80 y = 2*x*y+y0

90 x = xtemp

100 iteration = iteration + 1

110 If ((x*x+y*y<=4) And (iteration < maxIteration)) Then GoTo 70

120 If iteration <> maxIteration Then c = iteration Else c = 0

130 d%=150: dx%=300 : dy%=300

140 FillRect x0*d%+dx%,y0*d%+dy%,x0*d%+dx%+2,y0*d%+dy%+2,int(c)*16

150 Next y0

160 Next x0

Implementation 2

' Rosetta.bas

For x0 = -2 To 2 Step .01

   For y0 = -1.5 To 1.5 Step .01

      x = 0

      y = 0

      iteration = 0

      maxIteration = 223

      While ((x*x+y*y<=4) And (iteration < maxIteration)) 

         xtemp = x*x-y*y+x0

         y = 2*x*y+y0

         x = xtemp

         iteration = iteration + 1

      End While

      If iteration <> maxIteration Then

         c = iteration 

      Else 

         c = 0

      End If

      d%=150 

      dx%=300

      dy%=300 

      FillRect x0*d%+dx%,y0*d%+dy%,x0*d%+dx%+2,y0*d%+dy%+2,int(c)*16

    Next y0

Next x0

Is nuBASIC free?

Yes, nuBASIC is free, open source, and distributed under the MIT license since version 1.48. You can download the source code and binaries from either SourceForge or GitHub.

How can I access documentation on nuBASIC?

The standard documentation for the current stable version of nuBASIC is available in the nuBASIC Reference section of the website. User Guides in both PDF and ODT formats, available in English and Italian, can be found at https://sourceforge.net/projects/nubasic/files/documentation/.

Why C++11, and what is C++11?

C++11 refers to a version of the C++ programming language that was approved by ISO on August 12, 2011. It introduces several additions to the core language and extends the C++ Standard Library. If you're interested in more information about C++11, you can refer to http://www.stroustrup.com/C++11FAQ.html.

How do I build nuBASIC?

nuBASIC can be compiled on various operating systems, including Windows, Linux, and MacOS. To build nuBASIC, you can create a Visual Studio console application (Windows only) or use Clang or gcc/g++ (with C++11 support).

How do I use nuBASIC?

nuBASIC can be used by any user without additional programs. It includes the necessary components for creating and running programs, such as the command line interpreter (CLI) for inline editing and testing, the language interpreter for running nuBASIC programs, and an Integrated Development Environment (IDE) for Windows and Linux/GTK+2 platforms.

The nuBASIC programming language consists of two components: the language itself, defining elementary linguistic constructs like variable declarations and loops, and the built-in function library, providing standard functions for manipulating numbers, strings, and files.

How can I obtain support or submit bug reports?

For support or bug reports, you can send an email to antonino.calderone@gmail.com, and I will respond as soon as possible.

Acknowledgments:

I would like to express my gratitude to all the individuals who have contributed to the improvement of nuBASIC by providing feedback, ideas, and suggestions. A special thanks goes to Brian Decker for his assistance in bug discovery and his valuable suggestions on ensuring language compatibility with ECMA-55.


Thank you all!

Antonino