I'm just learning Scheme. Scheme is pretty cool. It's flexible, powerful, and yet it's still slim.
It's flexible, powerful, and yet it's still slim.
Originally posted by Level_7:
"It's flexible, powerful, and yet it's still slim."
So are most of the common programming languages.
Right, with the possible exception of:Originally posted by Level_7:
So are most of the common programming languages.
You'd call x86 assembler slim? Or even RISC assembler slim? Scheme is slimmer than both of them, and at least a hundred times more powerful.You want slim, use an assembler!
Originally posted by w.anders:
Does Scheme do object orientation? What does it look like?
I looked at SML, but the tutorial I followed didn't really make me any wiser as how to object orientation looks in a functional language.
Well, as a software designer I see OO as a damn convenient way of communicating concepts between developers and, to an extent, customers. There are lots of other ways of expression, but OO has shown itself to be extremely useful, I think.Well, if you're a C/C++/Java programmer, you probably see OO as a liberation from a world that doesn't include first class functions![]()
Would you be interested in showing some code examples of this?Objects (to a functional programmer) look like closures with (perhaps) mutable local state and multiple entry points.
Originally posted by w.anders:
From that perspective, there are benefits with languages that are designed with the intention of making OO straightforward and attractive.
Would you be interested in showing some code examples of this?
I'm a bit disappointed that there is no "built in" (or perhaps rather predeveloped, a la C++'s Standard Library) OO support in Scheme. Is there a functional language that provides such facilities?
code:<HR>Code:(lambda (x) (+ x y))
code:<HR>Code:int f(int x) { return x + y; }
code:<HR>Code:class Point { private double x; private double y;<P> public Point(double x, double y) { this.x = x; this.y = y; }<P> public double getX() { return x; } public double getY() { return y; }<P> public void setX(double newX) { x = newX; } public void setY(double newY) { y = newY; } }
code:<HR>Code:(define (make-point x y) (lambda (method . args) (case method ((get-x) x) ((get-y) y) ((set-x) (set! x (car args))) ((set-y) (set! y (car args))))))
code:<HR>Code:new Point(a, b) // Java<P>(make-point a b) ; Scheme
code:<HR>Code:somePoint.getX(); somePoint.setY(Math.sqrt(2)); // Java<P>(some-point 'get-x) (some-point 'set-y (sqrt 2)) ; Scheme
In a sense, yes. Mostly this was just a bad joke.You'd call x86 assembler slim? Or even RISC assembler slim? Scheme is slimmer than both of them, and at least a hundred times more powerful.
That would certainly be very interesting to see, especially with a few other languages thrown in for contrast.Perhaps what's needed (from a functional programming advocacy standpoint) is a tutorial showing how an OO design would be implemented in various functional languages (sort of like the chapters in the Rumbaugh book that show how such a design could be implemented in C, Fortran, (and maybe Ada, I don't have the book handy)).