From: bwalton@artsci.utoronto.ca (Ben Walton)
Subject: [sup-talk] In next: thread-view-mode labelling No method join for Set
Date: Wed, 19 Aug 2009 22:57:25 -0400 [thread overview]
Message-ID: <1250734085-sup-2162@ntdws12.chass.utoronto.ca> (raw)
In-Reply-To: <1250727630-sup-3112@yoom.home.cworth.org>
Excerpts from Carl Worth's message of Wed Aug 19 20:31:12 -0400 2009:
> [*] Totally off-topic: This is one of the things about "dynamically
> typed" languages that I've never been able to wrap my brain around. I
> really like that with static typing I can trust the compiler to help
> me be very thorough if I make a type change like this, (and catch all
> the cases before shipping any code). Instead, here, there's a hard
> task of exercising every possible code path (at run time) before we
> know if there are any type errors still lingering. I've seen some
> proponents of dynamically-typed languages argue that unit testing
> should provide the same coverage that a statically-typed compiler
> would, but I haven't seen that in practice.
The term you'll see bandied about in ruby circles/books/etc is 'duck
typing' which coming from strongly typed languages is definitely
something that takes some getting used to. Basically, instead of
caring about the type of the object, you case about what the object
does. If it walks like a duck and quacks like a duck, treat it like a
duck.
A very simple example is a function that expects to append data to
another object. You could pass it a string (which uses << to append)
or an array (which uses << to push elements on the end). If you
originally passed a string, but found performance (memory ->
realloc()) issues, you could swap the string object for an array
object and do array.join when everything is collected into array
elements.
Then, you'll see many examples where there is code like:
raise SomeException, "blah" unless someobject.respond_to?(:somemethod)
Your code doesn't care _what kind_ of object it gets as long as it
knows _how_ to talk to it.
Personally, I really like this. Ruby isn't perfect by any stretch,
but of all the languages I've used, it's hands down the most fun to
write.
-Ben
--
Ben Walton
Systems Programmer - CHASS
University of Toronto
C:416.407.5610 | W:416.978.4302
GPG Key Id: 8E89F6D2; Key Server: pgp.mit.edu
Contact me to arrange for a CAcert assurance meeting.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://rubyforge.org/pipermail/sup-talk/attachments/20090819/a644ea46/attachment.bin>
next prev parent reply other threads:[~2009-08-20 2:57 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-19 20:41 Wirt Wolff
2009-08-20 0:31 ` Carl Worth
2009-08-20 2:57 ` Ben Walton [this message]
2009-08-20 4:03 ` Carl Worth
2009-08-21 0:16 ` Ben Walton
2009-08-24 18:13 ` William Morgan
2009-08-25 7:44 ` Nicolas Pouillard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1250734085-sup-2162@ntdws12.chass.utoronto.ca \
--to=bwalton@artsci.utoronto.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox