News for hackers. Stuff that matters.
Re:Why MIT switched from Scheme to Python by time_management on Tuesday March 24, 2009 @04:14PM (#530730)
I wonder, if the switch had been made now, it they would have switched to Clojure instead of Python. It's a lot closer to Scheme, and its connection to the JVM gives it a lot of practical power. Does anyone have any thoughts on this?
Re:Why MIT switched from Scheme to Python by tlb on Tuesday March 24, 2009 @06:54PM (#531011)
People often say that Java has great libraries, but is it true? AWT is crufty and ugly. Maybe there are impressive XML parsers (Xerxes is 188,000 lines of Java!), but I don't want those. Numerical libraries seem bad. So what is the library that might convince me to use Java for something?
Re:Why MIT switched from Scheme to Python by herdrick on Wednesday March 25, 2009 @05:56PM (#532500)
No, they aren't very good. I think the problem is cultural. Programming Java gets you comfortable with extreme verbosity and tons of structure so its libraries end up like this: http://ws.apache.org/xmlrpc/apidocs/org/apache/xmlrpc/server... (In extreme cases.)

Lucene was mentioned earlier - it, at least, is very good.

I have the same impression about the numerical computation and machine learning libs too.

Re:Why MIT switched from Scheme to Python by time_management on Thursday March 26, 2009 @11:28PM (#534630)
There's a lot of "enterprise" crap in the Java libraries: extreme verbosity is the most notable problem. Object-orientation is also just the wrong metaphor for many problems. Finally, camelCaps are uglyAsFuckAndNotVeryReadable.

However, the JVM libraries are well-supported and generally can be trusted to work. For a lot of the wheels I'd rather not reimplement, they're quite useful. I don't think that the Clojure of 2020 will be as reliant on Java, but for now, the JVM libraries are very useful.

Re:Why MIT switched from Scheme to Python by acdha on Tuesday March 24, 2009 @07:16PM (#531054)
"The" library is which ever squirrelly database, file format, app, etc. your next project needs to talk to which doesn't have bindings for your favorite language. You compromise on Java to avoid writing that by hand and use a JVM language to avoid the pain of actually using Java.
Re:Why MIT switched from Scheme to Python by tlb on Tuesday March 24, 2009 @08:25PM (#531152)
Such as??? Can anyone point to a format I might want to use that has a Java library but no C++ or Python library?
Re:Why MIT switched from Scheme to Python by smallpaul on Tuesday March 24, 2009 @11:01PM (#531332)
A few years ago, I took over maintenance of a Windows program that depended upon a Java component wrapped in COM. With Sun and Microsoft at war, that seemed a bit risky to me.

I asked: "why is this Java component in the Windows client app?" The answer was that the server was also implemented in Java and the SOAP libraries were compatible, whereas Microsoft's and Java's were not (at that time).

I nearly choked: they chose a "standard" like SOAP and then re-standardized on a particular library (client and server components of it) "for compatibility."

So to bring this digression back to relevance, I'll say this: if you already have Java code around, it will be easiest to talk to it from Java. And since Java is the new COBOL, there is a bunch of Java floating around. (but if you need a Java client to talk to a Java server using a "standard" protocol then something is seriously awry somewhere)

Re:Why MIT switched from Scheme to Python by 10ren on Wednesday March 25, 2009 @12:29AM (#531414)
http://freshmeat.net/tags/java-libraries

I'm not saying they are all are high quality, or relevant to your task, or that there are no C++ or Python equivalents - just that there is a high quantity of Java projects. Why not have a quick search? Maybe there is a project there that will convince you.

AWT is about the most prejudiced example imaginable - it was rushed out, disowned by its authors, and quickly replaced.

I think one of the key aspects of the java ecosystem is the idea of free reference-implementation libraries, but you can pay ridiculous amount of money for corporate versions with better implementations. For example, the BEA Systems implementation of Java itself and related tools seems pretty good, well-documented and so on.

I find Java itself and its OO style is pretty horrible for writing prototype code that can be changed quickly and arbitrarily - so, probably, any revolutionary ideas that require that flexibility of interfaces will be hard to iterate in java, and therefore we probably won't find many such projects written in java.

Re:Why MIT switched from Scheme to Python by danbmil99 on Thursday March 26, 2009 @05:40AM (#533232)
"AWT is about the most prejudiced example imaginable - it was rushed out, disowned by its authors, and quickly replaced."

Ahh yes -- replaced with Swing. Do I need to spell it out?

Re:Why MIT switched from Scheme to Python by 10ren on Friday March 27, 2009 @03:52AM (#534834)
Please elaborate.
Re:Why MIT switched from Scheme to Python by danbmil99 on Sunday March 29, 2009 @02:31AM (#537173)
swing sucks almost as hard as AWT.
Re:Why MIT switched from Scheme to Python by failrate on Tuesday March 24, 2009 @07:56PM (#531118)
I don't know why people even bother with XML when it is so much easier to write S-Expression generators and parsers.
Re:Why MIT switched from Scheme to Python by ilkhd on Tuesday March 24, 2009 @10:24PM (#531288)
I beleive actually that s-expression are going to come back. Clojure, Arc, R6RS - these are harbingers of the return, I think.
Re:Why MIT switched from Scheme to Python by smallpaul on Tuesday March 24, 2009 @11:10PM (#531341)
JSON is much more popular than s-expressions, and not just accidentally. Explicit, compact syntax for both lists and key-value pairs is The Right Thing in a language like this.

   {
       "x": [
           {
               "y": "a",
               "z": 23,
               "q": [
                   54,
                   32,
                   45
                ]
            }
        ],
        "r": 43
    }
Re:Why MIT switched from Scheme to Python by anamax on Wednesday March 25, 2009 @09:34AM (#531783)
JSON is a subset of s-expressions. (Yes, s-expressions provide explicit and compact representations for mappings. They also handle other kinds of objects.)

The other difference is that there are JSON parsers and generators for more languages and they're not programmable.

Re:Why MIT switched from Scheme to Python by smallpaul on Wednesday March 25, 2009 @11:24AM (#531905)
Don't tell me. Show me. Please translate the example into s-expressions.
Re:Why MIT switched from Scheme to Python by anamax on Wednesday March 25, 2009 @01:30PM (#532117)
I'm confused why you don't see this as obvious. (There are several possible ways to represent mappings. I picked one that was close to something that you're happy with.)

{ ("x" ( { ("y" "a") ("z" 23) ("q" ( 54 32 45 )) } )) ("r" 43) }

Re:Why MIT switched from Scheme to Python by time_management on Thursday March 26, 2009 @11:23PM (#534624)
Clojure uses {} for maps, #{} for sets, and [] for vectors, and vectors are used in function definitions, let statements, etc. This slight decrease in regularity makes a lot of functionality more visible. For example:

SBCL:

(defun f (x y) (let ((z (gethash x :a))) (+ z y))

Clojure

(defn f [x y] (let [z (get x :a)] (+ x y)))

Having syntax for maps is a huge win. Like ML's pattern matching, it's one of those things that changes your coding style entirely for the better, in a way that you wouldn't predict just by looking at the feature.

The only think I miss from CL when I work in Clojure is keyword arguments to functions. There, the Clojure way is a bit worse:

(defun f (x &key y z) (list x y z)) (f 2 :z 3) => (2 nil 3)

(defn f [x {y :y z :z}] (list x y z)) (f 2 {:z 3}) => (2 nil 3)

Re:Why MIT switched from Scheme to Python by anamax on Friday March 27, 2009 @09:07AM (#535005)
> (defun f (x y) (let ((z (gethash x :a))) (+ z y))

vs

> (defn f [x y] (let [z (get x :a)] (+ x y)))

The CL defn of f is a function that is called with two arguments. That function is called like "(f a b)" If the Clojure definition is comparable, that is, the call looks like "(f a b)", why are []s used in the definition and the let?

> This slight decrease in regularity makes a lot of functionality more visible.

What functionality? x,y aren't part of a vector and neither is z. (x,y may come from a vector in the caller, but I'll assume that the defn works if they don't, so that shouldn't matter.)

Re:Why MIT switched from Scheme to Python by habibur on Tuesday March 24, 2009 @11:48PM (#531384)
Why can't we keep the indents and drop the parens?
Re:Why MIT switched from Scheme to Python by scott_s on Wednesday March 25, 2009 @09:56AM (#531806)
It would make data generation more difficult. When you emit any given data, you'd have to know its level of nesting to get the correct number of indents. Using begin and end tokens (whatever they are) makes that much easier.

(I actually prefer Python's style of using indentation to indicate blocks, but I recognize generating such code is harder than code with tokens.)

Re:Why MIT switched from Scheme to Python by abecedarius on Wednesday March 25, 2009 @03:34PM (#532313)
You don't have to know the level of nesting; you can add indents afterward just as easily as you can wrap a subexpression in parentheses afterward.

def indent(code): return code.replace('\n', '\n ')

Re:Why MIT switched from Scheme to Python by scott_s on Wednesday March 25, 2009 @05:28PM (#532462)
In my current project, I've implemented a source-to-source compiler. In the places where I emit C code, I usually don't have a handle to the scopes above me. I could get one, but it would take more work.

The code I generate has no indents and no newlines. Not having to keep track of these makes life simpler. To make my generated code more legible, I just run indent on it.

Re:Why MIT switched from Scheme to Python by abecedarius on Thursday March 26, 2009 @01:39AM (#533078)
I've written C code emitters too. FWIW, I've found nicely-indented output templates help to keep the source code of the emitter clear (and with no need to get at the enclosing scopes). But the question you raised was whether indentation-only was harder to generate, and I'd say no, because code.replace('\n', '\n ') is as simple as '{' + code + '}', if slightly slower.
Re:Why MIT switched from Scheme to Python by scott_s on Thursday March 26, 2009 @10:06AM (#533452)
And my point was that with the transformations I generate, I don't just say '{' + code + '}'. I'm applying transformations to existing code, not generating all of my own code from scratch.

Again, I see no point in making efforts to generate clean looking code when utilities like indent exist.

Re:Why MIT switched from Scheme to Python by rgoddard on Wednesday March 25, 2009 @10:26AM (#531842)
{} means object [] means array So you would not be able to just drop them, since they mean two different things.
Re:Why MIT switched from Scheme to Python by sharkbrainguy on Thursday March 26, 2009 @06:24AM (#533259)
for associative arrays foo: bar, for non-associative foo, bar,

surely this is unambiguous?

    x:
      y: "a",
      z: "23",
      q: 54,
         32,
         45
    ,
    r: 43
Re:Why MIT switched from Scheme to Python by smallpaul on Wednesday March 25, 2009 @01:13AM (#531450)
YAML?
Re:Why MIT switched from Scheme to Python by ilkhd2 on Wednesday March 25, 2009 @04:27AM (#531615)
1.hmm, well, if you try it you'll see that at least in the area of programming languages, after spending some time you'll see that you reinvented s-expressions. 2. can be very interesting to see for example this (sum of every vector-element) in json/yaml...

(defn sum-vec [vec] (let [vec-len (count vec)] (loop [idx 0 acc 0] (if (< idx vec-len) (recur (inc idx) (+ acc (vec idx))) acc))))

Re:Why MIT switched from Scheme to Python by smallpaul on Wednesday March 25, 2009 @11:51AM (#531944)
I don't want that in my json/yaml.

If I have Javascript then I already have mobile code.

If I'm using json in a situation where I don't have a Javascript interpreter, then I probably don't have a Lisp interpreter around either.

Re:Why MIT switched from Scheme to Python by failrate on Wednesday March 25, 2009 @02:33PM (#532210)
A decent JSON parser is also only a day's worth of work or less in just about any language.

My experience is that it is as little as and possibly less initial development and maintenance as a custom flat-file format or a really robust csv parser.

Re:Why MIT switched from Scheme to Python by ilkhd on Tuesday March 24, 2009 @10:26PM (#531292)
Java's JIT - this part is really interesting.
Re:Why MIT switched from Scheme to Python by NonEUCitizen on Tuesday March 24, 2009 @08:49PM (#531183)
lucene
Re:Why MIT switched from Scheme to Python by mahmud on Wednesday March 25, 2009 @05:46PM (#532483)
Which is a clone of a Common Lisp search engine ;-)
Re:Why MIT switched from Scheme to Python by sharkbrainguy on Thursday March 26, 2009 @06:33AM (#533266)
This took me quite a bit of googling to "confirm" so I thought I'd save the next guy some trouble.

Lucene is sort of Doug Cutting's Java version of Text Database (TDB), which he and Jan Pedersen developed at Xerox PARC, and which, to complete the circle, was written in Common Lisp (see "An Object-Oriented Architecture for Text Retrieval").

http://code.google.com/p/montezuma/

Re:Why MIT switched from Scheme to Python by scott_s on Thursday March 26, 2009 @10:07AM (#533453)
Please put newlines in the above, or don't put the two spaces in.
Re:Why MIT switched from Scheme to Python by sharkbrainguy on Thursday March 26, 2009 @04:21PM (#534083)
sorry, It seems I can't edit it now. Is there a timeout?
Re:Why MIT switched from Scheme to Python by scott_s on Thursday March 26, 2009 @05:03PM (#534160)
Yes, but I think I also triggered it by responding, which means only an admin can change it.
Re:Why MIT switched from Scheme to Python by rjprins on Tuesday March 24, 2009 @04:33PM (#530757)
Clojure is still something of a small hype. Python is a 18 year-old programming language.
Re:Why MIT switched from Scheme to Python by swannodette on Tuesday March 24, 2009 @05:13PM (#530851)
Clojure is a Lisp. Lisp is 50 years old.
Re:Why MIT switched from Scheme to Python by icey on Tuesday March 24, 2009 @06:13PM (#530958)
Don't you think that's a bit disingenuous? Clojure is still changing with a fair amount of frequency. As far as I'm aware, they have not even hit a 1.0 release yet (releases are currently referred to by their release date, which tells me it's still in the pre-final stages).

It's a great language, but there is nothing to gain here by claiming it somehow is mature because Lisp is 50.

Re:Why MIT switched from Scheme to Python by swannodette on Tuesday March 24, 2009 @06:54PM (#531015)
I suppose my point was that the principles of Lisp have lasted 50 years. Python (which is great) is the child of many, many Lisp-y ideas, but I don't think people will be using a variant of Python 32 years from now. But I would definitely bet there'll be many cool Lisp variants 50+ years from now, some of which may have taken some really good ideas from Clojure. Let's make it happen ;)