Live data from Hacker News

Python vs Common Lisp, workflow and ecosystem (2019)

lisp-journey.gitlab.io

71–80 of 83 posts

Re: Python vs Common Lisp, workflow and ecosystem (2019)

#71

He forgot: in python you read the code of somebody else and it's familiar. In lisp, you are learning a new language with every lib because each author think they are a god language designer and that their macro rock. Also they don't need a good doc cause they are obvious. Or good error message cause they never break. Also the way the author dismiss the number gap of packages available is ignoring the elephant in the…

> In lisp, you are learning a new language with every lib because each author think they are a god language designer and that their macro rock. Also they don't need a good doc cause they are obvious. Or good error message cause they never break.

I want to say this is an over generalization but I am living this in clojure right now.

Re: Python vs Common Lisp, workflow and ecosystem (2019)

#72

Not to start a flamewar, every time I see a python talk (pycon or else), with fancy tricks like metaclasses.. all I can think is that, well, CLOS would have been perfectly fit for this too. I know people are tired of the "lisp/smalltalk did it better" but what features of python are not possible (or hard) in CL[OS] ? ps: how many CL shops are out there ? I'd work near free just to try a CL team once.

> every time I see a python talk (pycon or else), with fancy tricks like metaclasses.. All I can think of is what a mistake those features were in python. "Fancy tricks" are generally the author trying to be clever (in the Kernighan sense) and ends up obfuscating the result. Not saying it works this way in CL, I don't have the experience to make the call, but in Python it was (and probably still is) prevalent.

I am sorry but what does this mean:

> the author trying to be clever (in the Kernighan sense)

I know that Kernighan is the author of the C book, but its been a while since I skimmed it.

Re: Python vs Common Lisp, workflow and ecosystem (2019)

#73

Not to start a flamewar, every time I see a python talk (pycon or else), with fancy tricks like metaclasses.. all I can think is that, well, CLOS would have been perfectly fit for this too. I know people are tired of the "lisp/smalltalk did it better" but what features of python are not possible (or hard) in CL[OS] ? ps: how many CL shops are out there ? I'd work near free just to try a CL team once.

CLOS (as you presumably know) models method application as calls to generic functions, instead of the now-more-mainstream Smalltalk-like message-dispatch approach which Python uses. The latter allows for things like overriding __getattr__ to intercept ‘all’ method calls and property accesses, for which I don't think there's any equivalent in CLOS. The way methods are ‘attached’ to classes gives you a natural form of…

> The latter allows for things like overriding __getattr__ to intercept ‘all’ method calls and property accesses, for which I don't think there's any equivalent in CLOS.

CLOS already offered AOP, which you can use to control such calls.

https://lispcookbook.github.io/cl-cookbook/clos.html#dispatc...

Re: Python vs Common Lisp, workflow and ecosystem (2019)

#74
post #73

Earlier quoted context omitted.

CLOS (as you presumably know) models method application as calls to generic functions, instead of the now-more-mainstream Smalltalk-like message-dispatch approach which Python uses. The latter allows for things like overriding __getattr__ to intercept ‘all’ method calls and property accesses, for which I don't think there's any equivalent in CLOS. The way methods are ‘attached’ to classes gives you a natural form of…

> The latter allows for things like overriding __getattr__ to intercept ‘all’ method calls and property accesses, for which I don't think there's any equivalent in CLOS. CLOS already offered AOP, which you can use to control such calls. https://lispcookbook.github.io/cl-cookbook/clos.html#dispatc...

I'm not sure what you're pointing at there. I'm aware of method combinations and method qualifiers—are you referring to being able to add a general :before/:after/:around on a single generic? If so, that's not what I mean; what I mean is vaguely similar but on the first-arg dispatch axis. Here's a toy Python example. Given:

  class KnowItAll(object):
      def __getattr__(self, attr):
          return lambda: "yes, I know how to " + attr
We then have:

  >>> k = KnowItAll()
  >>> k.reveal()
  'yes, I know how to reveal'
  >>> k.transfigure()
  'yes, I know how to transfigure'
  >>> k.make_sandwiches()
  'yes, I know how to make_sandwiches'
Ruby does this with method_missing instead, which is where I'm most used to it happening (and I think it's used a lot more in Ruby than in Python owing to the language-culture's higher tolerance for magic). Smalltalk used doesNotUnderstand, IIRC. One of the key secondary results of this is that you can do things like https://paste.ee/p/tUaRP, which is a toy “Tracer” class which intercepts, prints, and forwards method calls and attribute accesses (ignoring some edge cases).

