Peter Cooper

Author
+ Follow
since Jul 17, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Peter Cooper

Passenger, a.k.a. mod_rails or mod_rack, is the most common way to deploy Rails (and other Ruby web framework) applications nowadays. It works on both Apache and nginx. It's reliable, good with memory, and runs like a champ. It's easy to install on your own Apache-powered server, of course, but some shared hosts run it too, such as Dreamhost. An older technique is to use fcgi/FastCGI. Most hosts are moving to Passenger, but it's still possible to deploy apps via FastCGI and on some setups it works just great.
15 years ago
When I've taught developers who have come from languages like PHP and Cold Fusion, there has been a confusion over the flexibility of the syntax in many cases. One key example is stuff like:

puts "x is even" if x % 2 == 0

Versus the more traditional (but lengthier and less idiomatic):

if x % 2 == 0
puts "x is even"
end

Another stumbling block is the "pure" object oriented nature of Ruby. A lot of developers seem to be used to arbitrarily mixing procedural ideas with object oriented ones. In Ruby you can do this but in reality you'd try to avoid it as much as possible. Even in a similarly dynamic language like Python, there's a heavy reliance on functions.. such as using len(str) rather than str.length, or similar.

I find that most of the stumbling blocks come from assuming Ruby is as inconsistent or "mixed" as other languages, when really the standard is to try and keep things as simple as possible. Ruby tends to assume it's easier to learn operators than structural syntax, so while you won't see so much "structural" definitions or endless initiators as in Java, you'll instead see operators or shortcuts.

Consider this Java-ish example (I know this isn't Java, but it's a similar style):

arr = Array.new
arr.push(10)
arr.push(20)

Versus the more Ruby-esque:

arr = []
arr << 10
arr << 20

You *can* write Ruby in the former, more Java-esque way, but you'd tend to write more idiomatically as in the second example.

Regarding certain patterns that existing OO developers find tough, I'd say that from certain languages (such as Java), the lack of multiple inheritance can be "interesting" to start with The existence of modules that are then mixed in to classes can also provide a little bit of a learning curve, but it's mostly about changing expectations than learning anything hard.
15 years ago
There's a source download for the larger examples in the book, but no exercises, no.

If I had to be honest, I probably didn't include exercises because I've never used them or found them useful myself. I will certainly keep it in mind for future books though as I wasn't really aware they were so well appreciated by some
15 years ago
There are a lot of ways to do testing, load testing, and Web application testing from Ruby. The Ruby community seems to be a little bit nuts over testing - almost religious about it - so the number of testing libraries is.. quite large for the size of the community ;-)

One of the best known libraries is Watir. To steal some info: "Watir is an open-source library for automating web browsers. It allows you to write tests that are easy to read and maintain. It is simple and flexible. Watir drives browsers the same way people do. It clicks links, fills in forms, presses buttons. Watir also checks results, such as whether expected text appears on the page. Watir is a family of Ruby libraries. They support Internet Explorer on Windows, Firefox on Windows, Mac and Linux, Safari on Mac, Chrome on Windows and Flash testing with Firefox."

There's also an attempt to port Selenium to Ruby.

If you want something that's lower level and doesn't rely on a browser, there's also WebRat which provides an API for mechanizing Web requests and browser features using Ruby methods. With this you can put together scripts to perform whatever actions are necessary on your sites.

The above are all quite generic tools - if you actually write your app in Ruby, then you can test a bit "closer to the bone" with things like Rack::Test, but I'm assuming you're talking about using Ruby in a more generic way to access Web applications generally.
15 years ago
Perhaps it's a bit weird asking a question when I'm meant to be answering them this week (thanks for all your questions, by the way!) but I thought I'd take this opportunity to ask you all one..

I wrote Beginning Ruby and the second edition has just been released and it's doing well. But if I wanted to go on to writing an all new Ruby book (whether with a regular publisher or even as an e-book or free Web site), what sort of book/e-book or Ruby related guide would you like to see or buy? I'm open to all suggestions, no matter how crazy (even "don't write another book again, loser!") so let loose with what you think!
15 years ago

1. I heard "Twitter" is a Ruby application. What are the other major applications Ruby has been used?



