Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > [ANN] interface 0.1.0

Reply
Thread Tools

[ANN] interface 0.1.0

 
 
Daniel Berger
Guest
Posts: n/a
 
      05-09-2004
Hi all,

It is with some trepidation that I announce the first release of the
interface module.

What is it?
===========
Java style interfaces for Ruby. For example:

require "interface"

MyInterface = interface{
required_methods :foo, :bar
}

# raises an Interface::MethodMissing error
class A
include MyInterface
end

# Also raises an error
class B; end
b = B.new
b.extend(MyInterface)

# No error raised
class C
def foo; end
def bar; end
include MyInterface
end

See the docs for more details, including a way to implement a partial
interface.

Where is it?
============
You can find it on the RAA or the project home page at
http://ruby-miscutils.sf.net.

Why did I do it?
================
Mainly to silence the Java weenies and to show that it was possible.
See the README for the long version. I, personally, do not find
interfaces to be especially useful, but here you go.

Enjoy! (or not)

Dan
 
Reply With Quote
 
 
 
 
James Britt
Guest
Posts: n/a
 
      05-09-2004
Daniel Berger wrote:

> Hi all,
>
> It is with some trepidation that I announce the first release of the
> interface module.


This looks quite neat.

>
>
> Why did I do it?
> ================
> Mainly to silence the Java weenies and to show that it was possible.
> See the README for the long version. I, personally, do not find
> interfaces to be especially useful, but here you go.



Designer/developer theory question:

Do interfaces have a place in dynamically-typed/duck-typing languages?

Does the use of interfaces in Ruby encourage a poor (or, say, less
robust) design?

They seem like a handy way to embed assertions into code to ensure that
something blows up sooner than later, though perhaps the usual TDD
arguments apply here.


James



 
Reply With Quote
 
 
 
 
Gavin Sinclair
Guest
Posts: n/a
 
      05-09-2004
On Monday, May 10, 2004, 2:26:57 AM, James wrote:

> Designer/developer theory question:


> Do interfaces have a place in dynamically-typed/duck-typing languages?


Yes, if the developer thinks they have a place

> Does the use of interfaces in Ruby encourage a poor (or, say, less
> robust) design?


I don't understand this question :/

> They seem like a handy way to embed assertions into code to ensure that
> something blows up sooner than later, though perhaps the usual TDD
> arguments apply here.


They do apply, but it's not the end of the story. Being able to
selectively apply this interface approach (and/or the StrongTyping
module) is a good thing. If I were forced to use it with every class
I create, it would be frustrating, to say the least.

Cheers,
Gavin




 
Reply With Quote
 
James Britt
Guest
Posts: n/a
 
      05-09-2004
Gavin Sinclair wrote:

> On Monday, May 10, 2004, 2:26:57 AM, James wrote:
>
>>Does the use of interfaces in Ruby encourage a poor (or, say, less
>>robust) design?

>
>
> I don't understand this question :/


For example, some developers think Ruby needs static typing. They find
a way to add this in, and make it a habit. This is arguably a Bad Thing
to the extent that one loses a good deal of the power and flexibility of
the language. It's like when Pascal or FORTRAN developers first try
their hand at OOP; objects and classes (typically) become mere
namespaces for collections of procedures, and the benefits of OOD are
lost, because the developer is coding with a foreign mindset.

So I'm wondering if the use of interface classes leads one to design
Ruby code with a Java mentality.

>
>
>>They seem like a handy way to embed assertions into code to ensure that
>>something blows up sooner than later, though perhaps the usual TDD
>>arguments apply here.

>
>
> They do apply, but it's not the end of the story. Being able to
> selectively apply this interface approach (and/or the StrongTyping
> module) is a good thing. If I were forced to use it with every class
> I create, it would be frustrating, to say the least.


Quite true. But how often, I wonder, do people start out using
something like the StrongTyping module, and later on go back and rip it
out because it ends up getting in the way?

James



 
Reply With Quote
 
Gavin Sinclair
Guest
Posts: n/a
 
      05-09-2004
On Monday, May 10, 2004, 8:46:08 AM, James wrote:

>>>They seem like a handy way to embed assertions into code to ensure that
>>>something blows up sooner than later, though perhaps the usual TDD
>>>arguments apply here.

>>
>>
>> They do apply, but it's not the end of the story. Being able to
>> selectively apply this interface approach (and/or the StrongTyping
>> module) is a good thing. If I were forced to use it with every class
>> I create, it would be frustrating, to say the least.


> Quite true. But how often, I wonder, do people start out using
> something like the StrongTyping module, and later on go back and rip it
> out because it ends up getting in the way?


Possibly quite often, but that doesn't invalidate the usage in the
first place. It served a developmental purpose for a while; as you
wrote, to ensure that something blows up sooner rather than later.
It's the same as removing any other debugging code.

I like the feeling of removing scaffolding from my code

Gavin



 
Reply With Quote
 
David Alan Black
Guest
Posts: n/a
 
      05-09-2004
Hi --

James Britt <(E-Mail Removed)> writes:

> For example, some developers think Ruby needs static typing. They find
> a way to add this in, and make it a habit. This is arguably a Bad Thing
> to the extent that one loses a good deal of the power and flexibility of
> the language.


[and later...]

> Quite true. But how often, I wonder, do people start out using
> something like the StrongTyping module, and later on go back and rip it
> out because it ends up getting in the way?


I'd like to think so, but I doubt it. I've always felt that the real
loss with such things is, as you suggest, that they divert people from
understanding and exploring what Ruby offers that isn't the same as
the language(s) they "came from". Ruby discussions have always (i.e.,
in my 3.5 Ruby years, in the English-language forums) been full of
chameleon-like proposals and rationales, like "adding LISP macros to
Ruby" or "making C++ programmers feel more at home [with ++ or
whatever]" or "adding static/strong/whatever typing" (generally
meaning classname checking combined with suppression of the fact that
Ruby objects are not manacled to their classes of origin) and so on.
I'm actually strangely fascinated by the fact that Ruby attracts so
much of this kind of discourse (since everyone you ask says they
program Ruby because they specifically love Ruby), though in spite of
the fascination my preference would be for the tendency to subside and
for Ruby to be viewed as Ruby.

Dan's announcement was actually very amusing for its ironic and
somewhat jaded tone in this regard -- sort of like, "Oh, all right, if
you want to morph Ruby into Java, here!"


David

--
David A. Black
http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Going from higher security level interface to lower security interface- HELP!!! - AM Cisco 4 12-28-2004 09:52 PM
PCI interface or USB interface David Wireless Networking 4 09-16-2004 01:01 PM
allow ssh only on outside interface, but telnet on inside interface of router no-one Cisco 0 07-28-2004 04:17 PM
PIX: how to allow 1 host from outside interface to access another host on the inside interface? jonnah Cisco 1 04-21-2004 02:26 PM
static nat between phisical interface and virtual interface on same ethernet Andrea Cisco 0 04-19-2004 09:37 AM



Advertisments