One year after accidentally falling in love with Rails

September 9, 2017

One year after accidentally falling in love with Rails.

Really interesting article from the Two Pythonistas accidentally fall in love with rails post that was going around the net and the Rails circles a year ago. Now a year in they are back with another interesting post, moving from Rails to Node/CoffeeScript for their new beta release (of what I can’t tell you, I have no idea what ThinkFuse does).

Datamapper 1.0 Released

September 9, 2017

Image result for Datamapper 1.0 Released+Well, as of right now there aren’t any release notes or website update, but Dan Kubb (@dkubb) has tagged the 1.0 release of DataMapper. This is for the talk at RailsConf today that Dirkjan Bussink (@dbussink) will be giving in about 15 minutes.

A huge congrats to my friend Dan and the rest of the DataMapper team as I know this has been a colossal amount of work to get a project like this to the 1.0 state, especially with the amount of stability and test coverage that the project has.

Building a New Site With Rails

September 9, 2017

Fear on the BrainYou may have noticed that my ‘blog 6 days a week’ has lately been kinda lax lately, but I finally, finally, started work on Nothing out there public yet, but I’ve finally found the time and energy, and quite frankly, got through that old friend of mine, fear of getting stuff done instead of watching TV and reading RSS feeds, and actually got some code down on… uhm… an editor.

I figure that it’d be a good idea to start blogging the experience of building a site from scratch with Rails by a newbie (not that there aren’t a hundred of those already). Read My Code was done in 24 hours, I figure a week or so, or heck, a day or two per feature, ought to be enough.

I started by breaking things into some steps:

