Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Scheme Programming Language

Best intro language?


Read an article:

Thoughts about the Best Introductory Language
http://www.shlomifish.org/philosophy/computers/education/introductory...

Scheme is mentioned. Is it a fair evaluation?

Griff wrote:
> Read an article:

> Thoughts about the Best Introductory Language
> http://www.shlomifish.org/philosophy/computers/education/introductory...

> Scheme is mentioned. Is it a fair evaluation?

The author described BASIC as a language that can "grow with you." If
this doesn't set off any alarm bells, nothing will.

-thant

Thant Tessman wrote:
> Griff wrote:

>> Read an article:

>> Thoughts about the Best Introductory Language
>> http://www.shlomifish.org/philosophy/computers/education/introductory...

>> Scheme is mentioned. Is it a fair evaluation?

> The author described BASIC as a language that can "grow with you." If
> this doesn't set off any alarm bells, nothing will.

Hey, it worked for Bill Gates.
On Thu, 19 Apr 2007 19:51:16 -0600, Thant Tessman

<a@standarddeviance.com> wrote:
>Griff wrote:
>> Read an article:

>> Thoughts about the Best Introductory Language
>> http://www.shlomifish.org/philosophy/computers/education/introductory...

>> Scheme is mentioned. Is it a fair evaluation?

>The author described BASIC as a language that can "grow with you." If
>this doesn't set off any alarm bells, nothing will.

Actually Fish said he believes a beginning language should grow with
the programmer as BASIC did for him.  For me his credibility is
strained because he advocates Perl as a beginner language.

That a programmer learned "BASIC" doesn't necessarily ring bells for
me - Lisp couldn't do shit on my Apple ][, the only choices were
BASIC, Logo, Pascal, C and assembler.  I learned them all at one time
and I don't think exposure to them hurt me any.

Today, I would only become concerned if a person was new to
programming and learning (or considering) BASIC.  A considerable
amount of existing business software is written in Visual BASIC, and
though I never bothered with it, I know some experienced people who
learned it so they could do consulting.

George
--
for email reply remove "/" from address

BASIC is the first computer programming language I learned. The first
computer program I was ever paid to write was written in something
called MegaBASIC. Now that it's clear where I'm coming from, I will say
that BASIC is mentally crippling. Experience with BASIC is something a
programmer must recover from.

As for, er, Fish's section on Scheme, he says:

"However, there are several problems with teaching Scheme as an
introductory language. The first is that it is too impractical. Scheme
does not have system primitives that more modern languages take for
granted like ones for random file and directory I/O, sockets, graphics
primitives, Graphical User Interface (GUI), etc. Moreover, the core
language is limited and most practical code tends to become very verbose
in it. For example, whereas in Perl one would write $myarray[$i]++  to
increment an array element by one, in Scheme it would be: (vector-set!
myarray i (1+ (vector-ref myarray i)))."

This is uninformed. Things like sockets and graphics primitives may not
be defined in the Scheme standard, but that's because they have no
business being there. Such things belong in implementation-specific
libraries, which is in fact where you can find them.

As for describing Scheme as "verbose," that's also a sign that Fish
doesn't have any genuine experience with Scheme. If there's one thing
that sets Scheme apart, it is the degree to which it allows the
programmer to refactor for conciseness. This is a feature of functional
programming in general, and Scheme in particular. Clear primitive names
such as "vector-set!" are a feature, not a bug, *especially* in the
context of teaching beginners.

-thant

On Sun, 22 Apr 2007 08:22:11 -0600, Thant Tessman wrote:
> This is a feature of functional
> programming in general, and Scheme in particular. Clear primitive names
> such as "vector-set!" are a feature, not a bug, *especially* in the
> context of teaching beginners.

Still and all, and I'm a newbie at scheme, (and have no more exposure to
lisp than daily reading of comp.lang.lisp for the last month or so).  I'm
nearly 1000 lines into my first scheme project, and having a lot of fun
with it.  The vector-set! issue does bug me, though.  Is there a scheme
equivalent of the CL "setf-able reference"?  That would at least seem to
make some of these sorts of structure-update constructions a bit more
concise.  It's not that I mind the spelling of vector-foo too much, it's
that I have to describe the location twice, in order to do an update.

Just for instance, what's the idiomatic scheme way to double all of the
elements of a vector (containing only numbers)?

something like:
(vector-for-each (lambda (i x) (vector-set! a i (* 2 x))) a)
?
That seems apallingly ugly, because the function has to explicitly refer
to the vector a.

(On the OT: I learned to program on BASIC, too, but (a) I tried to
implement a stack and a coding style to fake "local" scope and function
arguments, when I discovered that my BASIC didn't have either, and (b) I
switched to assembly language and never looked back. I don't think that
today's kids get enough exposure to processor architecture and "the
metal". Functions and types are all well good, and necessary to get
professional work done, but I think that it helps to understand what the
bits are really doing, underneath.  What the goal is, if you like.)

