Friday, December 10, 2010

node.js REPL

I do like the node.js REPL.
The classic test is to enter 3 > 2 > 1

But consider this
/opt/curl/surge/8/bin/curl --shell
Entering 3 > 2 >1 gives a much better response.

Curl is an expression-based language - can you name another in which 42 > x > 0 evaluates to a success?

But let's stick to curl for now:  enter the string exit
Now that is a respectable result.  Douglas Crockford, applied science is not a popularity contest.

Simulate loosing your bearings for a moment and enter exit()

Are you convinced that JavaScript variables should always use var?  If so, enter
let answ:int = 42
Note the echo behavior is not annoyig.  To see answ enter answ or {value answ}
To change the value of answ, try
{set answ=65565}
So I such an
ln -s /opt/curl/surge/8/bin/curl xcurl
since the folks as curl.com failed to protect Curl from cURL.

And an icurl.sh gets you your rlwrap xcurl --shell

And to exit the REPL
{exit}
When Crockford talks about the origin of JavaScript and the involvement of SUN, he leaves out a few details.  His audience may not need to know about Self or Strongtalk.
But when Crockford lays out the weaknesses of JavaScript prior to ECMAScript5 he neglects to mention Curl.  Just as he neglects to mention Rebol or Io.  But at a GoogleTechTalk?  Were those talks intended to be misleading? Biased?

I do like JavaScript just as I do like Python (for my own needs.)  But Python is wrong for applications which must be tamper-proofed on the server-side.  Python dynamic objects in that regard are scary.  JavaScript is worse.  And Curl is (for now) absent on the server-side.

As for node.js, Curl has offered event loops in closures since forever.  and for generators, see RolledRandom at curl.com

3 comments:

KanjiRecog said...

notes for a response to Douglas Crockford: [part 1 of 2]

1) never misrepresent the facts in history of science - even an applied science

2) Curl is not 'swell'
Let's take Smalltalk as a 'swell' language (and yes, Squeak is both server and browser)

Smalltalk got many things right, but tended for years to reject composition in favor of inheritance
Smalltalk's pride was the Collection hierarchy with its list comprehensions exploiting blocks
Smalltalk's weakness was a lack of interfaces (implemented using inheritance as abstract classes relying on >> subclassResponsibility
In hindsight, given the work of Ducasse (the 'Crockford' of Smalltalk) we can see that both the perceived strength and weakness were neither. This is what Traits bring to Smalltalk: insight and results.
The strength of Smalltalk is in the ease with which both Traits and Seaside continuations could be introduced into a 'transparent' boot-strapped language.

Now Curl
Curl uses Regex. In an expression-based language this is a travesty (I exagg.) Call it
'the manager says use Perl' fallacy. That fallacy applies to JavaScript: the manager says,
use JavaScript in our custom site-specific intranet collaboration browser because we can tell the CIO that HR can always find us JavaScript programmers cheap. [ I heard for years how expensice Smalltalk developers even after we had proven the value of offering Smalltalk training to non-CS employees with domain expertise in telecom]. Until Crockford (or without Flanagan) they were hiring porgrammers
who often had not learned their language. Python programmers argue for python in the browser and python on the server so that they will be able to think in only one language. This is folly. But python out-performs Ruby so appears unstoppable.

Curl has not fostered the use of explicit constraint resolutiom or constraint handling
Curl for open-source has still seen key code libraries unavailable even though they are not compiler or runtime engine specific.

But. A Curl developer who learns Curl syntax has a much better chance of understanding the
Strength of the language if she also learns the AST and the maro facilities.

So what is the history of Curl? There is no need to compare JavaScript for serious server-side to 'wild cowboy python' and its dynamic objects. Every flaw in the JavaScript of 1999 was not
a flaw in the Curl of 1999.

It is true but trivial that Curl is not on the server-side (in public).

Rebol. It is just not relevant that Rebol is not in wide use. Monitoring the rebol-based altme.com 'rebol world' reveals where rebol is in use.

