Live data from Hacker News

Ooh Ooh My Turn Why Lisp? (2008)

smuglispweeny.blogspot.com

61–70 of 160 posts

Re: Ooh Ooh My Turn Why Lisp? (2008)

#61
post #55

Earlier quoted context omitted.

Hmm. In many walks of life, popular != best. In fashion, cars, investing, and to some extent cooking, for example, the top performing adherent is doing things differently than the crowd. Lisp code can be very readable, but it takes a few years to learn how to write it that way. I spent many years in Perl 5 myself, and I found Common Lisp tricky at first but ultimately very satisfying. Two jedi mind tricks for the beg…

>This is what you might code, which I humbly submit to you is very readable: It's not, if that's a real life example. There is no context for what the data is, like a variable names.

Valid point. In that example it's using a list to hold each bar because I was focusing on the iteration and the raw data came from a yahoo api utility.

You could use a struct or a class which would give you accessor functions, and would be better for a real program.

You setup a struct:

  (defstruct bar date open high low close vol)
And this would be a one-time conversion of the data:

  (mapcar (lambda (b)
            (apply 'make-bar
                   (mapcan 'list '(:date :open :high :low :close :vol) b)))
          cl-user::*spy2006*)
Then you can access the elements with nicer names:

  (bar-date bar)
  (bar-high bar)
  ...etc...
(If you use DEFCLASS you can do a few more things.)

That would make the revised COMBINE-BARS look like the following, which has more context, and would yield a BAR struct back.

  (defun combine-bars (bars)
      "Summarize a sequence of BARS into one bar."
      (let ((opening-bar (first bars))
            (closing-bar (car (last bars))))
        (series::let ((zbars (scan 'list bars)))
          (make-bar :date (bar-date opening-bar)
                    :open (bar-open opening-bar)
                    :high (collect-max (map-fn 'float #'bar-high zbars))
                    :low (collect-min (map-fn 'float #'bar-low zbars))
                    :close (bar-close closing-bar)
                    :vol (collect-sum (map-fn 'integer #'bar-vol zbars))))))

(edit: added revised combine-bars)

Re: Ooh Ooh My Turn Why Lisp? (2008)

#62
post #18

"The question is where will we be in five years, the answer is using Common Lisp, because of language features" says the author in the comments. This was 8 years ago. Kind of rude of me to take that potshot, but it's there. I've been reading these "Why Lisp?" Arguments for years and yet it still remains pretty niche. The longer this goes on the more I am unable tell Lisp advocates apart from Perl advocates. They both…

Well, I'm still using Common Lisp. If there was anything better, I'd have probably switched.

Re: Ooh Ooh My Turn Why Lisp? (2008)

#63
post #22
post #18

"The question is where will we be in five years, the answer is using Common Lisp, because of language features" says the author in the comments. This was 8 years ago. Kind of rude of me to take that potshot, but it's there. I've been reading these "Why Lisp?" Arguments for years and yet it still remains pretty niche. The longer this goes on the more I am unable tell Lisp advocates apart from Perl advocates. They both…

Heh, yeah. Lisp has powerful features, I'm sure, but something that's always stumped me is, if that power mattered for delivering better code, would we have to strain so hard to find examples of why it's better? Paul Graham's viaweb story, well, that's great, but why wasn't there a whole cohort of super-powered startups winning the day with lisp in the original dot com boom? Why are there so few big wins with lisp? T…

DWAVE uses Lisp / SBCL.

http://www.dwavesys.com

Some company doing mobile satellite-based Internet streaming used Lisp / Clozure CL.

Re: Ooh Ooh My Turn Why Lisp? (2008)

#64
post #14

It's a nice perspective. Very practical and down to earth. There is another side though, and that is that learning to think of code as data is extremely empowering and translates well when working with a fairly large set of other languages (Perl, Python, Ruby, and now even Java). Learning Lisp turns you into a better programmer.

I like Scheme/Lisp but I don't know if I buy the whole "learning Lisp turns you into a better programmer". Maybe more knowledgeable but not necessarily a better a developer. In some ways learning a really flexible language like Lisp can turn you even into a really bad developer. I say "developer" instead of "programer" because I want to emphasize working with others and thus sharing code with others. Of course this i…

There are some Lisp-related things which provide developers with new tools and new ways to think, maybe making them better:

a) code as data

b) interactive software development

c) user-defined language extensions where the developer is part-time language designer, syntactic abstraction

d) dynamic object-oriented programming

e) meta-object programming

Re: Ooh Ooh My Turn Why Lisp? (2008)

#65

Okay, I've spent a lot of time writing Common Lisp and even more time reading about Common Lisp, and to be honest, I'm just a little tired of the cult around it. People who know it well gloat about how great Common Lisp is, which just so happens to make them look great too. And people who don't know Common Lisp all talk about the little Common Lisp they know, because they don't want to seem like they aren't in on it,…

> So the very first thing you do with your macro powers, and pretty much the only useful thing you can do, is break s-expressions. Once the first macro is written you can no longer assume that inputs to macros will be s-expressions with the function at the beginning and arguments following.

