There are a few goals of my language project. These aren't in any priority order, just in me jotting down ideas as they come to me:
- lightweight language, with a feel like C, with only a little bit of C++'s object-oriented features, without C++'s bulk.
- targeting platforms ranging from desktops (Linux, Mac, Windows) to mobile (Android, iOS) to the web (HTML5 / JS) to maybe crazy unreasonable stuff like the Apple ][
- primarily for writing games (interactive, graphical), but maybe command-line stuff is OK (server support?)
- should be fun to program in
- should be performant, but this isn't the highest priority. If I can achieve performance through tools, rather than by burdening the developer with decisions, that's nice.
- David Beazley's PLY (Python lex/yacc) http://www.dabeaz.com/ply/
- LLVMPY, a python wrapper around LLVM: http://www.llvmpy.org/
- SDL, a media layer for games: https://www.libsdl.org/
- Emscripten, a tool for taking C (and LLVM bitcode) and turning it into Javascript: https://kripken.github.io/emscripten-site
- gnu make (for now)
- python (because I like python, I do. I was going to say I write everything in python. Except this is about writing a language that isn't python.)
WIP, hopefully still around by the time you read this: http://bigdicegames.com/BDGRT/Pong/pong.html
One nice thing about the Pong test is that it's showing me what features I can live without, and what features are painful in their absence. I only had integer variables, and they were all global. This worked, but it was gross, so now I've been adding local variables and float support to the language.
As of this morning, I've got a little sample program that does a Fahrenheit to Celsius conversion using locally allocated float variables. There's a few pieces that I expect from local variables:
- declared in the function where they're used
- or, declared in a block (a chunk of code delimited by curly braces, contrasted with a basic block, which is something a little different inside the guts of the compiler)
- has a well-defined lifetime (it goes away when the allocating block is exited)
- initialized to something well-defined, by default
- can be initialized as part of declaration (float x=8.0; #remember, Mallory, x=8)
- scopes can nest, so a more-specific scope will have priority over a less-specific scope.
Also working is reading and writing local variables. I didn't list those, above. Not really variables if you can't assign to and read from them.
The rest of that remains to be done, and I'll post here as I get it working.
No comments:
Post a Comment