Cheers,

--
Andrew

On Apr 23, 12:55 am, Andrew Reilly <andrew-newsp@areilly.bpc-

users.org> wrote:
> [...] It's not that I mind the spelling of vector-foo too much, it's
> that I have to describe the location twice, in order to do an update.

> Just for instance, what's the idiomatic scheme way to double all of the
> elements of a vector (containing only numbers)?

> something like:
> (vector-for-each (lambda (i x) (vector-set! a i (* 2 x))) a)
> ?
> That seems apallingly ugly, because the function has to explicitly refer
> to the vector a.

So you used the wrong abstraction (vector-for-each) for the problem.
No big deal; one day you won't :-).  If you want to update a vector in
place by performing an operation on each element, then you can easily
define a vector-update! procedure to do just that:

(define (vector-update! v proc)
  (let loop ((i 0)) ; with apologies to Olin
    (unless (= i (vector-length v))
      (vector-set! v i (proc (vector-ref v i)))
      (loop (+ i 1)))))

(define (double x) (+ x x))

(vector-update! some-vector double)

Aziz,,,

Thanks Aziz.  I guess that's pretty much what I've been doing up to now
(I even wrote my own vector-for-each, complete with variable argument
list, because I wasn't (and still aren't) sure that I wanted to pull all
of SRFI-43 into mzscheme.)

I just thought that there might be some sort of alternative to both
vector-ref and set! a bit like:

(define (my-vector-ref v i)
  (cond-lambda
    (() (vector-ref v i))
    ((x) (vector-set! v i x))))

(define (vector-update! p v)
  (let loop ((i 0))
    (when (< i (vector-length v))
      (let ((elt (my-vector-ref v i)))
        (elt (p (elt))))) (loop (+ i 1)))

Looks nasty next to your version, but I have uses for updates with
computed or looked-up indices that the scheme might work OK with.  Does
it look plausible?  Probably hideously inefficient, compared to just
writing the update expression out long hand, right?

Maybe I should try:
(define (vector-update-elt! v i p)
  (vector-set! v i (p (vector-ref v i))))

And then wrap that in a counting loop or whatever...

I just thought that I might be missing something, since it seems that you
*can* do (pushf (vector-ref v i) (foo bar)) and a bunch of similar
operations in common lisp..

Cheers,

--
Andrew

On Apr 23, 4:36 am, Andrew Reilly <andrew-newsp@areilly.bpc-

users.org> wrote:
> Thanks Aziz.  I guess that's pretty much what I've been doing up to now
> (I even wrote my own vector-for-each, complete with variable argument
> list, because I wasn't (and still aren't) sure that I wanted to pull all
> of SRFI-43 into mzscheme.)

Is there any reason for not pulling all of SRFI-43 into mzscheme?

Looks plausible, though I would call my-vector-ref something like
vector-locative or something like that.  Also, why do you think it's
not as efficient as the one I posted?  I tried your definition under
petite chez scheme, and it's just as fast as mine.  As a matter of
fact, it compiles to *exactly* the same code.  Try this in chez or
petite chez:

(print-gensym #f)
(pretty-print
  (expand/optimize
    '(module (vector-update!)
       (import scheme)
       (define (my-vector-ref v i)
         (case-lambda
           (() (vector-ref v i))
           ((x) (vector-set! v i x))))
       (define (vector-update! p v)
         (let loop ((i 0))
           (when (< i (vector-length v))
             (let ((elt (my-vector-ref v i)))
               (elt (p (elt))))) (loop (+ i 1)))))))

And see how my-vector-ref simply evaporates.  So, your code is as
hideously inefficient as the implementation that runs it I guess.

Aziz,,,

Andrew Reilly wrote:
> The vector-set! issue does bug me, though.

It bugs me too.

http://dharmatech.onigirihouse.com/scheme/with-vector-ref.scm

with-vector is a syntax-case macro that allows you to do this:

;; (let ((a (vector 10 20 30 40 50)))
;;   (with-vector a)
;;   (a: 0)                     ;; reference an element
;;   (a: 0 "hey"))            ;; set an element

I also have with-string and with-list. They're exercises for
y'all. :-)

I have a baroque version that allows for "methods".

(let ((a (vector 10 20 30)))
  (with-vector a)
  (+ a.first a.last) ;; 40
  (a.map sqrt) ;; map sqrt over a
  a.len ;; length of a. expands to: (vector-length a)
  ...)

The beautiful thing about this macro is that expands to efficient
code:

(a: 0) => (vector-ref a 0)

(a: 0 "hey") => (vector-set! a 0 "hey")

I'm also messing around with a with-record version that can do stuff
like this:

(define-record point x y z)

(let ((p (make-point 10 20 30)))
  (with-point p)
  p.x ; access the x component. Expands to: (point-x p)
  (p.x 5) ; Set the x component to 5. Expands to: (set-point-x! p 5)
  ...)

Ed

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc