Skip to content
The bee programming language.
C CMake
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Create FUNDING.yml Feb 27, 2020
logos Compiler operations development. Jan 26, 2020
src Fixed carriage returns and int conversion to bytes. Mar 22, 2020
.gitignore
.gitmodules Generic hash table development. Aug 13, 2019
LICENSE Update the copyright name holder. Feb 27, 2020
README.md Update README.md Feb 21, 2020
bytecode_scheme.xlsx Added MOD and POW operations. Feb 8, 2020
~$bytecode_scheme.xlsx Compiler operations development. Jan 26, 2020

README.md

Bee Banner

The Bee programming language.

A A A A

Under development!

We are working to make a great programming language that currently has no functionalities available. You will get updated as soon as possible.

Content

Contribution

You can make part of this community! Come and help Bee to fly!

You can support Bee in Patreon: https://www.patreon.com/beelang
Check our discord server: https://discord.gg/4Bx8bzN

Introduction

Bee is a programming language being built to allow programmers to do everything without worry about the language, operating system and cpu architecture.

Bee's focus is to be compiled into other languages source code (transpiling). This will allow you to develop any kind of software with Bee.

Why do we need to learn HTML, JavaScript, CSS and PHP (or any other backend language/framework) to make a website? Then if we want to make an app we need to learn Java/Kotlin (Android) and Swift (iOS). Either if you want to develop some kind of desktop app you need to develop different code for each platform, or use non-native tools that will decrease performance. You could even use C++ for everything but that's not produtive and you will also need to develop different code for everything!

So, the goal of Bee is to provide tools that allow it to be compiled to any language or framework. You can also develop your libraries in Bee and then export it to different programming languages and frameworks.

Bee's focus is on network sockets, web development, gaming and modding, general apps and software, also embedded systems and operating systems... Hm, It seems almost everything. Well that's the objective.

Bee Design

With a syntax similar to C#, Bee intends to have a common loved syntax, later being updated with unique features.

The general architecture design is not based on any specific language. It's a way that seems to work being simple, cross-platform and with a great performance.

Bee will have support to multiple paradigms such as object-oriented and procedural.

Compiler

The compiler will process the source code that you develop, parses it and generates the given byte code.

Each version of Bee will contain the previous compiler versions, so that if you want either downgrade or upgrade your code, that will be possible.

ByteCode

The byte code is what is generated after compile the code. This will be saved to a file and can later be used as a library or be interpreted by the virtual machine.

The byte code will command the virtual machine, to be faster and efficient. So, this:

int x = 4 + 5 * 3;

Will be converted to something like:

MOV R1, 5
MUL R1, 3
SUM R1, 4
SET x, R1

Virtual Machine

The virtual machine is what will execute your byte code. Like the compiler, each version will contain the previous ones, so you can execute any code with any version.

With an optimized byte code, the virtual machine can be lightweight and fast. This provides the choice of Bee for modding intentions.

Transpilation

Instead of executing your code, you can transpile it into other programming language's source code. Bee itself will not contains any language transpilation but will have a built-in API and tools that will allow you to do that. That's a library like any other one.

Insted of run your code in the virtual machine, the virtual machine will execute the code of the transpiler library which will transpile your code to the desired programming language.

This makes Bee more dynamic and usable for multi-purpose. You can also search for any transpilation library on the package manager. Maybe someone already did a transpiler for the language that you are looking for.

An example of a code transpilation to Javascript:

StringBuilder resultCode = new StringBuilder();

BeeTranspiler.SetOnVariableDeclaration(OnVariableDeclaration);

void OnVariableDeclaration(VarInfo variable)
{
	resultCode.Append("var " + variable.name + ";\n");
}

File.Write(BeeTranspiler.FileName + ".js", resultCode);

When we compile this code, we will be able to just generate variables on javascript. Check the example below:

int x;
int y = 4;

Transpiling this code using the code mentioned above will generate this:

var x;
var y;

We are looking to improve this method of transpiling, probably adding support to XML to make it easier.

Hive

Is a built-in package manager that will allow you to update Bee, install and update libraries.

Just by calling hive install <package-name>, you will be able to easly install packages globally in your Bee.

Development Previews

Since Bee is not functional yet, the examples above are to show you how Bee is going to be. Some changes may happen in the journey.

Console Development

  • Hello World
Console.Write("Hello World!");
  • Console Input
Console.SetColor(Color.Red);
int value = Console.ReadInt("Please enter a valid number.");

Console.SetColor(Color.White);
Console.Write("The number is: ", value);

Desktop App Development

  • Sample Window
Window sampleWindow = new Window("Hello", 640, 480);
Button sampleButton = new Button("Click me");

sampleButton.AddOnClickListener({
	sampleWindow.Alert("Hello World");
});

