3 ms·
Great post! A few observations. - It seems like the difficulty level ramps up really quickly starting with the "So, what makes the lisp example different?" sec
by meken 8y ago
Great post! A few observations.
- It seems like the difficulty level ramps up really quickly starting with the "So, what makes the lisp example different?" section. This was jarring enough that I pretty much glossed over it (too much effort required to process all the definitions at once).
As a more meta point, I wonder if symbolic differentiation is in fact a good example of highlighting lisp's differentiating features? One could write the same code in python/javascript with using lists and strings and recursion in a similar way, no?
Not that I have a better example to highlight lisp's differences, which I understand to be macros. I've read SICP and have written a fair amount of elisp and still have not once identified a good use case for writing a DSL nor even a macro for myself.
- fiddlerwoaroof 8y agoOne thing I’ve done recently in Common Lisp with macros was write a suite of macros to make working with objective-c in Common Lisp less burdensome: with a couple reader macros, I can almost copy-paste objective-c code samples into my Common Lisp program and have them work.
- fiddlerwoaroof 8y agoAlso, some of the biggest complaints about redux and other JavaScript libraries is the amount of boilerplate you have to write, leading to really complicated scaffolding and code generation utilities: Babel, for example, is essentially just a big macroexpander for JavaScript enabling, among other things, the use of language features as soon as they are standardized rather than having to wait years until a sufficient portion of the available browsers support the new feature.
- pflanze 8y ago> One could write the same code in python/javascript with using lists and strings and recursion in a similar way, no? Then you're implementing a Lisp (just one with square instead of round brackets, and commas between list elements) within Python/JS. Edit: to explain, you also need to either translate the result of the derivation back into Python/JS code (via stringification and eval or perhaps AST manipulation--i.e. a compiler of the list structures (Lisp) to Python/JS), or write an interpreter for the list structures (i.e. Lisp interpreter).
- myWindoonn 8y agoThe homoiconicity is important. Python and ECMAScript (don't use "JavaScript", it's a trademark of Oracle's) are not homoiconic. Consider this Monte translation of OP's blog post: https://github.com/monte-language/typhon/blob/master/mast/fun/symbolic.mt.md https://github.com/monte-language/typhon/blob/master/mast/fu... The main feature present in Lisps and in Monte but not in Python nor ECMAScript is quasiquotation. ES has template literals, and Python 3 has f-strings, but neither language can use them for pattern-matching, only value-building.
- taeric 8y agoYeah, I thought of saying more on the code I used from SICP, but don't feel i could add much to their treatment. I think you could write something in other languages, but it would likely be incumbent to you to lex/tokenize the data. And then to convert back to a string to send back to eval. You can also do something similar with annotation processing in Java. Or the macro languages in newer languages. Much more difficult to me, though. For highlighting the features, I don't know of much. I like lisp because i find it fun. In large from the parsimony of the language. Though, i think it is layered in ways we often gloss over in that phrase.
- kazinator 8y ago> One could write the same code in python/javascript with using lists and strings and recursion in a similar way, no? That point is made in the article. You'd need to invent a language for writing the formulas as strings, and handle it with a scanner, parser (for which you pick an output tree format). Then do the differentiation on the tree format, and finally reformat the transformed code back to a string to be passed to the character-based "eval".