DEV Community

Cover image for Introducing Burger! A Game Programming Language
XANOZOID
XANOZOID

Posted on

Introducing Burger! A Game Programming Language

Hello! I'm Xanozoid, and I'm excited to introduce the idea behind my language "Burger" (BGL: Burger Game Language). I'm writing this post today to provide a taste of Burger and ideas of what future BGL posts may contain.

Why Another Language?

I've been programming for a while. It was a year or so before Game Maker 8 was released (released Dec 2009), and I used that program almost daily for as much time as possible each day. So, by that, you can guess I got into programming because I liked making games - and you'd be right. Skip a couple of years, and Game Maker Studio comes out, and I'm still using it every day until it becomes unusable on my laptop. Not much longer, GM:S2 comes out, and I buy that too . . . well, something happened, and I felt like I had to move on.

So, what does this have to do with another language? Well, during the last few years I was using GM, I started moving on to new languages. It was a considerable difference from programming in GML - but in a good way (mostly). I found a LOT of programming languages I liked and a few I didn't. I've since dabbled with around 40 languages, just trying to familiarize myself with the options and the programming landscape. There were problems, though, and I was looking for something that didn't exist.

So, sorry to cut a long story short, but here comes BGL. What BGL does is solve a personal problem of mine. I'm looking for a free and open-source experience that captures much of my experience working with Game Maker (not the exact same, though). That's to say, Burger is an attempt at molding my experiences working in other languages, specifically GML, into something I can use to make games in a fashion I'm used to. In any case, hopefully, I can interest you in the project in this post: I'll go over (for now) a small detail of how it looks and some core ideas that further explain why I "want" "burger".

What does it look like?

🍔! No just joking . . . It's mostly a blend of my three most experienced languages. Without saying all three, I'll mention just two: JavaScript and Haxe. Do be fooled! If you're comfortable with either of those languages, you should only have to make a few small adjustments to take a bite at Burger!

So, what about the syntax and semantics? Like I said - it's a lot like JavaScript and Haxe, but since JavaScript is more widely known, here's a small example that exposes a lot of similarities to JS but a lot of differences.

method object(this.x, this.y) {
    return this;
}

method move_north_east(amt_right = 0, amt_up = 0) {
    x += amt_right;
    y -= amt_up;
}

function create_and_move_object(move_x, move_y) {
    var obj = new object(0, 0);

    for(var i = 0; i < 10; i ++) {
        obj:move_north_east(i * move_x, i * move_y);
    }

    // silly destructure
    var {x, y} = obj;

    return x - y;
}
Enter fullscreen mode Exit fullscreen mode

So this is a small but silly example. If you're comfortable with JS you should be able to tell what's going on with a slight correction to your JS-lenses. That being said, the first thing that probably jumped out to you is there are two notations for functions. One is for methods, and one is for . . . functions. The simple explanation is methods have access to this, and implicitly so, while functions have no concept of a this.

Is this in BGL different from this in JS? I won't bore you with the details, but let's say it is somewhat different. The main difference is that this carries through method calls implicitly via some context. If that doesn't make sense, we'll review it in more detail in later posts!

While I still have your attention, though, you may have noticed a few more small things. Firstly, this in the arguments. That's a small trick I picked up from Dart (check it out!) - it just means "apply those arguments to this object". The last thing you may have noticed is the colon (:) in obj:move_north_east.... This is a reflection of a core idea in BGL that we'll discuss next - but it essentially means "apply this method to obj".

Core Ideas

There isn't necessarily a ton to Burger as a language. In fact, it probably "feels" like any other "game language", perhaps as one person put it: "Lua in JS clothes". There are things that separate it from other languages, however, and it doesn't just have "inspired" syntax/semantics. Though, it should mostly seem this way.

As a whole, this is a scripting language that will be embedded in another language made to be used for writing games (for BGE: Burger Game Engine). This is all intentional because it's pretty much how I imagine a game scripting language should work. There are other reasons for this, but mostly because I see Burger as something other than for game-specific things. That does not mean you can only use Burger in an engine, though - as this is the #1 thing that bothered me about GML. Also, If you have been wondering about the name up to this point, it's because Burger is a scripting language that will be written in Beef (A lower-level language also made for game development. Check it out!). Lastly, I am going with Beef because of its many targets - I want to target as many platforms as possible (for me).

So now that we got an idea of the "whole", what about core ideas of the language? We might say there isn't much to the language because it's like many other C-like languages, but that's not entirely true. At least there are a few things that stick out or even separate it.

  • All calls are (mostly) statically resolvable
  • Language designed for game dev
  • Portable and embeddable
  • capable of server-side programming
  • has a decent concurrency story via workers and coroutines

A few of these ideas we'll discuss over the course of the BGL posts but one thing that might catch your attention at first glance is the first point. Like mentioned earlier, we have a special syntax object:method. There's also object: { block }. Like said before, it's related to point 1 and means "object :(applied to) logic" - we pretty much don't have callbacks in this language, or other ways of storing methods/functions inside of data that moves around (I'm slightly lying), but that's the gist of it. There is a reason for this, but we will talk about this in more detail as more posts come out.

Timeline and future posts

Burger has yet to have an entirely clear timeline (I only work on it during the weekends), but I want to use it sooner rather than later. That being said, a lot of the front work has been done already, and it's mostly a matter of implementation at this point. There's a lot to cover about the design and work that's been done so far, and I intend on writing some posts down the line about the design decisions and overall language - as well as where the implementation is heading these coming weeks.

The next few posts I write will expose even more central ideas around Burger and the challenges/experiences of writing a language. So be on the lookout!

If Burger has captured your interest, please feel free to look at the repository! There, you may find a complete outline of the intended syntax/semantics and a working ANTLR4 grammar. Have further comments or questions? Continue them here or on the repo!

Thanks for reading 🍔😁

Top comments (0)