RSS

Tag Archives: rails

In defense of dynamic languages

There are a good many truths and there are a better set of likelihoods. Given the current state of dynamic languages today they are less performance than static and functional languages, however, it is also true that dynamic languages are more productive than static and functional languages. (I am not talking about savants)

Don’t optimize your code at the first stage. First make it right, then (if necessary) make it fast (while keeping it right). –erlang programming rules

It is likely that regardless of the size of your project, the size or makeup of your team, or the breakthrough that you think the project represents… that your project is going to have average results at best. The Google’s, FaceBooks and Twitters of the world are extreme edge cases. As proof, look at the iPhone app store. There are over 600,000 apps and only a very small fraction of those apps have the following that Angry Birds does.

So before you go off in a corner reinventing the wheel in your favorite language consider this. WHat is going to be your return on investment? I cannot blame you for learning a new language or tool that would enhance your marketability or even just for hobby sake. But if your intent is to make some money and maybe a little independence they you really need to consider your ROI. And if you’re making money then rewriting your killer app in whatever killer fast programming language is available (and popular) will make make plenty of sense.

This is why I’m hot on python and python’s django, tornadoweb, flask; perl and perl’s mojolicious; ruby and ruby’s sinatra and rails; redis, sqlite, zeromq.

PS: While I’m not a fan of erlang, partly because of what it represents, I really like it’s Programming Rules and Conventions(PRC). By comparison python’s PEP-8 is amateurish. The PRC starts off with ideas like the one quoted above and giving you ideas on how best to approach the problem. This is like python’s PEP-20 but again it’s like signing your name with a crayon instead of a fountain pen.

 
Leave a comment

Posted by on 2012/05/03 in architecture, ProgLang

 

Tags: , , , , , , , , , , , ,

Agile Manifesto – Agile Rails – the proof

Typically in a scientific endeavor if just one component of the proof turns out to be false or unprovable then the entire  endeavor is considered a failure. This is not the same in software development. The successful parts are kept and the failures are deleted.

But this brings me to the point. The author of Agile Web Development with Rails Fourth Edition (pragprog) quotes the Agile Manifesto and then draws an inference with Rails.

“Individuals and interactions over processes and tools” –Agile Manifesto

and then …

There are just small groups of developers, their favorite editors, and chunks of Ruby code. –Agile Web Development

and then all was lost…

“Working software over comprehensive documentation” –Agile Manifesto

You won’t find 500-page specifications at the heart of a Rails project. –Agile Web Development

The “problem” here is that is assumes that everyone is an expert; everyone is performing to the same level all the time; that there is no attrition on the tech or business side; and that people never get bored in their jobs.

It’s nice to say that everyone can look at a SHA-512 function and determine what and how it works from the function prototype and the code… as easily as they would understand a hello world. That is simply not the case. The existence of the SHA-512 is based on a rigorous mathematical proof that is akin to the 500 pages of requirements.

I recently tweeted that I could not imagine the construction crew of the Empire State Building or the Brooklyn Bridge completing their projects without (a) a requirements doc (b) a blueprint or two.

The Agile group can work on small and less complicated projects but once you get to a certain scale in complexity or Mythical Man Month scale then Agile is the real myth.

 
1 Comment

Posted by on 2012/04/21 in agile, architecture, management

 

Tags: , , ,

Your Next Web Application Framework?

Suppose you are the person who has to make the decision as to what language and framework your startup is going to use to deploy it’s application.  What would you choose? There are so many interesting and qualified frameworks that are already powering a good portion of the internet.

(You don’t have to know the language and framework but enough to argue what makes it idea.)

What would it be?

For example: I read an article several years ago that strongly recommended Erlang. At the time it was a great idea. The author suggested that using Erlang would attract smart people and keep the actual number of respondents to something manageable. Since then I implemented several applications that in hindsight: (a) impossible to attract new talent. (b) the more time that passes the more fragile the app gets because my detail recollection is fading (c) and it lacks common tools that would make allow generalized apps to give access to “operators” instead of programmers.

Other examples include: perl, ruby, python… mojolicious, rails and sinatra, flask, tornadoweb, and django.

I have my ideas… what are yours?

 
Leave a comment

Posted by on 2012/04/12 in architecture, future, web

 

Tags: , , , , , , , , , , ,

What is so interesting about the Flask microframework?

