"I have a mind like a steel... uh... thingy." Patrick Logan's weblog.

Search This Blog

Friday, July 22, 2011

Kotlin == Harry Potter, Scala == LoTR?

kotlin is a new JVM language, from JetBrains. To understand my title, you may want to read a comparison with Scala from the Kotlin perspective, and some of the discussion taking place in the Scala community.

Perhaps since I recently saw the final Harry Potter movie, the title of this post came immediately to mind. Harry Potter appears to me to be a fun story, whose details exist mainly to support that story. For example, characters seem to have the abilities they require to meet a specific challenge.

On the other hand, the characters in Middle Earth seem be situated in a world that has its own physics. The stories are based on that world, those characters, and the given physics. My understanding is that this is the intention and the process taken to write the books.

Arguably, Harry Potter is far simpler than LoTR. But, arguably, Harry Potter has less to offer than LoTR.

Ten years ago this analogy could have been (and was, essentially) made between Java and Smalltalk. Ten years before *that* the argument had been made between C++ and Smalltalk.

Java is not "pure". Java is in essence Smalltalk but with the "magic" its authors deemed necessary to make Java more successful.

Harry's world is not pure. Middle Earth is (minus some of the complications that can also be found in Smalltalk and Scala.)

Kotlin is a big improvement over Java, but it is merely Java minus some cruft, plus enough magic to be useful in 2011. Scala on the other hand has its own physics that makes sense, and provides for a more rich future than Kotlin.

Hmmm. Just thinking...

Saturday, April 09, 2011

Implementing McCarthy's AMB Operator in Javascript Using a Trampoline

John McCarthy in 1963 wrote about his "AMB" operator for making nondeterministic choices. ("A Basis for a Mathematical Theory of Computation", PDF) AMB is also explained in detail in the (free, online) book Structure and Interpretation of Computer Programs.

AMB provides nondeterministic choices with backtracking in the case of failure. This is one of the major components of logic programming, with unification being the other major component. But AMB is useful even without unification. For example AMB makes it easy to collect all permutations of mutliple choices and to generate selective permutations. (Remember writing permutations as a beginning programmer? Yeah - you probably wish you had been taught AMB ahead of that.)

The SICP book uses Scheme for AMB. Scheme makes this easy, using call/cc and macros. And Common Lisp makes this manageable and pretty using macros. Javascript should not be too bad either - no continuations, no macros, but first-class functions help.

Mihai Bazon recently provided an implementations of AMB in Javascript. (Along with some great examples of using AMB, for example to implement N-Queens and Map Coloring).

Implementing AMB benefits from first-class functions, but they are not necessary. Some mechanism for a dynamic escape is needed. In C this is setjump/longjump. In Javascript (and many other languages) this is throw/catch. C does not have first-class functions, so that part gets ugly. Javascript though is a semi-functional language with first-class functions.

Rather than throw/catch, another versatile way to implement control structures with dynamic extent is to use a trampoline. A few weeks ago I wrote here about NCONC, the core of a Scheme interpreter written in Javascript using a "trampoline" for tail-recursion efficiency as well as for first class continuations.

The project ambjs is an implementation of AMB I wrote in Javascript using a trampoline. The source and the tests are explained using docco.

Using trampolines for dynamic-extent control structures can be cleaner, and they can provide more control options. In the case of AMB this implementation exposes fewer mechanisms than Mihai's, the nesting of AMBs is more apparent (to me), and there are fewer rules to be obeyed (and so fewer opportunities for bugs).

Tuesday, April 05, 2011

Moby Grape on the Mike Douglas Show

The video is not perfect, and the sound is not a lot better, but Moby Grape plays a couple of really good songs on the Mike Douglas Show. And it looks like they're having fun being there.

Sunday, April 03, 2011

I Have Monkeys In My Clouds

I took advantage of Amazon's offer for a year of 20GB free Cloud Drive storage by purchasing an album stored directly into the cloud. So far I am happy using the Cloud Player from linux, mac, and android. And I am v.happy uploading tons of music that had been spread over several machines and largely unsync'd together in a playable fashion.

The album I purchased to enable the additional storage is The Monkeys, "Head".

The Monkeys started as a TV show, and most of their work was produced and marketed as such. But they did have some talent, and fought, and broke through occasionally as a group that could sing and perform. On "Head" they reflect on their origins.