sampleWindow.AddChild(sampleButton);

sampleWindow.Show();

Mobile App Development

  • Sample Page
Page samplePage = new Page("Hello");
Button sampleButton = new Button("Click me");

sampleButton.AddOnClickListener({
	samplePage.Alert("Hello World");
});

samplePage.AddChild(sampleButton);

samplePage.Show();

Web App Development

  • Front-End
class IndexPage: HttpPage
{
	public IndexPage() {

		getUsersBtn.AddOnClickListener((event)
		{
			User[] users = GetUsers();

			foreach(User user in users)
			{
				Label userRow = new Label();
				userRow.Text = user.Id + " - " + user.Name + " - " + user.BirthDate;

				usersList.AppendChild(userRow);
			}
		});
	}
}
<IndexPage>

	<Label Text="Hello!" />

	<Button Id="getUsersBtn" Text="Get Users" />

	<ScrollView Id="usersList" />

</IndexPage>
  • Back-End
class MyHttpListener: HttpListener
{
    HttpListener listener = new HttpListener();
    MySqlConnection connection = new MySqlConnection("localhost", "root", "");

    [RegisterGet("/")]
    private void ShowIndex(HttpResponse response)
    {
        HttpRequest request = response.GetRequest();
        request.Show(IndexPage);
    }

    [RegisterGet("/api/users")]
    public User[] GetUsers(HttpResponse response) {

    	connection.Open();

	    var data = connection.ExecuteQuery("SELECT * FROM user");
    	User[] users = User.From(data);

	    connection.Close();

    	return users;
    }
}

MyHttpListener listener = new MyHttpListener();

// Starts the http listener on the port 80.
listener.Start(80);

Bee inside any language

If you want to embed Bee inside your project of some language, check the example below in Java:

public class MyClass
{
	public static void main(String[] args)
	{
		BeeCompiler compiler = new BeeCompiler();
		String code = "Console.Write(\"Hello World from Bee!\")";

		BeeCompiledData data = compiler.compile(code);

		BeeVM.Run(data);
	}
}

Any language inside Bee

Now if you want to call functions from you project inside Bee, check the example below in C:

  • C code:
float Sum(int n1, int n2)
{
	return n1 + n2;
}

void RunBee()
{
	BeeCompiler *compiler = BeeCompiler_Create();
	BeeVM *vm = BeeVM_Create();

	BeeCompiler_RegisterFunction("Sum", &Sum, BEE_TYPE_FLOAT, BEE_TYPE_INT, BEE_TYPE_INT);

	BeeCompiledData *data = BeeCompiler_CompileFile(compiler, "example.bee");

	BeeVM_Run(vm, data);

	BeeCompiler_Free(compiler);
	BeeVM_Free(vm);
	BeeCompiledData_Free(data);
}
  • Bee code:
float Sum(int n1, int n2)
{
	uniqueset BeeFunction mySumFunction = ImportedFunctions.Get("Sum");

	return (float) mySumFunction.Invoke(n1, n2);
}

// OR

[ImportedFunction]
float Sum(int n1, int n2);

Console.Write("Value from C: " + Sum(4, 5));

Future Plans

Bee will make your life easier, optimizing your code and essentially providing keywords, tools and features that will accelerate your development.

Keywords

uniqueset

This keyword will be used to clean up your code when you want to make a function that returns a constant value, but the value will be generated only the first time that is called. But you need to be careful when using this keyword, otherwise your function may return unexpected results.

  • The function above may be called many times, but the variable mySumFunction will be assigned once.
float Sum(int n1, int n2)
{
	uniqueset BeeFunction mySumFunction = ImportedFunctions.Get("Sum");

	return (float) mySumFunction.Invoke(n1, n2);
}
  • Like I said, this can cause unexpected results like this one:
uniqueset string myString;

for (int i = 0; i < 5; i++)
{
	myString = "Value: " + i;

	Console.Write(myString);
}

The code above will print this:

with: uniqueset string myString; with: string myString;
Value: 0 Value: 0
Value: 0 Value: 1
Value: 0 Value: 2
Value: 0 Value: 3
Value: 0 Value: 4

uniqueget

This is just the opposite as the one below. So you get set its value multiple times but after you get the value, its value will be changed to the default (depends on the variable type, can be 0, "", null, etc.).

  • The variable above will have the value "Hello", but after call Console.Write its value will be gone. So the next Console.Write will print empty in this case.
uniqueget string myString = "Hello";

Console.Write(myString);
Console.Write(myString);

The code above will print this:

with: uniqueget string myString; with: string myString;
Hello Hello
Hello

Again, using this incorrectly can cause issues in your code, so have caution.

You can’t perform that action at this time.