Twitter is a Rails application but they've started to use Scala a lot for things like message queues and heavy lifting in the backend. Other big apps using Ruby (and sometimes Rails) include Scribd, YellowPages.com, 43things, Penny Arcade, and all of the 37signals applications like Basecamp). Other companies use Ruby in the backend too, such as Amazon.com. See this list of some companies that use Ruby/Rails.

2. What is the advantage of Ruby, compared to other languages? What are the other languages similar to Ruby?



This has been covered a few times in answer to other questions, so please have a look through the last day's of posts in this forum, but.. to summarize.. Ruby isn't verbose (if you consider Java to be a 7 out of 10 on the verbosity scale, Ruby's perhaps a 2) and it "gets out of the way" and lets you simply code your logic and features with as little architectural work as necessary (of course, if you want to, you can write Ruby in a very anal way, but it's not necessary to start with). I'd say Python is quite similar to Ruby in some ways, but it's not quite as dynamic and consistent. Ruby takes a lot of influence from Smalltalk, so that's going to be quite similar too ;-)

3. What does your book cover, which other books do not cover?



I'd say it's not so much about the "what" but the "how." Beginning Ruby does cover some things other books don't simply because it's trying to get someone from knowing very little to being able to "talk the talk" and have a good feel for what's involved in a modern Ruby developer's day to day work. For example, SQL, network daemons, the daemonization of processes, RSS feeds.. these things are all covered at some level. Other Ruby books tend to focus solely on language mechanics. Beginning Ruby also has a chapter all about the history of Ruby and Rails and how the community works and how you can get involved. Again, other books don't look at these "soft" issues much, but I think they're important to learn to feel part of the community.

Generally, though, Beginning Ruby is aimed to cover as much as possible but without confusing or rushing the reader. This is a hard balance to get right, but explains why the book comes in at almost 700 pages. It's not a pile of waffle like in many books, we actually need that many pages to cover all of the ground at the right pace!

4. What job and commercial prospects does Ruby has?



A couple of years ago it was pretty crazy. You could get a pretty good job (or freelance gigs) by just saying you know some Ruby or Rails, but now it's a little harder. One problem is that a lot of the Ruby gigs going around now are for senior developers and it's hard to find positions if you're just starting out. That said, Ruby and Rails people get pretty good rates (on a par with the Java world, I'd say - and certainly better than for PHP developers) but.. there's definitely an expectation of community participation and a history of open source projects or contributions from a lot of companies in this field.

If I were a developer using another language, say Java or C#, and wanted to get into Ruby, I'd do it on the side. Get involved with some open source projects, and try to get some smaller gigs on the side, before even attempting to go into it full time.
15 years ago
Despite its open source routes, open source IDEs have been a bit of a sore spot for Ruby. Good ones, anyway ;-)

If you need to tick both boxes, Aptana RadRails is probably the way to go. It's based on Eclipse. Despite the name it's not just for Rails development and can be used for pure Ruby development if you want. It's a reasonable IDE as long as you like Eclipse (which I don't, but hey).

More celebrated is JetBrains' (of IntelliJ IDEA fame) RubyMine but it's a commercial product. I suspect a lot of Java-heads will love it though, and it gets the best reviews overall. I don't use it because I'm not into IDEs personally.

Ruby In Steel is definitely a good option on Windows. I've given it a go and it feels really nice. Despite not being a Windows user anymore, I still appreciate how well constructed Visual Studio is I wish there were an IDE as good as VS on other platforms. Eclipse just doesn't cut it for me.
15 years ago

I'm expanding my horizons with programming languages as I'm a Microsoft developer primarily doing ASP.NET web applications. I'd like to know how does Ruby scale in terms of application development and complexity? Is it possible to create Enterprise Grade applications or is it more geared towards providing quick results to small programming tasks?



Ruby is particularly well suited to small tasks, given its background as an interpreted, scripting language, but now it's generally considered more than that. It's basically in the same ballpark as Perl or Python in this regard. Many people use Ruby to build enterprise level applications (Thoughtworks, for example), however, but nearly always on a UNIX-related stack. I don't know of any enterprise grade Ruby applications on the Windows platform. Typically Ruby is scaled using the advantages UNIX provides - separation of processes, message queues, the ease at rolling out multiple boxes that do the same thing, etc. The scaling is an architectural thing rather than an inherent feature of the language and its associated technologies.

