For Programmers: Free Programming Magazines  


Home > Archive > Smalltalk > January 2005 > An utterly newbie question









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author An utterly newbie question
M.B.

2005-01-22, 3:58 pm

Hello everybody...

I have recently stumbled into the smalltalk language, and I'm trying
to get a grip on it to start coding something.
I've found a lot of (quite outdated I guess) free books, but in none
of them I found a full, completed clear exposition on how the "save
source" process work.
Let's refere to Cincom Smalltalk, for example (but I guess it's quite
the same for Squeak).

When I work with Java or C++ or even Basic, when I wrote a program,
there is a well defined standard class hierarchy. If I write my own
class, I have to define it in a source file which I save on a text
file (eventually for compiling). If I write a program, I save the
source in text files as well, which I give to compiler to make it
executable.
The process, from the developer point of view is roughly the same,
independently from the fact there is an interpreter, a cpu or a
virtual machine on the other side. If I have to share my code with a
fellow developer, I simply give him my .c and .h files (for instance),
he opens it in his IDE and do what he wants.

How does it work in Smalltalk, instead? As far as I guessed, you save
"snapshots" of the virtual machine instead... That is, I write my
BeautifulClass in the Browser, and it is now nested in the hierarchy.
Than I save the snapshot and next time I can use it... Is that right?
But, it is there even if I code, tomorrow, a different application
that does not need BeautifulClass at all, if I get it right...
And if I want to share my code, do I have to give my "snapshot" of the
virtual machine to my fellow?? And, if so, what if he has HIS snapshot
in which he defined UsefulClass? How can he keep both classes?
And what do I do for sharing a program that uses those classes?

I have read there are "change files" for that, but I didn't quite
understand how they work. What I would appreciate the most is some
sort of thorough explanation of how the saving process work when I,
say, write a class and want to save it for sharing (and I want it
saved isolated), and when I want to send code to another Smalltalk
installation. Of course, I'd like to understand how the loading
process work also! :)

Thank you very much to anybody can answer this (stupid, I know, but I
don't know the answer!) question.

Marco
Steven T Abell

2005-01-23, 3:58 am

Your presumptions about what has happened to your class are correct.
If you want to transport your code,
look for a menu item in the ClassBrowser that says "file out..."
ChangeSets are a better way of moving code, though,
because, if you're writing good OO code,
you'll probably have more than one new class
and possibly minor additions to existing classes.
VisualWorks has some newer ways of organizing code transport,
but these are the classic ways.

Steve
cstb

2005-01-23, 3:58 am



M.B. wrote:
> Hello everybody...
>
> I have recently stumbled into the smalltalk language, and I'm trying
> to get a grip on it to start coding something.
> I've found a lot of (quite outdated I guess) free books, but in none
> of them I found a full, completed clear exposition on how the "save
> source" process work.
> Let's refere to Cincom Smalltalk, for example (but I guess it's quite
> the same for Squeak).
>
> When I work with Java or C++ or even Basic, when I wrote a program,
> there is a well defined standard class hierarchy. If I write my own
> class, I have to define it in a source file which I save on a text
> file (eventually for compiling). If I write a program, I save the
> source in text files as well, which I give to compiler to make it
> executable.
> The process, from the developer point of view is roughly the same,
> independently from the fact there is an interpreter, a cpu or a
> virtual machine on the other side. If I have to share my code with a
> fellow developer, I simply give him my .c and .h files (for instance),
> he opens it in his IDE and do what he wants.
>
> How does it work in Smalltalk, instead? As far as I guessed, you save
> "snapshots" of the virtual machine instead...



You can snapshot the image, and restart it where you left off.
Or you can store the code in files, and reload it into a fresh
image the next time you start. (You can also save as precompiled
binaries, or keep the whole thing in a CMS database, but we'll leave
that for later).


> ... snip...
> I have read there are "change files" for that, but I didn't quite
> understand how they work.


