Posted: June 7th, 2009 | Author: irv | Filed under: android, java, Programming | Tags: ast, compiler, descent, difficult, executor, Interpreter, mides, PHP, recursive, top-down | No Comments »
For the past couple of months, I have been struggling to write a PHP interpreter for an upcoming Android version of Mides. The tokenizer was fairly easy, building the Abstract Syntax Tree was relatively uncomplicated, but now we come to actually writing the executor. This is giving me pause.
I totally understand why Joel Spolsky says that there are two classes of programmers, one class that sort of hacks their way through life, and another that writes compilers for fun. I guess I am trying to blunder my way into the latter class. At first, it didn’t seem to be so difficult, but eventually it has gotten so hard that sometimes I feel like just dropping the whole thing entirely. However, when I feel like bashing my head into the desk, and / or throwing my MacBook Pro out a window, I know I am on the right track. That is how I felt when I was trying to learn Java and Objective-C a few years ago, or attempting to understand domain modeling as it pertained to Object Oriented Programming, before understanding Object Oriented Programming.
I guess these are just things that we all must get through, I also see why most CS majors don’t every actually finish their compilers. I, however have a dream that I can develop web applications without being encumbered by any sort of connections from my handheld.
The first part that slowed me down was that I was trying to approach the executor by compiling the program to opcodes and then running them against the system, sort of like the asm function in C. That won’t work with Dalvik, at least not in an elegant way. Then I asked this question on StackOverflow, and the answer made me think; I don’t think I quite got it immediately, but now I understand. It basically comes down to a large hashmap of keys ( variable names ) and their values, ( the statements to evaluate into them ). OK, I get that, but the new problem I am facing with the top-down recursive descent parser is how to handle classes and functions efficiently.
I guess what I am understanding is why PHP has taken more than a couple years or more to get where it is today, why Ruby still has quite a few oddities to the language, and why Python basically needed a complete rewrite for version 3. This is not easy stuff, but nothing worthwhile is. I have never considered the possibility that this may not fully work in any practical sense. When I do release the Android Mides, the PHP parser functionality is likely to be beta. I did look at the code once for Quericus, but without some sort of object diagram, I can’t really understand what I am looking at. Much of the code is mixed up with the server code so it is difficult to figure out what is doing what. I have read a few pages of the Mak book and I’m thinking about buying it just to see how he implemented the parser, but I am not sure it will do me any good.
I may consider creating my own language for use with Mides, and then compilers that generate PHP and Ruby source code from it while I work on versions for Apache, Nginx, etc… In lots of ways I think it would be much easier, and I could offer type checking and other things from compiled languages that help build more robust code. I would maintain the PHP documentation that is present in Mides, and naturally you could FTP up the code to your server and test it there. But I think that would be copping out, and I don’t like to have something like this beat me. I do however have to realize that PHP wasn’t built in a day, and that this process will not happen immediately.
I keep asking myself what would Steve Jobs do, and the answer I keep coming up with is that he would go his own way, well I’ll keep stewing on it, and hopefully the end result is that I will become the sort of programmer that Joel would want to hire, although somehow I doubt I could ever achieve that level of software engineering excellence .
Posted: May 7th, 2009 | Author: irv | Filed under: android, iPhone, java, mides, PHP, Programming | Tags: android, IDE, Interpreter, iPhone, mides, parser, PHP, Programming | No Comments »
For the past few weeks I have been working on writing a PHP interpereter for Mides. As I know that I am not allowed to do it for iPhone, as it would involve downloading and executing scripting code, which is not allowed. I have only been looking at the tokenizer for the iPhone, while I have been looking at the full monty for Android.
I actually have gotten to the point where the tokenizer is passing a lot of my tests, but there is a lot of ground to cover with PHP. Tommy Carlier’s blog on writing a parser has helped tremendously. Still, even after getting the tokenizer working, I have to write an interpreter to execute the tokens. This involves implementing the many methods that PHP has built in, so it will be a while until I get that completely done.
I am pretty frustrated with Mides for iPhone, actually, I wanted it to be a full PHP implementation and editor, but until the Terms and Conditions change it isn’t worth the effort to build an entire PHP interpreter just to have the app rejected. I am still improving the iPhone version, and the next update should be a huge improvement over what is currently there. I had to remove the nesting because I need the memory for documentation search as well as the PHP tokenizer that I am working on. Overall, the next update for Mides will make it better, it will be close to what I was hoping for, but it will never be completely what I was hoping for on iPhone.
The Android version of Mides on the other hand is shaping up nicely. The Android text view supports color so I have some syntax highlighting happening which doesn’t hurt performance on the G1 too badly. The tokenizer is mostly done, and now I am designing the interpreter. Development on Android is going a lot faster since I don’t have to worry quite as much about memory leaks, although if you try you can still make them happen.
At any rate that is why there haven’t been any updates for Mides in a while, I have been working on localization, parsers, and interpreters. I am spending most of my time on the iPhone version of Mides, but it seems that I am getting farther with the Android version, go figure.
Posted: February 23rd, 2009 | Author: irv | Filed under: android, Companies, Google, java, Programming | Tags: android, floating point, fourier analysis, FPU, g1, Google, GPGPU, GPU/CPU | No Comments »
There are a lot of cool things about the G1, but most people don’t talk about he hardware very often. It has a pretty snappy CPU, a good amount of RAM, and expandable storage. The coolest thing about the CPU is that it is a CPU/GPU dual-core combo unit. That gave me some ideas.
I know that Apple is working on their OpenCL that will allow applications on Mac OS X Snow Leopard to leverage the GPU for tasks that use it to advantage, like say floating point math, etc… It abstracts away all of the lower level coding that one would normally have to do for this type of functionality. Nvidia has some APIs for this type of programming, and I believe that Intel does as well. But one of the spaces where I see this as being especially beneficial is in the mobile space for phones and the like. The reason is simple, there is usually no math coprocessor like their x86 counterparts, and while most software doesn’t use it, others, like say speech recognition and image processing could get a huge boost out of it, and at a modest power cost.
What would be awesome is if Qualcomm published some sort of GPGPU language or spec to the Android foundation, and that made it’s way into the Android framework. Then when the GPU wasn’t being used, or when it was being used lightly, it could be used by code in the way one would spawn a thread to be run, but instead of running in the main CPU it could be run in the GPU, and free up the CPU to spend time doing something else.
I’m sure this has already been thought of and discussed by the Android brain trust, but it just occurred to me, and it would be 100% awesome if it made it into the framework.
Posted: February 18th, 2009 | Author: irv | Filed under: android, Apple, Companies, Google, iPhone, java, Programming | Tags: 2.2.1, android, Apple, firmware, HTML 5, iPhone | No Comments »
Today I as looking into using HTML 5 databases on Android and iPhone. It turns out that the Android browser doesn’t seem to support window.createDatabase at all. It may be that it does work with Gears or something, but I didn’t try it.
What I did find, when enabling the developer menu for iPhone Safari was that in the 2.2.1 firmware, a user can view the databases that are currently stored on their device in the web browser by domain and delete them.
In the detail screen, it shows you how much data is currently stored in it, and it has a max, which appears to be stuck at 5 MB. I wonder if Apple has plans to improve the mobile Safari dev environment to allow for richer web applications at some point in the future when the AppStore revenues have died off a bit.
Actually I did figure out that the G1 uses gears, so I guess they are equal, but gears doesn’t seem to care too much how much space I can use. I haven’t tried the WorkerPool, or the local caching stuff, but I found another blog where the guy had an icon on his screen for a web-app.
Posted: February 16th, 2009 | Author: irv | Filed under: android, Companies, Google, java, Programming | Tags: android, g1, Google, t-mobile | No Comments »
Yesterday I got the T-Mobile G1. I’ll be putting it through its paces as I work to port Mides IDE to it. So far, so good, however ido have to say that I’m a little slower with the physical keyboard than I anticipated. I’ll be glad when the cupcake firmware comes out and I can use the virtual keyboard.
The apps so far are mostly good, the device is definitely quicker than the iPhone as far as raw hardware performance, but the navigation around the OS is a bit slower. Still, I’m excited to see what I can do with this SDK.
Overall I’d say that the philosophy of the device is different. The G1 and Android are definitely aiming to be a little computer in your pocket, while the iPhone is still an iPod first, which makes it more of an internet appliance than a computer. As such, it makes a direct comparison challenging at best.
The G1 is ugly, and Android is unpolished, but for a company that doesn’t make music players, it is pretty good. More importantly, it fits in better with my way of thinking, and I appreciate the freedom that Google and T-Mobile have given us. Hopefully it will continue to improve, but either way I am pretty happy with it. Hopefully Mides will turn out to be as good as it is in my head for the G1, and eventually the iPhone. Competition is a good thing.
Posted: January 5th, 2009 | Author: irv | Filed under: java, Programming, Uncategorized | Tags: java programming | No Comments »
Why I Will Never Specialize
I realized a few weeks ago that I had left behind the concept of being an expert in any particular language. Not that being an expert is all bad, however the pace of change in software development makes it impractical.
For a while now my interviewing ( candidates ) has changed to reflect that belief. I frequently get into constructive arguments with my hiring managers about the types of resumes they are sending to me to screen. The problem isn’t that they aren’t qualified, the problem that I see is that they are insanely qualified. Meaning that they have for example 20 years of Java or something with no hint of other languages, or techniques. I mean how many awesome programmers have you met that had never deployed their own PHP server, or their own tomcat server. How many programmers have had no experience with shell scripting.
Actually a red flag for me is someone who has never even looked at what Microsoft has to offer. I don’t use Microsoft technologies, but I have worked for companies where I did, and I stay as informed as possible about their various languages and APIs. The reason is because I am interested in programming, not in making a bunch of money ( even though that would be nice ) or finding a cush job to lounge in. I really want to understand what is happening inside of the compiler, etc…
I don’t have anything against people who specialize in one language. That is the way people hire, the reqs always are asking for 10 years experience in Java or some truck like that. I would prefer the req say, and they do when I have control of them, 10 years of programming experience, which means you could be 18 or 75, its all the same to me. The best resumes are the ones where the person has just about every language, with one at around 8 to 10 years of experience, but lots of side projects in everything from lisp to sed and awk. It is probably hurting my chances of getting ahead in my career, but that doesn’t matter, that I won’t just stick to one thing, but I really want to understand this, I want to know how it all works, and I want to have a part in making it better.
It probably means that I am a freak.
Posted: December 31st, 2008 | Author: irv | Filed under: Apple, ColdFusion, Companies, java, Programming, Uncategorized | Tags: apache, apxs, build, ColdFusion, connector, java programming, OS X Server, xserve | No Comments »
Installing ColdFusion MX 7, and the Apache Connector on Leopard Server (10.5.5)
This weekend, I spent an unpleasant 24 hours or so working on upgrading a client’s server to Leopard 10.5.5. The actual Leopard upgrade went pretty well on the G5 XServe. The secret to that was having a crossover cable, and knowing the specific RackMac system identifier to be able to get the IP address to SSH into. The problems started with ColdFusion.
Now I am going to rant. My client has an Enterprise license, so we aren’t running on some hacked up installation, we are running a major OS that has been on the market for about a year, it has been in the hands of developers for more than a year. That there isn’t a proper connector bundled with the installation is criminal. If I wanted to go hacking around inside of source code, building crap, I could run open source. Why did we pay so much money for this? I will not write any more private applications with ColdFusion. If a corporation wants me to build ColdFusion applications, I may, but only after I try to convince them to go with something that is more likely to be supported on UNIX / Mac OS X.
I mean, how long has Apache 2 64-bit been out there, this shouldn’t come as a surprise to Adobe. I can’t trust that they will support major platforms going into the future. This is because of one or both of two things. The first possibility is that Adobe doesn’t want to put money into ColdFusion because it is dead or dying, the second is that Adobe wants to force people to upgrade to ColdFusion 8 by any means necessary. What Adobe has done is to make me look bad in front of my clients for choosing a technology that was not supported. I have already begun to write my applications in RoR, now I am definitely going to write my applications in RoR. I am done. I could have made so much more money writing code instead of screwing around with compiler flags.
The problem is that I would expect to run into trouble installing or running my software when using OSS. That comes with the territory, but when you buy software and it claims to support the platform, one would reasonably assume that the platform would be fully and actively supported. Anyway, rant over.
Now I will show how I fixed the problem:
If you have a standalone installation (the only one that works), you will need to start it by switching to your ColdFusion directory, if you followed the defaults, it will be /Applications/ColdFusionMX7/runtime/bin. You will need to issue the JRun command from here ./jrun -start coldfusion. This will work, if you try to start it any other way, you will get the THIS_PROCESS_HAS_FORKED errors.
If you have installed it in multi-server, you are screwed, I have not found any decent way to get this to work.
You should be able to get to the administrator on http://127.0.0.1:8500/CFIDE/Administrator/index.cfm. Then you will need to set up the connector, this was crazy. The solution I am about to post I found on Scott Pinkston’s blog. The post is called ColdFusion 8 Leopard with apache an answer for the rest of us. It is generally for CF 8, but it will work on ColdFusion MX 7.
Here are the steps from his blog:
go to terminal window.
unzip -d src wsconfig.jar
apxs -c -Wc,-arch -Wc,x86_64 -Wl,-arch -Wl,x86_64 -n jrun22
mod_jrun22.c jrun_maptable_impl.c jrun_property.c jrun_session.c
platform.c jrun_mutex.c jrun_proxy.c jrun_utils.c
apxs -i -n jrun22 -S LIBEXECDIR=/Applications/JRun4/lib/src/connectors/src/
Now run the connector configuration:
sudo java -jar /Applications/JRun4/lib/wsconfig.jar
After it finishes, run this command:
cp /Applications/JRun4/lib/src/connectors/src/mod_jrun22.so /Applications/JRun4/lib/wsconfig/1/mod_jrun22.so
sudo apachectl restart
The order of the files to be compiled is *IMPORTANT* I was working on a Dual-G5 2.3 GHz so my command was /usr/sbin/apxs -c -Wc,-arch -Wc,ppc64 -Wl,-arch -Wl,ppc64 -n jrun22 mod_jrun22.c jrun_maptable_impl.c jrun_property.c jrun_session.c platform.c jrun_mutex.c jrun_proxy.c jrun_utils.c.
You will get some warnings, you can ignore them. If you get an error saying something about functions that start with an underscore in your apache error logs, when you try to start it, you have the file names in the wrong order. If you see an error that says it found the module, and it is mach-o, but it is the wrong architecture, you are probably using -WI (I as in imitate) instead of Wl (l as in Larry).
Make sure to add the add handler to your httpd.conf. in the ifmodule for mod_jrun22.so. Mine did not install this by default, so my ColdFusion templates were coming up with the code showing up as plain text. Here is the default handler: AddHandler jrun-handler .jsp .jws .cfm .cfml .cfc .cfr .cfswf.
I hope this prevents anyone from going through the ridiculous configuration nightmare that I went through this weekend. I apologize for the rant, but I have some other cool projects that I would rather work on than spending forever hacking around with my application server.
Posted: December 29th, 2008 | Author: irv | Filed under: Companies, java, Programming, Sun Microsystems, Uncategorized | Tags: java programming, sun companies | No Comments »
What Does a Sun Bankruptcy do to Enterprise?
For more than a few weeks now, I have been pondering some broad implications of companies that we all rely upon failing. Probably the grand-daddy of these is Sun Microsystems.
Normally I wouldn’t be concerned about tech companies going away. It is part of the normal advancement of the art, but in Sun’s case, it does concern me. While I don’t share many developers’ blind love of Java, or Solaris, or any product really. I do feel that Sun has given a tremendous amount to the software engineering community and would be sorely missed if they were to go belly up. At the time of my writing this, Sun’s stock is at $3.41 per share, and their market capitalization is 2.52 Billion, less than Sun has on hand in cash.
I don’t necessarily think that Sun is in financial trouble, but it does seem that there are a bunch of products that they release that are mostly not for pay. Not to mention that their financial performance may / should, be giving some corporate IT departments pause as to their dependence on their technologies. Many companies rely on support from Sun, and if that were to transition to the community, the level of response may not be sufficient. The question I would ask is, “Will a Sun Bankruptcy Drive Corporations Back to Microsoft?”
Unfortunately, I can’t see any other alternative at the moment. There are millions of lines of code out there written against the Sun JVM, and while the JVM is now mostly open source, and so is Solaris, the companies that count on those lines of code typically are not interested in maintaining that code as well. Without Sun, you could have JVM forking, Solaris forking, etc… where a particular application written against Java or Solaris may not run in a given company. Corporations would have none of these problems if they used the .net stack for application development.
Now, I am not advocating that all corporations out there should drop their Sun implementations and run to Microsoft, but what I am saying is that they should prepare themselves for a little instability. I tend to use Ruby and the Rails framework for most everything anymore, but I have come to be somewhat skeptical of the gems that I am using. I am also aware that there is currently no support beyond community support for most of these items, and the developers working on them could get bored and go away. So for functionality that is more than a nice-to-have, I tend to write it myself.
Hopefully this will go away when we start to see professional gem houses, but in the near term, I would hope that companies would begin to diversify their stack a bit so as to mitigate the cost, such as re-engineering their non-core systems to be less dependent on core software from a particular vendor. The last thing you would want would be to find a showstopper bug in something you were about to release that was based on a technology from a shaky vendor, that holds up your business process.
Most good IT shops already support a variety of technologies so as to not be locked in to any one particular implementation from any given vendor, but enterprise developers should not continue to believe that Sun or Java will be around forever in its current enterprise-blessed, no-brainer form. I think serious unbiased evaluation of technologies to be included in future products should gradually become the norm. If Microsoft wins, so-be it, there is some good stuff in .net, but I would hope that Ruby and PHP would benefit from this situation.
JoostBook – Joost to Facebook Interface Widget
Since I'm in love with Joost, I have been thinking about good applications that I could write for the platform. Before I get into talking about the widget / plugin, let me just say that the experience I have had with communicating with the Joost engineers, through their joost-dev google group, as well as them allowing early access to their SDK, has been outstanding. I have rarely come across a more open and generous group. Typically, the SDK guardians are very selfish about discussing future features, and are usually quite arrogant about the possibility of a developer finding an undiscovered bug. None of this has been the case with the Joost SDK staff.
If you don't want to read the details about how I built it, and you just want to use it, you can get it here: JoostBook: Joost / Facebook Interface. You will need Joost, and a facebook account to get started.
Now, about the widget. Firstly, the installation is a little wierd because of the level of control facebook insists on. In order to use the SDK, you have to authenticate, if an unauthenticated request is made, the response is with the facebook login page. This makes for some unique error catching conditions.
So basically, once you have downloaded Joost, and installed the plugin, the first thing I had to do was check for if you are logged in, if you aren't logged in, it has to show you the facebook login page in an iframe so that the XULRunner browser can be cookied. After that, the widget should work like one would expect. You may have to log in alot, and if you aren't logged in, obviously the application can't update the JoostBook facebook application.
Writing the Joost plugin was the easy part, getting the facebook stuff to work was the hard part. Most of it was because the error handling is terrible. Since facebook doesn't allow you to see the 500 errors that your server is throwing, and it doesn't log it, you have to find other ways to check to see if your server is behaving properly. I spent a lot of time in my logs checking for errors.
The install process is a little wierd too, for example, in Firefox 126.96.36.199 on Windows XP, when I clicked on the Joda file linked in the page, it tried to open it as if it were some kind of markup file, obviously the joda looked like garbage, I had to right click and save. Perhaps if I had used a joost:// link it would have worked OK, but I think more research is in order. I didn't really try it in IE because most of the readers of this blog use Firefox, but it should work the same way.
Then having to install the application in facebook can be a little difficult as well. Well, the installation isn't difficult, its the concept that you have to install two applications that work together that is hard. At least there is no particular order in which you need to install them, worst case whenever you run the JoostBook plugin in Joost, it'll show you the facebook login page all the time.
At any rate, it was a fun experience, and I still think the guys at Joost are on to something. I'm slightly less psyched about the facebook platform, but I'm still excited about it.
Posted: December 31st, 1969 | Author: irv | Filed under: java, Programming, Uncategorized | Tags: java programming | No Comments »
WebKit Nightlies With Local Storage and Wild CSS Functionality
My head is still spinning after downloading the WebKit nightlies and messing around with the local SQL Lite storage, and the css animation and transitions. Man, this stuff has my head swimming with the possibilities for interesting applications.
More importantly, when is this going to make its way to the iPhone. I hope we don't have to wait for Apple's next big cat to be released for us to get some of these features. I know the SQL Lite access is really early, and also that most of these features are HTML 5 things being given to us early by the webkit staff, but for early features, they sure are pretty complete looking at first glance.
I don't know what the what3g is in an uproar about, with Apple starting work on HTML 5 in their browser. To me it looks like innovation. It isn't always tidy, but it is always welcome. I haven't been this excited about the web since gmail hit and AJAX started taking over!