On 1 July 2011 12:39, Sven Van Caekenberghe <
sven@beta9.be> wrote:
On 01 Jul 2011, at 12:31, Nick Ager wrote:
or even:
hello world:
((ZnServer defaultOn: 1337)
delegate: (ZnDispatcherDelegate new
map: '/' to: [ :request :response | response entity: (ZnEntity text: 'Hello World!') ])) start
echo:
((ZnServer defaultOn: 1337)
delegate: (ZnDispatcherDelegate new
map: '/' to: [ :request :response | response entity: (ZnEntity with: request contents) ])) start
Yes, of course Nick, but then you better use the prefixes:
((ZnServer defaultOn: 1337)
delegate: (ZnDispatcherDelegate new
map: '/hello' to: [ :request :response | response entity: (ZnEntity text: 'Hello World!') ])) start
((ZnServer defaultOn: 1337)
delegate: (ZnDispatcherDelegate new
map: '/echo' to: [ :request :response | response entity: (ZnEntity with: request contents) ])) start
Writing the shortest possible server code is a dubioius challenge. Although few Smalltalker would be happy to use verbose and heavy Java and XML. It is important that simple things be easy, short and elegant and complex things be possible.
The problem with such short examples is that they usually serve as a
advertisement to attract new users, but has nothing to do with
reality.
Because once you put a real requirements before a framework which you
would like to use for your needs, and measure how easy/fast you could
implement it,
then you realising that simple things are not so simple as shown in
'hello world' examples.
So, such pieces of code could actually thwart users away: because once
you hit a wall (and you will always hit it no matter what framework
you using), the first reaction could be:
- hey but you said it will be easy!
:)