[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Teaching Ruby to COBOL programmers

Wilson Bilkovich

3/1/2006 1:45:00 AM

This isn't a troll, I promise. I'm actually going to be doing this tomorrow.

My normal Ruby spiel is geared more toward the differences between
dynamic and static langugages, and the power of blocks. In other
words, "Hey, look at what you can't do in Java."

This is a whole different scenario, because these people are coming on
board to be web application developers, and their previous programming
experience is 100% mainframe-based. They aren't going to know HTML,
XML, Java, C++, etc.

What are some key points I should make sure to cover for procedural programmers?
Things on my list so far:
1. Variables don't hold values, they are just labels.
2. Objects are nouns, methods are verbs.
3. Structure keeps you sane.
4. Duck typing makes testing easier.
5. Rake as an example of something procedural in an object-oriented language.

That being said, I've been immersed in OOP for so long, I don't
remember what the hurdles are.
Thoughts? This is going to be a three hour session, wherein I need to
cover Ruby and at least the bare beginnings of Rails. Obviously an
in-depth treatment of either of those things is impossible in that
timeframe, but I do want people to leave feeling like it's not a
magical tongue spoken by elves and wild spirits.

Thanks,
--Wilson.


19 Answers

Xeno Campanoli

3/1/2006 4:03:00 AM

0

I like the idea that to a great extent what you are trying to do in a
lot of programming tasks is reduce
major points to lists. If things look like nested messes you are not
getting it right. Also, you design objects, when you can, to represent
real world concepts, not to accommodate artificial internal conveniences
you find. The object to a great extent is not to make it go, but to
make it maintainable so it will continue to go.

xc

Wilson Bilkovich wrote:

>This isn't a troll, I promise. I'm actually going to be doing this tomorrow.
>
>My normal Ruby spiel is geared more toward the differences between
>dynamic and static langugages, and the power of blocks. In other
>words, "Hey, look at what you can't do in Java."
>
>This is a whole different scenario, because these people are coming on
>board to be web application developers, and their previous programming
>experience is 100% mainframe-based. They aren't going to know HTML,
>XML, Java, C++, etc.
>
>What are some key points I should make sure to cover for procedural programmers?
>Things on my list so far:
>1. Variables don't hold values, they are just labels.
>2. Objects are nouns, methods are verbs.
>3. Structure keeps you sane.
>4. Duck typing makes testing easier.
>5. Rake as an example of something procedural in an object-oriented language.
>
>That being said, I've been immersed in OOP for so long, I don't
>remember what the hurdles are.
>Thoughts? This is going to be a three hour session, wherein I need to
>cover Ruby and at least the bare beginnings of Rails. Obviously an
>in-depth treatment of either of those things is impossible in that
>timeframe, but I do want people to leave feeling like it's not a
>magical tongue spoken by elves and wild spirits.
>
>Thanks,
>--Wilson.
>
>
>
>
>
>

--
Xeno Campanoli: http://www.eskimo...
Robbing Republican Treasonists ARE MORE DANGEROUS than foreign terrorists!



Bill Guindon

3/1/2006 4:18:00 AM

0

On 2/28/06, Wilson Bilkovich <wilsonb@gmail.com> wrote:
> This isn't a troll, I promise. I'm actually going to be doing this tomorrow.
>
> My normal Ruby spiel is geared more toward the differences between
> dynamic and static langugages, and the power of blocks. In other
> words, "Hey, look at what you can't do in Java."
>
> This is a whole different scenario, because these people are coming on
> board to be web application developers, and their previous programming
> experience is 100% mainframe-based. They aren't going to know HTML,
> XML, Java, C++, etc.
>
> What are some key points I should make sure to cover for procedural programmers?
> Things on my list so far:
> 1. Variables don't hold values, they are just labels.
> 2. Objects are nouns, methods are verbs.
> 3. Structure keeps you sane.
> 4. Duck typing makes testing easier.
> 5. Rake as an example of something procedural in an object-oriented language.
>
> That being said, I've been immersed in OOP for so long, I don't
> remember what the hurdles are.
> Thoughts? This is going to be a three hour session, wherein I need to
> cover Ruby and at least the bare beginnings of Rails. Obviously an
> in-depth treatment of either of those things is impossible in that
> timeframe, but I do want people to leave feeling like it's not a
> magical tongue spoken by elves and wild spirits.

Forgetting OOP for a moment, and thinking WWW instead...
It's stateless.
Learn how to manage hidden values.

Those were the two toughest items for me when I moved to the web.

> Thanks,
> --Wilson.

--
Bill Guindon (aka aGorilla)
The best answer to most questions is "it depends".


Dave Burt

3/1/2006 6:14:00 AM

0

Wilson Bilkovich wrote:
> What are some key points I should make sure to cover for procedural
> programmers?
> Things on my list so far:
> 1. Variables don't hold values, they are just labels.
> 2. Objects are nouns, methods are verbs.

.... and methods belong to objects' classes. I'd be emphasizing OO. To me,
that means getting across the idea of classes as (more or less) types of
objects, whose behaviours you define, and objects as instances of those
classes. There's also inheritance and polymorphism to be covered. Mixins,
too, for bonus points.

> 3. Structure keeps you sane.

Does this just mean defining classes and modules and naming files
accordingly?

> 4. Duck typing makes testing easier.
> 5. Rake as an example of something procedural in an object-oriented
> language.

You've got 3 hours, you could cover metaprogramming (see Chapter 6 of Why's
(Poignant) Guide to Ruby and Dwemthy's Array) to give your people an
understanding of how Rails' before_filter, and has_and_belongs_to_many, etc.
work behind the scenes. It is ancilliary, though, and you may get better
value by looking at the Rails framework specifically (build a to-do list) or
drilling OO (read the rubyquiz.com for some problems and nice rubyish
solutions).

STOP RUN,
Dave


Stephen Waits

3/1/2006 6:23:00 AM

0

Bill Guindon wrote:
>
> Forgetting OOP for a moment, and thinking WWW instead...
> It's stateless.
> Learn how to manage hidden values.

I agree.. important to teach.

However, in this case.. COBOL -> Ruby, I'd say forget the WWW
altogether, teach Ruby.

You should be able to quickly teach them how to do the same things they
do every day in COBOL, only in Ruby. You can even show them some OO
stuff without having to dive completely into the OO pool. By doing that
first, maybe you can keep them tuned in awhile longer. Then you can
approach the topics more foreign to your students.

But, the bottom line is that you're going to *have* to teach them about
Objects if they're to learn Ruby.

Check out the "Why Ruby?" section over on ruby-doc.org for a great set
of links. Read Why's Poignant Guide for some inspiration too.

Good luck.

--Steve


Hal E. Fulton

3/1/2006 6:29:00 AM

0

Stephen Waits wrote:
> Bill Guindon wrote:
>
>>
>> Forgetting OOP for a moment, and thinking WWW instead...
>> It's stateless.
>> Learn how to manage hidden values.
>
>
> I agree.. important to teach.
>
> However, in this case.. COBOL -> Ruby, I'd say forget the WWW
> altogether, teach Ruby.
>
> You should be able to quickly teach them how to do the same things they
> do every day in COBOL, only in Ruby. You can even show them some OO
> stuff without having to dive completely into the OO pool. By doing that
> first, maybe you can keep them tuned in awhile longer. Then you can
> approach the topics more foreign to your students.
>
> But, the bottom line is that you're going to *have* to teach them about
> Objects if they're to learn Ruby.

All true enough.

My own list:

I'd emphasize character-oriented I/O, since they are so used to
fixed-length records read a record at a time.

I'd show them irb, which is fun to play in.

I'd emphasize that "it's all PROCEDURE DIVISION" -- all of a Ruby
program is executed, no real declarations.

I'd emphasize that variables are untyped, and introduce the concept
of object references.

Etc....


<joke>When the COBOL guys heard about C++, they were jealous. They made
an OOP version of their own language... called ADD ONE TO COBOL.</joke>


Hal




Joel VanderWerf

3/1/2006 7:33:00 AM

0

Wilson Bilkovich wrote:
...
> What are some key points I should make sure to cover for procedural programmers?
> Things on my list so far:
> 1. Variables don't hold values, they are just labels.

We hear that a lot, but, somehow, it never sounds right. If variables
are labels, why don't they follow the object around, and become
accessible to other users of the object? How do I calculate how many
labels an object has? Is a label an object? Can you change the text of
the label? Do they ever fall off when the glue dries out?

Anyway, variables *do* hold some kinds of values, like numbers,
booleans, and symbols, in almost exactly the way that C variables "hold"
values. Ironically, the only thing that ruby variables hold *is* VALUE,
as it is called in the source.

So, what to say to COBOL programmers?

I know little of these early 60's programming languages of which you
speak. However, if I were introducing ruby to C programmers, I would
show them the basic data types in ruby.h. Values are passed around as
unsigned long. Types like integers, symbols, etc. are encoded by certain
bit patterns. Other bit patterns encode pointers to heap-allocated
structs, which represent almost everything else: strings, arrays, user
defined objects. All assignment and argument passing is just copying
long words. An array is represented as a C array of long words that
encode either immediate values or pointers. Array access just means
getting and setting one (or more) of these long words.

This may seem extreme, to look at the implementation on the first day.
But it is very concrete, enough to inoculate against the usual
confusions: Is ruby pass-by-reference or pass-by-value? Why are there
are no destructive methods on Fixnum or Symbol?

> 4. Duck typing makes testing easier.

It also makes libraries more useful, if the libraries are written to
assume as little as possible about the objects they interact with.
Grokking this point is a major step in learning to write ruby programs
in ruby, rather than write cobol programs in ruby.


In general, I don't think it can hurt to be concrete, or to at least
give a concrete view of things as an alternative. For example, message
evaluation happens by looking up a symbol in the receiver's table, and,
if no entry is found, iterating up the superclass tables. For some
people (esp. those with a procedural background), that means a lot more
than "this object over here sends a message to that object over there,
which can either respond to it or let its superclass handle it".

--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407


Erik Veenstra

3/1/2006 10:17:00 AM

0

> When the COBOL guys heard about C++, they were jealous. They
> made an OOP version of their own language... called ADD ONE
> TO COBOL.

LOL :)

