From the looks of this blog the last few weeks, you'd think that I'd dropped off the face of the earth, but you'd be wrong. I've just been too busy to post. I took a week off for vacation, but I've also been coding quite a bit. I planned on doing a lot more while on vacation -- coding is fun for me -- but I ran into some problems which shot most of the time I could've spent writing code. Anyway, I'm in the process of retooling the code responsible for using project templates in order to make them more flexible. I've also been working on a couple of lessons. One finishes out the Translation Kit, but it's taking a *lot* longer than most lessons would because I'm in the process of learning the basics of writing a Translator and a support framework for writing them. Writing a Translator isn't hard, but it is unfamiliar for me.
Paladin's next release is now on the horizon. The new work on the template section will make more complicated possible, including one which is *this* *close* to being usable: a Tracker Addon template which should make writing them dramatically easier. There are some new command-line utilities which I've written that should come in handy. luare (lu-AR-ay), does regular expression search-and-replace without the mess that is sed. luagrep searches for text in a file, but only one file -- it's mostly meant to be used in combination with find. A text-based build system, pbuild, should make into the release. I've wanted to use a text-based build system for Paladin development, but I wasn't satisfied by any of them out there: make is weird and aggravating, scons is slow, jam has zero documentation, and many are just overkill. pbuild leverages full-blown Lua in a way that you don't have to write much to do basic tasks, but more complicated stuff is possible.
New to Paladin is a Find command which searches all project files and it works quite nicely. It'll be possible to search using regular expressions, but it will be using Lua's regular expressions. Lua doesn't do regular expressions quite the same as Perl or *NIX, but it's pretty close -- most of the differences are just few obscure uses. The boost in speed and simplicity are worth the change.
I haven't stopped writing, just slowed down because the work isn't as easy or fast as I'd like and I'm also trying to get most of the Paladin work for the release done before I have to go back to school. Have a great one, everybody!
Showing posts with label Lua. Show all posts
Showing posts with label Lua. Show all posts
Monday, August 1, 2011
Tuesday, June 14, 2011
Haiku, Meet Lua. Lua, Haiku
I've been pretty quiet since I got out of school last week. It's not because I've been too busy to do anything. Quite the contrary. I've had my head down in the trenches, hacking away. About six months ago, I posted a screenshot of CHaikuRun, a test application which interacted with the Haiku API from the C language. I have a new one:
On the outside, not all that different from the other one. Under the hood, though, the two test apps are worlds apart. Here is the source code:
That's pretty darn short, if you ask me. A graphical HelloWorld app can be written in 6 lines of code:
And I thought writing in C++ was easy. Yeesh. That beats everything I've seen under Haiku/BeOS except yab and quite competitive to something like wxPython. Then again, I could argue that this is a lot clearer than yab, but I digress.
The code snippets I've posted above are why I manually wrote Lua bindings instead of using SWIG. I'm not sure that I could have gotten SWIG to generate them in a way which has at least the same ease-of-use as the C++ API. I've still got a *lot* more testing to do and some more objects to implement before I can do a release, but this is definitely some progress and some good news, too. It's officially a good day now. :)
On the outside, not all that different from the other one. Under the hood, though, the two test apps are worlds apart. Here is the source code:
function LuaAppSetupFunction()
local win = MakeObject("PWindow");
win.SetProperty("Frame", PRect(100,100,500,400))
win.SetProperty("Flags", BQuitOnWindowClose)
win.SetProperty("Title", "LuaGUI")
local view = MakeObject("PView")
view.SetProperty("Frame", PRect(0,0,400,300))
view.SetProperty("BackColor", PColor(224,224,224));
win.RunMethod("AddChild", {view.id})
local label = MakeObject("PLabel");
label.SetProperty("Frame", PRect(10, 10, 350, 60))
label.SetProperty("Text", "Haiku, meet Lua!");
view.RunMethod("AddChild", {label.id})
end
RunApp("application/x-vnd.dw-LuaGUI", "LuaAppSetupFunction");
That's pretty darn short, if you ask me. A graphical HelloWorld app can be written in 6 lines of code:
function LuaAppSetupFunction()
local win = MakeObject("PWindow");
win.SetProperty("Flags", BQuitOnWindowClose)
win.SetProperty("Title", "Hello Haiku!")
end
RunApp("application/x-vnd.dw-LuaGUI", "LuaAppSetupFunction");
And I thought writing in C++ was easy. Yeesh. That beats everything I've seen under Haiku/BeOS except yab and quite competitive to something like wxPython. Then again, I could argue that this is a lot clearer than yab, but I digress.
The code snippets I've posted above are why I manually wrote Lua bindings instead of using SWIG. I'm not sure that I could have gotten SWIG to generate them in a way which has at least the same ease-of-use as the C++ API. I've still got a *lot* more testing to do and some more objects to implement before I can do a release, but this is definitely some progress and some good news, too. It's officially a good day now. :)
Thursday, June 2, 2011
Libcharlemagne and Paladin
Just a quick post before I head off to bed. :) While school has been as busy as typical this year, last week and this week (mostly this) have been spent with many moments coding. The results? Project-wide find and replace -- a long-needed feature -- and major progress on libcharlemagne. Most of this library work has actually been spent on writing Lua bindings for libcharlemagne. It's not there yet, but it's getting there.
Originally I was going to use SWIG to do it, but it's hard to have a nice API in a language using a generic wrapper. Some language features just don't wrap very well. On the up side, I found out just how flat-out easy it is to call C from Lua. It's almost scary how easy it is. Current code in writing is to turn tables into libcharlemagne's generic data container and vice versa. Hopefully it won't be *too* long before I can post the source for a Lua script that uses the GUI and make a testing release. TTFN
Originally I was going to use SWIG to do it, but it's hard to have a nice API in a language using a generic wrapper. Some language features just don't wrap very well. On the up side, I found out just how flat-out easy it is to call C from Lua. It's almost scary how easy it is. Current code in writing is to turn tables into libcharlemagne's generic data container and vice versa. Hopefully it won't be *too* long before I can post the source for a Lua script that uses the GUI and make a testing release. TTFN
Sunday, March 6, 2011
Automatic for the People
It's amazing how sometimes an idea hits me. It dawned on me this past week that much of the work I've been doing on libcharlemagne is grunt work. The code file for the PTextView text editing object is literally like 1000 lines long, far longer than most files that I write, and a large portion is stuff that is repeated with very little variation. In a matter of a few nights and a massive codefest yesterday, I've got the majority of a Lua code generation script which will automate most of the work for the different GUI controls. This is a good thing -- already I've found more than a couple bugs in a couple files just while reviewing them for work with the script. All that's left is the code for generating an object's methods -- tricky, but it should be doable with some thought. The more I work with Lua, the more I wonder what other tasks it might be useful for. Who knows? Perhaps PDesigner might end up as a visual designer with the ability to embed Lua code or something. Interesting thoughts for a pleasant Sunday night after a relaxing day. :)
Tuesday, February 22, 2011
More Progress on Code Lookup
I finally came upon a term for the new Paladin feature that I've been doing R&D on the last couple of weeks: Code Lookup, which will look up code definitions for enumerated types, methods, and more using a database from header files. I'm getting better at hacking Lua, though I would still call myself a novice. I rewrote the parser using a more structured, less hackish approach, and I've managed to make it work pretty well. Considering that I've never delved into this particular realm of computer science before, I'd say that I did OK. It sits on top of the luasql engine at the moment, which needs some more work. Once I've gotten it working properly under Ubuntu, I'll be migrating the project to Haiku. From there, integrating Code Lookup into PalEdit shouldn't be too difficult. I'm not wild about adding more dependencies, but I can easily see greater use of Lua with the Paladin suite because of its flexibility and ease of integration with C/C++. I can't wait until this gets to the point where I can use it under Haiku.
Subscribe to:
Posts (Atom)
