Now, I am not typically a fan of dynamically typed languages. I use PHP in my current job and while its "typeless-ness" can be useful and allow for quick prototyping of ideas, it is also fraught with many pitfalls that bite you in mysterious ways.
That being said, you can program in PHP, and I suspect Ruby, in a safe and responsible manner and I find myself interested to see what I can do.
Installation
To get started, I've gone to Ruby's main website. I normally work in Ubuntu but today I'm on my Windows machine. A quick skim over the page and that leads me to the Windows Ruby Installer page. I chose the default of installing Ruby with the devkit, which includes MSYS2 so gems that require C can be compiled. It seemed like a reasonable choice since I was new to the language.After running the installer, I was given the choice to run an MSYS2 utility for further installation configuration. I chose the defaults for all options.
I also decided I wanted to install Ruby on Rails. The tutorial page for the framework warns you should get to know Ruby first, and I probably should, but I'm going to go ahead and install the framework anyway. I am already aware of the gems package manager for Ruby and used it to install Rails per the Getting Started document on the website. It also looks like using the Windows installer was a good choice as it includes sqlite3 by default which the Rails tutorial recommends. Excellent!
Getting Started
These tutorials can be a mixed bag. With programming languages, they tend to be slow, boring and uninformative; targeted at new programmers and not experienced ones. That said, I've opted to give the Ruby quick-start Ruby in Twenty Minutes a whirl to see what's up.It encouraged me to start up the REPL for Ruby and do some basic tasks. Some notes:
- There's an exponential operator (**).
- Variables are dynamically declared, as expected, and require no special characters to denote a variable.
- Function declaration are reminiscent of Pascal where you declare the function start (def) and close the block with end. An interesting choice.
- Functions can be called with or without brackets. I'm not a fan of that and I think in my own code I would always include the brackets.
- String interpolation is nice if not slightly unconventional compared to other languages with the feature.
- I was glad to see there's some kind of notion of private/hidden class fields/properties.
- The ease of use of reflection is interesting.
- Accounting for variables types will likely require a lot of boiler plate.
- Using `if __FILE__ == $0` reminds me of Python.
Initial Musings
There are certainly things I like and things I don't. I prefer statically typed and strongly typed languages. Ruby is dynamically typed and weakly typed. Like with PHP, it's just something you have to live with or work around.It might be a bit premature to say after only spending a few minutes with the language, but it seems that like with most dynamically typed and weakly typed language you have to expend a fair amount of effort with boilerplate to determine what type any given variable is to take action on it. That said, the duck typing and using reflection does cut down on this a bit.
Coming bundled with an industry-wide accepted package manager is a refreshing change of pace. Package management is a tough topic and many languages still struggle with it. NodeJS, for example, has multiple competing tools. Go is only just starting to figure out its own management system. C and C++ don't really have one unless you could system tools like yum or apt.
Honestly, this is my second look at Ruby. In my first attempt, many years ago, I can quite confidently say I did not give it a fair chance and I didn't like. That's not Ruby's fault but my own. This second go around has left me with a different impression and I look forward to delving in further.
Going off the Rails
Where's the Rails portion I talked about? Well, that will come later.Ta-ta for now!
No comments:
Post a Comment