Also what advantages does Ruby provide over developing applications using ASP.NET or ASP.NET MVC?



I haven't used ASP for about 8 years so I can't really say. From my point of view, being able to use UNIX and UNIX-like operating systems (whether Linux, BSD, or Mac OS X) is the ultimate win for me. I know MS is doing a lot of good things with ASP.NET and ASP.NET MVC lately (with the latter adopting many of Rails' better ideas) but the OS and the draconian licensing are deal breakers to me. If you're used to that platform, though, MS is not doing a bad job from what I hear.

How well does Ruby integrate with other programming languages such as C#, PHP, etc? Is it possible to embedded Ruby with these languages due to Ruby having a particular knack at handling certain tasks quicker, easier, and better than other langauges?



Currently Ruby has, perhaps, the best relationship with Java, rather than C# or PHP, in the shape of JRuby, a JVM-powered Ruby implementation. There is also IronRuby, an implementation of Ruby for the CLR that should offer the same sort of integration with CLR based languages but I don't think it's considered production ready in the way JRuby is. IronRuby is being worked on by John Lam of Microsoft though, so it's an officially supported MS project.

BTW, since you're an experienced Microsoft developer, consider checking out Ruby In Steel. There's a free edition and it's a Ruby IDE and debugger that uses Visual Studio. You should feel right at home with it.
15 years ago
No, it's not an exercise driven book. I know a lot of people prefer that, though it's not very common to see nowadays. I think the main reason I didn't take that route was because Beginning Ruby is quite a long and thorough book in terms of how things are introduced. There are often multiple examples of the same concept, just with a slight bit of extension each time. It doesn't try and rush over topics too much. There are suggestions throughout the book as to what you could "do next" but they're not defined exercises, per se.

The book is based on Ruby generically and all code examples (except a few, which are noted) will work the same on Ruby 1.8 and Ruby 1.9. I'd personally advise no lower than 1.8.6 though. A couple of Ruby 1.9 specified topics are covered (character encoding and fibers, specifically).
15 years ago
Test::Unit. Mostly because that's the "standard" even if the trend has moved on elsewhere (although Rails creator David Heinemeier Hansson recently said he still uses Test::Unit)

I believe that once you have an idea of what testing is, regardless of the library, you'll find it easy to move on to something else. But, no, this isn't an RSpec book, etc.
15 years ago
Testing is covered but there are not extensive sections where test driven development is practiced (there's a short section when developing a library). Beginning Ruby covers a breadth of topics in a reasonable depth but not any specific things in intense depth. Design patterns, similarly, are not covered specifically. I consider these things to be useful once you reach the proficiency that Beginning Ruby will get a developer to, but then they can move on to Design Patterns in Ruby (which is an awesome book suitable for anyone who's finished BR!)
15 years ago
I'm not really qualified to answer corporate, management related questions, but I personally believe it can be very hard to "sell" indoctrinated managers on new technologies, even if they mean well. They're used to processes and stability. It requires a lot of work to get "buy in" for new technologies, even if they're good! There was a saying that "you never get fired for buying Microsoft" and I'd say in coding "you never get fired for choosing Java" even when it's not the best choice.

I'd say that JRuby in particular is enterprise ready now since it runs on the JVM and you can use all of the Java goodies from it ;-) It might, therefore, be a good way to build quick scripts that use your existing Java stack but give you more agility in the decreased development time.
15 years ago
Consider trying http://tryruby.sophrinix.com/ if you want to have a quick play with a Ruby interpreter. There's a short tutorial built into it too. It's a great way to give it a try without doing any installations

And, why learn Ruby? Well, it's a language designed to make programming "joyful." I know that sounds pretty stupid but it was actually the intention of the creator. Things are made quite simple to achieve (but without making them stupidly simple) with a lack of verbosity and needless keywords. Things are mostly very consistent. Everything's an object and once you get to grips with making classes and methods, you're on your way. It's very easy to learn and very easy to experiment.. not lots of compiling, etc.
15 years ago
Considering that all I heard about Groovy a cpl years ago was good, I suspect a cultural issue of some sort. Perhaps it didn't attract enough people or have a big enough landmark project to get people in and building out the ecosystem..
15 years ago