![]() Why nuBASIC?Ever since starting writing BASIC programs on my Commodore 64 I've always wanted to write a BASIC interpreter.During a programming course in C++11 which I held in 2014, I decided to implement an interpreter, as non-trivial coding example, and my choice fell on BASIC, fifty years after John G. Kemeny and Thomas E. Kurtz designed the original BASIC language. Despite Dijkstra's famous judgment, "It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration", BASIC was one of the few languages simple enough for a 8 year old kid to understand, so its simplicity made it easy for beginners to learn programming. I was 8 year-old kid when I started coding in BASIC and I'm not sure I could understand more advanced programming languages in those days. What does the prefix “nu” mean? The prefix "nu" does not mean "new", but it comes from a namespace that I often use in the source code, with a different meaning, but it sounded good enough to be used here. What is the evolution strategy for the language?nuBASIC lacks many features I would like to add. Also I would like to improve existing ones, but maintaining the current level of simplicity of the language and portability of the interpreter, because I want to keep nuBASIC as small and intuitive as possible. I cannot say when I'll have time to improve it, this one is an almost ludic activity for me, and BTW I am not getting paid for it! However, I will try to do it as I have done so far. Why nuBASIC runs as console application ?Console application is ideal for quickly trying out language features and it greatly simplifies the learning process by removing the complexity of a graphical user interface, providing the user with a traditional BASIC command line interface where he can enter programs directly and execute them. Nevertheless a graphical IDE (for Linux and Windows) is also provided.Why the console window (or the X-terminal in Linux) is also used to draw graphics? I have to admit this is an unusual choice, but again, this approach allows of writing simple application that needs to use graphics, although it has several drawbacks, including not optimal control of window repainting. I wish I had some time to extend nuBASIC to support full GUI paradigm, introducing also event driven programming. But who was used to 80s BASIC interpreters still likes such approach (I guess), especially considering the nature of nuBASIC and its educational main purpose. Is nuBASIC compatible with other BASIC dialects? nuBASIC is partially compatible with GW-BASIC, QBASIC and maybe other BASICs. It also allows you to write both classic BASIC programs, which use line numbers and GoTo or GoSub control structures, and procedure oriented programs, based on structured and procedural programming paradigm. The following two implementations of Rosetta Code example (the Rosetta stone of Fractal geometry is the Mandelbrot set) run correctly on nuBASIC interpreter: Implementation 15 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?nuBASIC is free, open source and distributed under MIT license since version 1.48. How do I get documentation on nuBASIC ?The standard documentation for the current stable version of nuBASIC is available at nuBASIC Reference session of this web site. User Guides (in both PDF and ODT formats, in English and Italian) are also available at https://sourceforge.net/projects/nubasic/files/documentation/ Why C++11, and what is C++11?C++11 is a version of the standard of the C++ programming language approved by ISO on 12 August 2011. It includes several additions to the core language and extends the C++ Standard Library. If you are interested in more information on C++11, please read this I was teaching C++ programming courses and needed to implement a non-trivial example in C++11. I just started writing such interpreter and then have continued in my spare time to improve it, ever since (the version presented in the course was really trivial compared the current one). How to build it?nuBASIC compiles under several operating systems including Windows, Linux and MacOS. To compile nuBASIC you may create a Visual Studio console application (Windows only) or build it by using Clang or gcc/g++ (you need a version which supports C++11). How to use it?nuBASIC can be used by any user without any additional programs. It has the components needed to create programs, including:
How to obtain support or submit bug reports?Send an email to me, antonino.calderone@gmail.com and I will answer you as soon as possible. AcknowledgmentsThank all the people who helped me to improve nuBASIC providing feedbacks, ideas, suggestions.Special Thanks to Brian Decker for his help on discovering bugs and his nice suggestions on how to make the language compatible with ECMA-55. Thank you all! Antonino |
nuBASIC 1.51 >