Killa: a new scripting language for Love 0.8.0

General discussion about LÖVE, Lua, game development, puns, and unicorns.
User avatar
_ex_
Citizen
Posts: 65
Joined: Thu Dec 08, 2011 2:59 pm

Killa: a new scripting language for Love 0.8.0

Post by _ex_ »

UPDATE 04/2013
I'm working in the 0.3 version of my language, making Killa a bit more JavaScript-like
updated the latest version with a port of Notch's minecraft4k.js demo: http://jsdo.it/notch/dB1E

Image

The code is pretty much similar to the JavaScript one, so I think I'm getting closer where I wanted:
https://bitbucket.org/ex/love/raw/7fe5e ... raft4k.kia

however the performance is poor compared with Canvas and Flash due to the time spent going from the script side to the C++ side,
Flash has a Bitmap data structure that helps a lot, I'll see what I can do for Love-Killa, using shaders for everything is not my thing,
I want this engine to be used by kids :D
Also because playing with pixels on the screen was very fun and the foundation of the Flash 3D engines before Stage3D.

For Windows there is a pre-built executable. If you need more details, please comment here.

UPDATE:
Hello, I've updated the engine to use the latest version (0.2) of my language Killa. Some highlights:
- Bitwise operators. They are implemented as VM opcodes and are one order of magnitude faster that Lua 5.2 bit32 library functions.
- Many bug fixes and little improvements like:
- Python-like multiline strings
- All the string and table functions are now using index base 0 instead of 1. Test scripts added.
- Fixed bugs with references and compound operators.

Image

Overall this release is a lot more stable than the initial release, I have been using Killa to solve Project Euler problems:
http://elrinconde-ex.blogspot.com/2012/ ... ed-in.html
I was able to beat Python in performance using bitwise operations:
http://elrinconde-ex.blogspot.com/2012/ ... t-lua.html
There is minimal documentation in the Github wiki but it needs lots of work. I'll work on that later, I'm just adding samples and test cases by the moment, but you are free to ask anytime.
About the future, I'm going to work in making my language more like TypeScript and removing parts that I don't like from the original Lua source code base to improve speed and game development time (in example native vectors, matrices, classes, mem-arrays, etc).

ORIGINAL POST:
I found Love and decided to use it for prototyping but no matter how hard I tried Lua always feel weird for me, not in the core I mean, Lua is a beautiful language, but is only that I prefer C-like languages, so I decided to change the syntax of Lua and integrate it with Love for a personal project of mine.
Right now the virtual machine has not changed but I suspect changes are likely in the future.
By now most of the changes were done in the Lua lexer and parser.

The repository is in : https://bitbucket.org/ex/love

This time only windows supports due to my laziness (sorry). Support of other platforms must be only a matter of updating the respective projects.

By default the executable loads the "game" folder where my simple tetris clone port is located:

Image

I'm preparing a post with more information but in resume the main differences between Killa and Lua are:

- Killa (moon in Quechua) is a language based in Lua 5.2 (think in Lua with a JavaScript-like syntax)
- Killa requires variable declaration (no more silent typo errors)
- Local variables and local functions are default, global symbols require the "public" keyword.
- Array tables start with index zero (no 1, so Dijkstra is finally happy)
- JavaScript like blocks: for, while, do. (missing switch)
- Ternary operator: (x != null)? doThis() : elseDo()
- Assignment operators: +=, -=, *=, /=, %=
- Use "this" instead of "self"
- Use "::" instead of ":" due to JavaScript labels and gotos. This can change in the future, I want to get rid of it and use default methods for objects.

Also Killa is not JavaScript, because no matter how much flair JavaScript is getting right now, it has very horrendous parts, so I was aiming for the "beautiful parts" (TM)