Create the Idiom scaffold, model validation, etc
User authentication and login
User integration (edit your own Idioms)
Site layout, look and feel
More site layout stuff (I’m thinking this might be the hardest part for me, as I am a programmer and not a designer for a very good reason 🙂
That’s of course a bit over simplified, and I’m probably missing out something huge, but that’s the current attack plan. All things are flexible of course. My grand plan is to code one day, blog the results and anything interesting or challenging that I find. I’ll make sure I push things up to the GitHub project page as well.

Thinking on The New Paradigm Of Web Application Development

September 9, 2017

This is probably old news to everyone who reads this, but today I had a bit of an epiphany. I was watching Charles Max Wood’s excellent Teach Me To Code Screen-cast and realized (after watching two parts of his “building a blog” series) that he wasn’t ever actually looking at the output of his coding, at least in the traditional sense.

The way I’ve coded since, well, forever has been like this. I open up my editor window, and an output window. When I was writing C code back in the dot com days this was another terminal with a “make && ./app” in it, and in my newer web application days, a browser window with my mouse hand on the reload button. After a bit of code was written, I’d either hit “up-arrow enter” for C code or reload the browser, and see what’s happened.

Watching the screen-cast I realize that Charles was doing the following (as far as I can tell, as I’m pretty new to the whole TDD thing):

Writing a scenario or feature (using cucumber)
Using that to generate tests (with rspec, I think)
Running the test, watching it fail
Writing the code to make the test pass
Running the test, watching it pass
Now the last four steps I do know about, those are standard TDD methodology, broken down into Red (write a failing test), Green (make it pass), Refactor (make the code better), but I was blown away with the realization that he wasn’t looking at the output of the code he was writing, but instead was letting the testing framework do the work, so instead of having to verify with your own eyes that the [insert web page you’re interested in here] is showing properly, you have it checked programmatically, no browser needed (in fact, at the point in part two when the browser is needed, there’s that uncomfortable pause while FireFox groans and raises itself into a running state).

Is that what TDD is really about? I’ve always imagined it as an augmentation to the previously-described way I used to code in that before I coded and reloaded the browser window you’d write the test, then the code, then the browser reload, then the test again to make sure it passed.

This is a whole new world that’s frankly thrown me for a loop, and into a fervor of reading up on cucumber. I’m not sure how this will affect my code writing, but this makes the whole world of TDD a lot more interesting! Course, I’ll have to re-watch the two episodes to make sure I truly grok the tools that he’s using

Optimizing Everything To Instant

September 9, 2017

Black Hole of OptimizationSo here’s a wacky idea on how Rails, Perl, Python, and everything else can be optimized to be so fast as it’d be almost instant. Bear with me here….

First, you find some code, a framework, a program, whatever it is you’re into, and find a benchmark or test suite you can run on it.
Next, grab some sort of code metrics suite that can record the time it takes for your test suite to run through it. Something like metric_fu, the built in benchmark module, New Relic RPM, or some other performance test system.
Run the benchmark and review the code metrics. You will probably see a few “hot spots” where certain functions or operations take longer than others.
Here’s the tricky part, but in the grand scheme of things, just a minor detail. Optimize the function, or the bit of the function that’s causing issues. This could take a short time (unused code, recursive loops, something like that) or a long time (refactor, iterate, rinse, repeat).
Now run the benchmark again, find the next hotspot, and repeat the process until no more hotspots are found.
Now the code will run instantly, as you have optimized it down to zero. Taking this method to it’s completely logical conclusion you could run another benchmark and find the next set of hotspots, or run it against the next module or part of the framework until you’ve optimized it all down to zero.
Congratulations, now Rails requests (obviously taking things like network latency into account, until you turn your now optimized optimizing brain to that problem) all run in 0.0 seconds. You won!

* Ok, so obviously (I hope) this is a post that is in jest, as at some point you will run up against issues that can’t be optimized, either because of latency you can’t avoid from disk loading, more database indexes vs loading from disk, the laws of physics, code complexity vs readability, etc. It is however something though that I hope gave you a bit of a giggle (that’s maybe a stretch I admit) or a slight pause to think that maybe, just maybe this could (in some fashion) work for you for some situation.

DataMapper 1.0 Interview

September 9, 2017

My buddy Dan Kubb has a nice interview on the recent DataMapper 1.0 Milestone. DM is something that I have been wanting to look at forever, everytime Dan does his “let me just show you how to do this in DM instead of ActiveRecord” stints, I’m always amazed at how fast and easy he does things. Of course, I’m also amazed at how fast and easy things are done in ActiveRecord by people who are proficient in it 🙂 Time to break out the Rails 3 and see how fast and easy the integration of DM into it is!

Anyway, a great interview and well worth the read.

Ruby and Rails on Windows Finally Simple?

September 9, 2017

Remember a bit ago when Wayne E. Seguin of RVM Fame (I think he should legally change his name to that BTW) was hired by Engine Yard to do, among other things, help get Rails working properly on Windows? Well, looks like in only weeks of work, there is now Ruby and Rails on Windows in a Single, Easy Install.

If this works as advertised (haven’t had a chance to test it yet), then this is huge in giving Ruby on Rails a big edge into the Windows world, and eliminates the need for such hacky (sorry Curtis) solutions like this, previously the “best” way to run Rails on Windows 🙂

Not only that, but this gives Rails on Windows almost the same advantage it has for development on Mac and Linux: stupidly low barrier to entry. Rails has always been easy to program in, but you had to get it up and running first. On Mac it’s been included in the OS for a few versions of Mac OS, on Linux it’s been as easy as “apt-get install rails” (or equivalent), and now on windows it’ll be as easy as “go to, download and clicky clicky”.


September 9, 2017

Anyone in the Ruby community probably knows about Why The Lucky Stiff and his numerous contributions to Ruby and the Ruby community[0]. They’ll also know that a while back _Why decided to disappear, removing his code, sites, and closing down his various accounts. In celebration of what he brought to us Today, August 19th is Why Day, in which people are encouraged to:

See how far you can push some weird corner of Ruby (or some other language).
Try that wild idea you’ve been sitting on because it’s too crazy.
or others….
One thing I know you can do is to use Skype to call “coderpath” and leave a message about what you think of _Why and Why Day. Call coderpath’s skype (you of course need Skype installed and a Skype account…).

If you’re looking for a reminder of what _Why brought to the community, you can check out whymirror on github, where most of _Why’s various projects have been restored and preserved. Most special though (in my opinion anyway) are:

TryRuby – running ruby in the browser, like IRB
Why’s Poignant Guide To Ruby – The man, the book, the legend.

Rails 3 in Action Book Review

September 9, 2017

So recently Rails 3.1 was released, bringing a ton of fun new features, such as the asset pipeline, streaming, a new migration syntax, and a bunch of other new features. You may ask “hey thinkingonrails guy, how can I learn all this new stuff? There are no books out there that are cutting edge and up to date enough to help me!”

Fear not gentle reader, you’ll be happy to hear that the newly updated book from Manning Publications Rails 3 in Action is fully updated to cover Rails 3.1 (and Rails 3 if you’re even farther behind).

I was able to read through some of this book and I have to say that Ryan Bigg and Yehuda Katz did a great job in making an accessible book on rails. Yes, it definitely helps to have at least some rails (and of course ruby) experience, but if you’re reading this blog, you probably have at least a passing understanding of these things. It covers topics such as:

Testing (early on, which is awesome)
Nested Resources
Authentication and authorization
File uploads
API design (for those wanting to go a bit beyond a blog site
Rack based applications
That’s not all of course, that’s just me cherry picking the table of contents. I admit I haven’t read fully all of the topics here, they are quite frankly, beyond me. The book looks great in layout as well, lots of whitespace (even @danbenjamin will approve).

I don’t want to go deep into a review and will just say this. This book hits topics that will matter in real life day to day work. Recipes such as twitter authentication and file uploads are well mixed in with a more traditional style of programming book which walks you through building an application, with successive sections building upon the previous. The writing style is fresh and feels more “conversational” (to me anyway) than other Rails books out there.

The eBook version of the book is released today and you can get a 50% off deal (that’s half price folks) for today only by using the code rails350e if you go and purchase the eBook here.

Disclosure: I was kindly given early access to the eBook by Candace over at Manning.

Ruby Creator Matz Joins Heroku

September 9, 2017

Cool news for the Ruby community…. Matz, creator of the language has joined Heroku (wonder if that’s what they did with their big payday?). Potentially very cool stuff, congrats to Matz and the ruby community (and especially Heroku).

Matz is going to be the Chief Architect. Here’s a press release for you.