[E-Lang] real live newbie caught trying to learn E

Marc Stiegler marcs@skyhunter.com
Tue, 23 Oct 2001 09:05:47 -0700


Thank you very much, Scott, for this feedback. And thank you very much,
Zooko and Steve, for hooking scott into our discussions here.

The Maker pattern is far and away the least Java-like element of "ordinary"
E programming. This chat session is a good reminder that the Walnut section
on Makers needs to be crafted and recrafted till it is like a polished
diamond...unless we can think of some more syntactic shorthand that can
simplify it even more than the "class" shorthand does. I myself was lured,
when writing my first E programs, into writing:

def foo(a) {
    var b := something1
    def c := something2
    to doBar() {...}
    to doBar2(e) :any {...}
}

in an attempt to have instance variables for an object without using a
Maker. Perhaps Walnut should tackle this piece of code head-on and show how
to convert it into something that works: since the transition from this
broken code to working code only requires 2 new lines of code and one
modified line, it may be an appropriate exercise:

class fooMaker(a) :any {          #modified line
    var b := something1
    def c := something2
    def foo {                              #new line
        to doBar() {...}
        to doBar2(e) :any {...}
     }                                        #new line
}

I will give this some thought.

My biggest moment of personal frustration reading this chat session was the
part of the discussion about selecting a few lines in eBrowser and executing
them, for which the chat discussion concluded it was not possible. In fact,
there is a button in the toolbar with the tooltip "Run Hilite", which does
exactly this: select a section of code, press the button, and the execution
result shows up in the bottom righthand pane. This, though, is probably not
worthy of as much care and rework as the section on Makers :-)

The other amusing observation I have is, E in a Walnut in its current form
is still much shorter than any Nutshell book: printed out it is less than
150 pages. I can think of 2 reasons why it might feel longer: one is,
things feel longer when they're online, and the other is, Walnut may feel
even denser than a typical Nutshell book because of the number of new
concepts it has to introduce (though I keep trying to minimize the number of
such concepts :-).


--marcs

----- Original Message -----
From: "Zooko" <zooko@zooko.com>
To: <e-lang@eros-os.org>
Cc: <scott@jaderholm.com>
Sent: Tuesday, October 23, 2001 7:05 AM
Subject: [E-Lang] real live newbie caught trying to learn E


