Flang (FriedLanguage) is an interpreted language created using C#. It's built upon the codebase of another project called "Spaghetto" by GoldenretriverYT (https://github.com/GoldenretriverYT/spaghetto). This project was undertaken because of a personal interest in developing a programming language.
The majority of the code in Flang is derived from "Spaghetto," and it's important to give proper credit to the original author. While I've made some modifications and added features, I want to acknowledge the significant contribution of GoldenretriverYT's work.
Flang's codebase inherits the licensing terms of "Spaghetto." It's important to familiarize yourself with the original project's license, which is likely the Mozilla Public License 2.0 (MPL 2.0). You can find details on the licensing terms by referring to the provided link to the original repository.
I'm not an expert on licenses, and I encourage you to review the original project's license to understand how it applies to your usage of Flang. If you're unsure about licensing or need legal advice, it's recommended to consult with professionals who specialize in software licensing.
(this readme was generated by chatgpt if it wasnt obvious enough) (if i made any (legal) mistakes, make sure to correct me and ill remove/fix/add whatever is needed)
To start using Flang, follow these steps:
- Clone the repository.
- Create a new instance of the
FLangclass. - Add the things that you want to be nativly imported using
ImportNativemethod. - Add variables and methods from the outside if needed.
- Write your Flang code. (returning at the top level will return from runcode)
- Run the code using
fLang.RunCode.
using System;
using System.Collections.Generic;
using System.Linq;
using FriedLang;
using FriedLanguage;
using FriedLanguage.BuiltinType;
using FriedLang.NativeLibraries;
namespace FriedLanguageConsole
{
internal class Program
{
static void Main(string[] args)
{
FLang fLang = new FLang();
fLang.ImportNative<IO>("io"); //import the default IO as "io"
fLang.ImportNative<Lang>("lang"); //import the default Lang as "lang"
fLang.ImportNative<Async>("async"); //import the default async as "io"
string code = """
import native io; //import the io we just added
print("Hello World!");
return "Goodbye";
""";
var output = fLang.RunCode(code);
Console.WriteLine("Flang output was:");
Console.ReadLine(); //stop console from exit
}
}
}
Flang supports various types of variables:
- String
- Int
- Float
- Bool
- Double
- Long
- List
- Dictionary
Example usage:
import native lang;
list example = "Hello World".split(" ");
example.removeAt(1);
example.add("beautiful");
example.add("World");
return example;
this will return 'Hello, beautiful, World'
Define and use classes in Flang:
class Person
{
string name = "";
Person(nam)
{
self.name = nam;
}
void hello()
{
print("Hello, my name is " + self.name);
}
}
var p = new Person("John");
p.hello();
return p;
you can also use the following syntax to run c# code
<{
MessageBox.Show("Hello World");
}>
implement like this
func showMsg(text)
{
<{
MessageBox.Show(context.getStr("text"));
}>
}
however this is compiled at runtime and will DEFINITELY slow down your code (up to 5 seconds!!)
im looking to add a second variant of this that doesnt have access to any varibles but is simpily a function that takes a few arguments and can return some
so that it can be pre compiled (taking longer at startup to compile, but then executes smoothly without any 3-5 second pauses)