I'm really starting to love Lua. It's one of those languages that's so simple, you get a little miffed at its lack of basic constructs like switch(), until you realize that construct is just an abstraction of something simpler (i.e. a table of functions).
What I really like about it though is it's just so easy to integrate into a C/C++ program, and there are so many libraries available (which can be loaded at runtime) to extend it. There's one that gives you access to pretty well all of GTK. So I can do all the actual logic and heavy work in a C "backend", while handling all the GUI in Lua. It's like perfect MVC, and so easy!
I've been working on a 3D map design program, and the GUI code in C was huge and ugly. All I really had to do was strip it down to an interface through which Lua scripts can control the model and camera and save/load files, and let those scripts set up a GUI around it. So much cleaner and simpler. As a bonus, it being interpreted means you get a completely customizable GUI, and full-blown scripting/automation through those same interfaces.
And you just have to love replacing page after page of this:
Code: Select all
Button = gtk_button_new_from_stock(GTK_STOCK_CLEAR);
gtk_box_pack_start(GTK_BOX(Box3), Button, FALSE, FALSE, 0);
void cMainWindow_CamPosZero_Click(GtkButton *Button, gpointer Win)
MainWindow *_this = (MainWindow*)Win;
_this->Cam.SetPosition(0, 0, 0);
_this->NeedRedraw = true;
Code: Select all
this.ResetPosButton = gtk.button_new_from_stock(gtk.GTK_STOCK_CLEAR)
HBox:pack_start(this.ResetPosButton, false, false, 0)
MainWindow_SetCameraPos(this.MainWindow, 0, 0, 0)
(I need to rework that to make MainWindow actually an object; this.MainWindow:Redraw() makes much more sense... >_> and maybe SetCameraPos should automatically update the textboxes as well. Still a work in progress.)