If we were in CLOS, and started with:

  ;;; widget.lisp
  (defclass widget () ((radius :initarg :radius)))
  (defmethod grow ((w widget)) (incf (slot-value w 'radius)))
What I would expect for the equivalent is that, given:

  ;;; tracer.lisp
  (declaim (ftype (function (t) t) make-tracer))
  (defun make-tracer (object) ...)
  ;; ... further code goes here ...
Somewhere else, we can do:

  ;;; fiddle-with-widgets.lisp
  (let* ((w (make-instance 'widget :radius 3))
         (w* (make-tracer w)))
    ;; ???
    (grow w*))
Can you add code to tracer.lisp, without specific reference to anything from widget.lisp, such that this has the effect of (grow w) but prints what it's doing? Note also that my use of slot-value above is very deliberately a ‘raw’ access. I'm here completely ignoring the “make up entirely new methods on the fly as needed” part that method_missing also gets used for, which is even more impossible in CLOS given that it would require intercepting, what, all symbol lookups…

In CLOS, the class doesn't ‘own’ the method, it provides a type for dispatching on, so there's no way to do “give me some control over every generic function so long as the first arg is of ‘my’ type”. Which is a reasonable model, but means you can't do the same thing. Indeed the flip side is that in the Smalltalk-like model, generics are not reified, and methods that are specializations of the ‘same’ thing have no ‘real’ identity to them, so you can't do a type-ignoring :around method for an ‘entire generic’. (Often there will be a superclass to attach to instead, but it's considered dangerous “monkey patching” to mess around with someone else's class hierarchy like that, and in the case of more abstract interfaces there's nothing.)

Does that make sense?

Re: Python vs Common Lisp, workflow and ecosystem (2019)

#75
post #42

I'm not a particularly experienced or good Lisp programmer, I can customize Emacs, but that's pretty much it. However, I think this article is a bit skewed and not highlighting things Python has. For instance, the standard library means that Python is more usable out of the box. Also when you've got things like iPython or Jupyter it means you can get off the ground easily. So, in the end, they're two different langua…

This point seems to be addressed in the “State of the Libraries” section[0] [0]: https://lisp-journey.gitlab.io/pythonvslisp/#state-of-the-li...

Not really, the basic Python install has a lot of things ready to use without any external libraries.

Re: Python vs Common Lisp, workflow and ecosystem (2019)

#76

Earlier quoted context omitted.

I've worked in this industry for a bit and had the opposite experience. Most of the slow solutions have been in other languages due to poor design and algo choice. There have been several projects I've been able to rewrite from R to Python where the runtime on a workstation went from days with R to seconds minutes with Python in a tiny tiny VM (like $10 DO box). Sure maybe a 3 minute task in python that reconciles a…

So the R code was pretty bad and your solution was more optimal - that's the only bit of information in here. The point is that rewriting something means you have extra domain knowledge, bottleneck knowledge, etc that you didn't have during the initial write. Tt might have gone the other way too, initial write in Python is too slow, rewrite in R is faster.

Oh yeah, it definitely was - my point wasn't that R is slower than Python. My point is the only time I've encountered "slow apps" in practice was when they were written in a much faster language, and rewriting them in a slower language resulted in really good performance.

Re: Python vs Common Lisp, workflow and ecosystem (2019)

#77

Earlier quoted context omitted.

Agreed. The only time in practice (working on datasets consisting of millions of rows) that Python has been too slow was when I was taking courses in college and their online code thing timed out on some specific graph problems. I rewrote the algo in C# without any fuss

All analysis we run is over 100s of millions of objects (objects can be a few megabytes large) every time it runs. The slightest increase or decrease for 1 object obviously makes a huge difference overall; either in cost, time or both.

Absolutely, but I don't feel the vast majority of corporations are doing that type of computation. I feel that even with hundreds of millions of rows Python can be a great solution (I have done multiple projects generating fairly complex projections from a few hundred million rows) for most projects.

Re: Python vs Common Lisp, workflow and ecosystem (2019)

#78

Earlier quoted context omitted.

Nobody cares about what you're saying though (with respect) in this area. It's all about the ecosystem or Anaconda distribution itself rather than just the core language. I agree that what you're saying is accurate, but it also happens to be irrelevant in this particular case. Numerical methods and data science are mostly done by engineers, mathematicians, and other random stem folks. I've yet to meet someone who is…

> I've yet to meet someone who is even cognizant that Numpy is really calling out to some low level C then you've never met anybody who builds the tools that you use. Which is alright. But if you disparage their point of view then you sound a bit funny.

In this particular niche', yes. But again, that is almost entirely irrelevant to the vast majority of the millions of scientific Python users.

I'd love to write my own solution in assembly or C where I give birth to every function, but nobody has time for that level of monumental effort. Low level matrix libraries have a lot of inertia for a reason.

I'm not disparaging anybody's point of view. Yours is certainly valid for a small group of elite users. I'm just trying to point out that it is only a valid point for a very small group. Most simply view these things from the perspective of the entire ecosystem. Even scientists well aware of the C internals will not always use that knowledge.

Re: Python vs Common Lisp, workflow and ecosystem (2019)

#79
post #19
post #18

Earlier quoted context omitted.

There are some famous examples[1], but to be honest, they are rare outliers for libraries published. And even for internal use, the amount of "local custom style" seems pretty minimal in my experience. [1] Off the top of my head, I can recall Cells (early reactive/dataflow system - weirdness included symbol names made to sort first in Allegro CL IDE) and hu.dwim.* stuff which had its own wrapper around CL:DEFUN and C…

> There are some famous examples As someone new to the ecosystem of Common Lisp and in general a bit sadist (ref https://www.youtube.com/watch?v=mZyvIHYn2zk ), could you share which ones these are so I can enjoy not understanding them at all? Edit: I see now after I made my comment you added examples, thanks :)

There's a long story of macros wrapping DEFUN/DEFGENERIC/DEFMETHOD/DEFCLASS. I'll admit I even used some for shortcuts in declaring types and constraints.

But their use isn't that widespread, and in practice you can pretty quickly get used to the rare case that needs you to understand them.

I think the most complex is stuff that requires code-walkers and involved things like macros for CPS transformers of code.

Re: Python vs Common Lisp, workflow and ecosystem (2019)

#80
post #52

Earlier quoted context omitted.

That's my take on it, but I've ran into people praising it like it was alien theory of everything dropped by gods as a gift. I like python but I'm a bit fed up with the mobthink (how surprising).

Another factor, I think, is that a heck of a lot of people don't think they will still be doing this for a long time. Programming is something interesting and fun they are going to do for a few years while young, until (pick one) {their band takes off, someone funds their startup idea and they hire others to do the programming while they generate genius ideas and run the business, they get promoted to a high paying e…

Yeah life as a weird tendency to not turn out like one anticipates :)
Post reply on HN