A co-worker needed to convert a Cygwin-dependent script to something that runs on a bare-bones
Windows system. The interesting part of the task was finding a replacement for the good ol'
head command-line utility.
Fortunately, this is fairly simple using a few lines of VBScript and the
Windows Scripting Host.
First, here's the VBScript code:
lines = WScript.Arguments(0)
Do Until WScript.stdin.AtEndOfStream Or lines=0
WScript.Echo WScript.stdin.ReadLine
lines = lines-1
Loop
This is an extremely stripped-down version of
head's original functionality, of course. For
example, the code above can only read from standard input, and things like command-line argument
validation and error handling are left as an exercise for the reader
Assuming you'd save the above into a file called
head.vbs
, this is how you can
display the first three lines of a text file called
someinputfile.txt
:
type someinputfile.txt | cscript /nologo head.vbs 3
Enjoy!
Wherever I travel, at least an hour or two of sightrunning is on top of my to-do list.
While I was in Milan for the European Lisp Symposium recently, I had to spend one
of the evenings in Milan preparing my presentation on CoCreate Modeling,
and so there wasn't much time left to enjoy the city. But I had my running
shoes with me, and so I sneaked out of the hotel for two hours in the evening
to marvel at sights such as the
magnificent dome,
the
Galleria Vittorio Emanuele,
the Parco Sempione and the Arena Civica,
Castello Sforzesco,
the Scala,
Cimitero Monumentale,
the Corso Como, the
Brera quarter, or
Peck (not much of a sight when closed, though).
Sightrunning is just perfect to get a first impression of a city - next time I'm in Milan,
I'll already know my way around and what I want to see more of!
Spruch des Tages, heute morgen in der S-Bahn gehört: "Das ist doch so einfach wie 1*1 = 2!".
It's more than a week now that I returned from Milan where I attended this year's
European Lisp Symposium, but memories are still
fairly fresh. The conferences I go to are usually all pretty nerdy, but this one
provided particularly impressive examples of general geekiness.
Not that this came as a surprise. After all, this was a conference about Lisp. Lisp is one of those
languages which, as it seems, many love and many others hate, but which leaves few indifferent.
And so naturally, the audience at the symposium deeply cared about the language and its
underlying value system, and wasn't in Milan just for a few days of company politics or
for sightseeing.
For me, this meant:
- Two days during which I didn't have to explain any
of
my T-shirts.
- Not having to hide my symptoms of internet deprivation on the first day
of the symposium (when the organizers were still working on
wifi access for everyone).
- Enjoying (uhm...) the complicated protocol dance involved in splitting up
a restaurant bill among five or six geeks. This is obviously something that
we, as a human subspecies, suck at Special shout-outs go to Jim Newton,
Edgar Gonçalves, Alessio Stalla, Francesco Petrogalli and his friend Michele.
(Sorry to those whose names I forgot; feel free to refresh my memory.)
- Meeting Lisp celebrities like Scott McKay (of Symbolics
fame)
- Crashing my hotel room with four other hackers (Attila Lendvai and the amazing
dwim.hu crew)
who demoed both their Emacs skills and their web framework to me, sometime after
midnight. (Special greetings also to Stelian Ionescu.)
How refreshing!
As promised earlier, here
are some more notes from this year's
European Lisp Symposium in Milan - this time about Scott McKay's keynote presentation on what he has learned in his years as a Lisp and Dylan programmer at companies like Symbolics, Harlequin, HotDispatch and
ITA Software.
Scott joked he might well be the
Zelig or
Forrest Gump of the Lisp community, after having been around for a long time and
making appearances in a number of (unlikely?) places. In amusing anecdotes,
he explained some of the key learnings he took away during his career, and what
those learnings might mean for the future of Lisp and the Lisp community.
Some notes (from memory, hence most certainly inaccurate):
- "Any bozo can write code" - this is how David Moon dismissed Scott's attempt
to back up one of his designs with code which demonstrated how the design
was meant to work.
- "Total rewrites are good" - Scott was the designer
of CLIM, which underwent several
major revisions until it finally arrived at a state he was reasonably happy with.
- "If you cannot describe something in a spec, that's a clue!" - amen, brother!
- "The Lisp community has a bad habit of building everything themselves"
- "Immutability is good" (even for single-threaded code)
- "Ruby on Rails gets it right"; only half-jokingly, he challenged the community to
build something like "Lisp on Rails". Later during the symposium, I learned that
we already have Lisp on Lines
("LoL" - I'm not kidding you here ).
- "Java + Eclipse + Maven + XXX + ... is insane!" - and later "J2EE got it spectacularly wrong"
- He reminded us that the Lisp Machine actually had C and Fortran compilers,
and that it was no small feat making sure that compiled C and Fortran programs
ran on the system without corrupting everybody else's memory. (I'd be curious
to learn more about this.)
- Lisp code which was developed during Scott's time at HotDispatch
was later converted to Java - they ended up in roughly 10x the code size.
- The QRes system at ITA has 650000 lines of code, and approx. 50 hackers
are working on it. Among other things, they have an ORM layer, transactions,
and a persistence framework which is "a lot less complicated than Hibernate".
- Both PLOT and
Alloy were mentioned as sources of inspiration.
Scott then went on to develop a list of features which a future version of Lisp, dubbed
Uncommon Lisp, should have. That list was pretty long; notable features which I remember were:
- Should run on a virtual machine
- Good FFI support very important
- Support for immutability
- Concurrency and parallelism support
- Optional type checking, statically typed interfaces (
define-strict-function
)
- "Code as data" not negotiable
Not surprisingly,
Clojure was mentioned quite often,
both during the keynote and in the subsequent Q&A session. I'm still
not quite sure what Scott's position on Clojure really is. To me, most of the points
he made seemed to actually back up design decisions in Clojure: For instance,
Clojure runs on a VM, reuses the libraries and tools of the underlying platform,
connects easily to other languages, makes a decided effort
to support concurrency well, and while it breaks with Common Lisp syntax, it is still
in the Common Lisp spirit of being a pragmatic implementation of the fundamental Lisp
ideas. On the other hand, Scott also criticised some Clojure details (name resolution
comes to mind), and seemed uncertain whether to full-heartedly recommend
everyone to join the Clojure camp right away.
I
think what Scott tried to get across is that a revolutionary approach
is both possible and worthwhile for the Lisp community. Revolution,
of course, means breaking with the past, and it became obvious during Friday's panel
discussion on the future of Common Lisp that not everybody at the symposium felt
comfortable with the thought.
PS:
Michele Simionato
discusses the keynote presentation from a Schemer's point of view.
Previous month: Click
here.