I get that Flask has a lot of the same design patterns that Ruby’s Sinatra has. I suppose if one used a metadata approach to application construction/deployment that you might be able to basically interchange between them.

I did a search hoping to find out the differences between Flask and Tornado. I was rewarded with a page from the the Flask development doc. The contributor was suggesting that one might link or cascade Flask with either Tornado, Gevent, Gunicorn or some other proxy setup.

While mentioning Tornado the contributor says…

Tornado is an open source version of the scalable, non-blocking web server and tools that power FriendFeed. Because it is non-blocking and uses epoll, it can handle thousands of simultaneous standing connections, which means it is ideal for real-time web services. Integrating this service with Flask is a trivial task:

In the deployment section of the doc Flask makes is clear that the built-in webserver is strictly for development. The reasons are probably very similar to Rails’ webrick but in the case of Flask there are no explanations. Nor is there a recommendation just a list of servers.

I recently deployed a Tornado-ZeroMQ bridge in order to increase the transaction throughput. Sitting in front of the Tornado instance is a traditional webserver like apache, lighttpd, nginx. These webservers are serving static content because that is what they do best and the dynamic requests are passed thru. But why would I deploy lighttpd->tornadoweb->flask? There is plenty of room for improvement here but someone transitioning from sinatra to/from flask could be rewarded.

hello world from their respective websites:
(Flask)

from flask import Flask
app = Flask(__name__)

@app.route("/")
def hello():
  return "Hello World!"

if __name__ == "__main__":
 app.run()

(Sinatra)

require 'sinatra' 
get '/hi' do 
  "Hello World!" 
end
 
Leave a comment

Posted by on 2012/03/22 in Tools, web

 

Tags: , , , , , , , , , ,

CRUD-fest : grails, rails, django shootout

The mission is to deploy a CRUD implementation in all three frameworks by reverse engineering my schema from an existing Postgres Database which I will construct with raw SQL. Later I would like to add some data to the tables so let’s see how it handles some ETL (export transform load) in the form of a CSV file into some REST calls that I’d implement or some other type of messaging.

What I did not do! I think O’Reilly has the most comprehensive map of the history of all computer programming languages, however, GitHub has a list of languages that would seem to be current or relevant. Granted that some of this, to be effective, would mean investigating popular frameworks within the domain of languages. Well of that semi-complete list from GitHub I picked out this set: php, go, lua, haskell, erlang, scala, clojure, perl, javascript, rhino, nodejs, iOS, Objective-C, C++, C, Pascal, Pro-SQL, CoffeeScript, OCaml, Scheme, tcl, Smalltalk, Visual Basic. I think they are the most relevant. As it goes, however, either they do not reverse engineer schema from a PG (postgres) connection like most ORMs, or they do not have web or other application frameworks in order for a user to interact with the data, and many do not have IDEs or version managers they way that Ruby and Python do. (I cover the IDE topic later.) I think I picked the sweetspot of frameworks to test and skipped the ones that would distract me from the task.

Code Wars: PHP vs Ruby vs Python – Who Reigns Supreme [Infographic]

Let’s start with the schema design. The actual SQL is here. The “message” represents an ISO8583 message. You can follow the link to read more about the message. What’s important to know is that it represents the standard message used between certified credit card acquirers and their associations like Visa, MasterCard, Amex, Discover and many others.  It also represents the message used between the associations and their issuing processors. The message format is also reused by many POS terminal software vendors as well as gateway and technical acquirers/processors. Each association has slightly different implementations depending on their specific needs, however, most of the fields have common names and usage.

