Beginning Ruby 172
TimHunter writes "Peter Cooper's Beginning Ruby: From Novice to Professional has two audiences, novices with no programming experience who want to learn Ruby as their first programming language, and veterans who want to add Ruby to their programming toolkit. Cooper's response to this challenge is a solid entry in the limited arena of Ruby tutorials. Even though the early chapters are marred by the occasional reference to an advanced topic, readers will appreciate the plentiful examples and thoughtful description of the Ruby language." Read below for the rest of Tim's review.
Beginning Ruby: From Novice to Professional | |
author | Peter Cooper |
pages | 631 |
publisher | Apress |
rating | 7 |
reviewer | Tim Hunter |
ISBN | 1590597664 |
summary | An introduction to Ruby programming |
Ruby is an object-oriented programming language in the same family as Perl and Python. Ruby is very popular for writing web applications but also widely used for the general-purpose programming tasks. Ruby is available for Linux, Mac OS X, and Microsoft Windows. It is Open Source software with a commercially friendly license.
I agreed to review this book in particular because, even though the Ruby community has a strong tradition of encouraging newcomers, there are actually very few resources for the Ruby beginner. Ruby has gained a repuation for being easy to learn and therefore is attractive to people with limited or no programming experience. Novice programmers post almost daily requests for help and direction to the ruby-lang mailing list.
In addition to serving people with no progamming experience, Beginning Ruby is also aimed at experienced programmers who want to learn Ruby. Progammers coming from languages such as Java or C++ often struggle with Ruby's dynamic typing and (even with the recent explosion of Ruby-related books) the relative scarcity of documentation. Beginning Ruby tries to satisfy this audience by explaining Ruby's design, history and place in the programming world and including an extensive survey of the currently-available Ruby libraries.
Beginning Ruby is divided into 3 parts. The first part is aimed at neophytes. Experienced programmers, especially those experienced with object-oriented programming, will be able to skip chapter 2 and skim chapters 3 and 4.
The book starts simply. Chapter 1 isn't even about programming. This chapter explains how to install Ruby on Windows, OS X, and Linux. The instructions are thorough and aimed squarely at beginners. For example, Cooper explains how to get a command prompt on Windows and how to run Terminal.app on OS X.
Chapters 2 and 3 introduce fundamental concepts such as variables, expressions, control flow, classes, and objects. Cooper emphasizes experimentation. He says that irb, Ruby's interactive programming module, "provides the perfect environment for tweaking and testing the language, as you cannot do any real damage from within irb." Such assurances are helpful, especially to the beginner who may be slightly afraid that he's going to somehow make a mistake that will "break" his computer.
Explaining programming to beginners is hard. I've read a number of books that try to teach object-oriented programming concepts to people with no programming experience whatsoever. None were stunningly successful. This one isn't either. The problem is that books are linear, but there are simply too many things – concepts, keywords, tools – that have to be introduced nearly simultaneously and initially taken on faith. Cooper distracts his readers by peppering his text with too many "don't worry about this yet" disclaimers and assurances that explanations will appear later. His references C and Perl will be meaningless and possibly confusing to the beginning programmer.
Chapter 4, "Developing a Basic Ruby Application," starts by explaining what a text editor is and offering a few recommendations for text editors on Windows, OS X, and Linux. Then it guides the reader through his first real program, a script to read a text file and compute simple statistics such as the number of lines and words. This is a well-chosen example that will, when completed, make the student feel like he's accomplished something.
Chapter 5, "The Ruby Ecosystem," feels out-of-place. This chapter doesn't teach anything about Ruby programming. Instead it explains Ruby's history, introduces Ruby On Rails, and talks about the Open Source movement. Little, if any, of this material will be interesting to a fledgling programmer. The chapter finishes with a list of internet-based Ruby resources such as mailing lists, IRC, and blogs. All of this seems much better suited as an appendix and indeed the list of resources appears again in Appendix C.
Part 2, "The Core of Ruby," has a slower pace. With the very basic material covered, Beginning Ruby gets a better footing. Starting in this part the material is useful to both beginners and veterans.
This is probably as good a place as any to talk about the examples, which are numerous and very likely the best part of the book. Most of the the examples are short and to the point. A few extend over several pages. My overall impression is that they are well-chosen and well-coded. I especially like the way the examples appear on the page, visually distinctive but without interrupting the flow of the text. Source code for all of the examples may be downloaded from the Apress web site. However, even though the files are divided into a directory per chapter, the examples aren't numbered in the text so it's difficult to find the code for the example you're looking at. I ended up using grep to search for keywords in the sources.
Chapter 6 is a slower pass through Ruby, focusing on Ruby's object-orientation. Though fewer than part 1, there are still problems with references to concepts that have not yet been introduced. For example, Cooper uses the require method in the context of namespaces even though require has not been introduced. Indeed, it's not even necessary to mention namespaces at all in this chapter since the entire concept could've been held off until the next chapter, which explains how to create programs from code in multiple files.
The remaining chapters in this part start to address the needs of the serious Ruby programmer. This is a lot of ground to cover, including documentation, debugging, test-driven development, I/O, databases, and how to deploy Ruby programs. I particularly liked Cooper's thorough instructions for installing and creating RubyGems, Ruby's third-part library management system. There are so many topics to cover that each one gets only an introduction, but Cooper uniformly provides links to extended online documentation.
The last chapter in this part works through an even larger example, a Ruby "chat bot." This is an ingenious and entertaining example, the kind of program that, had I read it when I was just starting to learn programming, would have spent many happy hours tweaking. Call me a geek, but I got a chuckle out of the example on page 383 of two very stupid bots conversing.
Part 3 is called "Ruby Online." Of course it starts with the obligatory chapter on Ruby on Rails. I suppose publishers require such a chapter in all Ruby books, even though RoR is more than amply covered by other excellent books. I'm not a RoR programmer so I blew off this chapter.
Chapter 14 describes Ruby's support for the Internet via its HTTP, email, and FTP libraries. Chapter 15 covers other networking support libraries. As usual there are many excellent examples. Chapter 16 is a very good survey of the standard and add-on libraries that the serious Ruby programmer will find useful. Each library is demonstrated with an example, and Cooper provides a link to the complete documentation.
At the start of this review I said that Beginning Ruby is divided into 3 parts, but actually there are four. The last part consists of 3 appendices. Appendix A is a summarization of Part 2. Appendix B is sort of a "semi-reference" to Ruby's core libraries. This is not intended to be a complete reference. Instead, Cooper limits his discussion to the most useful methods of the core classes. As I mentioned earlier, Appendix C is a list of Internet-based Ruby resources such as web pages, mailing lists, IRC channels, and blogs.
I'm giving Beginning Ruby a 7. It's a good book for someone who wants to learn Ruby as his first programming language. It could be better. I liked Cooper's patient and thoughtful explanations about installing Ruby and RubyGems, how to use a command line, and what a text editor is for. Cooper supplies answers to all the typical Ruby-nuby questions, but his explanation of basic concepts is marred by the occasional confusing reference to advanced or even irrelevant topics. For the experienced programmer who learns best by reading and working through examples this book is a good choice. Dave Thomas' Programming Ruby, The Pragmatic Programmer's Guide (a.k.a. the Pickaxe) is a tough competitor, but each book has a considerable amount of material that is not found in the other book. For example the Pickaxe's core library reference is exhaustive but it has only a limited amount of the kind of tutorial explanations that is Beginning Ruby's strength. Beginning Ruby is available in PDF format from Apress' web site at about half the price of the paper book.
I have been programming Ruby as a hobby for over 5 years. Apress gave me a review copy of this book, but otherwise I have no connection to the author or publisher."
You can purchase Beginning Ruby: From Novice to Professional from amazon.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
When you step back and consider history (Score:4, Interesting)
Wouldn't a venn diagram of key language features show substantial overlap?
Ruby sounds like your typical well-done tool, which clearly has its audience.
The only substantial criticism of Ruby I've ever heard is here:
http://ciaranm.org/show_post/110 [ciaranm.org]
Still, I'm wondering, what is the Next Big Thing? Is Python3000 going to rule the day? It's obviously 500 times better than Perl6. Then again, you've another round of C++ coming up for standardization: will svelte compiled languages recover some of the mindshare lost to these SUV scripting languages?
Is the point of making some new tool the buzz of the day simply to sell books?
Re: (Score:2)
Python 3000 is a cleanup of the inevitable evolutionary accretions that languages accumulate. Nothing ground breaking in this release feature-wise. So Python 3000 and Perl 6 are very different in scope. I (as a Python user), for one am very curious of what will come out of Perl 6.
There is a big list at
http://dev.perl.org/perl6/faq.html [perl.org]
The ones I am interested are
explicit strong typing (Python 3000 - optional interfaces)
corou
Re: (Score:3, Insightful)
How many different programming tools do we need?
Wouldn't a venn diagram of key language features show substantial overlap?
Sure, but that's not to say they overlap in the same places. I've never come across two programming languages with exactly the same strengths and weaknesses.
Ruby sounds like your typical well-done tool, which clearly has its audience.
The only substantial criticism of Ruby I've ever heard is here
Bah, you're obviously not looking hard enough :)
You can write pages on criticism on any language. For instance, you could criticise Ruby on it's efficiency, it's dynamic typing, it's syntax quirks, it's libraries, it's readability, it's method naming conventions... The list is substantial, and many people disagree whether certain features are advantag
Re: (Score:3, Interesting)
Re: (Score:3, Informative)
There are plenty of pairs where difference are marginal, though. Say, C# and Java.
C# has first-class functions and lambdas already, and will get neat syntax for them in v3.0. Java is going to get lambdas in the next version. Even C++0x is going to get something similar, though not with true closure se
Re: (Score:2)
C# has first-class functions and lambdas already, and will get neat syntax for them in v3.0. Java is going to get lambdas in the next version. Even C++0x is going to get something similar, though not with true closure semantics.
Does that include tail call elimination?
You don't have to wait for the Next Big Thing for functional stuff - it's already here, in the mainstream languages. It just doesn't look as neat as Haskell does, but you shouldn't care all that much about the looks.
Sure, this is all a step in the functional direction, but I was rather hoping for a more than just a single step. Since you mention Haskell, you'll probably be aware it contains a lot of functionality that is difficult or impossible to reproduce in a language like C# or Java.
Re: (Score:2)
No idea in either case. C++ standard certainly doesn't guarantee it, but IIRC, most optimizing compilers (and GCC in particular) try to perform it already. Java, I don't know. More likely for C#, since CIL already has a special bytecode for optimized tail calls.
Technically, first-class functions are all that is needed to consider the language functional. Pr
Re: (Score:2)
No idea in either case. C++ standard certainly doesn't guarantee it, but IIRC, most optimizing compilers (and GCC in particular) try to perform it already. Java, I don't know. More likely for C#, since CIL already has a special bytecode for optimized tail calls.
I didn't know GCC optimised that, though it would appear you're certainly right! I don't think tail call elimination is planned for Java (from what I've heard), and I haven't heard it being introduced into C#. I guess it's possible though, since as you say it's supported by CIL, although so far as I know only functional languages like F# etc. use it.
Technically, first-class functions are all that is needed to consider the language functional. Pragmatically, it's more like "convenient first-class functions". There are a few other things traditionally associated with functional languages, true - type inference and pattern matching, in particular.
Functional programming is a programming style that attempts to minimise side effects, and whilst first-class functions et all are steps to ensuring that goal,
Re: (Score:2)
I know what pure functional approach means; but it's just not practical for the vast majority of applications - we can't optimize it nearly as well as the more conventional imperative style. That's wh
Re: (Score:2)
I know what pure functional approach means; but it's just not practical for the vast majority of applications - we can't optimize it nearly as well as the more conventional imperative style. That's why you see more programs written in O'Caml than Haskell, for example. Haskell is great as a language to learn what FP is about, but pure functional programming certainly won't be the next big thing, not in the next few years at least.
Pure functional programming eliminates all side effects. More pragmatic forms of functional programming only attempt to minimise it. This is why I don't consider C# to be a very functional language, because it doesn't really attempt to minimise side effects. C#'s style is still very imperative.
Regarding optimization, I think you'd be surprised at how much pure functional languages can be optimized. If you compare the benchmarks of pure languages like Haskell or Clean again impure languages like OCaml, you'
Re: (Score:2)
So do I, I just hope that they manage to create a functional language till then that is actually easy on the eyes. Currently they often try to be a little to clever for their own good.
Re: (Score:2)
Re: (Score:2)
Another issue Ruby and many other 'scripting' languages have is lack of lexical scoping. I just don't understand where there is a benefit of not declaring variables properly, it not only makes the scope of a variable rather unclear it also makes automatically catching errors much harder. A little "var a = 5" isn't much more to type then "a = 5", but its a hell of a lot more expressive. Ruby does a ton of good stuff, in fact its the languages
Re: (Score:2)
But if Ruby is a better Perl, will P6 be a redder Ruby?
Re: (Score:2)
I like your point, but I'm coming to the conclusion that there is a standard normal distribution of tools and the
Re: (Score:2)
High level languages vs. assembly (Score:2)
The rules of the game have changed in two important ways over the intervening years, though:
Enlighten me (Score:4, Insightful)
If the main reason for writing server side software is web based applications, or at least dynamic content, isn't a huge factor in this how well it scales? Nobody makes sites to be used by 20 people.
Finally, if anybody can explain it's popularity to me, should I learn it? I'm currently doing freelance web dev mostly in PHP, would it be useful? How? In my spare time I'm writing a AJAX web app with PHP back-end at the moment and it's mostly for my personal use (task tracking from anywhere), is Ruby good here with the limited audience the site'll have?
Re:Enlighten me (Score:4, Informative)
Ruby isn't any more a server-side language than 68k assembler is. You've probably confused it with Ruby on Rails [rubyonrails.org] which is a framework (and an excellent one, I might add) for making websites. Compared to plain PHP it makes web development easy and fun and even supports stuff like AJAX out of the box.
Re:Enlighten me (Score:5, Informative)
Re: (Score:2)
Re: (Score:2)
PHP consists of both a programming language and a framework. I very shallow, "to the metal" framework to be sure, but still a framework. It provides features such as form submission parsing, cookie management and a concept of "sessions". CakePHP and friends add another layer of framework atop this existing functionality.
Re: (Score:2)
Must... Resist... Contraceptive... Joke...
Re: (Score:3, Interesting)
Re: (Score:2)
Re: (Score:2, Insightful)
That said, I started playing around with Ruby on Rails. Honestly, simple tasks like database access is so much simpler to handle in RoR it's just amazing. Creating database driven web sites, with one-to-many and many-to-many relationships is at least 10x quicker than in PHP. You have to get used to the MVC style of programming of course.
I'm still doing PHP at work, but at some point will push for a swi
Re:Enlighten me (Score:5, Informative)
Hi
First, Ruby != Rails. Ruby is the programming language. Rails (or Ruby on Rails) is the web development framework. Ruby has been around a lot longer than Rails, but has certainly had it's popularity boosted by the buzz surrounding Rails.
Second, I'd disagree that system performance is the biggest factor is selecting a web framework. Rails out of the box will support the load more most websites. There are many things that you can do to tune performance once you start getting enough page views for it to matter: caching pages, selectively replacing ActiveRecord's queries with raw SQL, etc. There are also people starting to focus on rails performance both from a developer's standpoint (e.g., the Rails Express Blog [railsexpress.de]) and from the hosting standpoint (e.g., Engine Yard [engineyard.com]).
To me, the first and foremost goal of building a website is to get the functionality there quick in order to attract users. Once you've got that, and have rapidly been able to iterate to what the users want to see, then you can start worrying about performance. And, if your site really makes it big, you are going to have to do custom tuning work no matter what framework you've chosen.
Personally, I've found Rails to be a wonderfully productive framework to use for web development
Re: (Score:3, Insightful)
Of course not. If it were, every high traffic website would be an NSAPI/ISAPI/Apache module. The vast majority of small to medium scale web apps are database limited much more than they are CPU limited on the web server. Twitter is such an app, as that coding horror article eventually mentions.
As far as whether you should learn it, I get paid to write mostly PHP, and I'd say anybody else in my po
Re: (Score:2)
All I can say is that after doing PHP on and off for a few years and then learning Ruby, I never want to touch another line of PHP shite again. Sorry, if
Why so down on perl? (Score:2)
Both Perl and Ruby are really rad. And RAD. And they both operate on the ever-so-helpful principle of least surprise. Unlike PHP, or a lot of other languages.
If there was one thing I don't like about perl (and I can totally sympathize from a language beauty POV), it's that sigils represent interpretation intent, and do not describe the base object.
I.E.
$foo[bar] is a value in @foo not @foo[bar]. Which seems silly because the array slicing operator has list and value
Re: (Score:2)
Perl 6 intends to do that, but Perl 6 seems a foregone conclusion now.
Re: (Score:3, Insightful)
Isn't the most important thing in a server side language fast performance rather than quick development time?
Only if you need performance. Not every dynamic site on the web needs to serve a bazillion people a day, and throwing hardware at a problem is often far cheaper than employing a skilled software developer for longer.
If the main reason for writing server side software is web based applications, or at least dynamic content, isn't a huge factor in this how well it scales? Nobody makes sites to be used by 20 people.
No, but very few sites have to deal with 11000 page views per second, as Twitter reputedly does. Since Rails (just) handles this, then it should handle more modest needs as well.
Also, the main problem Twitter has is the database bottleneck, not Ruby's speed (or lack thereof). Rails is designed
Re: (Score:2)
Not to doubt Twitter, but this would have it as the second most popular website on the net, behind Google: http://www.alexa.com/site/ds/top_500?&qterm=&p=Dev Corner [alexa.com], as MSN currently averages 9,700 page views per second (I should know).
I'm slightly sceptical.
That being said, I realize that Twitter's concept of page views is slightly different, and lighter than, MSN's.
Re: (Score:2)
Re: (Score:2)
Not to doubt Twitter, but this would have it as the second most popular website on the net, behind Google: http://www.alexa.com/site/ds/top_500?&qterm=&p=Dev [alexa.com] Corner, as MSN currently averages 9,700 page views per second (I should know).
I did some checking and you're probably right; according to this page [infoq.com] the oft-quoted 11000 figure is a misquote, and apparently the true figure is closer to 600 requests per second.
Oops! That's what happens when you don't check your sources, folks - my bad!
Still, 600 requests per second is still a fairly heavy traffic throughput for Rails to scale to.
Re: (Score:2)
Because its convenient for things people need to do, and the language at the center of a popular web framework.
Ruby isn't "python for websites". It would be closer to say its "python, but different". Sure, its most popular application is a web framework (Rails), but that's not the same thing as the language. Python has web frameworks like Rails too.
Re: (Score:2)
first language (Score:3, Interesting)
I know Assembler, C, Obj-C, C++, Haskell, Bash, Java, Python, Matlab (or whatever that language is called) plus a few proprietary languages and toy/educational languages.
Although, while I didn't start with C or Assembler (I started with C++ and felt it was a big piece of shit, though now days I find it quite useful; it is very abstracted though), this is certainly what I recommend for a person who is serious about programming.
As a side note, it is interesting that at the school at which I took my MSc, they used Haskell as a first starting language, basically to tell everyone that "you don't know shit about programming" and bring the sufferers of the perfect programmer syndrome down to the ground. A very good thing indeed.
Learn C or Assembler, and then learn Ruby, that is the way to go.
Re: (Score:2)
That said, C is probably a good start. If only so you realize just how much time high
Re: (Score:2)
In any field you tend to learn the basics first and then move in to more abstract levels. Any programmer should grasp the physics of a transistor, how a CMOS circuit works, what gates an
Re: (Score:2)
-matthew
Re: (Score:2)
Answer: Get an embedded system handy to work with. There are hundreds of types of embedded dev kits out there that can get you started. If you need a project, build a security system for your own home, network a coffee maker, or build an autonomous blimp-bot.
Re: (Score:2)
Heck, you could just use the emulators, if you're cheap. But it is so much cooler to see "Hello World" pop up on your GBA.
Re: (Score:3, Insightful)
Sucky in what way? Good code now days has more to do with structure and maintainability as opposed to squeezing every possisble extra CPU out of a procedure. Instead of wasting time learning C/assembler, which you probably wouldn't get any use out of, I would go with an OO language such as Java or
Re: (Score:2)
Re: (Score:2)
That is a point. OTOH, It seems to me—though I wasn't a beginner when I encountered any of them—that its a lot more beginner-friendly of a language than Java or C#.
That's true, but I'm not sure all that volume is really necessary. There is certainly a "critical mass" of resources necessary for a language to make a good first language,
Re: (Score:2)
A few simple example (simple usually means that the compiler will correct your misstakes, but I rather not get into to many details):
unsigned int a;
a = a / 2;
The next block dels with row major ordering, the code risks running several __thousands__ of times slower than foo[i][j] = bar() due to cache and MMU misses Y
Re: (Score:3, Insightful)
I'm still not sure why that means you should learn C or Assembler first.
Re: (Score:2)
For those who couldn't figure it out (it took me a few minutes of thought to "get it") the reason why is that precision is limited such that adding (let's do this in base 10 with 4 significant figures) 1.562*10E-5 to 1.328*10E+30 gets you 1.328*10E+30, even if you do the addition 10E50 times. If you start with the little numbers, you'll have added all of the little numbers up by the time you start pushing your significant digits farther and farther from the decimal point. If the ans
Re: (Score:2)
You write as if the two are mutually exclusive. IME, while this can be true, it rarely is in practice. The number of people who selectively quote part of Hoare's warning about premature optimisation, and use this as an excuse not to consider efficiency in their programming, is a major contributory factor in the amount of sucky code in the world today.
Re: (Score:2)
Re: (Score:3, Interesting)
As a first programming language, if you are serious about programming, learn C or some Assembler, this will make you understand how a computer actually works and think before you write sucky code.
I disagree. It's not necessary to know C or Assembler to program, or even program well (program efficiently, perhaps). It'll teach you about the low level workings of a computer, sure, but not knowing how computers work at a low level is not, I don't think, the reason for 90% or even 95% of all the "sucky code" you'll find.
As a side note, it is interesting that at the school at which I took my MSc, they used Haskell as a first starting language, basically to tell everyone that "you don't know shit about programming" and bring the sufferers of the perfect programmer syndrome down to the ground. A very good thing indeed.
Ouch! Trial by fire! :)
Rank this book if you've read it (Score:2)
Books for a language? Why? (Score:2)
So why waste 40-60USD on a book that provides information that is freely available on the Internet? Is it really something that looking at free documentation and examples wo
Re: (Score:2)
Try Haskell - I've been trying to learn it for several weeks now, but coming from a C background I'm really struggling. That's not necessarily a criticism of Haskell, more a sign of how different functional programming is to procedural programming.
Ruby on Blue Gene/L (Score:2)
http://www.ece.iastate.edu/~crb002/cnr.html [iastate.edu]
Re:Ruby as a first language? (Score:4, Funny)
Re: (Score:3, Funny)
Positive reinforcement is for spoiled Ruby programmers.
Ruby on Rails before PHP or bare JSP (Score:2)
Let's use MVC for our large sites for fuck's sake.
Thanks.
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
Of course, as beginner languages go, Java was great - fantastic for teaching OO fundamentals.
Re: (Score:1, Informative)
Re:Ruby as a first language? (Score:4, Informative)
I'm seriously considering starting programming with Ruby and plan to look on Amazon later this evening for this book. Do you have any eloquent reason why I shouldn't?
Re:Ruby as a first language? (Score:5, Insightful)
I know (as in, have written a substantial amount in) perl, java, ruby, C++, C, and (god forbid) PL/I. I am acquianted with quite a number more (like Haskel, Lisp) And have no fear, ruby is a fine language to start with. Especially the irb shell is very nice for getting your bearings, and the functional support will be good for you if you ever turn to the hardcore languages, like Haskell, C++ and that ilk. On the other hand, if you prefer the more limited languages, like Java, you will still have a good idea about most concepts you'll find. The only thing you will not learn that are common is static overloading and type checking, which is easy enough to pick up.
Good luck. Learning to code and coding is very rewarding :)
Re: (Score:2)
I think that's the first time I've seen Haskell and C++ lunked in an "ilk" together. I don't think that most new programmers would find much use to the functional piece of Ruby, because you can just as easily write procedural or OO code. Functional programming, at least for me, is something that you have to get used to and that I would never have gravitated towards in a self-guided ex
Re: (Score:2)
I don't think that's all that true. I think it easy for people who themselves came to program through imperative and OO programming to think of those approa
Re: (Score:2)
I think that's the first time I've seen Haskell and C++ lunked in an "ilk" together.
They are really not that dissimilar, though the syntax are :) (Meta)-programming with templates in C++ and doing Haskell is remarkedly similar, though the syntax is not --- if you don't believe me, have a look at the boost::lambda source. Anyway, above I just meant that they are both advanced languages, as in powerful and difficult to master.
As to the rest of your comment, I think passing closures around will come naturally to most newbies of taught. The hard part of functional languages, using the lambd
It would be a great first language (Score:5, Insightful)
Many computer science departments, including MIT, use Scheme as the language for their introductory computer science course. It's a wonderful language and helps the students learn a lot of key concepts that are important for formal computer science.
Scheme, though, is a little hard to use for real-world work. Ruby, on the other hand, is a great real-world language that has many of the features that I miss from Scheme: closures, lambda expresions, etc.
I haven't read this book, so I can't recommend it, but I can heartily recommend Ruby as a language that would be great to learn to program in. It'll let you focus on the key concepts rather than the tedium of implementing them in lower level languages.
Go for it!
Re: (Score:2)
Very few languages let you do the first th
Re: (Score:3, Informative)
Re: (Score:2, Informative)
I don't see why you think Ruby would make any of that difficult - p
Re: (Score:2)
Agreed. Ruby lets you learn in that progression, BTW. Everything is an object, but you don't need to know the details of that day one, at least for simple types like you're describing.
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
Re: (Score:3, Insightful)
Re: (Score:2)
Re: (Score:3, Insightful)
Shh, we need these Lisp jokes every once in a while to keep the Java people in Java, and the Ruby people in Ruby.
And yes, it's "Lisp" these days not "LISP". Go lurk at comp.lang.lisp if you don't believe me.
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
Ruby is very much like Lisp in many aspects, of course not in all, especially not syntax, but that is actually the good thing about Ruby. It gives you almost all the power of Lisp, but with a syntax that is much easier to read. I mean macros in Lisp are cool, but the blocks in Ruby are just way more readable and more practical, not as powerful, but powerful enough.
Re:I would rather have.... (Score:4, Funny)
Re: (Score:3, Informative)
Re: (Score:3, Informative)
Define "high usage website". RoR-powered sites like 43 Things [43things.com] and ODEO [odeo.com] don't seem like backyard hobby projects to me.
Re: (Score:2)
If you're going to discuss advantages of Ruby over Python, anonymous blocks and Ruby's class system would be better choices.
Re: (Score:2)
That's a lawyerly-phrased question. I still indent code. I don't like my indentation preferences determining the logic of the code.
I personally like Ruby more than Python and in particular like the class system, notation, and its implicit accessors. But I'd call these preferences just that, whereas I consider "sig
Re: (Score:2)
Re: (Score:2)
You don't dislike significant whitespace.
Perhaps if Guido Van Nostrum repeats this to me 50 times I will be cured!
It's just a matter of getting over it, using it, and seeing that it is no big deal.
Semi-colons can be used in Python, as you know. I believe I could live without them, but I consider them useful in some circumstances.
Ruby is just one example to show that a language can be readable without promoting Corporal Blankness to a three-star General.
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
The advantage is that it doesn't have Python's tab problem.
Sure, that's a problem, but not exactly a big one. You can solve it with a global search and replace if it ever crops up, whilst some of Ruby's problems are more difficult to get around. And the problem only crops up if you're copy-pasting code from a third party who shares different coding conventions to you.
Well, yeah, those are advantages, too. Its hardly as if one advantage negates the others.
Any problem that can be solved in five seconds by a decent editor is not much of a problem. Especially when it's compared against Ruby's performance, or should I say lack of it :)
Re: (Score:2)
As an experienced programmer prior learning Python it only caused me mild heartache. I don't know how easy or hard it would be for a total newcomer to programming. If they are some of the people that were in my early CS classes, I'd say they'll never get past it without help.
What p
Re: (Score:2)
Such as...what? The two main complaints I've seen about Ruby features are (1) lack of good Unicode support, which is certainly can be a real problem with I18n, but isn't a barrier to its utility in learning to program, for sure; and (2) its "too slow", which, again, isn't a barrier to its utility in learning to program in it
Re: (Score:2)
Such as...what? The two main complaints I've seen about Ruby features are (1) lack of good Unicode support, which is certainly can be a real problem with I18n, but isn't a barrier to its utility in learning to program, for sure; and (2) its "too slow", which, again, isn't a barrier to its utility in learning to program in it
Well, I was talking generally, rather than just from a beginners point of view. However, from a learning perspective, personally I found Ruby's class model to be more difficult to grasp than Python's, and it still has some odd bits to it. It's more elegant, however, I'll admit.
Ruby's syntax itself is also not as suited for a beginner, in my opinion, as there a lot of different ways to do the same thing. If you're learning by example, and each example employs a different technique, you have more to learn. S
Re: (Score:2)
I'm not sure this is really a weakness as a language for beginners; certainly, there is more to learn before you've learned every way to do everything, but that also means that there are more different approaches (suited for different learners) that can be taken and still cover t
C# is interesting. (Score:2)
Re: (Score:2)
Re: (Score:2)