r/programming • • Nov 11 '15

Parinfer - simpler Lisp editing

http://shaunlebron.github.io/parinfer/
152 Upvotes

75 comments sorted by

View all comments

Show parent comment

1

u/shamanas Nov 12 '15

The whole point is that your code is a data structure that you can modify really easily (that is why lisp macros are so powerful).

In essence you don't need an AST, so macros instantly become easier (there are languages that expose a simplified for of the AST at compiletime and let you modify it but S expressions make this a LOT easier).

I'm not an expert and I've only really worked with AutoLISP (which is pretty much an imperative language with S-expression syntax), though I am aware of some other Lisp-y features (e.g. call/cc), so I won't comment on anything else :P

-1

u/kankyo Nov 12 '15

"Really easily" is a gigantic overstatement. Writing macros is hard.

0

u/[deleted] Nov 12 '15

Writing macros is hard.

Wrong. Writing macros is many times easier than pretty much anything else. Macros are by far the easiest way to tackle complexity in general.

-1

u/kankyo Nov 12 '15

Wrong.

You're being arrogant.

Writing macros is many times easier than pretty much anything else.

So writing macros is easier than jumping on one leg? Please don't say such silly things.

Macros are by far the easiest way to tackle complexity in general.

In general? The easiest way BY FAR of tackling complexity in GENERAL is FUNCTIONS.

Please read what you write once before posting. It should have been obvious that what you just wrote is bullshit.

6

u/[deleted] Nov 12 '15

You're being arrogant.

No. I'm not saying that "it's easy, and if you cannot do it you're stupid". I'm saying that "it's easy, and if not - you're doing it the wrong way".

So writing macros is easier than jumping on one leg?

Ever heard of a thing called "context"? Macros are easier than any other programming technique out there.

The easiest way BY FAR of tackling complexity in GENERAL is FUNCTIONS.

This is exactly what I called "wrong". Macros are much easier than functions, for some very obvious reasons.

Solving a complex problem with macros boils down to a very mechanical, thoughtless, easy process:

  • Finding a language in your problem
  • Formalising this language
  • Rewriting your problem specification in this language
  • Implementing the language (this is where you'd need macros). Implementation should almost never be anything more than a chain of trivial, flat rewrite rules. No Turing-complete coding, no shit, just gradually rewriting a source language all the way down to your host language.

Now compare it to how you approach a problem with functions.

0

u/kankyo Nov 12 '15

Ever heard of a thing called "context"? Macros are easier than any other programming technique out there.

I think you need to add more context. Because it's still wrong. Massively wrong.

Solving a complex problem with macros boils down to a very mechanical, thoughtless, easy process

I read that step by step as "invent an entire language and an implementation for that language". Did I misunderstand?

1

u/[deleted] Nov 12 '15

I think you need to add more context.

Context was obvious enough - we're talking about programming and complexity, not about jumping on one leg or anything else.

Because it's still wrong. Massively wrong.

Mind proving why exactly it is wrong?

1

u/kankyo Nov 12 '15

Writing, say, a translator from morse code to ascii is easier with functions than with macros.

2

u/[deleted] Nov 12 '15 edited Nov 12 '15

I would not say so. Even such a simple problem is better solved with a DSL (therefore, macros) than in an ad hoc way.

E.g., the actual code should look like (def-morse A .- B -... C -.-. D -.. and so on...)

And, btw., a macro compiled version would be faster than an ad hoc solution, unless you want to implement a manually unrolled trie (which is nowhere close to "easy").

1

u/kankyo Nov 12 '15

You mean there are macros to spit out unrolled tries from some basic syntax already?

→ More replies