From: Charles Polisher on
On 2009-11-13, Janis Papanagnou <janis_papanagnou(a)hotmail.com> wrote:
> Charles Polisher wrote:

>> Cf. "UNIX Shell Objects", Christopher A. Jones, ISBN 0-7465-7004-8
>> subtitled "Developing Multilayered, Distributed, Object-Oriented
>> Applications Using the Korn Shell".
>
> And what exactly will we find in this book? (Descriptions of the new
> typeset -T features? Emulating OO by disciplined programming? A more
> elaborated framework to support OO better than in an object based
> approach?) Being a bit more verbose would help. Thanks.

Sure... this will be my first ever book report, but here goes!
(BTW, he touches not at all on typeset. Maybe that's because it
was published in 1998. I'm not sure what you meant by your
other questions, but I'll be happy to elaborate if my little
review fails to satisfy.)

This paperback book is 425pp, includes a CD-ROM with all the
code from the book. The book is aimed at UNIX SysAdmins
who have beginning to intermediate skills in shell scripting.

The book begins with a background chapter on OOP which
covers class basics using a Hello, World! type of
program written as a Korn shell class. He covers
encapsulation, inheritance, and polymorphism with more
simple examples to illustrate his points. As he does
throughout the book, the author provides fully worked
example code.

The next chapter is a review of shell scripting in
general. He makes some assertions about the relative
merits of different approaches to shell scripting, and
then presents measurements to support his recommendations.

Chapter 3 goes into detail about writing shell classes
and touches on interfaces, constructors, accessors,
data members, methods and destructors.

Next, the author tackles several real-world applications
of shell OOP, including classes for disks, users,
machine accounts, a container (list) class, some
subclassing, and a server class. He presents a class
factory.

Following is a chapter on object communication and
event handling.

The next 2 chapters jump into a mix of Java and
shell scripting, which I found a bit out of place.

Chapter 8 covers distributed objects, and defines
a distributed object protocol for Korn shell.

Chapter 12 covers application of his constructs to
CGI programming.

Overall, there is much good material in this book.
I found it an enjoyable read and worth the cover
price of US$40. Amazon lists several used copies for
under US$6.

I sense that you would like an analysis of how well
constructed his implementation is, but that would
be more than I feel qualified to undertake.
--
Charles Polisher
From: Janis Papanagnou on
Charles Polisher wrote:
> On 2009-11-13, Janis Papanagnou <janis_papanagnou(a)hotmail.com> wrote:
>> Charles Polisher wrote:
>
>>> Cf. "UNIX Shell Objects", Christopher A. Jones, ISBN 0-7465-7004-8
>>> subtitled "Developing Multilayered, Distributed, Object-Oriented
>>> Applications Using the Korn Shell".
>> And what exactly will we find in this book? (Descriptions of the new
>> typeset -T features? Emulating OO by disciplined programming? A more
>> elaborated framework to support OO better than in an object based
>> approach?) Being a bit more verbose would help. Thanks.
>
> Sure... this will be my first ever book report, but here goes!
> (BTW, he touches not at all on typeset. Maybe that's because it
> was published in 1998. I'm not sure what you meant by your
> other questions, but I'll be happy to elaborate if my little
> review fails to satisfy.)
>
> This paperback book is 425pp, includes a CD-ROM with all the
> code from the book. The book is aimed at UNIX SysAdmins
> who have beginning to intermediate skills in shell scripting.
>
> The book begins with a background chapter on OOP which
> covers class basics using a Hello, World! type of
> program written as a Korn shell class. He covers
> encapsulation, inheritance, and polymorphism with more
> simple examples to illustrate his points. As he does
> throughout the book, the author provides fully worked
> example code.
>
> The next chapter is a review of shell scripting in
> general. He makes some assertions about the relative
> merits of different approaches to shell scripting, and
> then presents measurements to support his recommendations.
>
> Chapter 3 goes into detail about writing shell classes
> and touches on interfaces, constructors, accessors,
> data members, methods and destructors.
>
> Next, the author tackles several real-world applications
> of shell OOP, including classes for disks, users,
> machine accounts, a container (list) class, some
> subclassing, and a server class. He presents a class
> factory.
>
> Following is a chapter on object communication and
> event handling.
>
> The next 2 chapters jump into a mix of Java and
> shell scripting, which I found a bit out of place.
>
> Chapter 8 covers distributed objects, and defines
> a distributed object protocol for Korn shell.
>
> Chapter 12 covers application of his constructs to
> CGI programming.
>
> Overall, there is much good material in this book.
> I found it an enjoyable read and worth the cover
> price of US$40. Amazon lists several used copies for
> under US$6.
>
> I sense that you would like an analysis of how well
> constructed his implementation is, but that would
> be more than I feel qualified to undertake.

Thanks for providing that information.

My questions - indeed I have some - go not as far as you fear[*]
(I think), they're rather very basic and I could not derive it
from what you wrote.

What exactly is that "Korn shell class"; a part of a framework
the author provides to build OO sources on top, or just a
methodology how to use standard shell constructs to achieve OO?
How does such a "Korn shell class" look like. I'd especially be
interested whether that framework(?) supports polymorphism (it
seems just to be mentioned in the "background chapter", but it's
probably readily supported?) and ideally how that would look like
in a small example. Thanks.

Janis

[*] I'd indeed be interested in the implementation (WRT used data
structures and impact on performance), but to get an impression
of the user interface is interesting as well, probably also for
the OP.
From: Charles Polisher on
On 2009-11-13, Janis Papanagnou <janis_papanagnou(a)hotmail.com> wrote:
> Charles Polisher wrote:
>> On 2009-11-13, Janis Papanagnou <janis_papanagnou(a)hotmail.com> wrote:
>>> Charles Polisher wrote:

