Language SkinsPosted: December 17, 2011
One of the challenges I find with modern day applications is the broad spectrum of paradigms, styles and whatnot that need to be employed to get anything really serious done. You have input devices like multi-touch and Kinect. You have 3D as well as 3D graphics. Tons of file formats for audio, video, images, 3D models, it goes on and on.
I want to play with all of that stuff, and I want to make it all available to end users in a seamlessly coherant way. Tall order! One of the biggest heart aches I have as an aging programmer is that to use a lot of different tools, I have to shift “language sets”, which makes my brain hurt. It literally takes me months to learn a new tool, and with each tool comes less proficiency as I don’t have the years of experience necessary to have put in the 10,000 hours for mastery, and soon enough I need to learn a new tool.
What to do?
Banate CAD is moving right along in terms of features. I am currently adding the CSG operations, which makes this as complete as I need for now, and gives it a fairly solid base to grow on. There is another part that I need to focus on though. That is the “visualization” part of the program.
What do I mean by ‘visualization’? Well, in Banate CAD, it is a given that anything that is a 3D solid will be printable. That includes anything you can construct through CSG or other means, like importing an STL file. But, what about other stuff, like being able to simply view some images, on the way to applying them as a texture map on a model? Or perhaps throwing some text up there to show the dimensions of an object.
I also want to be able to visualize things like the network traffic of a service running on the internet. So, a live trace of packets would be nice, and then “stop motion” to get a 3D print that looks very interesting.
I have been studying a few books of late:
- Processing – Creative Coding and Computational Art
- Processing for Visual Artists
- Web Publishing with HTML and CSS
- Programming Interactivity
- Fonts and Encodings
- Visualizing Data
They’re all very good, and provide valuable insights as to how various things can be done to present data and allow users to interact with it. And of course, they all represent slightly different ways to achieve it, using different domain specific languages.
Well, I’ve settled on one language, and that is Lua. So, one of the things I’ve been doing is creating a “Processing Language Skin”. I essentially mimic the processing API using Lua as the base instead of Java. It’s a fairly straight forward process. As a guide, I’m going through the “Processing” book, and just coding up example after example. It’s been a good experience. It is helping me to further factor the Banate CAD codebase to separate, eliminate, and further consolidate the bits and pieces that are truly core and the same across multiple domains. I’ve introduced the Vector3D and Point3D classes. There is an actual difference between points and Vectors from a math perspective, when you start dealing with transforms.
My goal with the Processing Skin is that anyone can pick up a Processing book, and without much modification, they can type that code into Banate CAD and get something to show up on the screen, including interactive, and animation based sketches.
That’s great, as I’ll then be able to do some creative visualizations.
Another reason to add some more 2D primitives is because soon enough, I’ll want to pop up a simple heads up display so I can configure one of my designs. Basically, I want to call out the parameterizable parts, throw them up on the screen for the user to alter, take their input, and inject it into the design. While doing this, I don’t want to break the illusion of the 3D environment. I don’t want to popup a nasty native modal dialog box, nor have it hanging off the side. I want to take a page from the game programmers playbook, and do something very nice and realistic to the scene.
Lua is turning out to be a good language choice for this task. It can easily represent data in forms that either JSON or XML or DDL have been used for. It can easily represent markup as is typically found in HTML and other forms of markup. It can even represent relational data fairly easily, without much adornment.
It’s very nice to be able to stick to one single language paradigm. Lua allows everything from raw ‘C’ style coding, to more advanced OO programming paradigms. It encapsulates markup, data description, data transport, all in one single form. I don’t have to switch paradigms to go between domains. That’s nice for my slowly aging brain, and ultimately, it will be nice for users as well. Sticking with the “the end user can do everything the platform programmer can do”, makes for a very interesting model.
And one last bit, since Lua is an interpreted language, it’s fairly easy to box up code snippets and have them executed elsewhere, and some other time. This might be used to great advantage in some cases…