- Blocks require the braces, they are not optional (you'll have to type two extra characters now, the madness)
- Killa require variable declaration, the "global" symbol is required to access global objects.
- Lua variable scope (no JavaScript hoisting, no need to declare everything at the beginning of functions and must declare before use)
- No arrays (by now) only Lua tables
- No switch neither exceptions (by now) also the prototype mechanism is missing (and I don't think I'll add it later)
- No ++ -- operators (they are not coming, many reasons, most important I'm not that smart to decipher quickly the one liners I have seen in real life)
- Lua Multiple assignment and return values
- Lua coroutines
- Lua powered for fast embedding and small footprint (this rocks) :D

There a lots of things I want to add to Killa (arrays, classes, vectors, matrices, etc) but I think this version is already in a point to make it public, and hopefully find users interested on it.

Thanks!
Last edited by _ex_ on Sun Apr 21, 2013 7:36 pm, edited 6 times in total.
User avatar
josefnpat
Inner party member
Posts: 955
Joined: Wed Oct 05, 2011 1:36 am
Location: your basement
Contact:

Re: Killa: a new scripting language for Love 0.8.0

Post by josefnpat »

I'm looking at the brunt of this commit: https://bitbucket.org/ex/love/changeset/89b38b074709

It's big because its a fork, but I don't see any source changes other than
  • platform/msvc2010/love.vcxproj.filters and
  • the binary file platform/msvc2010/app.rc.
Did you forget to hg add the source you changed?
Missing Sentinel Software | Twitter

FORCIBLY IGNORED.
<leafo> when in doubt delete all of your code
<bartbes> git rm -r *
<bartbes> git commit -m "Fixed all bugs"
<bartbes> git push
User avatar
_ex_
Citizen
Posts: 65
Joined: Thu Dec 08, 2011 2:59 pm

Re: Killa: a new scripting language for Love 0.8.0

Post by _ex_ »

I was working locally but i had problems trying to merge with the master
I'm new to mercurial and maybe I did something wrong so I think I corrupted the local repo,
so I created a new copy and passed my changes there.
I thought my changes were merged with the master.
I'll re-upload later today because I think the current repo is a mess.
Last edited by _ex_ on Mon Nov 05, 2012 1:01 am, edited 3 times in total.
User avatar
Inny
Party member
Posts: 652
Joined: Fri Jan 30, 2009 3:41 am
Location: New York

Re: Killa: a new scripting language for Love 0.8.0

Post by Inny »

How do you handle the upvalues in closures with the local-by-default behavior? In python, they had to go with the nonlocal keyword (see PEP 3104. Javascript went with undefined-by-default behavior and forced the var keyword so that the scope is apparent for all variables and closures.
User avatar
_ex_
Citizen
Posts: 65
Joined: Thu Dec 08, 2011 2:59 pm

Re: Killa: a new scripting language for Love 0.8.0

Post by _ex_ »

Inny wrote:How do you handle the upvalues in closures with the local-by-default behavior? In python, they had to go with the nonlocal keyword (see PEP 3104. Javascript went with undefined-by-default behavior and forced the var keyword so that the scope is apparent for all variables and closures.
Yes that is a known problem with closures and default something languages, Lua has default public that simplifies the implementation.
But Killa requires declaration and the variable scope is given by the position the declaration is done.
What I was trying to say was that Killa has default private declarations, so:

Code: Select all

var x = 0
it's the same as:

Code: Select all

private var x = 0
User avatar
_ex_
Citizen
Posts: 65
Joined: Thu Dec 08, 2011 2:59 pm

Re: Killa: a new scripting language for Love 0.8.0

Post by _ex_ »

josefnpat wrote:I'm looking at the brunt of this commit: https://bitbucket.org/ex/love/changeset/89b38b074709
Did you forget to hg add the source you changed?
I updated the repository, you can review the changes to the engine here: https://bitbucket.org/ex/love/changeset/be78fc95f023
User avatar
MarekkPie
Inner party member
Posts: 587
Joined: Wed Dec 28, 2011 4:48 pm
Contact:

Re: Killa: a new scripting language for Love 0.8.0

Post by MarekkPie »

Long time no post!

Have you checked out Moonscript? It seems to be based on Coffeescript syntax, but just from a cursory view it seems to have some similar intentions as Killa.

I saw you on the HaxeNME forums a while ago. Is that your main language, with Lua simply for prototyping?
User avatar
_ex_
Citizen
Posts: 65
Joined: Thu Dec 08, 2011 2:59 pm

Re: Killa: a new scripting language for Love 0.8.0

Post by _ex_ »

Hi MarekkPie,
yes, my studio has decided to go full force with NME.
Killa is more of a personal project of mine, I also use cocos2d-x, yesterday I integrated Killa on it, it was a bit more involved because I needed to modify a bit tolua++ but Killa is working in there right now :D, so I'm able to test Killa on iOS and Android, I think Killa (or Lua) is good for prototyping and have fun :D.
About MoonScript I didn't like the syntaxis, I would go with Lua if I liked that style of code, I was more interested in Bright that was a C-like Lua but it was never published. There is also Squirrel but there are few game engines using it (I have only evaluated one)
Killa allows me to use any engine that already support Lua 5.1 with my own language.
Last edited by _ex_ on Thu May 24, 2012 4:56 pm, edited 3 times in total.
User avatar
YellowAfterlife
Prole
Posts: 29
Joined: Mon Jan 23, 2012 4:05 pm
Contact:

Re: Killa: a new scripting language for Love 0.8.0

Post by YellowAfterlife »

Hey, this is really and really cool.
I am working with both Lua and JavaScript, and things like assignment operators or C-like for() structures always feel missing in Lua.
Few suggestions:
» Maybe leave "lua for" structure as comma-separated, rather than "to" operator?
Technically for-each loop in JavaScript acts like pairs(object) in Lua, so it looks strange.
For C-like languages symbol operators seem to be more common than alphabetic overall.
» Add an alias "->" to "::". Shouldn't be hard to implement, and would add option to make code look more logical from C++ class-based point of view.
» Add a automatic 'tostring' type coercion when adding values to string (anything + string = string in JS).
Maybe make it try calling '::tostring()' method of objects if present - then you'd have
» Make so that 'this' outside of methods references variable container, similar to 'this' in global scope of javascript pointing to a DOMWindow object.
This would add a JS-like option for variable access being

Code: Select all

this.variable = value
instead of standard "var" declaration.
» Add an alias "[]" to "{}" for 'linear' metatable declaration

A question - how are you going to add standard classes with methods without prototypes? These make sense in JavaScript by having all functions and default variable values defined in their prototype, and object only holding actual local values. Perhaps Lua-like libraries (i.e. "array.indexof(myarray, element)") would be more appropriate?

Also found an oddity: you cannot use already declared variables in for-each loop:

Code: Select all

var array = { 1, 2 }
var k, v
for each (/* var */k, v in pairs(array)) {
	print(tostring(k) .. ' = ' .. tostring(v))
}
Unless commented "var" is inserted, Killa alerts that "var" is expected near k, despite of k already being defined in scope.

So overall, looks lovely so far. I'll try making something with this in next few days.
yal.cc
Contains things I work on. Also gets Love2d examples time to time.
User avatar
_ex_
Citizen
Posts: 65
Joined: Thu Dec 08, 2011 2:59 pm

Re: Killa: a new scripting language for Love 0.8.0

Post by _ex_ »

wow thanks for your feedback!

I decided to go with for each (var k = 1 to 5) because in many languages I don't know if the for includes the upper limit or not.
ie: ruby ... .., haxe .. , python range, Lua is inclusive, etc, etc. I need to check the manual every time I need to change languages.
At least in C++/JavaScript you see the k <= 5 an there is no place to error.
So when I was looking that Lua for I decided to use "to" because I feel it seems to convey the range inclusion.

The "::" I don't like it either, I need to remember if it's a simple call or a method every time, "::" is indeed borrowed from C++, and I prefer it over '->' because I feel declaring my functions with function Table->methods() looks weird but look OK with "::" both as a declaration and call if you think they are static C++ functions. But anyway "::" is in my list of deletion when classes are implemented. They are just syntactic sugar in Lua.

Automatic coercion can be useful, I love that from AS3: trace("x: " + x)
but the only place I used it is there: logs, because it can abused in regular expressions and things can go messy like in JavaScript or don't speak PHP. I don't want messy conversions, so I would need to check no bad practices are introduced in Killa with that, also it would increase the complexity of Killa (even if a little). Right now .. seems to work fine for me even when I was planning to do exactly what you want at the beginning but I ended liking the separation of addition vs concatenation in my example code.

hmm not sure about the "this" outside blocks. Any pattern that you could gain with that? I'd prefer declaring my variables

Arrays are in the TODO list

Classes are going to be like AS3 or Haxe if you know them (think Java). No JavaScript like prototyping. I'll leave the metatables mechanism if prototyping is your thing.

Lua fors create the variable behind the scenes, the for each is just a Lua for and I felt the language was not honest about what it was doing and forced to declare the var because that is what is really happening, I plan to integrate the fors in the future and add support for not creating the variable if you don't declare the variable but right now they work just like Lua.
Last edited by _ex_ on Tue May 08, 2012 5:57 pm, edited 1 time in total.
Post Reply

Who is online

Users browsing this forum: No registered users and 48 guests