When building an endpoint or a gateway or any point in between there is a need to support ISO8583 and a bigger need to test the endpoint. As part of the testing phase it’s important to build a test harness that can generate the necessary test transactions. Depending the application’s position in the network it will have different testing needs. One thing for certain is that the messages and their contents need to be modeled, testable and repeatable. One huge challenge is TDD (test driven development) and another is simple regression testing. It’s my personal belief that a well defined toolset could be deployed in such a way that vendors across the board could contribute data a code for regression testing thus reducing the load on everyone. PS: while this mission is ISO8583 there is no reason why a request/response transaction could not be JSON, XML or S-exp; it’s a general enough schema.

  • TABLE: message_field_dictionary – this is a list of the field names and their formats. Nothing else.
    • FIELD: id (PK)
    • FIELD: field_id (FK)
    • FIELD: field_name
    • FIELD: field_description
    • FIELD: field_format (i.e.; ‘YYYYMMDD’)
    • FIELD: data_types (a, an, ans)
    • FIELD: default_values (i.e.; ’1′, ’2′, ’3′, ‘abc’…)
  • TABLE: message_request – this is the set of fields used in a particular request transaction. It is also possible that this represents the incoming request pattern. If the pattern does not match then that’s separate issue.
    • FIELD: id (PK)
    • FIELD: test_case_id (FK)
    • FIELD: field_id
    • FIELD: request_type
    • FIELD: field_value
  • TABLE: message_response – this is a set of fields in the response generated from the response. This might also represent a response message based on the incoming request pattern.
    • FIELD: id (PK)
    • FIELD: test_case_id (FK)
    • FIELD: field_id
    • FIELD: response_type (i.e.; absent, required, optional, conditional)
    • FIELD: field_value (i.e.; a value, regex, or a combination set, private function or other field_id)
  • TABLE: message_test_cases
    • FIELD: id (PK)
    • FIELD: test_case_id (FK)
    • FIELD: short_name (FK)
    • FIELD: description
    • FIELD: expected_results
    • FIELD: elapsed_ceiling
    • FIELD: is_active
    • FIELD: group_name
    • FIELD: sub_group_name
  • TABLE: message_test_results
    • FIELD: id (PK)
    • FIELD: test_case_id
    • FIELD: started
    • FIELD: finished
    • FIELD: elapsed_time
    • FIELD: results
    • FIELD: request
    • FIELD: response
    • FIELD: errors
    • FIELD: trace
  • TABLE: test_cards – I decided to put the test cards in a separate table because if contributors provided test transactions the actual card numbers and magstripes would be considered confidential data… and the associations do not want anyone recording that info with one possible exception.
    • FIELD: id – (PK)
    • FIELD: card_number (FK)
    • FIELD: serial_number (FK)
    • FIELD: expiration_date
    • FIELD: issue_date
    • FIELD: street
    • FIELD: zipcode
    • FIELD: pin
    • FIELD: atm_pin
    • FIELD: CVV
    • FIELD: CVV2
    • FIELD: track1
    • FIELD: track2
    • FIELD: track3
    • FIELD: reset_balance
    • FIELD: is_decrement
    • FIELD: actual_balance
    • FIELD: open_to_buy

The schema is self explanatory. I did not create any real indexes. I’m not certain (right now) whether I’m going to create any FKs or referential integrity. It depends on how much reverse engineering the different frameworks are going to execute. One thing for sure, this is not intended to be a lesson in DB design. Maybe another time. FKs might be required in order for the reverse engineering to work properly. Specially if I use tables to populate pulldowns and select lists.

The IDE I decided to use was RubyMine, PyCharm and IntelliJ. It is purely by coincidence that I decided to use this family of IDE from jetbrains. (for the record I’m currently using the demo version. I’m hoping that the licenses do not expire before I finish this article… this paragraph was written before coding began). What makes them interesting is that they support Django, Rails and Grails out of the box. After agonizing over it IntelliJ was the only reason why I included Grails. Java does not have a version manager like Ruby or Python, however, you can get there by collecting your jar files in a single folder alongside the JDK you’re using. And since many binary distributions of the JDK are in version folders it makes resetting the CLASSPATH and PATH easier… but still more manual than the ruby and python versions.

RubyMine heads up. When I originally installed RubyMine I had not installed RVM. I found a post from the folks at JetBrains about version 2.0.2 where they probably added RVM support. Anyway they said it just worked. That after a restart RubyMine would give you access to your tools. That was not the case. I had to take one extra step. I had to go into the preferences and navigate through the “Ruby and SDK” page. I also navigated through the gem sets for good measure. Now when I created my project I had access to my Rails version; previously unknown. I had a similar problem with PyCharm and it’s support for VirtualEnv but I will have to verify it with Django. (Shame on me. My desktop virtualenv did not have django installed. I will likely have to do a complete install based on my notes which were originally installed on my virtual machine and not my desktop).

Getting Started

Now that I’ve managed to crawl through the minutia of project preparation it’s time to start putting the project together. So Now that I have installed IntelliJ, PyCharm and RubyMine I have to create my project. I’m calling the project crud_fest_rb, crud_fest_py, and crud_fest_j.

