|P is for Practical|
A different approach to generating a GUIby qbxk (Friar)
|on Dec 28, 2005 at 21:38 UTC||Need Help??|
So, this is a concept I'm toying with (and I think it can become quite sophisticated in time) - but besides the fact that I implemented it in perl (why not?) it has no other real association with perl, as it could be done with just about any language.
So the concept, which after several attempts is proving harder to explain in prose than I had imagined it would be, is essentially writing your GUIs in HTML/JS and wrapping your code (virtually any perl code) in a mini web server to communicate with it through your browser. With this approach you instantly have a 100% cross-platform, GUI app. As long as the user has a browser (that's compatible with whatever JS you need to use) they can get the GUI for your program. The possibilities are endless, it strikes me that this is probably a good approach for writing GUIs for code running on "embedded devices" as well.
The module I've written to encapsulate the heavy lifting of an approach like this I'm tentatively calling ServerApp (though, other suggestions are welcome) - it's posted in the code section, there's also a (primitive) testing suite that I have not posted... However, my first program using this as a foundation can be used as a font previewer, it wants for more features, but is cool as-is: FontPreview
I'm posting this to initiate a discussion on several things relating to this concept:
- is this a good idea?
- has this been done before?
- how can this be made more secure?
- I'm not a CPAN author (yet?), if this concept proves useful I would encourage people to assist me in bringing it to the repository
- Queries (GET/POSTs) to the ServerApp need to spawn new threads so that it can respond to several simultaneously should that need occur. I think there should also be an option to call your ServerApp->run_with() method asynchronously. I want to ensure that this is done correctly and portably (as one of the goals of the project is providing easy cross-platform GUI development), can I request some expertise in this area? (spawing threads/forking portably, etc)