I'm thinking Scheme. You can get into it really simply, using it as just an imperitive language for graphics, or perhaps even generating HTML.
Oh, did I mention she also wants to get into HTML in a big way? She wants to maintain a Guild at Neopets.
I thought simple programs to generate the pages like:
(html-meta 'Title (style 1)) (html-heading 1 "Schedule for Today") (html-table (html-table-head "Time" "Activity") (map html-table-row (Activity-times) (Activities))) (html-footer)
You get the idea. I think I can demonstrate simple data types, how to execute simple functions and define them, introduce concepts like conditionals and map. All in the context of outputting simple HTML pages.
Maybe introduce loops and do something like:
(setq pages '(intro activities fun ... )) (do ([page (car pages)] [pages (cdr pages)]) ((not null? pages)) (html-meta (title page) (style page)) (html-page page) (html-footer page) )
And push down the individual page detail down into specific routines, while automating the common elements for look-and-feel.
I think stuff like the above is a lot more understandable and maintainable than straight HTML. Especially since I have a choice of good easy-to-use editors for Scheme code. I'm looking at the PLT Scheme environment.
I'm thinking that straight functional will be easier to grasp than languages that depend on infix algebra.
I've looked at Logo and I'm turned off by it. It's just a toy. What's learned there will necessarily need to be thrown away in a few years. A good Scheme environment could be made to work for arbitrary programming tasks for years to come. The MzScheme system at the heart of the PLT Tools is easily extended in C, so any API could be introduced. I played with interfacing it to C a few years ago and it's easy.
What do people think? Any suggestions about how to go about this? Am I crazy thinking a lisp-like language will be good to ease into slowly?
I know, maybe I should take this to a place where they discuss Scheme. I don't particularly feel comfortable there, though. I do somewhat feel comfortable here.
I'd say: go for it.
I've found that many people, including myself, can have trouble grokking functional programming after years of any other sort. If you get Scheme in there before, say, Perl, I would imagine they'd end up a better programmer (being able to grasp all sorts of different languages).
Re:Functional
mary.poppins on 2002-10-29T06:30:28
The functional features in Perl are the best part! map map grep map map grep map!
Sounds like a great idea to me. I wish someone had taught me scheme at 11. I'd say do everything as functional as you can, though; no imperative style. That will be easy enough to learn later.
Re:Go for it, and do it right!
jordan on 2002-08-23T19:06:59
I agree about doing it as functional as possible and I plan to.
I think that strictly speaking, even sequencing operations is procedural, not functional.
So,
(html-meta...)
(html-table...)
(html-footer...)
Is essentially procedural in nature.
The functional way to do this, I believe, would be something like:
(map html-gen
'((meta parm1 parm2 parm3)
(table parm1 parm2 parm3)
(footer parm1 parm2 parm3)))
Maybe I've been writing procedural code too long, but I find the procedural sequencing more natural here.
Should I really go to the trouble of eliminating sequencing?
I think I'd much rather introduce small functions that do part of the project and string them together.
Maybe I'm wrong here. I did want to push the details of specific page generation down so maybe the driver should be a (map) or an (ormap) or (and) or something.
This would make a procedure (html-gen) that looks something like:
(define (html-gen args)
(cond
((eq? (car args) 'meta)
(html-meta (cdr args))
((eq? (car args) 'table)
.
.
.I really envisioned writing up small routines that generate bits of HTML, testing these interactively and stringing them together. The fully functional implementation seems to me to require a lot more semantic details to get past before we can produce results. For example, I've not run any of the above code and I think I'll need to be doing various quoting in various places. I think to do this "right" it might involve quasi-quoting and other complicated concepts for those lists I'm passing to (map) above.
As I said, I'm willing to be convinced here. It does occur to me that I can still run-up the routines for HTML pieces and when we're happy, wrap them all up in a functional driver as I've outlined above.
If I'm going to go this route, no setq's either. Just call the outer driver with literal lists.
It's ambitious, but I'm beginning to convince myself that pure functional is the way to go and introduce imperitive later. I think I won't have to deal with the complicated quoting issues if I keep it simple.
Another issue along the 'purity' lines is should I introduce function definition with the convenience syntax:
(define (x a)...)
or
(define x (lambda(a)...)) If the second, then perhaps introduce functions like:
((lambda(a)...) arg) And then explain that define just expands a name in place:
(define foo (lambda(a)...)) =>
(foo args) == ((lambda(a)...) args)
This is one of the beauties of Scheme, actually, the first thing in a list is evaluated by the interpreter until a function is found (or not, in which case it's an error). If I'm going to teach functional, I'd like it be clear from the start that there's nothing "magic" about functions, just another basic datatype that can be returned by a function (or special form like lambda in the case above).
Maybe I should find a Scheme forum to discuss this, like comp.lang.scheme.
Re:Go for it, and do it right!
jdavidb on 2002-08-26T13:59:59
I'm not as into Lisp and functional programming as I want to be, so I can't provide expert insight. All I can say is what I wish.
:) Definitely search out Paul Graham's material on the net and absorb.
Should I really go to the trouble of eliminating sequencing?
I am not educated enough to say on that, yet.
If I'm going to go this route, no setq's either. Just call the outer driver with literal lists.
I do think avoiding setq's is good.
I learned scheme followed by Lisp, and the way I was taught made it impossible to know you had an alternative to programming functionally until you learned otherwise. But that was 1998, and unfortunately I have not had the opportunity to use it all. It wasn't until recently I started hearing things that made me think, "If I want to make myself a hacker, I must learn functional programming and actually use it for a real project some day."
Another issue along the 'purity' lines is should I introduce function definition with the convenience syntax: (define (x a)
...) or (define x (lambda(a) ...)) I learned it with the second syntax, and it has always made more sense to me that way.
Maybe I should find a Scheme forum to discuss this, like comp.lang.scheme.
Bah! There are plenty of scheme programmers here (and I'm not talking about folks like me who can't remember 90% of what they learned). There's even a scheme compiler for parrot, I think. By all means seek out the other forum, but don't take the discussion away from here!
:) Re:Go for it, and do it right!
jordan on 2002-08-27T19:07:26
- Definitely search out Paul Graham's material on the net and absorb.
I'm familiar with Paul Graham, but from what I can tell, he leans heavily toward Common Lisp and is pretty advanced. I prefer stuff like SICP, HtDP, the refreshingly simple TYSiFD and The Scheme Programming Language. All online! None of these texts is appropriate for my 11 year old, but I'm using some of their approaches as inspiration.
- Bah! There are plenty of scheme programmers here (and I'm not talking about folks like me who can't remember 90% of what they learned). There's even a scheme compiler for parrot, I think. By all means seek out the other forum, but don't take the discussion away from here!
:)
Thanks for the encouragement. I think I'm going to setup a Blog elsewhere (I'm thinking of Blogmax, the Blog mode for Emacs) and posting the experiences there. I'll put pointers here to that discussion if I get it setup. I'm also thinking of talking about it on comp.lang.scheme.
I have the first lesson nearly written up, but I haven't got class time scheduled, yet.