The truly great language that is only used on one important funded project: ICON. Ditto for Oz. Ditto for Caml (almost)
Where Curl was wrong in 1999. The Curl pay-for-use came about 10 years ahead of GoogleAppEngine and came a a bad economic juncture. Curl faled to protect its name ( cURL horror: if I type `curl` on my linux box I run cURL and not /opt/curl/surge/8/bin/curl
Curl failed in not separating content from presentation. This has been addressed.

If Curl had been free the way in which ICON was free ... (see the history of SNOBOL.)

Economies of scale:

The Chief Technology Officer and Python: the case of the summer intern

Why is there no lint ( Crlint ) for Curl ?

It could be just a grep for pragmas and directives.
It could be a grep for [ my const story ]

The missed 'killer app' was a Microsoft OneNote written in Curl or in ICON.

KanjiRecog said...

[part 2 of 2]
Rebol
p: 42 q: 65535 lst: [p q] what: first lst

GoogleTechTalk question: "What is the value of :what ??"

But ICON and Curl are also expression-based languages - is this an issue in both of them?

And this is the issue of get words and set words being types in rebol.

But wait a minute: look at {define-syntax} in Curl - such as

{define-syntax public {first ?item:identifer in
?list:expression where ?cond:expression}

This is a conditional {first} macro declaration head suggested by Chris Barber at developers.curl.com

Another useful comparison of Curl as a web content language in 2010 and JavaScript 5: the Arguments object

And then there is the Curl documentation and the Curl IDE with the interactive debugger. Now those are swell.

At the Michael Miller et al JS5 talk just before the release of the spec, a Google manager cautions
that the talk is public when a minify issue is raised. Why is minify not a Curl issue? Answer:
the pcurl file format.

To experiment with Curl:

/opt/curl/surge/8/bin/curl --shell

NOTE: Scripting with Curl on the server:
running an xcurl script does not launch the 'applet manager'.

A current Curl weakness: the web docs remain 6.0 when Curl is 7.0

The Curl strength: live code in the {example} macro and the documentation macros and 'text-procs'

Where to see good Curl code? http://code.google.com/p/zuzu-curl and various at sourceforge.net

A great strength of Curl: the packaging and the packaging macros.

Great strengths of JavaScript: JSLint, JSON, traits.js, node.js jQuery "use strict";

A weakness of JavaScript: the actual JSlint code. Compare how this would be packaged in Curl.
This remains a weakness of ICON and even ObjectIcon and is only addressed in Rebol3.

And I like the Crockford .create for new and the Crockford 'in closure find your privacy'

The manager for Perl also said not to use JSON because HR can always find XML programmers.

Here is my private constant story. I cannot tell you the many,many global 200 organizations
using this Curl codebase or a customized variant.

Suppose you ran grep on a src directory of source files for a modern language which provided encapsulation and a const declaration. Suppose that in that large codebase maintained by a large off-shore coding firm you could not find a file with either
private
const

So it is true that people will not learn their language; so it is true that a prototype can get shoveled-and-shoe-horned out into production.

Python has the author of straits.py and JavaScript has Crockford. Curl has Chris Barber, who really should be giving a Yahoo talk and a GoogleTechTalk.

Evolution's good ideas can start with few numbers. Applied science should not be a popularity contest: not for bridges, not for Bose-Eintein condensates, not for creating, marking-up and transforming
web content.

And like Pharo Smalltalk, Rebol, ICON, UNICON, ObjectIcon and Converge, Curl is evolving:
a recent example is the access modifier named 'library' and 'library' as a languge primitive.

PS: What Curl has rejected: continuations, coroutines, SNOBOL/ICON text strategies ...

A useful antidote: the paper on the Oz resizeable clock. Also of note: the use of logic and constraints in Smalltalk: SOUL (Roel Wuyts), Backtalk and lisp.

Of note in Smalltalk beyond Traits: Cog VM and multi-core Squeak.

KanjiRecog said...

Coorection to note [part 1]
But. A Curl developer who learns Curl syntax has a much better chance of understanding the strength of the language if she learns and uses the macro facilities.