Ignore these for the moment.
They'll make more sense after you practice a little bit
with fileouts. (They're sort of a fancier way to do fileouts).

> What I would appreciate the most is some
> sort of thorough explanation of how the saving process work when I,
> say, write a class and want to save it for sharing (and I want it
> saved isolated), and when I want to send code to another Smalltalk
> installation.


When the browser is showing you any part of your class, you can go to
the class menu and pick 'fileout'. This will write all the code for the
class into a file in the current directory.

You could then start over, with a clean image,
and 'filein' the class. Or send it to someone else, and they would
likewise 'filein' the contents.

You will also find 'fileout' on the method menu.
That one works the same way, but writes just the code for whatever
method is currently displayed in the browser.

Regards,

-cstb
DiegoC

2005-01-23, 3:58 am

You question is not stupid, is a very important one and I think the answer
is not in the tool you are using, but in understanding that Smalltalk is
not a programming language, its an ambience. Sources are not as important
as objects. Of course you can save sources and load them, but in Smalltalk
you also program with the inspector, the workspace and other things that
don't generate code, the instantiate objetct. Perhaps in Squeak is more
evident this but is the same in all Smalltalks, that's why is so important
the concept of image.
In OO programming languages like java or C++ you except to have some kind
of core-classes, and them your classes. Here, everything is at the same
level, because like I said before, there is something more than a
language.
If you create BeautifulClass, probably you will live it in you image, it's
ok. When you decide to make a distributable version you are going to strip
your image and leave only what you want. Stripping an ambience is not
easy, there are lot of tools to help you on that, but it's imposible to
make a deterministic procedure to do that.


Diego Coronel







CDX

2005-01-23, 3:58 am

Beyond just the fileout and change list, Visualworks has this
spectacular code repository called Store. Using store you can easily
load an image to any version you have published before. Better than
that, you and your development team can all easily merge your code after
each making changes. I can't really give Store justice in a quick
response, but even when I develop by myself, I use Store extensively in
order to manage changes and integrate different portions of my project.

VisualWorks is definately a unique development environment and it takes
a little while to get your head into the benefits it offers. I found it
odd that you could just save your image with your app up and running,
then restart it later on and contunie that app where it was. VW is not
just saving the souce, but also the environment, so you can come right
back to where you left off.

Among the numerous features I like to show off is the functionality of
the change manager. How many times have you coded in another language
and lost code because of some condition outside of your control (system
crashe, power outage, etc). So you lose everything since you last saved
right? VW has a built in transaction log, which allows you to capture
all changes made to the last change even if you just shut your machine
off. Not only that, but you can review all changes to a specific method
made since you created (not last saved) your image. Powerfull stuff.

There are a ton of real neat things in the environment which let you
develop outside the normal development style. So when you are playing
with Smalltalk, don't get hung up on the fact that things work
differently, but rather see how much more productive you can be.
Personally I've changed my coding habits to write code more on the fly,
instead of writing it all first, compiling and running. In VW you can
create the outline, then fill in the details on the fly with the app
running.

Regards,
Chip


M.B. wrote:

> Hello everybody...
>
> I have recently stumbled into the smalltalk language, and I'm trying
> to get a grip on it to start coding something.
> I've found a lot of (quite outdated I guess) free books, but in none
> of them I found a full, completed clear exposition on how the "save
> source" process work.
> Let's refere to Cincom Smalltalk, for example (but I guess it's quite
> the same for Squeak).
>
> When I work with Java or C++ or even Basic, when I wrote a program,
> there is a well defined standard class hierarchy. If I write my own
> class, I have to define it in a source file which I save on a text
> file (eventually for compiling). If I write a program, I save the
> source in text files as well, which I give to compiler to make it
> executable.
> The process, from the developer point of view is roughly the same,
> independently from the fact there is an interpreter, a cpu or a
> virtual machine on the other side. If I have to share my code with a
> fellow developer, I simply give him my .c and .h files (for instance),
> he opens it in his IDE and do what he wants.
>
> How does it work in Smalltalk, instead? As far as I guessed, you save
> "snapshots" of the virtual machine instead... That is, I write my
> BeautifulClass in the Browser, and it is now nested in the hierarchy.
> Than I save the snapshot and next time I can use it... Is that right?
> But, it is there even if I code, tomorrow, a different application
> that does not need BeautifulClass at all, if I get it right...
> And if I want to share my code, do I have to give my "snapshot" of the
> virtual machine to my fellow?? And, if so, what if he has HIS snapshot
> in which he defined UsefulClass? How can he keep both classes?
> And what do I do for sharing a program that uses those classes?
>
> I have read there are "change files" for that, but I didn't quite
> understand how they work. What I would appreciate the most is some
> sort of thorough explanation of how the saving process work when I,
> say, write a class and want to save it for sharing (and I want it
> saved isolated), and when I want to send code to another Smalltalk
> installation. Of course, I'd like to understand how the loading
> process work also! :)
>
> Thank you very much to anybody can answer this (stupid, I know, but I
> don't know the answer!) question.
>
> Marco

M.B.

2005-01-23, 8:58 am

On Sat, 22 Jan 2005 22:14:13 -0500, CDX <cdy@noSpamDiceNoSpamHome.Com>
wrote:

>Beyond just the fileout and change list, Visualworks has this
>spectacular code repository called Store. Using store you can easily
>load an image to any version you have published before. Better than
>that, you and your development team can all easily merge your code after
>each making changes. I can't really give Store justice in a quick
>response, but even when I develop by myself, I use Store extensively in
>order to manage changes and integrate different portions of my project.


If I get it right, one of the most magnificently stressed features of
the Smalltalk language is its portability; that is, I can run EXACTLY
the same code both on Windows or Unix or Mac in the same VM, and
(apart for specialized classes) even on different Smalltalk-80
compliant VMs, is that right?
Now, while I understand this Store is a good and easy way to store
personal code, and to share with fellow coders (with presumably uses
the same IDE I use), wouldn't it be some sort of a limitation when
publishing for the general audience?

Thanks
Marco
M.B.

2005-01-23, 8:58 am

On Sat, 22 Jan 2005 17:52:10 -0800, cstb <jas@cruzio.com> wrote:

I wish to thank each and every person who helped me out with this
question.

As I understood, apart from snapshots of the ambient, which are
extremely useful while coding on your own, you can use "fileouts" and
"fileins", and I suppose there is also some dependency check to help
you "export" all you need on files...

I'll dig now into the language syntax and "way of thinking", I hope
I'll be able to code something nice and useful! :)

Thanks
Thomas Gagne

2005-01-23, 8:58 am

MB, what you're describing sounds creepily similar to what went through my
mind learning Smalltalk, except my big hangup was the absence of "int main(int
argc, char **argv)". I couldn't figure out where my program started and ended.

