Currying. Continuations: Arc vs Java. What's a continuation? Despite much googling on the topic, continuations remained opaque to me until I stumbled upon Sam Ruby's amazingly excellent Continuations for Curmudgeons. Please read that article instead of this, it will be much more useful. Here's a really fast description of continuations in java terms. Imagine in java we had first-class functions (like javascript). In other words, we could say Function p = myObject.toString // no parens! // later ...p(); // calls myObject.toString() Now, let's jump a little further: imagine "return" is not just a keyword, but it is a special built-in function that is magically available in the body of every method, just like "this" and "super" are. Public String foo(int n) { this.cc = return; return("foo " + n); // "return" is a function} public void bar() { System.out.println("I have received " + foo(10)); System.out.println("end of bar");} bar(); // displays "I have received foo 10", then "end of bar"cc("haha!
") But I was undeterred. Arc Web REPL. Rees Re: OO. (Jonathan Rees had a really interesting response to Why Arc isn't Especially Object-Oriented, which he has allowed me to reproduce here.) Here is an a la carte menu of features or properties that are related to these terms; I have heard OO defined to be many different subsets of this list.
Encapsulation - the ability to syntactically hide the implementation of a type. E.g. in C or Pascal you always know whether something is a struct or an array, but in CLU and Java you can hide the difference. Protection - the inability of the client of a type to detect its implementation. So OO is not a well defined concept. The conventional Simula 67-like pattern of class and instance will get you {1,3,7,9}, and I think many people take this as a definition of OO. Because OO is a moving target, OO zealots will choose some subset of this menu by whim and then use it to try to convince you that you are a loser. I recently contributed to a discussion of anti-OO on the e-lang list. Arc 3.1 (works on latest MzScheme) Arc Forum | New Features. What's new in arc3?
The long-awaited new update of Arc (arc3) has been made available. I've examined the release to determine what's new in arc3 beyond the mysterious new logo: arc3 is a major change from arc2, with about 3000 lines and most files changed. The following gratuitous pie chart illustrates that the largest number of changes are in the news server (news.arc), with many changes to the fundamental language (ac.scm and arc.arc) as well as the web and application servers (app.arc and srv.arc). The news server has been heavily modified with new ranking, support for polls, and improved spam rejection, among other features. If you're looking to try arc3, it can be downloaded here.
Incompatibilities Arc now requires mzscheme 372. New functions Bug fixes Optimizations complement in function position The <, >, and + operations when applied to two arguments. Other changes Debugging has been improved by giving the Arc names of things to Scheme, and turning on line counting. My Language Is More Agile Than Yours. Thank you pg and rtm! I’ve been programming in Arc seriously for about six months now, so I thought this would be a nice time to pause and thank Paul Graham and Robert Morris for this language I find so delightful. I’ve long liked Lisp, but hadn’t been programming in Lisp for a long time because I hadn’t found any features in Lisp compelling enough to overcome the advantage other languages had in having large libraries available and such like.
At one point I had gotten into trying out macros, but I was programming in Scheme (which generally I liked) and so thought I should be using hygienic macros. I found the rationale of hygienic macros -- avoiding all possibility of conflicting identifiers in macro expansions -- to be compelling. After all, who would want to write a macro that breaks just because the user happens to be using a variable of the same name as one used in the macro? Some years ago I read Refactoring by Martin Fowler. With other languages I’ve programmed in, there’s a translation step. Arc at 3 Weeks. November 2001 1. Preliminaries: - Arc isn't finished. - Suggestions are invited. - Don't be too shocked (you may get used to it).
Arc was the youngest language presented at LL1. A few of the ideas in Arc will seem shocking, especially to compiler writers. 2. . - A language with dialects. - No new Lisp since mid 80s (and not new then). - Languages different now: Unix won, big libraries, active development. - No onions in the varnish. Lisp is an unusual language because it has dialects. It's about time for a new dialect of Lisp. Another thing has changed since 1985: Unix won. If you just made a Lisp that could talk to the OS and had powerful string libraries, I think it would more than hold its own. In The Periodic Table, Primo Levi tells a story that happened when he was working in a varnish factory. We're going to try not to include any onions in Arc. 3. . - Target user: opposite of Java. - Programmable programming language. - By default, allow. - The language I wish someone would make for me. 4. 5.
F# for Cheapskates. Since I've been hearing good things about the F# language from various people, I wanted to give it a try, but I wasn't interested in spending $250 on Microsoft Visual Studio . It turns out, however, that you can run F# for free in several ways. F# with Visual Studio Shell On Windows, you can run F# with a complete IDE by using Visual Studio Shell (not to be confused with Visual Studio or Visual Studio Express). Visual Studio Shell is an IDE without any included languages, and is available for free. Installation (Instructions updated August 2009 for latest versions.) Running F# inside Visual Studio Shell Start Visual Studio Shell. Printfn "Hello world! " Note that in the interactive window, you must enter ;; to have your input processed. To see the F# tutorial, click "Create Project ... " in the "Recent Projects" window, then double-click "F# Tutorial". To create a new program, click "Create Project ...
" in the "Recent Projects" window, then double-click "F# Application". Printfn "Hello world! " Readline support for Arc. When using the Arc REPL, I've often wanted to edit a previous line. Python lets you access and edit lines using the arrow keys, so why not Arc? You can do this with Arc by using rlwrap and the GNU Readline library. (Not to be confused with Arc's readline I/O operation.) Readline provides many editing operations. If you're not an Emacs user, you'll probably want to use the arrow keys to move through your current line and history, Home and End to move to the beginning and end of the line, and Delete or Backspace to delete characters. Installing rlwrap But how do you use readline with Arc? The easiest way is to install the rlwrap command, which wraps an arbitrary command in readline. For Windows, rlwrap is part of cygwin, although you need to explicitly select in the installer under "Select Packages to Install"; it's under "Utils -> rlwrap".
Once installed, add rlwrap in front of your mzscheme command. Rlwrap mzscheme -m -f as.scm. -= Yegge, Clojure, Arc, and Lolita: or Days of Future Past =- What Arc should learn from Ruby. Posted on Oct 26th, 2008 in Programming | 10 comments There was a lot of buzz surrounding Arc before it was released. Then Paul Graham made an early version available to the public and most people weren’t too impressed. Paul is a charismatic figure and has his own following, so despite the uncertain welcome that the language received, Arc managed to attract a small community of curious developers. Then silence. For a few months, most people hardly heard anything about Arc. Until today. I joked about this and said that “Arc is the infogami of programming languages”.
Don’t hold this against Paul (or Aaron); projects fail or have rocky starts all the time. I think that Paul is trying to distinguish between what the core features of the language are and its libraries, and his aim and focus is currently directed towards the former; a core that he wishes to change and evolve with a certain degree of freedom. This approach to the design of the core language is far from off course. Succinctness is Power. May 2002 In the discussion about issues raised by Revenge of the Nerds on the LL1 mailing list, Paul Prescod wrote something that stuck in my mind.
Python's goal is regularity and readability, not succinctness. On the face of it, this seems a rather damning thing to claim about a programming language. As far as I can tell, succinctness = power. If so, then substituting, we get Python's goal is regularity and readability, not power. and this doesn't seem a tradeoff (if it is a tradeoff) that you'd want to make. Does succinctness = power? Hypothesis My hypothesis is that succinctness is power, or is close enough that except in pathological examples you can treat them as identical.
It seems to me that succinctness is what programming languages are for. If smaller source code is the purpose of high-level languages, and the power of something is how well it achieves its purpose, then the measure of the power of a programming language is how small it makes your programs. Metrics Design Comparison. Non-deterministic regex in arc. By Conrad Barski, M.D. Sep 2008Licensed under the GNU Free Documentation License 1.2 Hi Everyone- I've put together a little regex library for my favorite Lisp dialect, arc lisp. The cool part IMHO is that the regular expressions are matched nondeterministically. This means, the program will speculatively evaluate arbitrary code based on preliminary matches and will "roll back" if it turns out follow-up matches fail. Such nondeterminism is straightforward in languages that support "call with current continuation", but nigh impossible in traditional languages.
Check out pg's On Lisp for details on implementing nondeterminism. Another cool thing about this library is that it has what I would argue is the "canonical" arc style. Simplicity- The most confusing part in using regexes, in my opinion, is the process of variable extraction. Not much focus was put towards performance in this system. Supported Regex Features Examples arc> (w/target "iiiix2yiiii" (re "x.y")) "x2y" Fancy Examples re.arc. What was the problem with internal define in Arc. According to Paul Graham, an early version of Arc had internal define, but there was a problem: In a language with implicit local variables and macros, you're always tripping over unexpected lexical contours.
You don't want to create new lexical contours without announcing it. But a lot of macros that don't look like blocks in the call expand into blocks. So we provided a second block operator, called justdo, which was like do but didn't create a new lexical contour (i.e. it is Common Lisp progn), and this is what you were supposed to use in macroexpansions.
The trouble was, I kept forgetting and using do instead. And I was thereby writing utilities with the worst sort of bug: the kind that might not show up for years, and only then in someone else's code. Huh? I'm also surprised by how complicated the implementation was said to be: We wrote a hideously complicated interpreter that allowed local variables to be declared this way. I suspect they just implemented it the wrong way. Idioms for programming in Arc. The code that implements Arc illustrates many useful programming techniques. Some of the techniques occur multiple times, and can be considered idioms of Arc programming; techniques that can be applied to many problems. This article describes some of the most common idioms, and how they can be used in Arc programming. The techniques described focus largely on macros and recursion.
Macros Not surprisingly, given Paul Graham's enthusiasm for macros, Arc makes heavy use of macros. "Decorated body" The most common use of macros in Arc is something I call the "decorated body", which wraps a chunk of body code with something to extend it, analogous to the decorator design pattern. To examine the implementation of this idiom, consider let, which is defined as: (mac let (var val . body) `(with (,var ,val) ,@body)) arc> (macex1 '(let foo 42 body1 body2)) (with (foo 42) body1 body2) Macro for control of evaluation Unlike functions, macros receive their arguments unevaluated.
Macro as lambda adapter. (fn Arc Language Blog): Many Arc compilers and interpreters. The introduction of the Arc language has spawned a mini-boom of Arc compilers and interpreters implemented in everything from JavaScript to .NET. Because Arc is a fairly simple Lisp dialect, it is relatively straightforward to implement, and many people are using it to learn about compiler and interpreter design, and to showcase different implementation techniques and languages. Paul Graham's official distribution started it all, of course. This version is implemented in MzScheme and translates Arc into Scheme code. The writeup on Arc Internals provides more information on how it is implemented. The Arc Forum is the site of most of the unofficial Arc development effort. The "Anarki" branches of Arc on github consist of a "stable" bug-fixed version of official Arc, and a more exploratory version with many modifications.
(For information on using github, see Brief Guide to Anarki and Git. Anarki includes "ac.sbcl.lisp", an implementation of Arc in SBCL. Ajax and Arc. Ajax is surprisingly easy to use with the Arc language. This article shows how to implement Ajax-based autocompletion and dynamic page updates using the script.aculo.us and Prototype JavaScript frameworks. These frameworks allow Ajax applications to be implemented with just a few lines of additional code. The hard work is done by the script.aculo.us and Prototype libraries.
All the Arc code needs to do is provide the list of autocompletion candidates, and the dynamic page content. The example This example implements a simple Ajax input autocompleter and dynamic page update. For the purposes of the demonstration, the content is information on the countries of the world, obtained from the CIA World Factbook. To summarize how it all works: When you enter characters in the input field, the script.aculo.us autocompleter JavaScript sends the charaters to the Arc server, which returns the autocomplete suggestions. Running the example First set up the necessary files. The Arc code Debugging. Sacado's arc2c. A Web Framework for Every Language.