Today is a good day to code

Mides 1.7 New Features and Changes

Posted: January 25th, 2010 | Author: | Filed under: Apple, iPhone, JavaScript, mides, PHP, Programming | Tags: , , , , , | 2 Comments »

I wrote Mides originally to help me to write web applications when I am on the go.  A huge part of web application development is JavaScript.  The iPhone / iPod is an awesome device for heavy client JavaScript apps.  So as a result, I added JSLint in Mides 1.7 to make debugging JavaScript easier.

The main problem with the developer setting in Mobile Safari is that it is inaccessible to other applications.  Since one of the main purposes of Mides is to enable development with either no, or an unreliable internet connection, it wouldn’t be possible for Mides’ internal HTTP server to run and serve the mobile safari application with content.  This is the entire reason I wrote an HTTP server for Mides, so that JavaScript XHRs would work correctly for testing.

What I have done to help out with JavaScript debugging is to modify Douglas Crockford’s JSLint library slightly to make it work on the iPhone.  It helps out with outright errors, but also with many excellent tips for writing safe and readable JavaScript applications.  You can see the errors and optimizations by tapping on the burst and exclamation point icon when it appears over your JavaScript or HTML.  This feature is optional and can be disabled in the iPhone settings.

Another issue I wanted to address with a new feature is that I always forget the argument, or the exact PHP method call that I want to use, especially around MySQL.  I already had the documentation in there, but since it is a full-text search, it tends to take a while.  So I added a new feature that allows you to look up just the method signature, that is the method name and the arguments to the method.  I didn’t want to put a button in there for this, it just didn’t seem right.  I tried for a while to come up with something usable, and I think I have figured out something that works.  You just need to twist the phone to the right ( or left ) to do the code-completion on the method.  If the text before the cursor matches one or more PHP method signatures, then it will add that value in context, in line into your code with the argument types.  If it matches more than one, it will display a modal dialog that will allow you to choose from the top 5 PHP methods that match what you have typed.

One fix that a customer asked for on getsatisfaction.com/mides was that I make tabs parse properly.  I also added that in Mides 1.7, now your tabs will be properly displayed.  To create a tab, just space 5 chars into the document.

I am adding features both at the request of customers on the burgeoning community on getsatisfaction, as well as through my own usage of the product.  I probably won’t implement all of them, but please keep the suggestions coming.  They help tremendously.  Some of them are really tough to implement, but if they make it more usable I’m all for it.

One of the main issues around Mides is moving files onto and off of the phone, Apple hasn’t made it easy, and FTP is not the best solution, it is a nightmare to support, and difficult for users to set up.  I thought about having a small application that you could install on your Mac and PC that would make it much easier to transfer files with, but this didn’t seem like the best solution either.  I am actively thinking through better ways, but nothing so far has really stuck.

At any rate, I am constantly trying to make Mides more useful, I know it has been rough, but I’m glad to see that some of you are starting to get real use out of Mides.  I hope to keep making it better and eventually to rival and in some ways improve upon the desktop coding experience.


Come Through Rails Back to PHP

Posted: November 17th, 2009 | Author: | Filed under: PHP, Programming, Rails, Ruby | No Comments »

I am struggling mightily with this one. I love ruby and rails, but more and more I am resenting the constraints of the controller architecture, the router, and activerecord, and I miss writing and tweaking raw SQL. This is not to say that I don’t love rails for quick and dirty stuff, and it has done wonders for writing MVC web applications, but I miss being able to break that pattern where it applies and being able to understand the result. I view rails just like I view Cocoa Bindings. I love the magic that they do, but there is a performance cost, and it is suboptimal for me to have little to no visibility into how they do what they do.

My friends who are really into rails tell me of course, you can use it without those modules, namely ActiveRecord, but if my problem is with ActiveController, and its routing magic, along with the conventions then what is the point. I was looking at MERB, but it is difficult to say what the result will be in rails 3. But almost no matter how I consider the outcome of that Merb will inevitably become more Rails like. I mean, rails is the 800 lbs gorilla in the web dev space, who would argue with Rails and win?

Well, there are plenty of examples of ugly PHP sites, and there are some examples of almost elegant code in PHP. Better yet, there is no magic, I can avoid heavy frameworks if I choose and still have my choice of easy deployment options with mod_php. The rails community keeps saying that hardware is cheap, and it is if you have money to begin with. If I need to deploy on a $30 / month host, it is very hard to deploy a rails app with a homegrown framework on rack. I am sure they exist, but PHP hosting has gotten so cheap as to almost be an afterthought.

Some of the PHP code that I have written recently is quite clean and readable. Its using classes and MVC to a degree, but I have objects that implement a hydration base class that allow them to persist their contents by overriding some simple parameterized SQL via PDO in the subclass. That is really all of the database abstraction that I need. If I want to persist objects, I’ll just save them to disk. Ruby’s marshal works just fine for that, so does PHP’s serialize / unserialize. If I want to use a relational database, I’ll write SQL and let it play to its strengths instead of pretending that it doesn’t exist.

The functional and library support that PHP has is unparalleled in the web dev community. I would have to agree with Rasmus Lerdorf that I like my SQL to look like SQL, my JavaScript to look like JavaScript, and my implementation language to look like my implementation language.

This is not an anti-framework rant, despite the way it sounds. I love Rails, Cake PHP, Groovy, Struts, etc… I think they are a great way to get a project going quickly or as a way to learn good web development processes, but I also think there is a time where you need performance and control, and this is it for me. I think most web developers should start by learning one of these frameworks. Once they can understand the tradeoffs you make when using them, it is probably time to leave. I don’t differentiate, I think that JavaScript frameworks are the same thing. They are awesome until you are performance bound, or you are trying to express a design that the frameworks either didn’t consider, don’t support, or don’t match the framework creator’s view of the world. That is fine, I don’t want for DHH to accept that there are times when convention over configuration is too cumbersome and the performance tradeoff isn’t worth the simplicity, or that some things are better expressed in a functional way instead of an OO way. For those projects, I just won’t use his framework.

There are totally justifiable situations in which Rails is the absolute best choice. I work in Rails every day at work and love it for that particular problem domain. I just have started realizing that I have been seeing the world as Rails shaped nails. There is no one language, framework, design pattern, or library that is the end-all-be-all method for solving problems. It takes good practices and pragmatic choices to choose the best tool or tools for the job. I was getting away from that, now I am coming back.


Writing a PHP Interpreter for Mides

Posted: May 7th, 2009 | Author: | Filed under: android, iPhone, java, mides, PHP, Programming | Tags: , , , , , , , | 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.