Showing posts with label Scala. Show all posts
Showing posts with label Scala. Show all posts

Monday, March 28, 2011

Apache Wicket

Igor Vaynberg has an Apache Wicket Cookbook over at packtpub.com

A bit price-y for an epub in that genre.

Wicket has some virtues: it was not near impossible to convert to non-HTML/non-XML web content markup (unlike Scala Lift which is, well, ahem.)

Okay Lift: they have no excuse for the XML-lockstep as they have something like Traits available in the Scala language.  Type of output should be orthogonal to HTTP forwarding, redirecting and the rest.  But Lift has a project leader first, and a framework second.  Scala itself has more promise.

Friday, November 5, 2010

Seven Languages and a few questions

Pragmatic Programmer has published Bruce Tate's Seven Languages.  I have some reservations.

The languages are Clojure, Haskell, Io, Prolog, Scala, Erlang, and Ruby.  Looks cool.  But look again.

Clojure is something of a Lisp reincarnate.  Io and Ruby are botrh Smalltalk in another guise: Ruby is Smalltalk in files à la Perl; Dekorte's Io is Smalltalk-2 (Self) + actor (but not morphic - for which see one brand of Squeak Smalltalk.)

Erlang is best understood as Prolog reduced.  So what would have been beyond 1974 Prolog? Oz.  Or Mercury.  Or XSB.  Or think outside the box with a chapter on Logtalk instead.

Scala Traits come from Squeak Smalltalk, btw.

I have no quarrel with Haskell being there, though some would argue for OCaml.

