Web Development & Programming Thoughts

By Timothy Elliott

Rails Is Not Newcomer-friendly

4/22/2011

Let's say I create a new rails application and I look at the generated file structure:

$ rails new foo
      create  
      create  README
      create  Rakefile
      create  config.ru
      ...
      ...
      ...

$ cd foo
$ find .

What an experienced rails dev sees:

./config
./config/application.rb
./config/initializers
./config/initializers/inflections.rb
./config/initializers/session_store.rb
./config/initializers/secret_token.rb
./config/initializers/backtrace_silencers.rb
./config/initializers/mime_types.rb
./config/database.yml
./config/routes.rb
./config/environments
./config/environments/development.rb
./config/environments/test.rb
./config/environments/production.rb
./config/environment.rb
./config/boot.rb
./config/locales
./config/locales/en.yml
./README
./tmp
./tmp/cache
./tmp/cache/.gitkeep
./db
./db/seeds.rb
./log
./log/.gitkeep
./doc
./doc/README_FOR_APP
./Gemfile
./app
./app/mailers
./app/mailers/.gitkeep
./app/models
./app/models/.gitkeep
./app/assets
./app/assets/stylesheets
./app/assets/stylesheets/application.css
./app/assets/javascripts
./app/assets/javascripts/application.js
./app/assets/images
./app/assets/images/rails.png
./app/views
./app/views/layouts
./app/views/layouts/application.html.erb
./app/controllers
./app/controllers/application_controller.rb
./app/helpers
./app/helpers/application_helper.rb
./script
./script/rails
./.gitignore
./config.ru
./lib
./lib/tasks
./lib/tasks/.gitkeep
./test
./test/fixtures
./test/fixtures/.gitkeep
./test/integration
./test/integration/.gitkeep
./test/performance
./test/performance/browsing_test.rb
./test/functional
./test/functional/.gitkeep
./test/unit
./test/unit/.gitkeep
./test/test_helper.rb
./Rakefile
./vendor
./vendor/assets
./vendor/assets/stylesheets
./vendor/assets/stylesheets/.gitkeep
./vendor/assets/javascripts
./vendor/assets/javascripts/jquery.js
./vendor/assets/javascripts/jquery_ujs.js
./vendor/plugins
./vendor/plugins/.gitkeep
./public
./public/robots.txt
./public/422.html
./public/favicon.ico
./public/404.html
./public/500.html
./public/index.html

What a newcomer sees:

./XEAnIr
./XEAnIr/TwwSIXTiIEA.KR
./XEAnIr/IAIiITSIysKf
./XEAnIr/IAIiITSIysKf/IAnSsXiIEAf.KR
./XEAnIr/IAIiITSIysKf/fsffIEA_fiEKs.KR
./XEAnIr/IAIiITSIysKf/fsXKsi_iEOsA.KR
./XEAnIr/IAIiITSIysKf/RTXOiKTXs_fISsAXsKf.KR
./XEAnIr/IAIiITSIysKf/cIcs_ikwsf.KR
./XEAnIr/uTiTRTfs.kcS
./XEAnIr/KEvisf.KR
./XEAnIr/sAUIKEAcsAif
./XEAnIr/sAUIKEAcsAif/usUsSEwcsAi.KR
./XEAnIr/sAUIKEAcsAif/isfi.KR
./XEAnIr/sAUIKEAcsAif/wKEuvXiIEA.KR
./XEAnIr/sAUIKEAcsAi.KR
./XEAnIr/REEi.KR
./XEAnIr/SEXTSsf
./XEAnIr/SEXTSsf/sA.kcS
./README
./icw
./icw/XTXHs
./icw/XTXHs/.rIiOssw
./uR
./uR/fssuf.KR
./SEr
./SEr/.rIiOssw
./uEX
./uEX/QWZltW_GPQ_ZMM
./dscnISs
./Tww
./Tww/cTISsKf
./Tww/cTISsKf/.rIiOssw
./Tww/cEusSf
./Tww/cEusSf/.rIiOssw
./Tww/Tffsif
./Tww/Tffsif/fikSsfHssif
./Tww/Tffsif/fikSsfHssif/TwwSIXTiIEA.Xff
./Tww/Tffsif/pTUTfXKIwif
./Tww/Tffsif/pTUTfXKIwif/TwwSIXTiIEA.pf
./Tww/Tffsif/IcTrsf
./Tww/Tffsif/IcTrsf/KTISf.wAr
./Tww/UIsVf
./Tww/UIsVf/STkEvif
./Tww/UIsVf/STkEvif/TwwSIXTiIEA.HicS.sKR
./Tww/XEAiKESSsKf
./Tww/XEAiKESSsKf/TwwSIXTiIEA_XEAiKESSsK.KR
./Tww/HsSwsKf
./Tww/HsSwsKf/TwwSIXTiIEA_HsSwsK.KR
./fXKIwi
./fXKIwi/KTISf
./.rIiIrAEKs
./XEAnIr.Kv
./SIR
./SIR/iTfOf
./SIR/iTfOf/.rIiOssw
./isfi
./isfi/nIhivKsf
./isfi/nIhivKsf/.rIiOssw
./isfi/IAisrKTiIEA
./isfi/IAisrKTiIEA/.rIiOssw
./isfi/wsKnEKcTAXs
./isfi/wsKnEKcTAXs/RKEVfIAr_isfi.KR
./isfi/nvAXiIEATS
./isfi/nvAXiIEATS/.rIiOssw
./isfi/vAIi
./isfi/vAIi/.rIiOssw
./isfi/isfi_HsSwsK.KR
./QTOsnISs
./UsAuEK
./UsAuEK/Tffsif
./UsAuEK/Tffsif/fikSsfHssif
./UsAuEK/Tffsif/fikSsfHssif/.rIiOssw
./UsAuEK/Tffsif/pTUTfXKIwif
./UsAuEK/Tffsif/pTUTfXKIwif/pJvsKk.pf
./UsAuEK/Tffsif/pTUTfXKIwif/pJvsKk_vpf.pf
./UsAuEK/wSvrIAf
./UsAuEK/wSvrIAf/.rIiOssw
./wvRSIX
./wvRSIX/KEREif.ihi
./wvRSIX/422.HicS
./wvRSIX/nTUIXEA.IXE
./wvRSIX/404.HicS
./wvRSIX/500.HicS
./wvRSIX/IAush.HicS

When you are a newcomer, those 80 files and directories are intimidating! The README is a good start and it explains the directories, but tl;dr. A typical rails guide will now take the newcomer through creating a scaffold and database migration. But it is still too difficult to get to that magic point where you write a piece of code, and you get to see work.

All a beginner wants to do is put some code into an HTML file and see how Ruby on Rails works. Even with guidance, you currently have to navigate through too many obscure looking directories and files.

Let's make it as easy as possible for our newcomer devs to feel rewarded for installing Ruby on Rails. The true reward is when you get to write some original code and see it in your browser. In time, newcomers will learn to appreciate MVC, tests, and ActiveRecord, but for now all they want to do is write an HTML file and see the result in their browser:

<html>
  <body>
    Hello world! My cat had <%= 2 + 2 %> legs before it picked a fight with that mean raccoon.
  </body>
</html>

Perhaps we can add a new rails command, such as "easy" (note that this doesn't actually exist, I'm just fantasizing here):

$ rails easy foo
      creating foo/
      creating foo/README_FOR_BEGINNERS
      creating foo/app
      creating foo/app/views
      creating foo/app/views/application
      creating foo/app/views/application/index.html.erb
      Thank you for trying Ruby on Rails! Run "rails server" from within your project to launch a web server.

This looks a lot less intimidating. It's pretty obvious that there is a README file and there is a file that does something with HTML. This invites the newcomer to jump straight in and play. It would require that rails internally uses a default application/routes/etc. when everything is missing. But this should then work:

$ rails server
[2011-04-22 15:00:50] INFO  WEBrick 1.3.1
[2011-04-22 15:00:50] INFO  ruby 1.9.2 (2010-12-25) [x86_64-linux]
[2011-04-22 15:00:50] INFO  WEBrick::HTTPServer#start: pid=6299 port=3000

At a later date, perhaps the easy project can be upgraded to a full rails project:

$ rails level_up .
      create  README
      create  Rakefile
      create  config.ru
      ...
      exists  app
      ...

Let's make our newcomers happy, including those who don't want to read a guide or watch a video, and instead want to go straight to playing with their own code.