Hacker News new | past | comments | ask | show | jobs | submit login

> Each time you define a method or a class (C#, Java, C++), you're extending and defining your "language".

One mostly only adds new words to these languages: nouns and verbs. With Lisp you can add new syntax as a user as part of the program. This allows us to do code transformations at compile time as part of a program. This allows us relatively straight forward to generate more complex code from simpler descriptive code.




> With Lisp you can add new syntax

"With Lisp you can have any syntax, as long as it looks like Lisp."


Unless it doesn't:

    CL-USER 14 > (loop for i from 0 below 10
                       sum i into isum
                       when (evenp i) sum i into evensum of-type integer
                       else when (oddp i) sum i into oddsum
                       finally (return (* isum evensum oddsum)))
    22500


Arguably that still looks like Lisp (i.e. it's a valid S-expression). But then you also have reader macros...


Well, s-expressions are not Lisp. Not every s-expression is a valid Lisp program.

(1 * 2 ^ 3 + 1) is a valid s-expression, but not a valid Lisp program. With an INFIX macro it could be:

(infix 1 * 2 ^ 3 + 1) could be a valid Lisp program, with a corresponding infix macro.

But the Lisp syntax still is on top of the s-expression syntax...


I could do that in C# as well if I felt I needed it. Define classes representing the "syntax/AST", utility functions to build the AST and an interpreter that compiles the AST to an expression tree which in turn is an executable lambda.

It's what EFCore does, translates C# method calls into SQL statements via lambdas bound to expression trees.

So, no, LISP is not special in that regard.


> LISP is not special in that regard

It's just MUCH MUCH easier, standardized and widely used.


> easier

For routine code generation, there are even simpler T4 templates. That one gets as easy as one could want.

> standardized

So are expression trees: https://docs.microsoft.com/en-us/dotnet/api/system.linq.expr...

> and widely used

By what statistics?


> So are expression trees

But they are not easier. Pick one or two out of three.

> By what statistics?

Number of defined or used macros per lines of Lisp code.




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: