July 26th, 2024

Show HN: ClifferBasic, a simple BASIC interpreter as a .NET REPL

ClifferBasic is a GitHub repository featuring a BASIC interpreter as a REPL, allowing interactive command execution, variable management, and arithmetic operations, with plans for future enhancements and additional commands.

Read original articleLink Icon
Show HN: ClifferBasic, a simple BASIC interpreter as a .NET REPL

ClifferBasic is a GitHub repository that showcases a simple BASIC interpreter environment implemented as a REPL (Read-Eval-Print Loop) using the Cliffer CLI library. The program allows users to execute BASIC-like commands interactively, manage programs, and perform variable assignments and arithmetic operations. To start the REPL, users can run the ClifferBasic executable. Commands can be executed, such as printing text or running saved programs. The interpreter supports various commands including `cls` to clear the screen, `delete` to remove a line from a program, `end` to terminate execution, and `let` for variable assignments. An example session demonstrates how to assign values to variables and print results, as well as save programs to storage. The project structure includes key files such as ClifferBasic.cs, which serves as the entry point, and BasicReplContext.cs, which manages command input and execution. Future enhancements planned for the project include the addition of more commands, support for arrays, structured programming constructs, and improved documentation. For further information, the repository can be accessed directly on GitHub.

Link Icon 3 comments
By @giancarlostoro - 6 months
I'm seeing my career basically go head first into .NET despite my attempts at going all in on Python, Visual Basic 6 was my first language followed by C#, and in college, the moment I learned about preprocessor directives in C I did what probably everyone who likes BASIC and learns C has done, define BEING and END as { and } respectively... to the horror of C developers everywhere.

I think .NET is a fantastic platform, and I'm still surprised there's not more attempts at building languages on top of it, especially when you consider how IronPython was built to "prove" .NET was a terrible platform, but the Jython developer fell in love with .NET as a result of his attempt, heck, Microsoft hired the developer! At least thats how I've heard the story told on random HN comments over the years. :)

I havent had the pleasure of building a full interpreter yet, so props on doing the work.

Edit:

A few weeks ago I tried VB .NET and theres something nice about it, it feels like when I write some pieces of code, I can verbalize what it is, instead of some obscure character someone gave a meaning to, but building out VB .NET projects means translating C# to VB .NET the entire time, since most .NET things today are all in C# and it can be more effort than just writing in C#. There is something really nice and almost elegant about BASIC.

My only complaint with Microsoft was that VB6 made native binaries, I wish they had done VB7 with threading support before .NET became a thing.

I REALLY hope they open source Visual Basic 6 with the MIT License, would love to see what might happen if people fork it and make improvements to it...

By @WorldMaker - 6 months
Something fun to compare your efforts against is Small Basic: https://smallbasic-publicwebsite.azurewebsites.net/ (https://github.com/sb) [0]

That's also a BASIC built in .NET. It's focus is on "pedagogy" (teaching programming a step at a time in a revealing pattern sort of way), and offers a lot of fun silly things like a Turtle module and other basic GUI tools.

[0] Apparently not to be confused with SmallBASIC, a C/C++-based somewhat math-focused one: https://github.com/smallbasic/SmallBASIC

By @jasperry - 6 months
This is great. It makes me think there's something about the simplicity of a line-based interface for both editing and running code that we could still learn from in today's tooling. The interface to BASIC programming had to be simple because the only way you could do anything was by typing at the next line. But due to that very limitation, there was less friction from context switching. I think that's something that hasn't been fully recaptured even by advanced current REPLs.