>>>> Cf. "UNIX Shell Objects", Christopher A. Jones, ISBN 0-7465-7004-8
>>>> subtitled "Developing Multilayered, Distributed, Object-Oriented
>>>> Applications Using the Korn Shell".
>>> And what exactly will we find in this book? (Descriptions of the new
>>> typeset -T features? Emulating OO by disciplined programming? A more
>>> elaborated framework to support OO better than in an object based
>>> approach?) Being a bit more verbose would help. Thanks.

<snip>

> Thanks for providing that information.
>
> My questions - indeed I have some - go not as far as you fear[*]
> (I think), they're rather very basic and I could not derive it
> from what you wrote.
>
> What exactly is that "Korn shell class"; a part of a framework
> the author provides to build OO sources on top, or just a
> methodology how to use standard shell constructs to achieve OO?
> How does such a "Korn shell class" look like. I'd especially be
> interested whether that framework(?) supports polymorphism (it
> seems just to be mentioned in the "background chapter", but it's
> probably readily supported?) and ideally how that would look like
> in a small example. Thanks.
>
> Janis
>
> [*] I'd indeed be interested in the implementation (WRT used data
> structures and impact on performance), but to get an impression
> of the user interface is interesting as well, probably also for
> the OP.

A very simple example from the book,

##---- A person class
## Constructor
_person() {
_strName=$1
_nAge=$2
}
## Accessors
_getName() {
echo $_strName
}
_setName() {
_strName=$1
}
_getAge() {
echo $_nAge
}
_setAge() {
_nAge=$1
}
##---- End of person class

$> shcc person.cls # run the compiler (written in Korn shell)

$> . ./person myperson Bob 43 # create a person object

$> myperson_getname # exersize an accessor
Bob

$> myperson_getAge # another accessor
43

(The shcc script is under 200 lines of source.)

For polymorphism, maybe this will serve to illustrate:

.. person $args # $args is a reserved word
##---- A customer class
## Constructor
_customer() {
_person $1 $2 # inherits from person
_nAcctNumber=$3
_getAcctNumber() {
echo $_nAcctNumber
}
_setAcctNumber() {
_nAcctNumber=$1
}
##---- End of customer class

A customer can be constructed and used anywhere a person
can be used. A script can use a person, a customer, (or
perhaps a student), and ask it how old it is without
regard to actual type. I'm afraid I haven't really
conveyed an answer, and instead have illustrated only
inheritance. But I hope this partly satisfies your
curiosity.

The environment includes these after the person is constructed:

args='myperson Bob 43'
call_args='Bob 43'
myperson_nAge=43
myperson_strName=Bob
myperson_Delete ()
{
set | grep ^myperson | while read var; do
unset ${var%=*};
done
}
myperson_getAge ()
{
echo $myperson_nAge
}
myperson_getName ()
{
echo $myperson_strName
}
myperson_person ()
{
myperson_strName=$1;
myperson_nAge=$2
}
myperson_setAge ()
{
myperson_nAge=$1
}
myperson_setName ()
{
myperson_strName=$1
}

The compiled person class looks like this:

#!/bin/ksh
#
###############################################################################
## ClassFile: person.cls
## Created: Fri Nov 13 16:04:17 PST 2009
###############################################################################
ObjectId=$1
args=$@
## Constructor
eval "${ObjectId}_person() {
${ObjectId}_strName=\$1
${ObjectId}_nAge=\$2
}"
## Accessors
eval "${ObjectId}_getName() {
echo \$${ObjectId}_strName
}"
eval "${ObjectId}_setName() {
${ObjectId}_strName=\$1
}"
eval "${ObjectId}_getAge() {
echo \$${ObjectId}_nAge
}"
eval "${ObjectId}_setAge() {
${ObjectId}_nAge=\$1
}"

eval "${ObjectId}_Delete() {
set | grep ^$ObjectId | while read var
do
unset \${var%=*}
done

}"
#
# Construction
# -called when class first executes.
#
call_args=${args#*\ } # remove objname from arglist
${ObjectId}_person $call_args # Call constructor with arglist




Best regards,
--
Charles Polisher


From: Sidney Lambe on
On comp.unix.shell, Dominic Fandrey <kamikaze(a)bsdforen.de> wrote:

[delete]

>
> Shell scripting often is a purpose of its own. It's really more
> of an art form than real programming,

I have been following this thread with interest and liked the
way you handled the local gangsters.

But the above statement of yours is ludicrous. Your OS wouldn't
run without shell scripts and they are incredibly useful.

Any command entered at a shell prompt is a shell script.

At the other end of the scale, you could write a complete desktop
environment in bash that functioned as well as KDE and used a
tiny fraction of the resources.

Next to the C family, it's the most useful programming language
in the nix world.

We can get along without perl or ruby or java or slang. We can't
get along without shell scripts.


Sid


From: Seebs on
On 2009-11-14, Sidney Lambe <sidneylambe(a)nospam.invalid> wrote:
> At the other end of the scale, you could write a complete desktop
> environment in bash that functioned as well as KDE and used a
> tiny fraction of the resources.

That is a fascinating assertion. While I certainly think that KDE, et
al., are pretty hugely bloated... It's hard for me to believe that a
shell-based solution would be competitive. I don't know that I could
be easily convinced that a shell-based window manager would be viable.
Are there any?

-s
--
Copyright 2009, all wrongs reversed. Peter Seebach / usenet-nospam(a)seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!