2 ms·
> I know PG claims meta programming was the secret to ViaWeb's success, but I'm not sure how exactly that was the case IIRC, PG said the advantage of Lisp was
by pdonis 7y ago
> I know PG claims meta programming was the secret to ViaWeb's success, but I'm not sure how exactly that was the case
IIRC, PG said the advantage of Lisp was being able to add features much more quickly than the competition, so that (a) they could be adding features almost daily that the competition would take weeks or months to match, and (b) whenever the competition added a new feature that looked like a good idea, they could implement it within a day or two, so by the time the press came around to ask them if they had it too, they could say yes.
I also remember him saying that Lisp macros were about 25% of Viaweb's code, so a significant part of the advantage of Lisp was metaprogamming.
> even if true whether that is still relevant today.
It's probably not that much of an advantage any more if your competition is other startups, since they probably have access to basically the same metaprogramming tools that you do.
It might still be a significant advantage if your competition is large, mature businesses whose business model you are trying to disrupt.
> I have found Python to hit the sweet spot much better in terms of rapid prototyping, and providing a runway to making the prototype more rigorous and maintainable.
I have found this to be true as well. But I also find that I do a significant amount of metaprogramming in Python, and one of the key things to transitioning to more rigorous and maintainable code is to make sure that whatever metaprogramming needs to stay there for the long term is packaged into a library or a tool whose internals won't need to change.
- alwalo 7y agoCould you write something more on metaprogramming in Python ? And how does this compare with Lisp, what do you use it for ? Any good resources to learn this ?
- pdonis 7y agoMetaprogramming is a fairly broad term, but some of the kinds of things I often find myself doing in Python are: - Writing functions that make functions: often I'll find that I want a family of functions that all follow a the same general pattern. In Lisp this would generally be done with a macro; in Python it can usually be done by writing a function that returns a function. The "maker" function will generally have some parameters that fill in specific parts of the general pattern; the function that gets returned is therefore a closure over those parameters (i.e., it has specific values of them filled in). Doing this with a "maker" function is less error prone (particularly if there are a large number of variations on the general pattern) and follows the DRY (don't repeat yourself) principle, which I think is a very good one. - Writing decorators that add a particular common behavior (such as logging or debug output) to a variety of different functions or classes or methods. This is a common case. (In fact one could argue that decorators in general are examples of metaprogramming.) - Using data to construct code. Database programming is a common application of this: for example, I have a database library I commonly use (it's on GitLab here: https://gitlab.com/pdonis/plib3-dbtools https://gitlab.com/pdonis/plib3-dbtools) which constructs typed namedtuples specific to a database table's fields, and wraps rows returned from queries in them for easier field access. More complicated database ORMs use similar techniques. Unfortunately I don't know of any good resources on metaprogramming in general.
- BoiledCabbage 7y agoIt seems extremely perplexing that you describe how you'd solve the problem using first-class functions in Python, but then wouldn't simply use first class functions in LISP...The language that invented first class functions. It's possible LISP was more complex because you weren't comfortable with using it?
- lispm 7y ago> Python it can usually be done by writing a function that returns a function (defun make-incr-functions (numbers) (mapcar (lambda (n) (lambda (arg) (+ arg n))) numbers)) Why would I write it as a macro?