Creating an empty rails and an empty django project was pretty simple. Specially after all the setup I’ve done in preparation. The one observation I’ll make is that there are a lot more artifacts in an empty rails project than there are in a similar django project. The Grails project has a lot more artifacts than that and since there is a compilation step it takes a lot longer to get started. One thing that bugs me about IntelliJ is that it starts the browser to a default page once it’s ready to run.

This project was not meant to be a JetBrains tutorial, however, I’ll mention a few more things. Rails started right away. Django required the user to enable the admin function, update the settings file to point to the proper DB, and then you had to manually execute the ‘manage.py syncdb’ command in order to create a default admin  user. This step will be required later in order to sync the db schema to the model. Rails and Grails are still under investigation.

One nice thing about the Rails and Django projects is that they respect SQLite3. Not that Grails goes out of it’s way to reject SQLite3 but the support is hard to come by. This means that when I put my SQL together it will need to support but SQLite3 and H2. Which will probably work but what a pain. I suppose I could use Postgres but there is nothing easier than a ‘cp’ command to reset the DB to it’s default. And if this project is successful then copying the output table to the target application means that that the SQLite DB file is now the config file.

The Schema

I have created the SQL. I was not going to embed the code directly but the Gist is here. It’s only six small tables and the foreign keys are few. There are a few constraints which should be removed when the constraints are fully represented in code instead of schema. (Keep in mind that when calculating performance things like O(log<n>) no longer makes sense when there are cascading reads based on constraints. And frankly it does not make any sense to have the constraint modeled in code and SQL at the same time.)

Import the Schema

… into the project is the next step.

Django

PyCharm could execute the following commands but currently it feels better to execute them manually from the command line.

The first step is making sure that the DBs are configured properly in the settings.py file. In a recent version of Django the developers made it possible and easy to support multiple and different databases simultaneously. That means I could connect to one DB for one set of actions and another DB for a different set. There are plenty of interesting use-cases here. So let’s configure the DB:

DATABASES = {
 'default': {
     'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
     'NAME': '/tmp/crud_fest.db', # Or path to database file if using sqlite3.
     'USER': '', # Not used with sqlite3.
     'PASSWORD': '', # Not used with sqlite3.
     'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
     'PORT': '', # Set to empty string for default. Not used with sqlite3.
 },
 'messages': {
     'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
     'NAME': '/tmp/crud_fest_py.db', # Or path to database file if using sqlite3.
     'USER': '', # Not used with sqlite3.
     'PASSWORD': '', # Not used with sqlite3.
     'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
     'PORT': '', # Set to empty string for default. Not used with sqlite3.
 }
}

(The indenting is not exact here but that’s a WordPress thing)

The second step is to make certain that the admin functionality that we previous enabled (and now stored in the default database: crud_fest.db) has been sync’d properly. (you’ll need to answer some questions about the admin user including the username and password.)

/Users/rbucker/git/flafreeit/crud_fest_py/manage.py syncdb

Now that the admin tables have been created, you’ll need to create the actual crud_fest_py tables.

cd ${HOME}/git/flafreeit/crud_fest_db
sqlite3 /tmp/crud_fest_py.db <./setup.sql

And then the last step is to dump or reverse engineer the table(s) into a models.py file.

/Users/rbucker/git/flafreeit/crud_fest_py/manage.py inspectdb > /Users/rbucker/git/flafreeit/crud_fest_py/test_config/models.py

Looking at the models.py file you’ll see something like (looks like I have some trimming to do; the admin tables were included):

# This is an auto-generated Django model module.
# You'll have to do the following manually to clean this up:
# * Rearrange models' order
# * Make sure each model has one field with primary_key=True
# Feel free to rename the models, but don't rename db_table values or field names.
#
# Also note: You'll have to insert the output of 'django-admin.py sqlcustom [appname]'
# into your database.
from django.db import models
class MessageFieldDictionary(models.Model):
    id = models.IntegerField(null=True, primary_key=True, blank=True)
    field_id = models.IntegerField(unique=True, null=True, blank=True)
    field_name = models.CharField(unique=True, max_length=25, blank=True)
    field_description = models.TextField(blank=True)
    field_format = models.CharField(max_length=200, blank=True)
    data_types = models.CharField(max_length=200, blank=True)
    default_values = models.CharField(max_length=200, blank=True)
    class Meta:
        db_table = u'message_field_dictionary'

