Live data from Hacker News

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

adambard.com

1–10 of 178 posts

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

#5
One of the failures of conventional programming libraries is that parsing libraries such as yacc work in only one direction. In 2018 we could easily have libraries that work both ways by default, but we don't. Bidirectional parsing is great for code generation and opens up a lot of things you could do easily, but because common parsing libraries are unidirectional, people aren't aware of what you can do and don't clamor for bidirectional parsing.

It is very possible and practical to parse conventional languages down to an AST tree, work on the tree, and run that code. See

https://github.com/lihaoyi/macropy

Sometimes I wonder if the LISP cult is just trying to pretend Noam Chomsky was never born.

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

#7
And, as I wrote in another thread yesterday, it allows you to work with your text editor at a higher level of abstraction than non-lisp-coding people may have seen before (https://news.ycombinator.com/item?id=16386380).

Rather than thinking in letters, words, lines, or paragraphs, editor modes like paredit let you edit in terms of the structure of your code. I find this really hard to give up after lispy sessions.

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

#8
When I was first learning C, I wondered the point of macros; especially with inline functions.

It wasn't until I taught myself Racket and Clojure a few years later that I realized the utility, and it was immediately one of those "the world is different now" moments; I could actually augment the language without having to contribute to the core compiler.

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

#9

One of the failures of conventional programming libraries is that parsing libraries such as yacc work in only one direction. In 2018 we could easily have libraries that work both ways by default, but we don't. Bidirectional parsing is great for code generation and opens up a lot of things you could do easily, but because common parsing libraries are unidirectional, people aren't aware of what you can do and don't cla…

What do you actually mean by "bidirectional parsing" - re-generating the original input, or something equivalent to it, from the AST?

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

#10
post #8

When I was first learning C, I wondered the point of macros; especially with inline functions. It wasn't until I taught myself Racket and Clojure a few years later that I realized the utility, and it was immediately one of those "the world is different now" moments; I could actually augment the language without having to contribute to the core compiler.

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.
Post reply on HN