gegroet,
Erik V. - http://www.erikve...

Christian Neukirchen

3/1/2006 12:46:00 PM

0

Hal Fulton <hal9000@hypermetrics.com> writes:

> My own list:
>
> I'd emphasize character-oriented I/O, since they are so used to
> fixed-length records read a record at a time.
>
> I'd show them irb, which is fun to play in.
>
> I'd emphasize that "it's all PROCEDURE DIVISION" -- all of a Ruby
> program is executed, no real declarations.
>
> I'd emphasize that variables are untyped, and introduce the concept
> of object references.

Finally, tell them that Rails 1.1 new Object#copy_instance_variables_from
feature is very much like "COPY CORRESPONDING". *duck*

> Hal
--
Christian Neukirchen <chneukirchen@gmail.com> http://chneuk...


Wilson Bilkovich

3/1/2006 2:10:00 PM

0

On 3/1/06, Hal Fulton <hal9000@hypermetrics.com> wrote:
> Stephen Waits wrote:
> > Bill Guindon wrote:
> >
> >>
> >> Forgetting OOP for a moment, and thinking WWW instead...
> >> It's stateless.
> >> Learn how to manage hidden values.
> >
> >
> > I agree.. important to teach.
> >
> > However, in this case.. COBOL -> Ruby, I'd say forget the WWW
> > altogether, teach Ruby.
> >
> > You should be able to quickly teach them how to do the same things they
> > do every day in COBOL, only in Ruby. You can even show them some OO
> > stuff without having to dive completely into the OO pool. By doing that
> > first, maybe you can keep them tuned in awhile longer. Then you can
> > approach the topics more foreign to your students.
> >
> > But, the bottom line is that you're going to *have* to teach them about
> > Objects if they're to learn Ruby.
>
> All true enough.
>
> My own list:
>
> I'd emphasize character-oriented I/O, since they are so used to
> fixed-length records read a record at a time.
>
> I'd show them irb, which is fun to play in.
>
> I'd emphasize that "it's all PROCEDURE DIVISION" -- all of a Ruby
> program is executed, no real declarations.
>
> I'd emphasize that variables are untyped, and introduce the concept
> of object references.
>

Thanks Hal (and everyone).. this kind of thing definitely helps. Part
of my problem is that I can't draw analogies to a language I don't
know.


Aníbal Rojas

3/1/2006 9:10:00 PM

0

I'll focus it as a introduction to Object Oriented Programming with
practical Ruby examples. I have had the experience of teaching a MVC
framework (based on J2EE) to "procedural programmers" and I had to go
back over and over explaining Object Oriented Programming....