This is just a sample of the tables that inspectdb generated… because there is one final step. Now that we have a models.py file with the individual schema we need to tell Django about the tables and the individual fields that need to be editable. There are some shortcuts; the online docs are really good. So we are going to create an admin.py file like this.

from django.contrib import admin
from myproject.myapp.models import MessageFieldDictionary

class MessageFieldDictionaryAdmin(admin.ModelAdmin):
    pass
admin.site.register(MessageFieldDictionary, MessageFieldDictionaryAdmin)

Once this last step is completed then you need to launch the django server and navigate to the admin site with your favorite browser. All of your tables should be there. You might still need to customize the widgets but this is the place where we stop.

One Final note. Sadly my decision to use SQLite means that I might have to do all of this all over again. It seems that the foreign keys have not been incorporated into the results of the ‘inspectdb’ command. There is a pragme in SQLite that enables FKs but it has to be compiled in beforehand. There was also at least one multi field constraint that does not appear.

But this is a good place to stop for now.

Rails

The first thing I noticed is that there is no code in Rails for reverse engineering a legacy database the way that Django does. So I had to install a missing gem.

gem install rmre

Then I had to reverse engineer my DB.

cd ${HOME}/git/flafreeit/crud_fest_rb
rmre -d /tmp/crud_fest_py.db -o ./app/models/

After the command completed I was returned to the command line. There were no error messages so I assume that it completed OK. I looked in the ./app/models/ directory and noticed that there were a handful of new files. These files were 1:1 with the table names. Here’s an example:

class MessageFieldDictionary < ActiveRecord::Base
    set_table_name 'message_field_dictionary'
end

This is a little hinky because none of the field names or types have been included. After doing some searching I found that this is OK and that ActiveRecord will fill in the blanks. I don’t know if I buy that. I like that Django fills in the holes and this sparse programming … *sigh*.

There is another command that is interesting:

rake db:schema:dump

This will dump the schema into a file db/schema.rb. It represents the complete schema. I suppose that this code could be copied to the model files. But for the moment this is not required… I think the db:migrate command will regenerate this db/schema.rb file when it completes.

Another caveat here is that it is possible to have multiple databases configured in the database.yml file. The difference, however, is that ActiveRecord needs to know which database goes with which definition. So there is some manual work to be done here. There are some simple google searches you can execute and most of them make perfect sense. It’s a little beyond the scope here even though I described the python version.

Grails

Grails supports multiple databases in it’s DataSource.groovy file. Since I’m working with Grails 2.0.0 there is a possibility that the latest Hibernate is included. Hibernate is the ORM that Grails uses to communicate with the DB. But the tool for reverse engineering needs to be installed.

cd ${HOME}/git/flafreeit/crud_fest_j
grails install-plugin db-reverse-engineer

The output was pretty simple.

rbucker@rmac[crud_fest_j]$ grails install-plugin db-reverse-engineer
| Plugin installed.

… but I have no idea which version was installed. So we move forward for the moment. The next step is to locate the h2 command line version.

java -cp ${HOME}/lib/grails-2.0.0/lib/com.h2database/h2/jars/h2-1.2.147.jar org.h2.tools.Shell

You’ll need to answer a few default questions. You can accept the default values for the moment.

Now that H2 is running and pointing to the same repository as the DataSource.groovy, now we need to run the SQL to create the database tables as we did previously. (I had to make some changes to the code because there are some differences with H2.

Now we try to do the reverse engineering…. actually, it’s not going to happen. I’m going to leave this up to the reader to complete. And if anyone wants to contribute, please, by all means. For the moment This is the end of the road for this project.

Conclusion

It is safe to say that I’m done with this project. While it seems plausible that I could reverse engineer a database using the Grails Plugin – the amount of configuration required just amazes me. Spring is heavily dependent on XML config files and it appears that Grails uses some of each. One thing for certain is that Java has these huge namespaces everywhere so just the slights config requirement for reverse engineering is so incredibly painful. I’m really surprised that the Grails guys did not do more Groovy scripting for this sort of thing.

Ruby/Rails on the other hand still required an outside GEM in order to perform the reverse engineering. I’m surprised that with Rails3 and 3.2 that they never addressed the issue directly. And not to mention that the resulting models were still sparsely emitted.

Finally, Django seems to have gotten it right. It emits the code in it’s entirety. Getting to the CRUD is a simple matter of some manual labor which the user could script easy enough. My vote is going to Python as the all around winner and Ruby a close second. The Java code is on hold, maybe we can call this a “did not finish”. The overall performance of the dependencies and the compile step make it a less valuable experience.And let’s not forget the JDK version madness.

So for the time being I’m inclined to purchase a license for PyCharm and RubyMine just because this is where I’m going to be spending my time for a little while… and it’s my money.

 
 

Tags: , , , , , ,

My Ruby Installation

[update 2012-01-22] A new project is underway. ‘crud-fest-rb’ it’s part of a new story I’m writing. I just tried to launch a new rails project and I was blocked because I was missing some basic gems. They are now in the list below. The names are: jquery-rails, coffee-rails, sass-rails, uglifier. My empty RubyMine/rails-3.2 project is now running. The CRUD comes next.

[update 2012-01-21] I just published this article a few hours ago and I realized that I forgot some stuff. I forgot to mention that I need Twitter’s Bootstrap project here too. So when I start working on my first project I’ll need to import Bootstrap. I might have missed a few more things… I have been following python and many of the python libs longer than ruby so that makes sense. If you have any recommendations send them on. PS: TextMate is getting an update soon but I think I’m going to install and use RubyMine from jetbrains.com. It’s like PyCharm, also from jetbrains.com but for Ruby and supports Rails. (hopefully Rails 3.2). Like PyCharm, RubyMine support RVM out of the box. Nothing special required.

I’m not a great fan of Ruby. I was in the beginning when I was first introduced to Spring. And it was not so much Ruby as it was Rails. The fact that it did all the CRUD one could want was a big deal. Now it’s not that uncommon. Django offers CRUD for python app developers and Grails offers CRUD for java developers.

Reddit recently linked to a visual comparing python, ruby and php. There were some interesting observations about the number of programmers and projects in each vertical. That combined with my new love for RVM has given Ruby a new lease on life in my toolkit. (I have also worked on professional Ruby projects but without RVM they were no fun).

RVM is a big deal. Not unlike virtualenv for python, RVM allows the programmer to install and configure his/her development environment in userspace. This means that many of the fears I had about creating my dev environment on my local hardware and version collision and dependency mismatch means that all I really need to do is create a separate user directory on my laptop for each project. This way everything is nicely partitioned and what I can focus on is backups rather than the crazy live of remote virtual servers for development. Of which there is still some value for demonstrations and client access.

So let’s setup a basic RVM install so that we can start our next project. Some of the installation is going to overlap with the python installation (here). You can skip all of the userspace installation but the sudo installation is all you’ll need. Keep in mind that this installation was all about a virtual server at RackSpace. If you are installing on a Mac or Windows machine your install will be different.

Install the default ruby. I originally thought that I’d need to install at least one Ruby installation in the core OS but it turned out to be unnecessary. RVM will install any version of ruby for you. Once RVM is installed you can issue the command (rvm list known) and you’ll get a list of the known rubies available. In fact I had to remove this package and start again because of some side effects down the road.

apt-get install ruby1.9.1

Install RVM

bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)

startup RVM… you can logoff and back in or you can look at the last line of your ‘.profile’ and execute the source command.

source "/home/rbucker/.rvm/scripts/rvm"

NOTE: I did some looking at the .rvm directory and I saw some things that did not make sense.  It seems that many of the modules and ruby artifacts were being installed in a ruby folder labeled 1.9.1 presumably that was a ruby version. I have restarted the install process several times now and it appears that RVM is installing my version of ruby 1.9.3-p0 as a set of patches over version 1.9.1 which explains the folder structure.

install a recent Ruby version

rvm install 1.9.3-p0

Make this version current (you will have to run this command every time you login)

rvm use 1.9.3-p0

If you want to make this version of ruby the default version run this command (note the default command will insure this version of ruby os ready each time you login)

rvm use 1.9.3-p0 --default

which rubies are installed and which is current

ruby list

install some gems in userspace. Note that rvm is taking over the gem install. Lucky for me Rails 3.2 was released a few days ago and now it’s installing. I’ve elected to install Sinatra too. That’s because it’s a useful micro framework when rails is just too much.