Eventually I discovered that in many cases I didn't need one (more on that
another time) but I still /wanted/ one. Eventually I needed one when I
started using Smalltalk at the office and needed to run Smalltalk from the
command line and redirect input and ouput to and from it.

Because I was using Linux it was fairly straight-forward to develop a
framework for writing headless (stdio) Smalltalk applications
<http://gagne.homedns.org/~tgagne/articles/commandline/>.

Having that available has helped me use Smalltalk for more tasks than would
have been otherwise practical.
CDX

2005-01-24, 3:59 am

Marco,
Store is just a development tool for managing your code. It actually
makes deployment easier because it organizes your code better and makes
recreating versions easier.

Portability of the code is a main selling point, however I've found no
use for it. I develop for Windows only. While you can do what you say
with regards to portability, there are places where you can add
functionality that is specific to one OS. So if you are concerned about
portability, make sure you know these areas. Mostly they deal with
access to external resources.



M.B. wrote:
> On Sat, 22 Jan 2005 22:14:13 -0500, CDX <cdy@noSpamDiceNoSpamHome.Com>
> wrote:
>
>
>
>
> If I get it right, one of the most magnificently stressed features of
> the Smalltalk language is its portability; that is, I can run EXACTLY
> the same code both on Windows or Unix or Mac in the same VM, and
> (apart for specialized classes) even on different Smalltalk-80
> compliant VMs, is that right?
> Now, while I understand this Store is a good and easy way to store
> personal code, and to share with fellow coders (with presumably uses
> the same IDE I use), wouldn't it be some sort of a limitation when
> publishing for the general audience?
>
> Thanks
> Marco


