Hi Hans-Martin, you posed the question
The question is: do we want to let hardware characteristics dominate our way of thinking?
And the answer is no! And I deeply appreciate Smalltalk for the #// and #\ operators, for Integers that are unlimeted, and for things like garbage collection that no real machine can achieve! Smalltalk leverages on being run by a virtual machine. And it does very well so. Furthermore, it lets you adopt things to your likes much easier than any other language I know. (I don't know Lisp) So, in this respect, I couldn't agree more with you.
collection, I want the first at index 1 and the fifth at index 5. When I'm using Integers, I don't want to think about 16 vs 32 bits, signed vs unsigned etc. The argument about loop bounds is somewhat related. I've seen quite some beginner's C code which did "for (i=0; i<=10; i++)" to address a 10-element array :-) Seasoned C programmers don't do that anymore, but it tells me a bit about what is "natural" :-)
And that is my point: Different challenges need different numbers for the first index. When I am implementing a Gaussian algorithm to invert matrices, I'd never use 0 as the first index. But whenever I am computing indexes, I'd never use one as the first index. And this is not supported by BASIC and Smalltalk.
Greetings, Wolfgang
Cheers, Hans-Martin
-- Weniger, aber besser.
Hi Wolfgang, Smalltalk, as an ambience, can be used for doing other activities than writing "programs" (aProgram, aComponent, or aModule). When you compare Smalltalk with languages you are comparing syntax (the only thing comparable from a language perspective). Newbies use to compare smalltalk from language perspective, or from OO way (through design, abstractions, patters) to the tools they used in the past. Only with time, opportiunities of real use in production and contact with people that use smalltalk in another way (not simply like the best OOL); new ways of doing informatics emerges. Smalltalk as a open system, let you do non-formal development (e.g. pass the limits imposed by formalization, reductionism & encapsulation). As a non-formal device/medium, it is not the opposite of formal design; it is a convenient complement (the only one competitive complement to formal design used in software industry today) best, Ale.
----- Original Message ----- From: "Wolfgang Helbig" helbig@Lehre.BA-Stuttgart.DE To: squeak-dev@lists.squeakfoundation.org Sent: Monday, May 01, 2006 9:02 AM Subject: Re: new Smalltalk programmer's thoughts
Hi Hans-Martin, you posed the question
The question is: do we want to let hardware characteristics dominate our way of thinking?
And the answer is no! And I deeply appreciate Smalltalk for the #// and #\ operators, for
Integers
that are unlimeted, and for things like garbage collection that no real
machine
can achieve! Smalltalk leverages on being run by a virtual machine. And it
does
very well so. Furthermore, it lets you adopt things to your likes much
easier
than any other language I know. (I don't know Lisp) So, in this respect, I couldn't agree more with you.
collection, I want the first at index 1 and the fifth at index 5. When I'm using Integers, I don't want to think about 16 vs 32 bits, signed vs unsigned etc. The argument about loop bounds is somewhat related. I've seen quite some beginner's C code which did "for (i=0; i<=10; i++)" to address a 10-element array :-) Seasoned C programmers don't do that anymore, but it tells me a bit about what is "natural" :-)
And that is my point: Different challenges need different numbers for the
first
index. When I am implementing a Gaussian algorithm to invert matrices, I'd
never
use 0 as the first index. But whenever I am computing indexes, I'd never
use
one as the first index. And this is not supported by BASIC and Smalltalk.
Greetings, Wolfgang
Cheers, Hans-Martin
-- Weniger, aber besser.
Wolfgang Helbig wrote on Mon, 1 May 2006 14:02:19 +0200 (MEST)
And that is my point: Different challenges need different numbers for the first index. When I am implementing a Gaussian algorithm to invert matrices, I'd never use 0 as the first index. But whenever I am computing indexes, I'd never use one as the first index. And this is not supported by BASIC and Smalltalk.
To be fair, I have used more than one BASIC that allowed you to set either 0 or 1 as the base index for all arrays in a program. And the Self dialect of Smalltalk (http://www.merlintec.com:8080/Self/) does borrow several C conventions including 0 based arrays.
The current program I am writing in Squeak simulates hardware and 1 based arrays were a bit inconvenient, so the first thing I did was define a ZArray class as a subclass of ArrayedCollection with
at: index ^ super at: index + 1
at: index put: obj ^ super at: index + 1 put: obj
do: block 0 to: self size - 1 do: [ :index | block value: (self at: index) ]
and then all I had to do was write the rest of my application naturally and just remember to use "ZArray new: x" instead of "Array new: x". Inspecting ZArrays still shows the contents as having indexes starting with 1, but other than that small confusion (which I could easily fix if I wanted to) it works just great. There is probably a significant performance hit but I am not worried about that here.
-- Jecel
squeak-dev@lists.squeakfoundation.org