Pick a scripting language. Any Scripting Language. Learn to use it really, really well.Compiled programming languages obviously have a purpose, but lightweight, interpreted scripting languages are an important tool as well. An interpreted scripting language is the perfect choice for one off tests, tedious text manipulation, automated tasks, and simple tools. Scripts are easy to write, easy to share, and good enough to get the job done.
My prof used Perl and was a whiz at it. I eventually settled on Ruby as my scripting language of choice. While the core language works really well across different platforms, as a predominantly Windows user, I find that Ruby sometimes runs into problems in odd situations. One thing that is particularly annoying is the lack of a Ruby version manager. Version managers are a great idea. The basic idea is to make it easier to switch between different Ruby versions on the command line so that it's easier to test and develop against multiple projects.
OS X and Linux users get RVM. Until recently, the only option on Windows was pik, a woefully out of date and problematic open source project that is no longer under active development (I'm not going to even bother linking to it). Thankfully, now there's uru, a cross platform Ruby environment manager that works on Windows, Linux, and OS X.
I've been using uru for close to a year now and it's worked out very well for me. That said, when first getting uru up and running I did run into a few snags. Here's the steps I used to overcome those problems. If you're trying to run multiple Ruby versions on Windows you should give uru a try.
Step 1: Install uruFirst, download and install uru. To do this, download the zip and unpack it to a place on your path. I have a generic "tools" folder for things like this. Next, follow the instructions on the uru website. Basically, just run...
C:\tools> uru_rt admin install
Step 2: Install RubyNext, download and install the Ruby versions you want. You may have up to 1 "system" Ruby when using uru. If you choose to have a system Ruby then that should be the only one you allow to be added to the path. I installed different versions of Ruby using the Ruby Windows Installer and also the latest JRuby. I don't have any Ruby versions on my path and instead choose the Ruby version I want to use explicitly each time. The main thing is to just be careful about what gets added to your path when performing the installations.
Step 3: Register your Ruby Installations with uruBy this point I have installed all of my Ruby versions to the C:\ruby\ directory with none on the path. The next step is to register each Ruby version using the uru command line.
C:\> uru admin add c:\ruby\jruby-1.7.18\bin\ ---> Registered jruby at `c:\ruby\jruby-1.7.18\bin` as `1718` C:\> uru ls 1718 : jruby 1.7.18 (1.9.3p551) 2014-12-22 625381c on Java HotSpot(TM) ... 193 : ruby 1.9.3p551 (2014-11-13) [i386-mingw32] 215 : ruby 2.1.5p273 (2014-11-13 revision 48405) [x64-mingw32]
Once installed I changed the tag associated with JRuby to be a little easier to remember.
C:\> uru admin retag 1718 jruby ---> retagged `1718` to `jruby`
At this point, I'm up and running. Now switching my environment to use JRuby is as simple as...
C:\> uru jruby ---> Now using jruby 1.7.18 tagged as `jruby` C:\> jruby --version jruby 1.7.18 (1.9.3p551) 2014-12-22 625381c on Java HotSpot(TM) Client VM 1.8.0_31-b13 +jit [Windows 7-x86] C:\> ruby --version 'ruby' is not recognized as an internal or external command, operable program or batch file. C:\> uru 193 ---> Now using ruby 1.9.3-p551 tagged as `193` C:\> jruby --version 'jruby' is not recognized as an internal or external command, operable program or batch file. C:\> ruby --version ruby 1.9.3p551 (2014-11-13) [i386-mingw32]
Step 4: Install Ruby Windows DevKitThe last step I took was installing the Ruby Windows DevKit. You'll need this to install any gems that require native extensions such as json. DevKit is just an archive that you unzip to a specific location and run an install script to copy some files into the right places so Ruby can use them.
I generally store the DevKit next to the version of Ruby to which it belongs, for example, C:\ruby\Ruby193\devkit where Ruby193 is the folder containing the 193 version of Ruby that I registered with uru. JRuby does not need a DevKit. Just follow the normal instructions for installing DevKit and install it for each of the Ruby versions you want to use, obviously using the version of Ruby for which you are installing DevKit.
As a last step, install the json gem to make sure DevKit is installed correctly...
C:\> gem install json ERROR: Could not find a valid gem 'json', here is why: Unable to download data from https://rubygems.org/ - SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed ....
Oh no! SSL Hell! Apparently rubygems.org recently updated their SSL Certificates which requires clients to also update. This error comes up because the security certificates used by gem are out of date. Thankfully it's pretty easy to update the certs.
To fix this, follow the instructions on this StackOverflow question: SSL Error When installing rubygems, Unable to pull data from 'https://rubygems.org/ You'll need to download the updated certificate and manually install it in each Gem directory....
C:\> uru 193 C:\> gem which rubygems C:/ruby/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems.rb
With all that completed, everything should now work as expected.
C:\> gem install json Temporarily enhancing PATH to include DevKit... Building native extensions. This could take a while... Successfully installed json-1.8.2 Parsing documentation for json-1.8.2 Done installing documentation for json after 0 seconds 1 gem installed
Step 5: Enjoy Hacking in RubyMy workmates tell me I just need to switch to Linux already. I do run a very Linux-like Windows environment with most of the GNU command line tools available from the Windows command line. Whatevs. I like my Windows and with uru at least I can switch between different Rubies with relative ease.
Whether it's Ruby or something else, pick a scripting language, any scripting language, and learn it well. If you're running Ruby on Windows, hopefully this little guide helped you skip some frustrations!