Skip to content

cdhanna/fadebasic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The ghost of Lee

Fade Basic

Fade's actually Dotnet embeddable

FOR n = 1 to 10
    PRINT n
NEXT n

Fade Basic is a dialect of BASIC inspired by my personal love for Dark Basic Pro. My father downloaded Dark Basic sometime circa 2003 and showed a then-kid version of me how to program a FOR-LOOP. That moment sparked a life long obsession with programming and game development. I wanted to create something that kindled the same joy for programming that Dark Basic did all those years ago. I created Fade Basic for myself, to fuel my inner nostalgia for a bygone era of my own life. And I figured I'd share it, because I think it is cool.

Fade is a scripting language for dotnet. Fade code runs inside a dotnet process. It is debuggable. It does not use Reflection. The Fade code gets compiled into a custom byte-code, and then that byte-code is interpreted by a custom state machine. The language has almost no dependencies, which means it can run wherever dotnet can run. For now, I have been focusing on stand-alone applications that bootstrap a Fade script as their primary execution, but it is possible to embed Fade scripts into any dotnet compatible program, such as Godot, Unity, an ASP.NET Server, or a custom program.

This project is under active development and is only available in a preview-capacity.

Getting Started

Prerequisites

Before you can get started,

  1. dotnet 8 SDK (or later) installed on your machine. Verify the installation by opening a terminal and checking the dotnet version,

    dotnet --version
  2. Download Visual Studio Code, because it is the only IDE I have added developer tooling for.

Install Fade Basic

  1. Download the templates package from nuget using the following command,
    dotnet new install FadeBasic.Templates.Common
  2. In Visual Studio Code, install the Fade Basic Extension.

Your first Fade program

  1. Create a new folder and use dotnet to create a new project from the templates you just installed.

    mkdir tunaFade
    cd tunaFade
    dotnet new fadebasic-project-console -n tunaFade
  2. Open Visual Studio Code to the folder containing your project,

    code .

    You should see a few files,

    filename description
    main.fbasic This is where your program source code is!
    tunaFade.csproj By default, this template creates a standalone dotnet console application, and this .csproj file is the build configuration file for the console application. This file contains the version of Fade you are using.
  3. Open the main.fbasic file, and you should see the following contents...

    remstart 
        tunaProject main entry point
    remend
    
    print "hello world"
  4. Click on the run and debug tab in Visual Studio Code, and select the big blue Run and Debug button. You shouldn't need to specify any new launch configuration, because one should appear automatically. The .vscode/launch.json file should look like the following,

    {
        // Use IntelliSense to learn about possible attributes.
        // Hover to view descriptions of existing attributes.
        // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
        "version": "0.2.0",
        "configurations": [
        
            {
                "type": "fadeBasicDebugger",
                "request": "launch",
                "name": "Fade Debug",
                "program": "${workspaceFolder}/${command:AskForProgramName}"
            }
        ]
    }
  5. Now, click the green play button to run the Fade Debug launch configuration. You should see "hello world" appear in the Terminal tab of Visual Studio Code.

    Congratulations! You just ran your first Fade program!

  6. Bonus: If you hover your mouse over the print command, you should see a popup that provides a small amount of documentation for the command. Click the link that says, Full Documentation, and a web browser should open to a localhost address showing a list of all available commands.

Run it as a script

So far, you've run the Fade program as something that appears to be a standalone program. However, Fade's actually Dotnet embeddable, so you can run the Fade script directly from existing C# code. For now, just read along.

You could create a brand new C# Console application and reference the Fade Nuget libraries. Then, inside that C# application, you could write some code like this,

var commands = new CommandCollection(
    new ConsoleCommands(), 
    new StandardCommands()
);
var path = "/tunaFade/tunaFade.csproj";

Fade.TryFromProject(path, commands, out var ctx, out _);
ctx.Debug(); // run the Fade program in debug mode

The last line boots up the Fade code as a runtime script within the C# application. Back in Visual Studio Code, you can attach the debugger to the running script and inspect the program or modify the state.

Fade has almost no dependencies, so you could run this code from a more complex C# environment, like Unity...

Next Steps

Now that you have Fade running locally, you should check out the full language specification! Or learn how to debug your program? Maybe even create a custom command collection.

Contact and Help

Fade Basic is in active development. As such, I am sure there are many bugs I don't know about yet. If you find one of them, please tell me about it! Feel free to join the Discord, or post a Github Issue.

License

Fade Basic has many parts, and at the moment, all of them are MIT licensed. I plan on keeping the core language and tooling systems open sourced under the MIT license. However, at some point in the future, I reserve the right to release closed-source extensions or domain specific command collections.

Contributing

I welcome feedback, but at the moment, I am not expecting to accept contributions to the project. I have a vision for Fade, and I want to see that vision to completion. Thank you for your consideration.