logo
Published on Input Jam (http://www.kleinfelter.com)

RAD Web Development Frameworks and Tools

By Kevin Kleinfelter
Created 2007-05-15 01:43
  1. Rails [1]
  2. Grails [2]
  3. Trails [3]
  4. AppFuse [4]
  5. Django [5]
  6. Seaside [6]

What I’d like to try:

Summary (from the experiences below):

  1. Rails is easy to spark a simple app to life, owing in part to InstantRails.
  2. Grails is easy to spark to life a simple app, but it takes more grunt work.
  3. Java EE (Trails and AppFuse) is harder and more work than Rails/Grails/Django.
  4. Django is easy to spark a simple app to life.  It doesn’t appear to have anything comparable to Rails migrations, but its CRUD starter-app has more functionality than Rails.
  5. Seaside is elegant. So is Smalltalk.  I need more syntactic sugar. I can get past unusual if-statements, but I’m not going to use (word) messages for array subscripting.

Conclusions:

  1. The Ruby + Rails guys really understand packaging and reduction of barriers to entry, in addition to the oft-cited promotion.
  2. InstantGrails and InstantDjango would enable more developers to quickly become more familiar with these frameworks.
  3. Even the easy starter tools for Java EE frameworks take too much effort to attract developers from small ASP or PHP shops.
  4. I started off expecting Rails to be a clear winner.  I was impressed by Django.


 Rails (May 4, 2007)

  1. Download http://rubyforge.org/frs/download.php/18843/InstantRails-1.7-win.zip [7]
  2. Unzip into C:\
  3. Run: C:\InstantRails\InstantRails.exe
  4. Add C:\InstantRails\mysql\bin;C:\InstantRails\ruby\bin to PATH
  5. mysql -u root
    • create database addressbook_development;
    • quit;
  6. Run: rails addressbook
  7. cd addressbook
  8. Run: ruby script\generate model Address
  9. Run: ruby script\generate controller Address
  10. Add “scaffold :address” to C:\addressbook\app\controllers\address_controller.rb
  11. Edit C:\addressbook\db\migrate\001_create_addresses.rb adding this Ruby code [7] to the create_table bvlock
  12. Run: rake db:migrate
  13. Run: ruby script/server
  14. Browse to http://localhost:3000/address/list [8] and test the CRUD
  15. Run: ruby script/generate migration add_email_field
  16. Edit C:\addressbook\db\migrate\002_add_email_field.rb , adding “add_column :addresses, :email, :string, :limit => 80” to self.up and “remove_column :addresses, :email” to self.down
  17. Run rake db:migrate
  18. Browse to http://localhost:3000/address/list [9] and test the CRUD

Note: It appears to me that Rails development activities can all be run as a ‘portable app’ from a flash drive.


Grails (May 6, 2007)

  1. Download http://build.canoo.com/grails/artifacts/grails-bin-0.5.5-SNAPSHOT.zip [10]
  2. Unzip to C:\ and rename grails-0.5 to grails
  3. Download JDK 6u1 from http://java.sun.com/javase/downloads/index.jsp [11]
  4. Run the JDK install
  5. Add environment variable GRAILS_HOME=C:\grails
  6. Add “C:\grails\bin;C:\ant\bin” to PATH
  7. Download Ant 1.7 from http://ant.apache.org/bindownload.cgi [12]
  8. Extract Ant to C:\ and rename to C:\ant.  [Note: If there is an InstantGrails that is comparable to InstantRails, somebody please tell me.]
  9. Add environment variable ANT_HOME=C:\ant
  10. Set environment variable JAVA_HOME to C:\Program Files\java\jdk1.6.0_01
  11. Open a Command prompt in C:\ and run “grails” and you get a message that you can use “grails help” for help.  Try it.  Get “Error executing script Help: String index out of range: 1” and a Java runtime exception.  Great.
  12. Run “grails create-app”.  Oops. That throws the same error.
  13. On a whim, “mkdir grails_apps” and “cd grails_apps”
  14. Run “grails create-app addressbook”. Bingo!  I’m guessing that the grails developers aren’t big on Windows, or perhaps they have a philosophical  objection to letting me create an app directory at the root level. I’m betting that they can’t be bothered to deal with a current directory ending with a backslash.
  15. cd addressbook
  16. grails create-domain-class Address
  17. Edit C:\grails_apps\addressbook\grails-app\domain\Address.groovy and add this Groovy code [12] inside the class
  18. Run “grails create-controller Address”
  19. Edit C:\grails_apps\addressbook\grails-app\controllers\AddressController.java and replace “def index = {}” with “def scaffold = Address”
  20. Run grails run-app
  21. Browse to http://localhost:8080/addressbook/address [13] and test the CRUD
    1. How odd!  It sequences the columns as Zip, Phone, Street, Name, State, City. It is neither the order I defined them nor alphabetic, or any other sequence I can discern.
  22. Edit  C:\grails_apps\addressbook\grails-app\domain\Address.groovy and add “String email”
  23. Stop and restart the app (may not be necessary).
    1. Oops! We lost all the old data.  Oh. That’s right, it uses an in-memory database by default.
  24. Download and install MySQL “Windows Essentials” from http://dev.mysql.com/downloads/mysql/5.0.html#win32 [14]
  25. mysql -u root
    • create database addressbook_development;
    • quit;
  26. Edit C:\grails_apps\addressbook\grails-app\conf\DevelopmentDataSource.groovy and make it look like this Groovy code [14]:
  27. Download the MySQL JDBC driver from http://www.mysql.com/products/connector/j/ [15]
  28. Extract mysql-connector-java-5.0.5-bin.jar to C:\grails_apps\addressbook\lib
  29. Stop and restart the app (necessary).

Note: It appears to me that grails development activities can NOT be run as a ‘portable app’ from a flash drive.  Also, I didn’t find evidence of anything like Rails’ migrations.  Yes, Grails can automatically alter your database structure to match your domain model, but if you need to do anything more than add/drop database entities, you’ll have to write and sequence your updates, and you’ll own repeating the process against your production database.


 Trails (May 7, 2007)

  1. Download JDK 6u1 from http://java.sun.com/javase/downloads/index.jsp [16]
  2. Run the JDK install
  3. Add “C:\ant\bin” to PATH
  4. Download Ant 1.7 from http://ant.apache.org/bindownload.cgi [17]
  5. Extract Ant to C:\ and rename to C:\ant.  [Note: If there is an InstantTrails that is comparable to InstantRails, somebody please tell me.]
  6. Add environment variable ANT_HOME=C:\ant
  7. Set environment variable JAVA_HOME to C:\Program Files\java\jdk1.6.0_01
  8. Download Maven from http://maven.apache.org/download.html [18]
  9. Extract Maven to C:\ and rename it to c:\maven
  10. Add c:\maven\bin to your PATH.
  11. Download http://www.reverse.net/pub/apache/tomcat/tomcat-6/v6.0.10/bin/apache-tomcat-6.0.10.exe [19]
  12. Install the downloaded Tomcat
  13. mvn archetype:create -DarchetypeGroupId=org.trailsframework -DarchetypeArtifactId=trails-archetype -DremoteRepositories=http://snapshots.repository.codehaus.org -DarchetypeVersion=1.0-SNAPSHOT -DgroupId=addressbook -DartifactId=addressbook
  14. cd addressbook
  15. mvn tomcat:run
  16. Error message:
    1. Reason: POM 'org.codehaus.mojo:tomcat-maven-plugin' not found in repository: Unable to download the artifact from any rep repository    org.codehaus.mojo:tomcat-maven-plugin:pom:1.0-SNAPSHOT
    2. Note: This is based on the instructions at http://www.trailsframework.org/Quick+Start at 9:58 PM (Eastern Daylight Time) on May 6, 2007.  It says they just changed things around a lot, so it looks to me like they haven’t finished with their changes.  Maybe I’ll try again another day.

Trying to work around the problem:

  1. Create folder C:\maven\repository
  2. Edit c:\maven\conf\settings.xml and point localRepository to C:/maven/repository. Also define ibiblio as a mirror.
  3. Fiddle with settings.xml until the following works:
    • mvn archetype:create -DarchetypeGroupId=org.apache.maven.archetypes -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeVersion=1.0
    • Note: See http://repo1.maven.org/maven2/org/apache/maven/archetypes/maven-archetype-quickstart [20]
    • Somewhere in there I added ibiblio as a mirror [20] (in the maven settings.xml)
    • mvn archetype:create -DarchetypeGroupId=org.trailsframework -DarchetypeArtifactId=trails-archetype -DremoteRepositories=http://snapshots.repository.codehaus.org -DarchetypeVersion=1.0-SNAPSHOT -DgroupId=com.kleinfelter.demo1 -DartifactId=addressbook
    • Edit c:\code\addressbook\pom.xml and change the version on tomcat-maven-plugin to “1.0-alpha-1”
    • Note: I found the version from http://repository.codehaus.org/org/codehaus/mojo/tomcat-maven-plugin [21]
  4. Add this XML [21] to your project’s pom.xml, just before the “<build>” line.
  5. Add a repository to pom.xml for tapernate at http://www.carmanconsulting.com/mvn/ [22]
  6. Download tapestry-spring-1.0.0 from http://howardlewisship.com/downloads/tapestry-javaforge/ [23]
  7. Install tapestry-spring via: mvn install:install-file -DgroupId=com.javaforge.tapestry -DartifactId=tapestry-spring -Dversion=1.0.0 -Dpackaging=jar -Dfile=tapestry-spring-1.0.0.jar
  8. mvn tomcat:run
  9. Boom! It starts tomcat, but when I browse to http://localhost:8080/ [24], it dies with
    • javax.servlet.ServletException: Unable to construct service tapernate.MergeReattachPropertyPersistenceStrategy: Unable to construct service hivemind…

I’m sure this all works for someone, but this is hardly making development easy.  I can see why the Grails team is proud of its work; by comparison, it is far better than this.


 

AppFuse with Candy (May 17, 2007)

  1. Download and install Java EE 5 SDK Update 2 from http://java.sun.com/javaee/downloads/index.jsp [25]
     User=admin/password
     admin-port=4848
     HTTP-port=9090
     HTTPS-port=9191
     Tell it not to start (not sure how I did this; may have disabled the Service)
  2. Download Eclipse SDK 3.2.2 from http://www.eclipse.org/downloads/ [26] and extract to C:\
  3. Add jdk\bin to your PATH
  4. Download and install Windows Essentials from http://dev.mysql.com/downloads/mysql/5.0.html#downloads [27].  Install to C:\MySQL
     Transactional
     Data files in C:\mysql-databases
     Root password = password
  5. Start Eclipse, set C:\Code as your default workspace, add
     http://candy4appfuse.sf.net/site [28]
     http://commonclipse.sourceforge.net.as [29] an update site, run update, select all available except Eclipse 3.2.1 patches
  6. Window/Preferences/Java/Commonclipse. Select the General tab. Uncheck Append super in hashCode() and Append super in equals(). Click OK. 
  7.  Window/Show View/Console
  8. In the Package Explorer pane (left side), right-click and
      New/Project/New AppFuse project, name it HelloAppFuse, Struts 2 Basic, group =com.kleinfelter
  9. Wait. Wait some more.
  10. Edit pom.xml, and set jdbc.password to password
  11. Right-click the project in Package Explorer/Run As/Maven Build... (the one with ...)
    • In the "Goals:" text box, enter jetty:run-war
    • Click Run
  12. Browse to http://localhost:8080/ [30]
  13. Save this code [30] as C:\code\HelloAppFuse\src\main\java\com\kleinfelter\model\Address.java (upper-case A)
  14. Right-click the source code, and select Generate Getters and Setters
  15. Select Address.java in Package Explorer, right-click/Source/"Generate hashCode() and equals()" and DE-select id.
  16. Right-click the source/Commonclipse/"Generate toString()"
  17. Edit src/main/resources/hibernate.cfg.xml for the basic archetypes and add after the other mapping rows:
    • <mapping class="com.kleinfelter.model.Address"/>
  18. Create src/main/webapp/WEB-INF/applicationContext.xml containing this code [30]
  19. Create C:\code\HelloAppFuse\src\main\java\com\kleinfelter\webapp\action\AddressAction.java  containing this code [30]
  20. Create a src/main/webapp/WEB-INF/pages/addressList.jsp containing this code [30]
  21. Edit src/main/resources/struts.xml and append this code [30] after the row with "<!-- Add additional actions here -->":
  22. Edit src/main/resources/ApplicationResources.properties and append these properties [30]
  23. Create a src/main/webapp/WEB-INF/pages/addressForm.jsp containing this code [30]
  24. Browse to http://localhost:8080/addresses.html [31] (login is mraible/tomcat)
  25. I still need to add the email field... This one has worn me out!


Django

  1. Install Python 2.5.1 from http://www.python.org/download/ [32]
  2. Download Django 0.96 from http://www.djangoproject.com/download/ [33] , extract it into a temp directory, cd to the directory, run python setup.py install
    • Make sure your PATH includes C:\python;C:\Python\Lib\site-packages\django\bin
  3. Download and install MySQL “Windows Essentials” from http://dev.mysql.com/downloads/mysql/5.0.html#win32 [34] . Check your my.ini to verify that “default-storage-engine=INNODB” is in the “[mysqld]” section.
  4. mysql -u root
    • CREATE DATABASE addressbook_development CHARACTER SET utf8;
    • quit;
  5. Download and run mysql for python (win32 exe edition) from http://sourceforge.net/project/showfiles.php?group_id=22307 [35]
  6. “cd c:\code” and run “django-admin.py startproject addressbook”
  7. “cd addressbook” and run “python manage.py startapp address”
  8. Edit settings.py and make it resemble this code [35]
  9. Edit addressbook/address/models.py to contain this [35]
  10. Add to INSTALLED_APPS in addressbook/settings.py: ‘addressbook.address’ and ‘django.contrib.admin
  11. Edit your mysite/urls.py file and uncomment the line below “Uncomment this for admin:”.
  12. python manage.py syncdb
    • Admin user=admin, password=password
  13. python manage.py runserver
  14. Browse to http://localhost:8000/admin/ [36]
  15. Test out the CRUD
    • Hey! It enforces the length=2 on state!
    • The basic CRUD is pretty nice, with admin login, shortcuts, history.
  16. Edit addressbook/address/models.py and add: ‘    email = models.CharField(maxlength=80)’
  17. I’d like to see “python manage.py syncdb” add the new column, but it doesn’t.  You have two choices: either write and run your own SQL script to do so (‘alter table address_address add column email char(80);’) or you could:
    • python manage.py dumpdata address > temp.json
    • python manage.py reset address
    • python manage.py loaddata temp.json
  18. Test CRUD with the new field.


 

Seaside

This exercise is not really Seaside’s forte.  Smalltalkers aren’t really into relational databases, preferring object databases

  1. Download http://wwwmaster.postgresql.org/download/mirrors-ftp?file=%2Fbinary%2Fv8.2.4%2Fwin32%2Fpostgresql-8.2.4-1.zip [37]
  2. Create your database (“addressbook-development”) via PostgreSQL’s GUI tools.
  3. Go into pg_hba.conf and change the authentication method from md5 to password
  4. Download and install Seaside 2.7 via Squeak’s “world menu”/open/squeakmap, navigate to Seaside 2.7, right-click, and install.
    1. Tell it Debug and then Proceed on the redefining Cache error.
    2. Config user=admin/password
  5. Download and install Postgress Client 1.0 via Squeak’s “world menu”/open/squeakmap, navigate to PostgresSQL Client, right-click, and install.
    1. Windows Service Account = kevin on local machine domain
    2. DB user = admin/password
  6. Download and install Glorp 0.3.138 via Squeak’s “world menu”/open/squeakmap, navigate to Glorp port, right-click, and install.
  7. After you load Glorp, edit PGConnection class>>buildDefaultConnectionArgs and point it to your postgres server and database.
  8. Evaluate (“do it”) “WAKom startOn: 9090” in a Squeak workspace window, and browse to http://localhost:9090/seaside/config [38]
    1. Add “addressbook” as an application.

I'm unlikely to finish this one. There is too much construction required.  For starters, if I want it to work with MySQL, I'll have to write the database driver.  You get your choice of databases, so long as your choice is PostgreSQL.

Seaside is elegant. So is Smalltalk.  I need more syntactic sugar. I can get past unusual if-statements, but I’m not going to use (word) messages for array subscripting. I like minimalism in theory; in practice, I really like common array subscripting, whether via [] or () or even (. and .) (which I used for Pascal on the DEC-10).  I like the convenience if-modifiers and the unless-statement.  I don’t need them.  I like them.  I think in English.  I think that if I were a mathematician I might like Smalltalk better.  I like its concepts, but I don’t like practicing with those concepts.

Note: http://www.squeaksource.com/MagritteGlorp.html [39] might be interesting for a follow-up test.


Source URL:
http://www.kleinfelter.com/node/62