News for hackers. Stuff that matters.
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.