That's just completely wrong, and makes me wonder if you have actually spent much time writing Common Lisp at all. Macros are orthogonal to S-expressions: they manipulate code (which is just lists) in-memory, after it's been read in from S-expressions by the reader. They don't break S-expressions at all (and indeed, the output of a macro is necessarily PRINTable as an S-expression, e.g. (macroexpand '(with-open-file (foo "/tmp/"))) expands to:

    (LET ((FOO (OPEN "/tmp/foo")) (#:G637 T))
         (UNWIND-PROTECT (MULTIPLE-VALUE-PROG1 (PROGN) (SETQ #:G637 NIL))
                         (WHEN FOO (CLOSE FOO :ABORT #:G637))))
When Lisp programmers talk of implementing a DSL with its own syntax, we almost always mean an S-expression-based DSL, where the fundamental syntax still uses S-expressions and the DSL is built atop them. An example would be CL-WHO[1], where HTML tags are represented e.g. as (:p "Some text " (:em "emphasised")).

Maybe you're thinking of read macros, which really can be used to implement other syntaxes, e.g. CLSQL[2], which uses custom reader syntax to implement inline SQL expressions? In that case, you're not wrong: implementing your own reader syntax does, indeed, break S-expressions. But it doesn't matter: due to the specification of the reader algorithm, neither elements containing nor elements within custom syntax care. The reader algorithm is quite elegant that way.

> I have to say I don’t care about macros, and actually think we’re better off without them. First-class functions are a much more coherent, consumable way of using code-as-data.

At the cost of being much more verbose. I've taken a look at trying to implement restarts in Go, and the sheer number of times I'd have to type 'func' is insane.

> But I tend to think that learning functional programming is the part that people are referring to

Once again, I disagree. IMHO writing Lisp makes one a better programmer because one starts to think of code as clay, which can be sculpted and crafted, moved around, deleted, generated &c. The worst good programmers I know of simply aren't comfortable with that concept; the best programmers I know are.

Compared to that, functional programming is merely interesting IMHO.

[1] http://weitz.de/cl-who/ [2] http://clsql.kpe.io/

Re: Ooh Ooh My Turn Why Lisp? (2008)

#66

> he simply asked if Python could gracefully manipulate Python code as data Have there been any big LISP macro code injection vulnerabilities in the wild?

As the other comment says, that doesn't really make sense. However, I have had to debug a codebase where lisps unhygienic macros led to extremely weird errors. The second time that happened in a big project I decided that schemes hygienic macros are superior. The extra cruft writing them is worth it. I have literally spent weeks debugging weird macro errors introduced years after the macro was first written.

You're not wrong: simple macros can be written poorly. Macros which don't properly use GENSYM should be rejected in review. Also, it's entirely possible to write a hygienic macro implementation with DEFMACRO: nothing stops a team from doing that (or using one off-the-shelf).

But sometimes you do need the full power of DEFMACRO, and it's not possible to write DEFMACRO with DEFINE-SYNTAX. So one tool enables you to do anything you need, and the other only some of what you need. I know what I prefer.

Re: Ooh Ooh My Turn Why Lisp? (2008)

#67
post #46

Earlier quoted context omitted.

Well, no, I'm not confusing powerful and popular. I'm asking why, for all lisp's power, there's almost no examples of that power actually doing anyone any good. Is it because most projects don't need something powerful? The benefits of that power aren't actually that great compared to the rest of the lisp baggage? We have this trope of the smug lisp weenie and there's definitely a whiff of high wizardry around lisp,…

You've probably played a Naughty Dog game. They use Scheme as the scripting language, but their PS1 games were written entirely in a Lisp. …except it didn't have garbage collection. Lisp weenies are all GC weenies too, right? Is that acceptable?

Nah, GC weenies would probably be the Java guys ;). GC is an important and helpful part of a working Lisp system, but it's not the core of the magic.

Re: Ooh Ooh My Turn Why Lisp? (2008)

#68

Okay, I've spent a lot of time writing Common Lisp and even more time reading about Common Lisp, and to be honest, I'm just a little tired of the cult around it. People who know it well gloat about how great Common Lisp is, which just so happens to make them look great too. And people who don't know Common Lisp all talk about the little Common Lisp they know, because they don't want to seem like they aren't in on it,…

> a lot of the problems with macros can be seen as type problems

If it had a type, it would be something like code->code. You seem to hold one of those "not even wrong" kind of notions about types and/or macros.

Re: Ooh Ooh My Turn Why Lisp? (2008)

#69
post #35

Okay, I've spent a lot of time writing Common Lisp and even more time reading about Common Lisp, and to be honest, I'm just a little tired of the cult around it. People who know it well gloat about how great Common Lisp is, which just so happens to make them look great too. And people who don't know Common Lisp all talk about the little Common Lisp they know, because they don't want to seem like they aren't in on it,…

>Let's talk about this fabled exchange between Norvig and McCarthy, where McCarthy asks if Python can gracefully manipulate code as data, and Norvig said no, and supposedly a thousand words were said in the ensuing silence. Python has this: https://docs.python.org/2/library/ast.html so it is possible to manipulate code as data. It just happens that it's not homoiconic, but so what?

> Python has this: https://docs.python.org/2/library/ast.html so it is possible to manipulate code as data. It just happens that it's not homoiconic, but so what?

The difference is that when you can do it gracefully, you'll end up doing it and using this possibility to build your project. If you can't do it gracefully, you'll dread using it and will not consider it a possible solution to your problem unless all other options are exhausted.

Re: Ooh Ooh My Turn Why Lisp? (2008)

#70
post #48

For UI application programming You can do without FP language features. Hell, you can even do without smart pointers checked arrays or GC. But you cannot do without a decent desktop or web development experience. I got involved with pretty large desktop applications written in delphi. The design-time, the debugger, native compilation without having to install some msvc runtime, deriving and combining visual component…

Would you pay for it? http://www.lispworks.com/products/capi.html

I did buy frameworks for work, and this does look OK, but coding gui by hand is not something our developers can handle in large scales.
Post reply on HN