>
> The very best way to see how your design works with a new user is to find
a
> new user, sit him down in front of your product, ask him to talk out loud
to
> himself as he works, and then silently watch over his shoulder and take
notes.
>
> A more convenient substitute for that is to find a helpful person who will
> volunteer to do this to himself and type his musings into an IRC channel.
Many
> thanks to Scott Jaderholm who did just that a few days ago.  Here is an
> unedited transcript of his session.
>
> Regards,
>
> Zooko
>
> scott: wow, there are people here :)
> scott: and people who are awake also
> zooko: greetz, scott.
> scott: hi
> scott: I'm installing java so I can run e
> scott: what's a jar file?
> scott: interest...sun's java installation crashes in windows xp
> zooko: a jar file is a Java ARchive -- a file containing a bunch of
classes.
> zooko: Heh heh heh.  Think that's accidental?  ;-)
> scott: I knew it was java archive, but wasn't sure of what :)
> scott: ebrowser takes like 15 seconds to start up :)
> scott: lol
> scott: I thought e in a walnut was going to be like ina  nutshel, and be
really small
> scott: what a surprise I got :)
> zooko: how did hear about e?
> scott: demoncrat used to always stalk about it
> scott: do you know him?
> scott: darius bacon
> scott: I think he's writing something similiar in C
> scott: anyway though, some guys were discussing concurrency on the squeak
mailing list, and e came up for a brief moment..I thought I'd check it out
> zooko: yeah I've met him on irc and email.
> zooko: Cool!
> scott: I know nothing about it but I'm installing it :)
> scott: something about being distributed
> scott: and secure.
> scott: whatever that all means :)
> zooko_asleep_or_reading: Cool!  I look forward to your discoveries.
> zooko_asleep_or_reading: If you could post to #erights here or else e-mail
zooko@zooko.com with absolutely every little irritant, confusion,
revelation, or whatever I would really love that.
> zooko_asleep_or_reading waves.
> zooko_asleep_or_reading: Good night, #erights.
> scott: night
> scott: finally an explanation of mobile code :)
> scott: dynamically typed, woohoo
> scott: good choice :)
> scott: hi
> scott: I wonder if there's a way to select a section of code and say "eval
this"
> scott2: who's stevej? :)
> stevej: me
> stevej: who are you?
> scott2: me :)
> stevej: I'm steve jenson.
> scott2: I'm scott jaderholm, nice to meet you
> stevej: hello.
> scott2: are you involved in E dev?
> stevej: on the fringe, yeah.
> scott2: explain
> stevej: meaning I've read a lot of the E source, I write in E, and I
understand E pretty well.
> scott2: I see
> scott2: I just started reading the walnut doc a few hours ago, that's the
extent of my experience (and understnading) of E
> stevej: right on, that's a good doc.
> stevej: The mailing list archives are quite interesting, if a bit long at
three years old.
> scott2: I need to get to the fireworks part :)
> stevej: fireworks?
> scott2: oh, now I remember some stuff I needed to ask
> scott2: the part about distributed programming,s upposedlyw hat makes E
shine
> scott2: the walnut doc refers to those topics as fireworks part of the doc
> stevej: ah
> scott2: so, say I have a bunch of code in ebrowser
> scott2: can I select a few lines and tell it to run that?
> stevej: No.
> stevej: You'd want to use Elmer for that.
> scott2: but with elmer it seems I can only do one statement
> scott2: have to press enter for each statement
> stevej: Elmer is an interactive E shell.
> stevej: yeah, but it gains state.
> scott2: btw, the Object method(args) looks an awful lot like Smalltalk
syntax
> stevej: it's definitely smalltalk influenced.
> scott2: are things like + actually methods of different objects?
> stevej: yes.
> scott2: not operators?
> stevej: I actually forget.
> scott2: so with elmer there's no way to eval a bunch of code?
> scott2: w/o pressing enter at each line
> stevej: there is.
> scott2: oh, how?
> stevej: when you place your cursor at the end of a block, and press enter,
then it evaluates the entire block.
> stevej: for instance
> stevej: > x +
> stevej: err
> stevej: ? x + <enter>
> scott2: I wonder, can I just put { tons of code } and press enter?
> stevej: > 5
> scott2: yeah, I'm familiar with how it works like that
> stevej: ok, honestly I can see why it'd be confusing but in development, I
really have never had much trouble with it.
> scott2: btw, in ebrowser is there a shortcut key for the run
button/function?
> stevej: There should be in the new version but there wasn't in old
versions.
> scott2: I have the latest release
> scott2: 8 soemthing I think
> stevej: If it doesn't exist in the new version, you can always ask MarcS
to put one in.
> scott2: 0.8.10
> stevej: the wonderful part about eBrowser being written in a scripting
language is that you can do it yourself as a learning experience.
> scott2: I notice that the copyright is 1999...
> stevej: Ah, you have the 8.10alpha release, that's a new eBrowser (as of
the past few months)
> scott2: it's got an old copyright..
> stevej: that's ok.
> stevej: Thanks to Disney, copyright will end up lasting forever...
> scott2: what's the text box at the top of ebrowser?
> scott2: what's the story w/ that?
> stevej: you can place a string and search for that string in the source,
or put a number in there and it will jump to that line.
> scott2: nice
> scott2: the sections on the right and left are weird
> scott2: one has lines of code, the other has my variables
> stevej: They're different but I find them to be useful.
> stevej: syntax highlighting would be useful.
> stevej: There's an emacs-mode for E, btw.
> scott2: I figured there would be :)
> scott2: I don't understand the syntax for classes and making objects
> scott2: class carMaker(name) :any {
> scott2:     var xLocation := 0
> scott2:     var yLocation := 0
> scott2:     def car {
> scott2:         to moveTo(x,y) {
> scott2:             xLocation := x
> scott2:             yLocation := y
> scott2:         }
> scott2:         to getX() :any {xLocation}
> scott2:         to getY() :any {yLocation}
> scott2:         to getName() :any {name}
> scott2:     }
> scott2: }
> scott2: I don't understand why they have the def car in there
> stevej: Please realize that this is the Maker pattern, and not the way
objects are always created in E.
> scott2: normally you'd define what variables & methods for some class, and
then say def car := carMaker new or something
> stevej: This is a specific case where you have one object make another
object.
> scott2: I don't understna dhte Maker pattern
> stevej: carMaker is a singleton that's used to create a car object.
> scott2: what's a singleton? (that really sounds like it gives away my
ignorance)
> stevej: heh
> stevej: Well, how many OO languages have you written/
> stevej: ?
> stevej: written software in, I mean.
> scott2: smalltalk and a bit of common lisp
> scott2: I've not written any substantial software
> scott2: I've written a bit in java also, but very tiny bit
> stevej: ok, well we all start somewhere.
> stevej: smalltalk and lisp are good places to start!!
> stevej: it's a lot better than BASIC being your first language.
> scott2: yeah, they're kind of interesting
> scott2: lisp was my first, then I played with C, basic, vb, scheme, java,
smalltalk, php
> scott2: but only played
> stevej: Have you written any scheme?
> scott2: yeah, for SICP
> stevej: cool.
> stevej: I'm sure you'll find E to be pretty simple once you understand a
few things.
> scott2: yeah, I hope
> scott2: I'm not sure what all this distributed stuff means, but we'll see
> stevej: 1) I was incorrent, a Maker is not a singleton.
> scott2: I wonder if the "no virus possible" is really as true as
erights.org tries to claim
> stevej: Yes.
> scott2: I need to use the Maker pattern to make objects w/ instnace
variables
> stevej: Java has proven to be incorrect in many of it's security
statements, based on it's overly permissive design. E, on the other hand,
revels in giving away as little authority as possible.
> scott2: but I don't know why they define some object car in the class
definition
> scott2: doesn't make any sense
> stevej: scott2: that's not true.
> stevej: You should honestly email the e-lang list requesting when to use
the Maker pattern.
> stevej: they won't bite, I promise. ;-)
> scott2: I'll keep that in mind
> scott2: is carMaker not a class?
> stevej: carMaker is a class.
> stevej: not all classes need to be instantiated.
> stevej: Think of a static class in Java.
> scott2: I don't know java that well :)
> stevej: ok.
> scott2: if it's a class, then I can say I want a new object of class
carMaker correct?
> scott2: I don't understand why they are doing that in the class itself
> stevej: a static class in Java is one that doesn't need to be
instantiated. You know how you can use Math methods without creating a Math
object?
> scott2: oh yes
> stevej: scott2: you can't create a new carMaker.
> stevej: there's just the carMaker.
> scott2: I thought that those math methods were just class methods
> stevej: scott2: they are, of the Math object.
> stevej: but you never had to instantiate the Math object.
> stevej: you can jsut call it's methods, because they are static.
> scott2: isn't that just because classes are objects?
> stevej: (please realize that static in Java means differently in other
languages)
> stevej: classes are descriptions of objects.
> stevej: OO theory gets rather complicated sometimes.
> scott2: oh, they're actually objects in Smalltalk..I should get my
languages straight sometime :)
> scott2: so like you send a message new to the object TextMorph (which
happens to be a class) and get a new object of that class.
> stevej: are we talking about Java, Smalltalk, or E?
> scott2: that last thing was about Smalltalk..
> scott2: ok, I guess I'll keep reading to see how I can make a class I'm
used to
> stevej: well, I can help you make a class.
> stevej: in E, I mean.
> stevej: you don't need Maker to make a class.
> scott2: by using class does that mean I made a Maker?
> scott2: or having Maker in the name?
> stevej: no.
> stevej: ok, I found the ambigous sentence
> stevej: "Stateful objects, i.e., objects that have instance variables, can
be constructed with the Maker pattern.
> stevej: "
> stevej: Note the use of the work 'can'
> stevej: not 'has to'
> scott2: yeah, but that's the only way they show it bieng done
> stevej: this is excellent, Marcs will be very pleased to have somebody
reading his paper.
> stevej: I've read it but I had enough E context that I didn't find any
ambiguity.
> scott2: heh, I find this whole Maker bit very very confusing
> scott2: zooko isn't marc is he?
> stevej: zooko is zooko
> stevej: zooko.com
> stevej: Marcs isn't on this channel.
> scott2: I see
> scott2: do you know marcs email?
> scott2: I'll contact him and ask if he wants my comments on things I have
trouble with when reading his doc..
> stevej: I'm sending an email to him now.
> stevej: You know where you found E in a Walnut?
www.skyhunter.com/marcs/ewalnut.html
> stevej: well, marcs@skyhunter.com reaches
> stevej: him.
> scott2: erights.org
> stevej: the erights site links to skyhunter.com/marcs/ewalnut.html
> scott2: ahh, they redirected me, didn't even notice :)
> stevej: at least, I think it does.
> stevej: heh, that's an easy thing to not notice.
> stevej: I'm drafting an email to MarcS right now and talking to him about
your confusion, I can CC you if you'd like.
> scott2: btw, I can't find a link to subscribe to the e-lang mailing list
on erights.org
> scott2: sure, scott@jaderholm.com
> stevej: mail.eros-os.org/mailman/listinfo/e-lang
> stevej: (that should be right, it's coming out of my memory)
> scott2: oh wait, I think the dns for my site is down atm
> scott2: one sec
> scott2: nm, appears to be up, must just be sshd that crashed
> stevej: Here's what I've written:
> stevej: Scott (whom I've CC'd) is confused by the discussion of the Maker
Pattern
> stevej: as the seemingly first discussion of stateful objects leading him
to
> stevej: believe that Makers were the only way to create stateful objects
in E.
> stevej: Do you think that properly sums it up?
> stevej: hello?
> scott2: sorry, was away
> scott2: yeah
> stevej: def car(name) :any {
> stevej: newName := name
> stevej: location = [0,0]
> stevej: erk, :=
> stevej: to move(x,y) { location := [x,y]}
> stevej: }
> stevej: that's a stateful object.
> scott2: ok, that's an object or a class?
> stevej: that's a class.
> scott2: and I can go foo := car new("foo") ?
> stevej: def stevesCar := car("Steve's Car")
> stevej: car("Steve's Car") is shorthand for car new("Steve's Car")
> scott2: cool
> stevej: hurray!
> scott2: and I can't assign anything new to stevesCar?
> scott2: iirc def was for constants, or things I can't change?
> stevej: yup yup
> stevej: def means immutable, var means mutable
> scott2: like maybe I want to use var instead so I can assign a new object
to stevesCar later?
> scott2: ok
> stevej: you can still change instance variables when the object is
immutable, you just can't change it to a different object.
> scott2: well sweet, he showed an example like that but for stateless only
> scott2: yeah
> scott2: def Account(aNumber, aString) :any {
> scott2:     var balance := aNumber
> scott2:     def owner := aString
> scott2:     to withdraw(aNumber) { balance -= aNumber }
> scott2: }
> scott2: what do you think's wrong with that?
> scott2: it gives me a syntax error on the to withdraw line
> stevej: what's the error>?
> scott2: # syntax error:
> scott2: #       to withdraw(aNumber) :any { balance -= aNumber }
> scott2: #        ^
> scott2: #   <file:Untitled#:span::4:5::4:5>
> scott2: that's with the :any in there..it gives me same error w/o :any
> stevej: without the ValueGuard any, it defaults to :void
> stevej: a ValueGuard is a way to force what's the object returns.
> scott2: either way, still gives me that syntax error
> stevej: You know what.
> stevej: I could be wrong about E syntax, things have changed since I
started writing E.
> stevej: I've written entirely functions and Makers, and have never tried
to write a stateful E object without using the Maker but always assumed it
was possible.
> stevej: since it seem sintuitive.
> scott2: I don't think you can have instnace variables with the def
nameOfClass way
> stevej: Let me look at some of my E code.
> stevej: yeah.
> stevej: Makers are the only way to make a stateful object as far as I've
ever used and can find use of.
> stevej: why is that?
> stevej: There has to be a thread of this on the list.
> stevej: I can't believe I've never noticed this.
> scott2: class Account(aNumber, aString) :any {
> scott2:     var balance := aNumber
> scott2:     def owner := aString
> scott2:     def car {
> scott2:         to withdraw(aNumber) {
> scott2:             balance -= aNumber
> scott2:         }
> scott2:         to getBalance() :any {balance}
> scott2:         to getOwner() :any {owner}
> scott2:     }
> scott2: }
> scott2: opps, forgot to change car
> scott2: anyway, is car actually an object when that code is run, or when I
create a new account, for internal purposes (like instead of using this) car
is used to reference the object being created?
> stevej: excellent, except that you're trying to create an Account object,
so you should call the outer object AccountMaker.
> scott2: I don't want all my classes to end with Maker all the time
> stevej: ? def scottAccount := AccountMaker(aNumber,aString)
> stevej: will result in the account (called car in your code) object.
> scott2: I don't have to define a constructor?
> scott2: or is that what the first line is?
> stevej: You've implicitly defined a constrcutor.
> stevej: which is the first line, corrent.
> stevej: correct.
> stevej: agh.
> scott2: # problem: <NoSuchMethodException: <EImplByProxy:<AccountMaker>>
run/2>
> stevej!stevej@dsl092-008-063.sfo1.dsl.speakeasy.net is getting very tired.
> scott2: def scott := AccountMaker(10, "Scott") seems to be the problem
> scott2: ok, I'm going to go to bed also, thanks for your help!
> stevej: hmm. I'm thinking about the run/2 error
> scott2: run appears to be the constructor
> scott2: that takes 2 args (is that the same as in erlang, foo/x means x
args?
> scott2!test@128.187.244.137 away - brushing teeth and getting ready for
bed
> stevej: first of all.
> stevej: class AccountMaker(aNumber, aString) {
> stevej: should be renamed to AccountMaker(balance, owner)
> stevej: then you don't have to assign them again inside the class.
> stevej: but that doesn't answer your question.
> stevej: I think we've found a legitimate bug in E.
> stevej: the run/2 error, I mean.
> stevej: because E is dynamically typed, it's looking for you to have a run
method with two arguments.
> stevej: in Java, it would be like  void run(String,Integer) not found
> stevej: (does that make sense?)
> scott2: never seen a run error in java
> stevej: heh, you really haven't written much Java, then. ;-)
> scott2: nope :)
> scott2: just a few assignments for a CS class
> scott2: I'm not really a programmer
> stevej: Do you aspire to be one?
> scott2: not really
> stevej: then why do you program at all?
> scott2: I'm not sure why...
> scott2: something to do
> stevej: that's fair.
> stevej: Programming isn't like weekend football, though.
> stevej: Not to discourage you from programming.
> stevej: not at all.
> scott2: yeah, I understand
> scott2: partly because there are some programs I'd like to see written
that no one seems interested in writing
> scott2: anyway, good night
> stevej: Like what?
> stevej: (btw, are you on the e-lang list yet?)
> scott2: umm, check jaderholm.com under projects
> scott2: yeah
> stevej: cool, I'm sending a message to the list.
> scott2: I don't have very good descriptions up there, but two projects I'd
especially like to see written are Caribbean and Paris
> scott2: night
> stevej: you're playing with vapour?
> stevej: Then you probably know my good friend Dan Moniz.
> stevej: anyway, good night.
> stevej: Btw, you grew up in Ontario? I grew up in Pendleton.
> scott2: 5thgrade through 12th in ontario, yeah
> scott2: I know dan a bit, I hooked him up with his lisp machine :)
> stevej: I don't miss Eastern Oregon a bit, really.
> stevej: Dan's symbolics machine was fun to play with last time I was in
Toronto.
> scott2: heh, I don't either :)
> scott2!test@128.187.244.137 karate chops #erights and does  a backflip
into bed
>
> _______________________________________________
> e-lang mailing list
> e-lang@mail.eros-os.org
> http://www.eros-os.org/mailman/listinfo/e-lang
>