Hey, hey, we're The Monkeys
...
The money's in, we're made of tin
We're here to give you more!
"Head" is a movie starring The Monkeys and produced by Jack Nicholson. The music is a soundtrack and a really good album in its own right. It's no more dated than the best music from the late 60s, and it's more fresh because it hasn't been overplayed. Or even played.

Saturday, April 02, 2011

Practical Common Lisp

I am reposting this from February 24, 2005 - given my renewed interest in Common Lisp. It has been 22 years since programming in CL professionally. I have brought up a CL implementation several times in between, but never to do much of anything real. Most of my Lisping over these years has been in various Scheme dialects.

I love Scheme and some great Scheme implementations like Gambit. I may not have given up on Scheme forever, but... After all these years the Scheme standard is a kernel and there's not much in the way of a portable registry of libraries.

There are several commercial and free Common Lisp implementations of very good quality. And an apparently long list of portable libraries. I've only recently tried Steel Bank Common Lisp (derived from CMU CL, which was first implemented in the early 1980s), but my impression is that any of these high-quality CL implementations is as good a choice as ever. Nothing like Java's base of software, but rich enough to keep exploring nevertheless.

What about Clojure? I've used Clojure a bit over the last couple of years. Clojure is great, and has access to Java's libraries. However I recently gave up the JVM for Lent. Really I'm just stepping away from the Java platform to see what other things can do. For exploring and fun I felt the need to step away at least temporarily from all the Java-based bits and pieces. I am not really missing anything so far.

I am happy to move around. There are a lot of good options in the wide web world. One dream not quite yet fulfilled is a world where all these languages can get along with extreme ease. (And by that I do *not* mean "running in the same virtual machine".) They can each get along fairly well with Javascript, running on a server and talking over HTTP. They can get along with each other modestly using JSON or XML, one as the HTTP client, another as the HTTP server. Better than ever, but the difficulties mount rapidly beyond this simple case.

Oh yeah, I digress. Here's that repost from 2005:

As seen on Lemonodor...

The book Practical Common Lisp shows the power of Lisp not only in the areas that it has traditionally been noted for—such as developing a complete unit test framework in only 26 lines of code but also in new areas such as parsing binary MP3 files, building a Web application for browsing a collection of songs, and streaming audio over the Web. Many readers will be surprised that Lisp allows you to do all this with conciseness similar to scripting languages such as Python, efficiency similar to C++, and unparalleled flexibility in designing your own language extensions.

Using SPARQL endpoints and 4store RDF databases from Common Lisp

Jeni Tennison posted an interesting article using the 4store for RDF databases from Ruby. This was an experiment to see how close one can get to meeting a challenge from Richard Pope. The challenge puts forth criteria for a set of easy-to-use "linked data" programming tools.

I have duplicated the essence of the ruby/4store demonstration, using common lisp. Mainly because I like programming in various lisp dialects, I want to explore using 4store, and I recently decided to pick up common lisp again after, for all intents and purposes, a 20 year hiatus from that particular dialect.

The source and sample data is on github at https://github.com/patrickdlogan/sbcl-4store

These are just some examples that a reusable package could be based on. The code in workspace.lisp includes instructions for installing 4store on ubuntu, installing Steel Bank Common Lisp, and using the quicklisp system (think ruby gems) for finding and installing useful libraries.

Several functions are defined showing quickly how to load, query, and process RDF data. Two primary functions and their results are listed here:

The function extract-rdfs-classes performs a SPARQL "select" query to select all of the RDFS classes from the sample data. Note: these are not 'object-oriented classes', rather an RDFS class is more like the identifier of a logical "set" of members which are themselves identifiers.

The SPARQL query is:

prefix rdf: 
prefix rdfs: 
select distinct ?type 
where { 
  ?x a ?type .
} 
order by ?type
And running it from the lisp REPL:
* (extract-rdfs-classes)

