Writing Boring Code

I have bad news. Using Go as a shared library on Android 5.0 is simply not a good idea. In fact, it’s a horrible idea. Android 5.0 introduced a new runtime called ART. This replaces JIT compilation (Just-In-Time compilation).

If you don’t know, a JIT analyzes runtime heuristics and modifies the compiled program to run faster. JIT is one of the reasons you might see javascript outperforming C code on the DNA regex benchmark that’s been floating around for  years.

ART actually precompiles dalvik bytecode to native code and runs that native code in its runtime. As a refresher, when you write java code for android, the java code gets compiled to java bytecode and then gets transpiled to dalvik bytecode to run on the dalvik virtual machine (so no one has to pay oracle any cash).

Tangent, there’s a new experimental compiler for android studio (based on intellij) that compiles java 7.x source directly to dalvik bytecode.

But, the ART runtime is much like the Go runtime, and the two fight over things. For the most part, it works and works well. But, when you begin trying to load native code such as PublisherAdView for ads that load in chromium webview that loads native code, bad things seem to happen.

It is essentially a no-go. For pure Go projects as is the initial target, this is a non-issue. But, for integrating Go into a normal Java app, this is a huge blocker. I’ve given up on using Go for normal apps.

I’ve actually stopped using Scala as well. I like Scala, and programming in a functional language (i.e. Lisp like) has really taught me a few things I appreciate greatly. There just hasn’t been much uptake from the other android developer on our team. He’s much older than me, in his 60’s. He doesn’t have anything bad to say, he just doesn’t pursue it or have much interest.

I really can’t blame him. It’s not just Scala, it’s anything that becomes too involved that’s not well documented. He dropped an email about fixing some SQL entries in a 2 year old word game I wrote but mentioned he wasn’t sure how to build the project.

The issue was two-fold. First, there’s five different versions of the app; google, google pro, amazon, amazon pro, nook. Second, two years ago Google didn’t have tools to help with this kind of stuff. As of maybe two months ago, they finally have stable tools to help with this.

I wrote a Makefile that would build all the apps and collect all the apk files into a single directory. If you’re running OSX or Linux, as most developers on our team are, then it’s trivial to build. If your running Windows, you’re shit-outta-luck.

Another tangent, I found a make.exe command for windows a year back for a browser extension plugin I wrote that worked pretty well, based on the work done by the git-for-windows team.

Still, me giving up scala is actually more like paying respects to Go. One thing I’ve really come to embrace with Go is being boring. Boring works. Boring is readable by people other than me. Boring is quickly buildable by people other than me.

One thing I’ve been considering is the golang/mobile repo added a Dockerfile. It’s really neat, boots up ubuntu, installs build tools, android sdk, go, gradle (used in android studio to build projects), and builds your source code for you. What’s neat is now Docker is available for windows. Even bootstrapping android studio and android sdk with necessary requirements can be a pain. But saying “did you install docker.exe? great just run this file” is really boring and works. This works whether you’re a developer or not.

Hell, even if I’m not writing go code, it works. It works for developers, it works for build servers, whatever.

So I’ve gone back to Java, I’m embracing the boring. I’m also typing “public static void” a lot.

I like Go like I like functional programming. It’s taught me many things and it’s certainly worth review.

Advertisements

Fast Web Development with Damsel for Python

Time feels surmountable when looking forward. In retrospect, I see surmise.

My title to this post feels like a real plug piece, but I guess that’s what happens when you’re looking to get indexed. Recently, I tagged two new versions of dmsl in git. If you’ve never heard of dmsl, please go check out the README on github to see what it’s all about.

https://github.com/dskinner/dmsl

I started off implementing haml in python which gave way to a unique direction for the project. I’ve been using it quite actively in work and am continuously enamored with its simplicity and power. Of course I wrote it and there might be a sense of bias, but this isn’t the first or second or third or fourth attempt I’ve made to write something like this. Each of those projects were short lived in the same way that once they were mostly complete, they just flat out didn’t “have it” for me.

0.3-stable is a wrap up of features and fixes over the course of many months of use and has, in the end, proven reliable. This tag is available on github. There were still some annoyances in the code related to speed and the dependency on lxml though that I badly wanted to fix.

The speed issue was solely in the use of a class inheriting python’s Formatter to handle extensions to string substitutions. These substitutions alone could take three times as much of the time as the parser for the whole document. Granted, on a whole, this was still quite a bit faster then a number of template engines out there, but I felt this could be drastically reduced.

The second issue was the dependency on lxml. Simply put, I wanted that to go.

So recently I addressed these issues and tagged 0.4 in git. I’ve also made this tag available on pypi. If installing from pypi, the only dependency is a build environment and python headers for building the C extensions. If building from github, you will need cython 0.15.1+ installed.

0.4 also has another change with how context variables end up in the templates sandbox. Previously, these items were packed in a kwargs dict available to templates. In 0.4, this is no longer the case and those items are unpacked in the environment for use. Planned though is the ability to revert to the old behaviour as needed for upgrading older installs.

While I feel the changes in 0.4 are drastic, unit tests pass and I’ve upgraded my personal projects successfully to do a little stress testing while also using it in another upcoming public project with success.

So check it out and tell me what you think.

Line 6 UX2 and Linux

I originally wrote a bad/sad review about the Line 6 UX2 not working under linux as can be seen here:
http://line6.com/community/thread/17663

I was looking to sell it recently when I decided to give it another look over and try out the drivers done for the PodXT devices by someone as can be found here:
http://www.tanzband-scream.at/line6/

