Live data from Hacker News

Just what does “code as data” mean anyway? (2014)

adambard.com

101–110 of 178 posts

Re: Just what does “code as data” mean anyway? (2014)

#101

See what I did there? Despite the good intention, no, because you're trying to explain lisp using lisp. If I knew lisp, I wouldnt need you to explain what code-as-data means. Maybe it's time for a different strategy. As a matter of fact, I've tried to explain code-as-data using OOP just this morning: https://news.ycombinator.com/item?id=16389514

Your linked comment is great but it sweeps one thing under the rug. There is a reason lisp didn't win. We put up with it (I use emacs, so I have to write it at times) but in general it's harder to reason about transformable lists of code than it is about plain old objects and their methods. Almost every problem elegantly solved in lisp has a parallel elegant solution in Ruby (using blocks, dynamic method definition,…

I don't think that's the reason lisp didn't win. I'd say it's more because of Price, Slowness and Unfamiliarity.

I've used Clojure professionally now for a year, and I'm not finding the problem you mention to exist. Maybe its exclusive to emacs lisp?

Re: Just what does “code as data” mean anyway? (2014)

#102
post #91

Earlier quoted context omitted.

>There is a reason lisp didn't win. We put up with it (I use emacs, so I have to write it at times) but in general it's harder to reason about transformable lists of code than it is about plain old objects and their methods. Sounds like your experience was with Emacs Lisp, a very clunky Lisp. >Though I completely agree that inheritance gets clunky and I strongly favour composition. Check out CLOS (Common Lisp Object…

>>Sounds like your experience was with Emacs Lisp, a very clunky Lisp. Emacs lisp is actually a very practical, easy to use and fun lisp to do a lot of great work in. Richard Matthew Stallman notes: It was Bernie Greenberg, who discovered that it was (2). He wrote a version of Emacs in Multics MacLisp, and he wrote his commands in MacLisp in a straightforward fashion. The editor itself was written entirely in Lisp. M…

Please do not conflate MacLisp and Emacs Lisp, they are different languages. GNU Emacs is not directly derived from Multics Emacs, it's one of the many reimplementations of the original Emacs. The closest thing to MacLisp today is actually Common Lisp, and it's much more advanced than Emacs Lisp, which is not surprising considering that Stallman was not interested in creating a state-of-the-art Lisp implementation with his limited resources but wanted to merely provide a minimal foundation for a programmable text editor.

Re: Just what does “code as data” mean anyway? (2014)

#103
post #99

Earlier quoted context omitted.

The hardware is more fundamental. (Unless you want to invoke mathematics e.g. term rewriting) The compiler/seq of bytes example requires von neumann, because in that case it is the behavior of the whole system that is self-modifying. You could not have the beautiful executable and interchangable files of bytes without von neumann.

I don't think that's right. There have been systems that were Harvard architecture (Motorola 88000, I think, and definitely others). But the code to run on them still started out as a sequence of bytes in a text file, that is, as data, and a compiler still took that data file and wrote another data file that was the executable image.

Sure, I guess

Re: Just what does “code as data” mean anyway? (2014)

#104
For me, "code as data" means that the code I write provides a particular structure (whether to create a report, or go through an editing task or find particular information in the computer). I then use a table-driven "data" approach to finding the particulars that are significant for this particular class of information. That might mean that I have the unique code stored in a table which I lookup using a relevant key, hence "table-driven code", or I have "setup code", "one iteration", and "teardown code" accessible through an indirect call because the structure of the code to do the task can stay the same. It is also common to have a general "event" fire at the end of the code to inform any other programs that need to know this data structure or real-world event has been accounted for. I think this approach is amentable to better testing, and can be viewed as a higher-level abstraction similar to LISP macros. (Even though my language of choice - MUMPS) doesn't have LISP-style syntactic macros.

Re: Just what does “code as data” mean anyway? (2014)

#105
post #66

Earlier quoted context omitted.

>There is a reason lisp didn't win. We put up with it (I use emacs, so I have to write it at times) but in general it's harder to reason about transformable lists of code than it is about plain old objects and their methods. Sounds like your experience was with Emacs Lisp, a very clunky Lisp. >Though I completely agree that inheritance gets clunky and I strongly favour composition. Check out CLOS (Common Lisp Object…

> Sounds like your experience was with Emacs Lisp, a very clunky Lisp. The lisp that didn't win is not an acceptable lisp.

So we have only unacceptable lisps. That doesn't really have any bearing on the fact that Emacs Lisp is a bad unacceptable lisp to use as an example if you want to talk about the potential of the Lisp family of languages.

Re: Just what does “code as data” mean anyway? (2014)

#106
post #70

Earlier quoted context omitted.

>I agree, OO is ultimately good enough. And Common Lisp has arguably the most flexible and powerful OOP system around, CLOS. Why don't write OOP in Lisp? It is done successfully by lispers around the world.

>>Why don't write OOP in Lisp? Because most people understand OO as some kind of namespace scheme. Basically to bunch together functionality under a name(class). When people talk of OO, most of them, are actually talking about modularizing code.

[deleted]

Re: Just what does “code as data” mean anyway? (2014)

#107

Earlier quoted context omitted.

>It is very possible and practical to parse conventional languages down to an AST tree, work on the tree, and run that code. Yes, of course. >Sometimes I wonder if the LISP cult is just trying to pretend Noam Chomsky was never born. Life is great at our cult, you see? Now, seriously, what you propose is to transforme "conventional language" (say, Java) to AST, work on it, and then spit out conventional language again…

In Lisp, my understanding is that while you can manipulate the AST directly, you will likely introduce a bug unless you use the special functions for handling hygienic macros? And each flavor of Lisp has its own way of doing hygienic macros.

If you don’t know what you’re doing, you can introduce bugs regardless of programming language.

Re: Just what does “code as data” mean anyway? (2014)

#109
post #34
post #10

Earlier quoted context omitted.

It's very nice, but with great power comes great responsibility. Some people program so many things with C macros that it becomes very hard to read their code.

That's the beauty of Lisp: it's all very readable, because it's a real language, not a string-substitution preprocessor. Yes, any idiot can write unreadable Lisp — but good Lisp is a work of art. The Art of the Metaobject Protocol should be required reading: it builds an entire object system, complete with classes and generic functions (multimethods), written in the language itself . It's a tour de force .

And I'm just pointing this out for those who aren't already aware -- C macros and Lisp macros aren't really comparable.

C macros are implemented as string substitutions in a separate step before compilation. Lisp macros can make use of the rest of the language features and allow for operations on the abstract syntax tree of the code, opening up things like adding new control constructs, generating boilerplate code, string substitution, and the creation of domain specific languages.

Re: Just what does “code as data” mean anyway? (2014)

#110
As someone who uses Clojure for only side projects, macros seem to get a lot of attention, both good and bad, for something I very rarely write. Maybe I'm missing something though, and programmers using these languages professionally resort to them more often than I do.
Post reply on HN