("http://purl.org/linked-data/cube#DataSet"
"http://purl.org/linked-data/cube#DataStructureDefinition"
"http://purl.org/linked-data/cube#Observation"
"http://purl.org/net/opmv/ns#Artifact" "http://purl.org/net/opmv/ns#Process"
"http://purl.org/net/opmv/types/google-refine#OperationDescription"
"http://purl.org/net/opmv/types/google-refine#Process"
"http://purl.org/net/opmv/types/google-refine#Project"
"http://rdfs.org/ns/void#Dataset"
"http://reference.data.gov.uk/def/central-government/AssistantParliamentaryCounsel"
"http://reference.data.gov.uk/def/central-government/CivilServicePost"
"http://reference.data.gov.uk/def/central-government/Department"
"http://reference.data.gov.uk/def/central-government/DeputyDirector"
...
The function extract-persons performs a SPARQL "construct" query to construct a graph of FOAF Person instances along with their FOAF names and other triples having the instance as the subject.

The SPARQL query is:

prefix foaf: 
construct {
  ?person 
    a foaf:Person ;
    foaf:name ?name ;
    ?prop ?value .
} where { 
  ?person a foaf:Person ;
  foaf:name ?name ;
  ?prop ?value .                        
}
And running it from the lisp REPL:
* (extract-persons)

(("http://source.data.gov.uk/data/reference/organogram-co/2010-10-31#person189"
  "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
  "http://xmlns.com/foaf/0.1/Person")
 ("http://source.data.gov.uk/data/reference/organogram-co/2010-10-31#person189"
  "http://xmlns.com/foaf/0.1/name" #<"Philip Davies"@en>)
 ("http://source.data.gov.uk/data/reference/organogram-co/2010-10-31#person189"
  "http://reference.data.gov.uk/def/central-government/holdsPost"
  "http://reference.data.gov.uk/id/department/co/post/190")
 ("http://source.data.gov.uk/data/reference/organogram-co/2010-10-31#person189"
  "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
  "http://xmlns.com/foaf/0.1/Person")
 ("http://source.data.gov.uk/data/reference/organogram-co/2010-10-31#person189"
  "http://xmlns.com/foaf/0.1/name" #<"Philip Davies"@en>)
 ("http://source.data.gov.uk/data/reference/organogram-co/2010-10-31#person189"
  "http://xmlns.com/foaf/0.1/mbox"
  "mailto:philip.j.davies@cabinet-office.x.gsi.gov.uk")
 ("http://source.data.gov.uk/data/reference/organogram-co/2010-10-31#person189"
  "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
  "http://xmlns.com/foaf/0.1/Person")
...

Bill Hicks

Netflix now has four "watch instantly" shows regarding Bill Hicks. Three standups and one posthumous documentary.

Youtube has a number of videos too, including a good portion of the posthumous documentary, and the 2009 Late Show With David Letterman with Bill Hicks' mother. The Late Show decided to censor Hicks' October 1993 appearance.

The following February, Hicks died of pancreatic cancer in his early 30's. Letterman had his mother on in 2009, regretted the censorship and the additional pain it caused in Hicks' last months, then aired the censored performance. Letterman had had Hicks on a dozen times, on his previous 12:30am NBC show.

(Aside: I also recall Letterman had an episode at 12:30am in the 1980s where, during the course of the hour, the broadcast rotated once around the center of the screen. i.e. at 1:00am the show was upside down. An ongoing theme originally was the absurdity of television. There were many ways the show was "toned down" for the 11:30pm slot.)

There are a handful of social critics/satirists/comedians I continue to rate high my the list:

I'd have to put the Pythons on the list too, from my early teens and their series showing up on PBS, waiting each week for the next one, trying to memorize as much as possible in the half-hour. I didn't really recognize the Pythons or Carlin as social critics at the time. And Andy Kaufman, in his own way. More recently, Bill Maher and probably Eddie Izzard.

Hicks and I were born the same year. I wonder where he'd have gone over the last 17 years. He was pretty far out on the edge back then, and he didn't seem to hold anything back.

"It's just a ride... a choice right now, between fear and love." -Bill Hicks

Common Lisp libraries and Quicklisp

I made a modest donation to quicklisp, a very handy hosted-library system for common lisp. (Think of ruby gems and clojure's clojars) Quicklisp is fairly new, but already worth using at very low effort.

One thing that strikes me about common lisp libraries, beyond quicklisp per se, is the number of libraries available. I've been away from common lisp for all intents and purposes since 1989. The total number of libraries, and the number of library alternatives in any one feature area, are nowhere near those for the currently popular languages like java, ruby, or python. However I am impressed at the ease I've had finding what I am looking for, and then installing and using these libraries with ease.

I can simply say my recently renewed engagement with common lisp has been more than satisfactory on this front, and others I'll write about later.

Thursday, March 31, 2011

Richard Stallman at Portland State - April 7

Richard Stallman will be speaking at Portland State University next Thursday (April 7th) at 7:30.

Details are now on caligator:

http://calagator.org/events/1250460423

Friday, March 25, 2011

Building and Running 4store on Ubuntu 10.10

Note to self, if no one else: it's not immediately obvious, but time-saving to know, that 4store 1.1.2 will build with raptor 2.0.2 and rasqal 0.9.25.

All the other dependencies are available as packages on Ubuntu 10.10.

Upon building and installing raptor and rasqal, it is also not immediately obvious, but you might have to run sudo ldconfig for those shared libs to be found by 4store.

Starting the sparql http server includes one strange message in its output, something like:

4store[31919]: 4s-client.c:129 kb=sample getaddrinfo failed for “fe80::21e:64ff:fe2b:f42%wlan0” with error: Address family for hostname not supported

This probably is related to 4store using avahi to perform dynamic discoveries. Running 4store on a single machine, with a single store, this does not seem to be a problem. (Although I don't want to ignore this for long... so if you have any information...)

Wednesday, March 16, 2011

Bouncing Back

Over the years whenever I've wanted to learn a new programming language, the first significant application I've tried is a Scheme interpreter. Many (most?) Scheme interpreters on the web don't implement call-with-current-continuation and often do not handle tail calls well (i.e. they blow the implementation language's stack).

It's not hard to implement these things using simple mechanisms, but the simple mechanisms are not widely known. And as it happens, implementing these two very mechanisms tell you a lot about the implementation language. (Primarily because most languages have neither, and most languages do not have closures, and so you have to go to widely varying lengths to implement these two things.)

I've wanted to try out Javascript on a "significant" application. So below is a link to NCONC, which uses "trampoline style" to trampoline a "continuation-passing style" interpreter written in Javascript. I have a reasonable start on docco-style comments which I will put up asap. I presented this at pdxfunc last Monday and will use my memory of that to write more. 8^D

Note since I have only put in (parts of) a couple of weekends, and my only interest has been illustrating trampolines and call-with-current-continuation, you will not yet find more than a handful of implemented standard procedures. (Enough to run some tests.) And you will not find display so no printing yet. Oh, and no macros yet! But you do have call/cc.

https://github.com/patrickdlogan/nconc

Suggestions for better Javascript style are welcome too. I have a few in mind already, but people wanted to see the code. So.

Saturday, March 12, 2011

Node.js and the Javascript Tools Ecosystem

I recently have been picking up some javascript tools to test the waters of "serious" programming in that language (browser-side or otherwise). Although I've not used node.js yet for application development, it curiously shows up in several javascript-based shell tools.

And it works fine so far. My initial impression was, "Why use a web server to run shell tools?" But, e.g. docco installed perfectly using node.js and npm.

Being a skeptic, I first tried pycco, a a similar tool but more traditionally installed pythonically. Something wasn't right and it didn't run. This is just one, unfair, data point. But it was a reassuring experience that javascript tools are showing up and working fine.

Another javascript tool installed and run using node.js and npm is PEG.js, a parser generator based on, well, PEGs (parsing expression grammars).

These tools run fine, and I'm thinking they startup much more quickly than the java-based rhino javascript runtime tools. I've not bothered to investigate though.

Wednesday, November 10, 2010

This is not the one: On Lisp

This is not the post I'm going to write, but it is the one I'm writing.

I recently saw a tweet that reads something like, "Nice presentation on Clojure, but any language where you write 1 + 2 as (+ 1 2) is not for me." Fair enough. I won't hold it against you if you share that sentiment.

What about a language where you write 1 + 2 + 3 + ... + 1000 as:

(apply + (take 1000 (iterate inc 1)))
Lisp may seem foreign at first. And looking at a small expression in your language compared to the same in lisp may turn you off lisp forever. Fair enough.

Maybe your language has something equally as expressive. Fair enough.

But lisp is more than prefixes and parentheses, and you may want to dig deeper into the benefits of all of lisp's characteristics. Fair enough if you don't.

Tuesday, November 09, 2010

Is This Thing On?

Hi! (Insert animated gif of that guy digging. "Under Construction" - I'm working on a new blog post...)

Monday, June 08, 2009

Jobs of the Not-Steve Kind

An interesting graph of jobs related to some relatively hot programming language...

David Gelernter re: programming for/with clouds, etc.

"the reason why our approach was considered radical and strange in the
1980's was the so-called Tuple Space Model — the idea being that if
you had a lot of computing agents who needed to communicate, instead
of sending messages to each other, essentially like e-mail, if I had
information for someone, I'd just write it on a piece of datum and
release it and it would just float up into the cybersphere. If I
needed information, I'd look around, grab whatever I want, I would
read it or, if it were a task to be done, I'd grab it so nobody else
could grab it. "
-David Gelernter

http://www.edge.org/3rd_culture/gelernter09/gelernter09_index.html

(still beats the pants off all that crap we call integration
technology today. -me)

Friday, June 05, 2009

On Clojure, Testing the Implementation, and Protecting Your Investment

Over on the Object Mentor blog, Dean Wampler writes about the Clojure
programming language and the designer's stand on testing the
implementation. Dean writes that...

"TDD provides two important benefits
* Driving the design.
* Building a suite of automated regression tests. "

But another important benefit of a good collection of tests is communication.

Clojure is a fine Lisp in many ways. I personally would hesitate to
use it for anything in which I had a significant investment given the
maintainer's stand on testing. At least not without a good deal of
evidence that Clojure will continue to be maintainable and understood
(at the implementation level in particular) by more than one person.

Maybe his approach will work over a long period of time, and for a
user community that will rely on Clojure for many heavy-duty, valuable
production uses. I cannot say that it won't.

I can only say that for _me_ this would be a significant reason to
hesitate before taking too significant of a plunge.

And that's saying something because I am a veteran of programming in
various Lisps for 29 years, and Lisp generally is my favorite
language. I love that Clojure has rejuvenated interest in Lisp.

http://blog.objectmentor.com/articles/2009/06/05/rich-hickey-on-testing

Monday, May 18, 2009

TriSano: "Best Project for Government"

Click on this badge to vote for TriSano for "Best Project for Government"...

Friday, April 10, 2009

XPDX April: Bugs Do Not Exist

This month's http://xpdx.org meeting...

http://calagator.org/events/1250456971

Chris Sterling and Michael Tardiff are coming to Portland and will be
running April's XPDX session:

"We know about items on the product backlog, and getting them to
"Done." We know about impediments, and removing them as soon as
possible. And agile methods lead us toward shipping software with zero
defects, we hope. But bugs remain, for now, and we think of and treat
them quite differently from stories, tasks, and other work
items—perhaps to our, and our project's, detriment.
Buy why? We need your help finding an answer, or posing better questions.

In this interactive session, we'll explore the wealth of thoughts,
opinions, and especially the strong feelings behind the things we call
bugs."

>>> Pizza is sponsored by YesMail <<<

Pizza arrives at 6:30pm, the session starts at 7pm, and at 9pm we move
on to a local bar.

CHIFOO: Workshop: Interaction Design & Agile Development Techniques

From the xpportland yahoo group...

"Jeff Patton is giving a one-day workshop on user-centered design and
agile methods, organized by CHIFOO. The notice is below, in case
you're interested."
-Arlo


Come join the Computer Human Interaction Forum of Oregon (CHIFOO) for
a full-day workshop with two leading UX designers and Agile
Practictioners...

All Together Now: Blending Interaction Design and Agile Development Techniques

Lane Halley and Jeff Patton will lead a fast-paced day of fun and
learning. Through a combination of lecture and hands-on exercises, you
will increase your understanding of both User-Centered Design (UCD)
and Agile methods and gain useful techniques you can use immediately.

In this full-day workshop, you will learn how to:
• Choose appropriate UCD and Agile development techniques for your needs
• Successfully collaborate with diverse teams
• Understand who your "user" is, and what he or she values
• Create compelling design concepts that are shared by the entire team
• Iteratively sketch solutions as a group
• Translate design concepts into smaller user stories that can be implemented
• Prioritize and sequence product construction, without losing sight
of the "big picture"

This workshop is appropriate for people working in the UCD field, as
well as people curious about UCD or Agile.

Register Now for Lane Halley and Jeff Patton's Workshop

Registration is now open for Lane Halley and Jeff Patton's May 7, 2009
Workshop, "All Together Now: Blending Interaction Design and Agile
Development Techniques."

CHIFOO members receive a $50 discount off the price of the workshop!
Visit www.chifoo.org

Blog Archive

About Me

Portland, Oregon, United States
I'm usually writing from my favorite location on the planet, the pacific northwest of the u.s. I write for myself only and unless otherwise specified my posts here should not be taken as representing an official position of my employer. Contact me at my gee mail account, username patrickdlogan.