adamon@mailandnews.com

2005-01-24, 3:59 am


Thomas Gagne wrote:
>
> MB, what you're describing sounds creepily similar to what went

through my
> mind learning Smalltalk, except my big hangup was the absence of "int

main(int
> argc, char **argv)". I couldn't figure out where my program started

and ended.
>


I think questions such as these (code management, image maintenance,
and run-time point of entry) are very, very common questions for
beginning Smalltalk programmers. They are even more common than the
Smalltalk language itself, which can be satisfied by reading a book,
while environment management requires practice and experience. Can
someone put together best practices document which tackles these
problems?

It should probaly be vendor-specific as well. VW, VAST, Squeak, and
Dolphin all have slightly different ways of addressing these issues.

M.B.

2005-01-24, 3:59 am

On 23 Jan 2005 21:28:09 -0800, adamon@mailandnews.com wrote:


>
>I think questions such as these (code management, image maintenance,
>and run-time point of entry) are very, very common questions for
>beginning Smalltalk programmers. They are even more common than the
>Smalltalk language itself, which can be satisfied by reading a book,
>while environment management requires practice and experience. Can
>someone put together best practices document which tackles these
>problems?


Yeah, I agree. Infact, I read the FAQ prior to posting, but didn't
found anything... IMO, knowing what's the difference between a Small
Int and a Large Int (which I still didn't know, in Smalltalk terms)
comes only after you understand how to save your code. :)

Bye
M.B.

2005-01-24, 3:59 am

On Sun, 23 Jan 2005 07:13:55 -0500, Thomas Gagne
<tgagne@wide-open-west.com> wrote:

>MB, what you're describing sounds creepily similar to what went through my
>mind learning Smalltalk, except my big hangup was the absence of "int main(int
>argc, char **argv)". I couldn't figure out where my program started and ended.


Lol, well I had this question in my mind too, but then I read
something in one of the free books I have, and the "Joy of Smalltalk"
Farm example (with open method) got me the answer. :)

>Eventually I discovered that in many cases I didn't need one (more on that
>another time) but I still /wanted/ one. Eventually I needed one when I
>started using Smalltalk at the office and needed to run Smalltalk from the
>command line and redirect input and ouput to and from it.


You know what I feel missing the most? Constructors and destructors.
Or better "language standardized" ones. If I got it right, Smalltalk
does not have "schematized" constructors. "new" is the method commonly
used to create an instance, and "initialize" helps it, but you can use
the methods "create" or "useme" as well... Surely it's not a MUST, but
having learn OO programming with them, I still miss the fact I am not
OBLIGED to use the constructor naming scheme I've always been used to.
:)

Bye
Marco
Dave Harris

2005-01-24, 4:02 pm

xprofx__REMOVEMEANDDASHES__@katamail.com (M.B.) wrote (abridged):
> You know what I feel missing the most? Constructors and destructors.
> Or better "language standardized" ones.


That's something that I dislike about C++ et al. If you have, for example,
a complex number class, and you want to initialise instances with either
cartesian or polar coordinates, then overloading isn't really appropriate.
I have been reduced to things like:

class Complex {
enum cartesian_t { asCartesian };
enum polar_t { asPolar };

Complex( double re, double im, cartesian_t );
Complex( double len, double angle, polar_t );
// ...
};

Complex a( 10, 20, Complex::asCartesian );
Complex b( 10, Pi/2, Complex::asPolar );

Smalltalk seems so much better:

a := Complex re: 10 im: 20.
b := Complex len: 10 angle: Pi/2.

-- Dave Harris, Nottingham, UK
Niall Ross

2005-01-24, 8:58 pm

Dear MB,
you wish

> ...a full, completed clear exposition on how the "save source"
> process work. Let's refer to Cincom Smalltalk, for example...


I'll do my best, briefly.

There are various ways to persist code in Smalltalk.

1) Code and objects are saved when the image is saved. The analogy is to
saving text you are typing in a document by putting your laptop on standby.
It is very useful for letting you resume work where you left off (and it's a
lot more reliable than laptop standby :-), but it's not the right way to
preserve code you value.

