Live data from Hacker News

Why Lisp?

blog.rongarret.info

201–210 of 248 posts

Re: Why Lisp?

#201

Earlier quoted context omitted.

Macros are easy to understand if you are shown that whatever language you are using already has them . The difference is that they are locked in and wrapped behind at least two layers. Firstly, there rigid surface syntax which customizes the look of every macro at the character level. For instance, in C, the do ... while(); loop must have a trailing semicolon. (No Lisp macro has such requirements.) Secondly, that sur…

This doesn't really address the issue of readability or understanding though. You still have to go through someone else's uncommented code and figure out what their weirdo macros actually do versus having standard, documented language features that you already understand. Because there's not a ton of standardization (and for other reasons) you end up with a million different dialects of lisp and a fragmented communit…

If someone writes "weirdo macros" and you take them away, that same someone will write weirdo code using something other than macros. Either way, you will have to understand what they are doing. In the worst case, that person will expand, by hand, the code their macros would have written. Now you can't fix a bug in the expander and cheaply re-expand.

Re: Why Lisp?

#203
post #57

Earlier quoted context omitted.

I think you need a bigger reference frame of Lisp's usage over its 50 year history that extends even to 2015. But even then, quoting Kent Pitman: "Please don't assume Lisp is only useful for Animation and Graphics, AI, Bioinformatics, B2B and E-Commerce, Data Mining, EDA/Semiconductor applications, Expert Systems, Finance, Intelligent Agents, Knowledge Management, Mechanical CAD, Modeling and Simulation, Natural Lang…

Part of the visibility issue is that there are very few big-name open source Common Lisp success stories which aren't CL implementations, or CL ecosystem tools. Most of the things in that list are big-ticket enterprisey applications.

There are a lot of CL open source tools and applications. But they tend to be specialized to domains which are exotic to many people.

Math: Maxima and Axiom

Blackboards: GBB

Robots: ROS

Music: OpenMusic

Bioinformatics: Biobike

Theorem Provers: ACL2, PVS

AI / Logic: Racer, KM

etc etc...

Re: Why Lisp?

#204

The article doesn't discuss macros, which is one of the answers to "Why Lisp?" I didn't "get" macros until I read a footnote in the (freely available) book Practical Common Lisp . In chapter 7, it introduces the `dolist` macro. DOLIST loops across the items of a list, executing the loop body with a variable holding the successive items of the list. This is the basic skeleton (leaving out some of the more esoteric opt…

Could someone please explain the difference between Lisp macros and, say, languages that have first-class functions? I get that a Lisp macro will be expanded into the respective code, while a function's execution is different. However, at the practical (i.e., developer's) level, are there any additional benefits? Can, say, a Lisp macro be 'partially formed', in the sense that it can expand into some boilerplate that…

The difference is subtle. With high order function you coule define (abstract out) a new idiom, while with proper macros you could define a new special form.

In case of using high-order procedure all its arguments will be evaluated in order before application of the procedure while in case if a macro you could explicitly define all the transformations (evaluation rules) for each argument. This is why it is called a special form - it has its own evalustion rules.

Shortcircuiting if or and are canonical examples.

So, with macros you are extending Lisp with new special forms.

Re: Why Lisp?

#206

Earlier quoted context omitted.

Seconding the Clozure CL recommendation. It supports threads on Windows, which really expands your options if you want to do web development in Common Lisp. I run Linux on my web servers but develop from a Windows desktop. CCL works great on both.

I have the same workflow. Develop on Windows, push to Linux (including apps that use FFI/threading). Never had a problem with CCL.

I'm surprised how many Windows-based CL devs there are. I am too, however I use SBCL and it works pretty well too, although I have stumbled upon strange Windows-only bugs with it.

Re: Why Lisp?

#207

Earlier quoted context omitted.

That's a great example right there. Notice, the end result is just data, as terse and minimal as possible. But to act on (aka "interpret) that data, he wrote functions called "term", "part-of-speech" and "definition." So now, that data is code . Code is data and data is code.

Agreed - that example is amazing. However, the devil's advocate in me can't help but ask: what if I want more than one transformation? What if I want to generate both HTML and, say, JSON for returning that information from a web service? Hmm... it might work if I use some sort of global parameter: I first "execute the data" (damn!) with the output type set to HTML and then do it again with an output type of JSON.

There's an answer there too. In Lisp, it is possible to have local functions. In other words, you're defining a function, and inside it you have a couple of functions that are local to the containing function.

That's one way for "term" and the other items to have different definitions.

There are probably other even better ways to do it.

Re: Why Lisp?

#208
post #161
post #147

Earlier quoted context omitted.

Agreed about your Java example. However, for the purpose of this discussion, let's assume we're talking about modern, well-designed languages without ugly kludges and with access to nice features such as lazy evaluation and real closures. > Macros can be viewed as libraries that act on the language itself. There isn't a difference between language-level features and "library functions" in a language with macros. I si…

One that helped some Java friends understand is passing blocks of code, but still having it look like just writing code. Imagine instead of try/catch/finally, a transaction/commit/rollback in Java: transaction { // everything in here is in one transaction } commit { // do stuff if the commit is successful } rollback { // do stuff if we rollback } All the try's and catch's can be stuff into the macro. It can be made t…

I find this argument pretty unconvincing too.

>For all practical purposes, you can't add that to Java. You'll always have to wrap up your transactions in boilerplate.

Aren't you wrapping the lisp code in boilerplate when doing the macro too? This appears to be the same as your other example. Java has lambda expressions (since Java 8) that could do this.

If you are wrapping it in a macro, how is it different than wrapping it in a method? In Java 8, with lambda expressions, you can write code to wrap your transaction example to get something exactly equivalent to

>transaction(stuff, commit-stuff, rollback-stuff)

and you would be keeping the definition in the implementation. I also seem to be missing why it's important to be keeping the definition and implementation together.

Re: Why Lisp?

#209

Earlier quoted context omitted.

Your lame idiom example in java is why I love Lua so much: log.debug(debugIsEnabled and "yo expensive" or "yikes!")

Calling log.debug() with and argument of `false` is a no-op? That sounds like someone bending the language to fit an idiom, because it doesn't sound like a sane API except that it enables this use case.

It is insane in an eager-evaluated calling context. You're not wrong. But in Lisp it's not insane at all to let a macro consume a parameter and yield a no-op. Think of how this plays with a JIT and having code that can dynamically switch between dev/QA/production behavior and performance profiles, just for one example.

Re: Why Lisp?

#210
post #203

Earlier quoted context omitted.

Part of the visibility issue is that there are very few big-name open source Common Lisp success stories which aren't CL implementations, or CL ecosystem tools. Most of the things in that list are big-ticket enterprisey applications.

There are a lot of CL open source tools and applications. But they tend to be specialized to domains which are exotic to many people. Math: Maxima and Axiom Blackboards: GBB Robots: ROS Music: OpenMusic Bioinformatics: Biobike Theorem Provers: ACL2, PVS AI / Logic: Racer, KM etc etc...

Exactly. Where's CL's Rails, or Eclipse, or Postgres?
Post reply on HN