Some Programming Notes

Some of the stuff I’ve run across in the last few months that I consider cool:

Emscripten is a LLVM-based C++ compiler that emits JavaScript code, specifically asm.JS. This is being used to try to bring Avida-ED to the browser, since Avida has a C++ codebase.

Speaking of JavaScript, since Diane has been using that as her primary language at work I’ve been picking it up as well. Tim Schmidt recommended JavaScript: The Good Parts as a resource, which so far seems like a pretty good guide to it generally. It is certainly an update on the venerable O’Reilly tome, “JavaScript: The Definitive Guide”. Once one starts to get further into things, one does run into a problem… which JavaScript framework should I use? JavaScript frameworks appear to be the mayflies of computer science. There are tons of extinct, abandoned codebases in this space. If you go by the number of StackOverflow questions, JQuery is the winner, and that would certainly indicate it isn’t likely to die soon. However, I’ve been attracted to the Dojo toolkit, another recommendation from Tim Schmidt. It seems more cohesive than JQuery in my limited exposure to each.

Something that seemed missing from JavaScript coding was a RAD (Rapid Application Development environment). Maybe there are a batch out there that I’m missing, but the one I was actually able to track down and make work was Maqetta. This does appear to fall into the realm of projects that are no longer active, but at least the tool is free and still functional as it is. It is pretty well tied into Dojo’s widgets (called Dijits). There are a few things that experience teaches about Maqetta. While I’m used to a RAD that allows doing whatever I want to the code, Maqetta tends to break down when trying to parse additions like HTML comments. It seems that Maqetta’s role is pretty much GUI design tool, and the plumbing should be left to the end of the design process. Another oddity is Maqetta’s insistence on “registered users”. All you have to do is provide an email address and associate a password with it. The email address does not have to work. In fact, Maqetta doesn’t even have a “lost your password” facility. You either remember it or you can write off your work on that project. And, by the way, it seems that Maqetta associates each login to a specific project, so you’ll just want to create new logins for each new project that you want. Maqetta has a handy “download project as Zip” button, which gets a zip file that can be deployed in a web server. What doesn’t seem to work is importing that zip file into a different Maqetta installation. There are definite flaws, but Maqetta is still a useful tool if you have a complex user interface to get laid out in a short amount of time.

I had done some mapping using Python and the Folium package. Folium is a wrapper for Leaflet.JS maps. Lately, I’ve been looking at more direct use of Leaflet, especially to allow me to use the “imageOverlay” function. That permits me to generate a graphic that a browser can load (say, in PNG), and overlay it on a map given the specification of latitude and longitude for two of its corners. I can also specify an opacity.

To get Python and JavaScript talking, I’ve also been looking at web micro-frameworks. A lot of people use and like Flask for this, but I’ve been finding that I am getting good results with CherryPy. I can contemplate deploying a Dojo application created with Maqetta with use of CherryPy for both static and dynamic content. Maqetta collects a bunch of JavaScript libraries and CSS in a directory tree, and it would be a pain to have to individually set entries for each file that should be served. Another approach would be to use something like PyJS to generate JavaScript, but much of what I want to do involves Python’s stack for scientific computing, including NumPy, SciPy, and Pandas. I think I am stuck with a client-server model in order to combine JavaScript web application UI work with a full scientific Python stack on the backend.

On the computational finance side of things, some time ago I scraped the Wikipedia page on the Standard and Poor’s 500 to get the listing of stock ticker abbreviations. That serves as the basis of the stocks I have some automated tracking tools operating on. I noticed that some of the ticker names in that list no longer get data updates. Companies change, and so does S&P 500 membership. A search took me to Pollock’s S&P 500 dataset code. I had to uncomment the line in the “execute” function in to actually download a file from the Standard and Poor’s website to get it to work. I wrote a few support functions so that if I ask for an S&P 500 list, it will check to see if the downloaded file is more recent than one hour, and if it isn’t it will update that. I can get either a Pandas dataframe with the ticker names and their ancillary financial data, or a simple list like what I’m already using in my other code.

The computational finance codebase I have is an excellent candidate for putting a JavaScript UI on. Currently, I don’t have a UI as such; it generates a PDF of the daily results. The Python script emits LaTeX markup which gets compiled into the PDF. The PDF would still be useful, but the interactivity of a UI would provide a lot more scope for features.

Wesley R. Elsberry

Falconer. Interdisciplinary researcher: biology and computer science. Data scientist in real estate and econometrics. Blogger. Speaker. Photographer. Husband. Christian. Activist.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.