2) The default ChangeSet logs what you do and lets you recover your latest
work if your image crashes. Long ago, multiple ChangeSets could be used for
organising and saving code, but almost everyone now uses them only for
recovery. Until the rare occasion when you need to recover occurs, you need
not look at them.

3) File-outs, like (2), were once widely used but are now very much a
secondary mechanism and are not the way to manage code of any size. They
are most often used to move code between dialects that have different
approaches to (5).

4) Deployment artefacts: in VisualWorks, these are parcels. This isn't
quite what you are asking for. Parcels are optimised for efficient loading
into and modification of running deployed systems; they ignore some of the
timestamping, ownership and structuring you want when managing code, but
have all the preLoad, postLoad, actions you would expect, etc. In VW, you
create these when using (5) via 'Publish as parcel...'; there are also
parcel-specific views and the parcel manager UI.

5) Source code management systems are how Smalltalkers manage code.
VisualWorks uses Store; read the SourceCodeMgmtGuide.pdf to learn how it
works. You assign code to packages, and packages to bundles, and publish
these from time to time.

> (but I guess it's quite the same for Squeak).


Not necessarily; SCMs run in whatever dialects they've been ported to.
Squeak uses Monticello. VisualAge uses Envy. Envy is also available for
Dolphin. Etc., etc. Envy provides its own database back-end. Store runs
on a relational database. Other systems can have other backends but all
present an object-like view to the user; you deal with objects that
describe your code and how they are stored behind the scenes doesn't matter.
("Source code in files; how quaint!" Kent Beck).

As and when you reach that point in learning VW, you will need to download a
database to be Store's backend if you don't already have an RDB on your
machine. If all is not then clear, posting again at that point, with your
machine's OS, will get you pointers.

Yours faithfully
Niall Ross

"M.B." <xprofx__REMOVEMEANDDASHES__@katamail.com> wrote in message
news:jo25v01q4pr4p9f1ua3tdp5i6v6ojtir0r@
4ax.com...
> Hello everybody...
>
> I have recently stumbled into the smalltalk language, and I'm trying
> to get a grip on it to start coding something.
> I've found a lot of (quite outdated I guess) free books, but in none
> of them I found a full, completed clear exposition on how the "save
> source" process work.
> Let's refere to Cincom Smalltalk, for example (but I guess it's quite
> the same for Squeak).
>
> When I work with Java or C++ or even Basic, when I wrote a program,
> there is a well defined standard class hierarchy. If I write my own
> class, I have to define it in a source file which I save on a text
> file (eventually for compiling). If I write a program, I save the
> source in text files as well, which I give to compiler to make it
> executable.
> The process, from the developer point of view is roughly the same,
> independently from the fact there is an interpreter, a cpu or a
> virtual machine on the other side. If I have to share my code with a
> fellow developer, I simply give him my .c and .h files (for instance),
> he opens it in his IDE and do what he wants.
>
> How does it work in Smalltalk, instead? As far as I guessed, you save
> "snapshots" of the virtual machine instead... That is, I write my
> BeautifulClass in the Browser, and it is now nested in the hierarchy.
> Than I save the snapshot and next time I can use it... Is that right?
> But, it is there even if I code, tomorrow, a different application
> that does not need BeautifulClass at all, if I get it right...
> And if I want to share my code, do I have to give my "snapshot" of the
> virtual machine to my fellow?? And, if so, what if he has HIS snapshot
> in which he defined UsefulClass? How can he keep both classes?
> And what do I do for sharing a program that uses those classes?
>
> I have read there are "change files" for that, but I didn't quite
> understand how they work. What I would appreciate the most is some
> sort of thorough explanation of how the saving process work when I,
> say, write a class and want to save it for sharing (and I want it
> saved isolated), and when I want to send code to another Smalltalk
> installation. Of course, I'd like to understand how the loading
> process work also! :)
>
> Thank you very much to anybody can answer this (stupid, I know, but I
> don't know the answer!) question.
>
> Marco




Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com