The 0.8.1 release failed to compile so i checked out the trunk of the development version
$> svn co https://line6linux.svn.sourceforge.net/svnroot/line6linux
$> cd line6linux/driver/trunk
$> make
$> sudo make install

To my surprise, it worked fairly ok. My line 6 ux2 device lit up and seemed ready to go. One of the first things I noticed was that there was a constant buzzing out of the right channel monitor. This was alleviated by simply plugging my guitar in. Next, I read through the docs to get some general info. I went ahead and fired up alsamixer, increased pcm output and zero’d out the monitor. Note: the docs say to set pcm output to zero as they can be much louder then the guitar monitor. I had no trouble with this when i increased output to 75, volume was normal.

So then I fired up jack and played around with a couple settings. To my surprise I was able to get latency down to 1.5 ms according to ardour (2.87 according to qjackctl)! Either way, this was much lower then I ever managed with my edirol which normally clocked in around 15ms and was littered with xruns that were very audible in the recording. Normally around 22ms I could achieve good sound with no xruns. After a short recording session, I noticed qjackctl had logged numerous xruns but I never heard a thing. Once during the recording, ardour disconnected from jack but this could be totally unrelated.

This is fine news indeed and prompts me to want to hold on to this device. The bad news is I have been unable to get the microphone inputs working. I haven’t had time to look into it fully but hopefully after exploring the line6linux docs some more, I can have some success with getting this working.

So all in all, this is great. What I would really like to see is Line6 spend a few resources on this project or doing something themselves. But that aside, hardware wise (i guess), this little bugger rocks!

js.js say whaa

whaa? oh, right. Well Ive dug in deep to javascript. Well sorta, and it was all in an effort to evaluate whether to use prototype.js or mootools. My choice? neither. Instead I’ll focus my energy on expanding the default object in my js.js file. I know, its totally unoriginal. But lets face the facts, its 488 bytes.

And hot damn its amazing what 488 bytes can do. You can check it out here:
http://js.dasa.cc

Ive placed it in the public domain and what not. I think the focus will be mostly on custom constructors and lettings prototype() paste it all together. And of course, it can just be a staging ground for continued explicit prototypal declaration. It just uses whats there, and thats pretty sweet.

Google Chrome, Os’, and Web Development

Ok so everyone, their mama, and her pet hamster have written an article about google chrome. Ive also read an interesting article that some-what theorizes on a google os based on chrome in the distant future. Only interesting b/c of what I have been planning to do.

First off, I read about people complaining over initial memory consumption of Google Chrome. I dont know why but I feel a need to state my opinion on the matter. What I care about most is a responsive system and chrome does that, short and simple. If i were to liken chrome to something id say starting an instance of google chrome is like typing

$> ls

at a command prompt. Its freaggin fast. Period. Running chrome nay interferes with most anything else i do. That is using it on a core 2 duo laptop with 2 gigs of ram and a amd64 desktop with 1 gig of ram. Just a quick statement of facts. Anyway, im not really interested in the distant future, what i AM interested in is the possibility of now. Honestly with very few modifications i would use chrome as a full shell replacement, on both linux and windows. Here’s my wish list,

  1. A better file manager
  2. the ability to launch local programs from the address bar
Ok so thats all i have for the most part. Frequently used programs, I could simply bookmark. Launching them from the addy bar would be very similar to what Ive always enjoyed doing on linux using the likes of katapult in the past and gnome-do nowadays (which does alot more interesting stuff). Ubiquity is a mozilla project that has a similarly driven concept of a type-into pop console to accomplish tasks (a little more complex than just launching a program). To accomplish this my local computer would need to be indexed or the standard entries for programs installed would need to be, but id prefer the first so i can search my computer for a file
local:[search-term]
anyone? I think alot of this couldn’t really be accomplished without patching some code (mostly the use of the addy bar).
As for the file manager, the builtin file manager is of the likes of firefox. just a point and click and launch scheme. An actual robust file system could be written as a local webapp. Chrome is like a staging ground for writing a new breed of applications as I see it, I actually just wrote something today to display an index of my movie collection and made a shortcut with chrome, works beautifully. Yes it runs in firefox and anything else for that matter, but would i ever use it in such? likely not b/c when i want to watch a movie, i want to click an icon and i WANT it NOW. I dont have all day to wait for something to start up. Well I do, but its a real buzz-killer.
Ok enough ranting. I am looking at chrome as a means to develop desktop centric applications (one of which is a music app based on the likes of the sndobj library that would allow multiple people to mix at the same time) and I think the best first place to start is to write a file manager and be able to bookmark applications i use and also index my local drive so i can search it. the urls wont be the prettiest with accessing 127. but it will do for now. Then on X startup or on windows startup, chrome is launched instead of gnome or kde or fluxbox or my beloved openbox which has always come to save my day in one way or another, or explorer.exe
Those are my ideas, I will be starting some of them soon and developing in python/cherrypy (unless theres due cause for something else) and then looking into investigating how to create a windows service. If anyones interested in collaborating, feel free to contact me.

WordPress, Blogspot

Ive only recently started blogging and there were two choices that came to mind. WordPress, which ive heard about and a rather famous blogging util, and blogger, which i once looked at many years ago and also integrates with my other google services. I figured i would give both a go and after a few hours of accumulative use, I decided i liked blogger best as i accomplished what i wanted more quickly. Unfortunately i noticed that nothing i posted in blogger showed up as a google search result, whereas my post in wordpress would show up as a first result, when typing in two keywords, overnight! Since my utmost main concern is access to my meager blog, I will be discontinuing my use of blogger but leaving it up incase it was indexed by some other service. Here is a Link to both blogs

https://dasacc22.wordpress.com
http://dasacc22.blogspot.com