But if LISP is not there, what is Prolog doing there?  Why not JESS or Drools instead?  And not a single expression-based language (Rebol, ICON/UNICON ( and now ObjectIcon and Converge) or MIT Curl, the language (ww.curl.com.)

With Ruby there, we at least have a reminder that performance matters - so maybe it should have been JRuby.  But I can imagine how Pythonists might feel incensed.

I would suggest 12 languages in 12 months or 3 languages in 3 months.

Take a moment to look at the comments on the Prolog N-Queens code.  Is Tate claiming that the two files in question are his copyrighted code?  Compare the ICON code for N-Queens and ask whether you wouldn't be better looking there for an alternative language on your shelf.  And Rebol 3 is really starting to take shape over at Rebol.net, Rebol.org and Rebol.com

Most CS folks recall the course in which they were required to do some Prolog.  But would they skip a chapter on JESS or Logtalk?

The real story in Prolog in the past 25 years is constraint resolution, and that can be seen best in Oz.  But the reader will have to use emacs.  Oops.

I don't mean to knock Amzi! Prolog for Eclipse or many of the excellent Prolog projects such as swi-prolog.org (now with UNICODE and constraint-handling rules) but I would argue that what makes SWI interesting is Logtalk - and if there is RDF in the picture, that points to XSB.

Clojure, Haskell, Io, XSB, Scala, Erlang, JESS and JRuby in 8 weeks.  Ok, now I'm more likely to recommend a book.

"Clojure, F#, Io, Oz, Scala, Erlang, and JRuby in 7 months".  Call it "between vacations reading-and-testing-and-coding-and-designing".  And you would have my attention.

And whatever became of Tcl ( it only gave us Tk, Expect, Sqlite and now TclOO.)  Oops.

Oh, and Mercury now generates Erlang in addition to C or Java.

PS
Isn't concurrency coming to UNICON?  Isn't Oz now distributed Oz?  Isn't ObjectIcon at code.google.com/p/objecticon
Oh - right.  The cool factor.  And Smalltalk itself - after giving us so much and then the RefactoringBrowser and then UnitTest and pair-programming and eXtreme Programming and the wiki at c2.com ... is not yet cool again.  Might as well wait for Hermes2 on a non-Linux OS.
Oh - and Rebol is already PEG-equivalent at 300+ Kb core running with a claim to a whole 15 Mb of working memory.  Hmmm.

Saturday, December 19, 2009

while ( write( read(resource) ) ) # no ;
#pragmatic programming

while(write(read())) may not be as succinct as the equivalent expression in Rebol, but this Icon expression - which composes correctly in ObjectIcon, UNICON, Converge and ICON itself - has an important property: it can fail and its failure is neither an exception nor an error.  And until it fails, it succeeds.

Yet for all the pragmatic programmer interest in languages such as Erlang and Clojure, Icon seems to attract no interest at all (judging from activity at the code.google pages for ObjectIcon.)

Indeed, the apparent disappearance of goto as a reserved word in JavaScript-family languages (except DMDScript, where goto is implemented) would seem to indicate that the Algol-like syntax of the replacement for SNOBOL may never get the attention it deserved.  GOTO is now masked as throw and try/catch and break-to-tag and the "resume-elsewhere-as-resume-next" of Icon failure may remain unknown to another generation of programmers.

When I last looked, goto remained an unused reserved word of Java, just as it was of JavaScript. For programmers who never worked with Prolog back-tracking, the idea that boolean expressions evaluate to TRUE or FALSE may seem a truism.  But it remains the case that a great deal of the internet, for one striking example, depends on all manner of objects deemed "empty" to default in boolean expressions to an evaluation as FALSE.

Just as it was false that SNOBOL would never be performant (SPITBOL put that to rest but too late), so it was false that GOTO is always dangerous (and useful long jumps in C are still with us.)

There is a useful word in German, Aufhebung, which does not always translate cleanly into English: but it might be the one word to capture the response of Icon to the challenges laid before SNOBOL by Algol, Fortran, Pascal and C.

You need only consider that recent languages as advanced as Java, C#, Curl, ECMAScript, Python and Scala continue to use Regular Expressions as if there had never been a programmers' tool which was an alternative to Perl.  PCRE is now an acronym if not also a shibboleth.

Icon was intended for non-computer scientists to use just as was SNOBOL before it, but even an MIT language intended for visual artists, Processing of proceessing.org, continues to advise its users to learn regexp.

Perhaps the release of ICON 9.5 (under the guidance of an award-winning CS teacher and mentor) will attract some attention. Or the future release of pythonic Converge 2.0

But I have my doubts.  Perhaps it will come when an HP innovator looks at available languages for new help center software for help desks in Africa.  Perhaps the interest will come from Latvia or western China.  In any other area of applied science, the likes of regexp would have been gone.  But we have yet to fall under the spell of some great offering us the dictum "RegExp considered harmful".

while ( write( read( responseStream ) ) ) 
# idiom, semi-colon terminator optional

PS
Icon: generators, iterators, practical co-routines, goal-directed evaluation, expression-based language (Carl Sturtivant, G. Townsend with others)
ObjectIcon: UNICODE Icon with classes (Robert Parlett)
Converge: pythonic Icon (Laurie Tratt)
Rebol: www.rebol.net, www.rebol.org, www.rebol.com (from Carl Sassenrath and team; now in alpha for REBOL 3 with closures and modules)
Curl: Clojure-like homiconic web content language with macros, closures, optional types and permiting scoped tags within iteration macros to facilitate expressions such as the macro {for tag=outer permitting {break tag=outer}

Saturday, June 9, 2007

Jetty Lift Scala Tutorial for Windows XP

First install Jetty as a web server.
Open a cmd session in that Jetty directory (for this I use Microsoft PowerToys "Open Command Window" tool.)
In that cmd session, execute
java -cp . -jar start.jar

Open an IE browser and enter the address http://localhost:8080
When the web page comes up, click the Jetty test link
Go to the cmd window and enter CTRL-c to stop jetty

Now install Lift if you have not already done so.
Copy the Lift JAR file to jetty\lib
Copy the Lift Examples WAR file to jetty\webapps
restart jetty
refresh the localhost web page with the F5 key
This time click the Lift Examples link

Welcome to Lift on Jetty

Thursday, June 7, 2007

Scala and the interpreter

I have been looking at Prolog-like facilities implemented in languages which could benefit from something like the partially determined clauses found in Mercury for which there is no backtracking: a matching clause is found among a set of clauses or we fail.
There are interesting implementations of prolog available as add-ons to many languages including Scala.

I began my foray into Scala with a PDF by Martin Odersky which presented the following code:
def sort(xs: Array[int]): Array[int] =
if (xs.length <= 1) xs else { val pivot = xs(xs.length / 2) Array.concat( sort(xs filter (pivot >)),
xs filter (pivot ==),
sort(xs filter (pivot <))) }

This implementation of a quicksort chokes Scala when it is fed line-by-line to the interpreter by my own shell tool.
Here is one variant that keeps the interpreter waiting for more:
def sort(xs: Array[int]):
Array[int] = if (xs.length <= 1) xs else { val pivot = xs(xs.length / 2) Array.concat( sort(xs filter (pivot >)),
xs filter (pivot ==),
sort(xs filter (pivot <))) }


It is the sort of thing that those who script Perl are used to but might seem odd to someone from the functional-side whose interpreters would be waiting for the closing embrace.

If you would like to contribute to a portal on declarative+imperative, there is a new SmalltalkProlog portal that I have opened at aboutus.org