gem install rails
gem install jquery-rails
gem install coffee-rails
gem install sass-rails
gwm install uglifier
gem install sinatra
gem install redis
gem install mongodb
gem install pg
gem install mustache
gem install fastercsv 
gem install iso8583
gem install sqlite3
gem install ruote 
gem install json
gem install sxp
gem install sexp
gem install zmq
gem install beanstalk-client
gem install rmre
gem install haml
gem install db-charmer
gem install mail
gem install activemerchant
...
gem update money rack rake sourcify sprockets

**there were some initial difficulties installing the ‘pg’ gem. It started off as a problem because the install would not complete. I kinda realized that I was missing the postgres dev files so I installed that core package as the root user. When I installed the gem on my OSX machine it installed nicely. I’m not certain I know why or how the postgres client was installed on my OSX machine but it seems to have included enough code to compile the gem. MacPort was not installed on either machine or maybe it was corrupted because it’s not functioning and I’d swear that it was installed once before.

**one other thing that is concerning me is the version number of the ZMQ gem. If the version number maps to the version of the main lib then they are mountains apart and that’s something I cannot afford. It’s one of the reasons that I’m going down the path of RVM and native gem management. Some interesting notes; the version of the GEM is 2.0.7 and when you run ZMQ.version() from the IRB you get different results so it must be checking the binary libs.

On my OSX

rbucker@rmac[usr]$ irb
1.9.3-p0 :001 > require 'zmq'
 => true
1.9.3-p0 :002 > ZMQ.version()
 => [2, 1, 10]

On my Ubuntu

rbucker@soldev:~$ irb
1.9.3-p0 :001 > require 'zmq'
 => true
1.9.3-p0 :002 > ZMQ.version()
 => [2, 1, 11]

install gems for building gems. I do not know anything about them except that I hope that they work.  I’ve installed all three because they should not collide. There is a 4th and 5th option.  There are some devs that have github general templates that they use. You can always roll your own in a similar way. Personally I’m interested in these 3 projects because it might mean less editing for me.

gem install jeweler
gem install hoe
gem install echoe

At this point I’d create my bare bones project, install bootstrap just like the python version, and then start hacking my project.

Reference material: I really like pragprog.com. They seem to have the most current docs. Their PDF and epub ebooks are great and they keep me updated. (Rails 3.2 was just released and their eBook was also updated just a few days later; granted not much was supposed to have changed, but still).

In the coming week I’ll be writing an article on the CRUD-fest in django and rails as I start building my credit card association test harness. Stay tuned as this page will be updated as I add gems to my basic installation.

 
Leave a comment

Posted by on 2012/01/21 in Tools, web

 

Tags: , , , , ,

“Rails Is Not For Beginners”

[UPDATE] I don’t know anything about this book and the fact that it’s Ruby is not interesting but the quotes and snippets are: here

Oscar posted “Rails Is Not For Beginners“. His general assertion is that Rails is complex and has a lot of code making it difficult for beginners… and that Sinatra is a better tool because it’s only a fraction of the code. (about 100:1)

I responded to the original post with this comment:

“not for beginners” is mostly true but meaningless. The noobs have adopted it instead of VB. However, I think that it’s a little more complicated than that and is much a psychological mystery as trying to understand the stock market.

There is something to be said about “full stack awareness” and sinatra’s LOC makes that easier. Sinatra also allows you to get some real work done. My intuition tells me that sinatra does not do as much fancy META magic under the covers as Rails does; which is more of a property of the language than the framework.

My issue with noobs, rails and ruby… is that while the “UNIX way” suggests building projects on top of each other like layers of a cake. Many of the useful GEMS have such deep dependencies that FSA is extremely unlikely… If the MBAs that ran our companies fully appreciated the complexity and risk then Rails would still be in the drawing room.

While I agree with the assertion I think it’s probably a little more complicated than that. The fact of the matter is that “most” and not “all” beginners suck at programming. It’s not enough to know language syntax or to have built a few hosted and dynamic websites. This career/profession requires a lot more attention to detail, situational awareness … and with all due respect to Dorsey … a finely tuned intuition; in addition to the syntax and idioms of at least 3 or 4 mainstream languages. Not to mention plenty of business awareness.

 
Leave a comment

Posted by on 2011/12/08 in business, management, web

 

Tags: , ,

 
One Page Docs

Creating a library one page at a time.

One Page Bugs

Reducing the friction of writing and fixing bugs or features.

Follow

Get every new post delivered to your Inbox.

Join 223 other followers