News Archive

Movement to Pure C

I had to make a difficult decision about 3 weeks ago. I gave myself 6 months, from July 2015 to the New Year, to make my programming language, Kong.

I worked on it the entire time, through several major refactors, and had a pretty solid product by January – but it wasn’t complete. I spent another month trying to fill the holes, and had a cube rendering.

The problem was the speed.

It just isn’t fast enough for game development.

So, all wasn’t lost: I knew of a lot of ways I could speed it up. I could rework the virtual machine bytecode, to make it more efficient for execution; I could write a partial JITer; I could write a Kong-to-C transpiler, or an LLVM backend, etc.

But I was out of time. My next deadline for having a game developed is only a few months away, and my first experimental changes to Kong would take another 2 months. And then, what if it still wasn’t fast enough? I would be way over schedule without any games.

So I ditched it.

One good thing about writing the VM in C is that I became really comfortable with C. I used to program in C++ a long time ago, and I had spent most of December and January working on the VM in C99, which is a pretty nice language, all things considered. It’s much better than C89, and is widely supported.

What sucks is that I’m basically throwing away 6 months of work, and giving up on the dream of creating a programming language – at least, for now.

I didn’t make the decision lightly, but I also didn’t really have a choice. I could let Kong consume all of my time, and never ship a game, or I could let it go, and focus on game development on a proven platform, C.

So, starting around February 15th 2016, I chucked the majority of my codebase, and started over, using pure C.

The bad news is that I’m behind schedule (and if I had skipped Kong completely, I would be ridiculously ahead of schedule!). But I’m not that far behind, and I’m making up ground pretty quickly.

And instead of meditating on how to improve the Kong codebase, and how to speed up compilation, and how to speed up the garbage collector, or speed up the VM execution: my focus is now (correctly!) on how to make a game.

I’ve learned Blender, and have a pretty cool setup so far. I’ve written around 8,500 lines of code the past 3 weeks, and have the start of an animation engine:

Person Animator

Person Animator

What’s nice too is that I can now post a lot of screenshots of my progress, since I’m working on graphical things, and not compilers 😀.

Follow me on Twitter @velipso to see random screenshots as I do actual game development 😀.


Posted article on Kong’s garbage collector

Decided to take a day to write up how Kong’s garbage collector works:

Tri-Color Garbage Collector

Enjoy!


Kong Runs SDL and OpenGL

Kong is rendering a cube!

Kong Application

Kong Application

I know it doesn’t look like much, but at this point, it’s more about how that cube is being rendered, rather than the impressiveness of the cube itself 😀.

Here is the code:

kong:v1.0

import gfx.sdl, gfx.basic3d, gfx.basic3d.node,
  gfx.basic3d.camera, gfx.basic3d.geometry,
  gfx.basic3d.material, gfx.basic3d.mesh

sdl.Init(sdl.INIT_EVERYTHING)

var width: 640, height: 480

var win: sdl.CreateWindow(
  'Hello, from Kong',
  sdl.WINDOWPOS_CENTERED, sdl.WINDOWPOS_CENTERED,
  width, height,
  int.bitor(
    sdl.WINDOW_SHOWN,
    sdl.WINDOW_OPENGL,
    sdl.WINDOW_RESIZABLE
  )
)

var b3d: basic3d.new(win)

var root: node.new('root')
var cam: camera
  .newPerspective(num.tau / 5, width, height, 1, 1000)
  .position(10, 10, 30)
var boxGeo: geometry.newBox(10)
var boxMat: material.new()
var boxMesh: mesh.new(boxGeo, boxMat)

root.add(boxMesh)

var done: false
do
  do
    var ev: sdl.PollEvent()
  while (ev != false)
    if (ev.type == sdl.QUIT)
      done = true
      exit
    end
  end
while (!done)
  b3d.render(root, cam)
end

boxGeo.destroy()
b3d.destroy()
sdl.DestroyWindow(win)
sdl.Quit()

If you don’t recognize that language, that’s because it’s my language 😀.

It took a lot to get to this point… and I still have a lot to go. But this is where I am today.

« Newer Page 11 of 12 Older »