7 ms·
There seem to be two big camps that preach a "learn this weird new programming paradigm because it'll help you see things from a new perspective and will make y
by ohazi 9y ago
There seem to be two big camps that preach a "learn this weird new programming paradigm because it'll help you see things from a new perspective and will make you a better engineer" message: the lispy languages, and the ML-like languages. Both of these languages categories give you functional programming as well as metaprogramming, which is great. Having tried both, I've found that the ML-derived languages tend to have a stronger type system that's more rigorously enforced at compile time. I personally find this much more valuable in practice than some of the dynamic magic that you can do with lisp.
There are some notable exceptions, of course, but part of this is just inherent to the design of lisp, and I think it's easy to end up with a type safety system that feels more like it's bolted on than part of the language.
- davexunit 9y agoThere are also plenty of Lisp programmers that think that it's a real tool to solve real problems, not just an educational oddity. There are a bunch of Lisps out there, and plenty of them are by no means toys. My laptop's initial RAM disk and init system are Scheme programs.
- krapp 9y agoAnd it's not a Lisp per se, but WebAssembly's text format uses s-expressions[0]. It's likely that the "oddity" of Lisps will seem less odd as adoption increases if they stick with that. [0]https://developer.mozilla.org/en-US/docs/WebAssembly/Understanding_the_text_format https://developer.mozilla.org/en-US/docs/WebAssembly/Underst...
- tomjakubowski 9y agogcc’s IR, “GIMPLE”, is also commonly printed in s-expression form.
- Mikeb85 9y agoAs is LLVM's. I think JVM's might be too, but not 100% sure. Haskell is also pretty much just a lisp with a whole lot of sugar added on.
- eropple 9y agoHow is Haskell a Lisp? To me, a Lisp pretty necessarily needs to treat the structure of its code as mutable data, which seems kind of incompatible?
- dllthomas 9y ago> How is Haskell a Lisp? ... both communities care a lot about rose trees?
- dllthomas 9y agoIf you squint right, both monads and lisp S-expressions are rose trees.
- mattgreenrocks 9y agoThe evaluation model of both is quite similar though (reduction), and you can see it in the similarities between Core Haskell and Core Scheme. AFAIK, there are very few truly built in types in Haskell. Most everything can be built out of data constructors and functions. That idea of many things being in language user space is pretty Lisp-y IMO.
- lispm 9y agoThe evaluation model is different. Lisp is using strict evaluation and Haskell is using lazy evaluation. Haskell is statically typed, Lisp is not. Lisp uses s-expressions for writing programs, Haskell does not. Generally Haskell and Lisp are very different languages: in syntax, semantics and pragmatics (how the language is used).
- kazinator 9y agoNo, it actually doesn't; that is a common misconception. Lisp images can modify themselves at run-time by replacing global function bindings with new functions, not by mutating code. Lisp macros must not in fact mutate the incoming source code which they transform.
- dang 9y agoI had no idea they did that! Thanks! I was just thinking this morning about making Arc work in web assembly sometime.
- criddell 9y agoI just listened to an interview with Philippe Kahn and he mentioned that the language he uses today is Scheme.
- muxator 9y agowhat are you using? I want to try it.
- pmoriarty 9y agoNot to mention that one can get static typing in Lisps, if one wanted. See Typed Racket, for instance: https://download.racket-lang.org/docs/5.0/pdf/ts-guide.pdf https://download.racket-lang.org/docs/5.0/pdf/ts-guide.pdf
- threatofrain 9y agoWhat about typed Racket? https://docs.racket-lang.org/ts-guide/beginning.html https://docs.racket-lang.org/ts-guide/beginning.html
- ohazi 9y agoYeah, this was the "notable exception" I had in mind.
- metawhatnow 9y agoML has metaprogramming? The only thing I know approaching that is template haskell, which is a weak form of metaprogramming (still powerful obviously). Meanwhile, lisp is metaprogramming. No, it's not useful in many (or even most) applications, but when it is useful, you can bet there's some type of analogous pattern for a lisp-type language. Certainly still useful to learn along side ML. :) Hell, the best quote to illustrate this is the article itself: > A fun thing about it this is that once you’ve grokked it, you can think right away of better programming languages than Lisp, and you can think right away of better ways to write the meta descriptions than John did. This is the “POV = 80 IQ points” part. In this sense, everyone should learn lisp, even if it's not the tool you intend to use.
- conistonwater 9y ago> ML has metaprogramming? The only thing I know approaching that is template haskell, which is a weak form of metaprogramming (still powerful obviously). Of course, it has had it for a very long time (a decade at least?), see camlp4/camlp5.
- pmoriarty 9y agoHow often is camlp4/5 used among the typical OCaml programmer compared to how often macros are used among typical Lisp programmers? How easy is camlp4/5 metaprogramming to read and write compared to Lisp macros? This reminds me of Alan Perlis' admonition to "beware of the Turing tar-pit in which everything is possible but nothing of interest is easy."[1] and of a question John McCarthy asked Peter Norvig after the latter's talk about how Python was a Lisp: "When he finished Peter took questions and to my surprise called first on the rumpled old guy who had wandered in just before the talk began and eased himself into a chair just across the aisle from me and a few rows up. This guy had wild white hair and a scraggly white beard and looked hopelessly lost as if he had gotten separated from the tour group and wandered in mostly to rest his feet and just a little to see what we were all up to. My first thought was that he would be terribly disappointed by our bizarre topic and my second thought was that he would be about the right age, Stanford is just down the road, I think he is still at Stanford -- could it be? "Yes, John?" Peter said. I won't pretend to remember Lisp inventor John McCarthy's exact words which is odd because there were only about ten but he simply asked if Python could gracefully manipulate Python code as data. "No, John, it can't," said Peter and nothing more, graciously assenting to the professor's critique, and McCarthy said no more though Peter waited a moment to see if he would and in the silence a thousand words were said."[2] [1] - https://en.wikipedia.org/wiki/Turing_tarpit https://en.wikipedia.org/wiki/Turing_tarpit [2] - http://smuglispweeny.blogspot.com/2008/02/ooh-ooh-my-turn-why-lisp.html http://smuglispweeny.blogspot.com/2008/02/ooh-ooh-my-turn-wh...
- kobeya 9y agoI've long desired a strongly-typed s-expression syntax that has the power of Haskell or Idris, but still looks and feels like the blank canvas that is Lisp.
- pmoriarty 9y ago"Having tried both, I've found that the ML-derived languages tend to have a stronger type system that's more rigorously enforced at compile time. I personally find this much more valuable in practice than some of the dynamic magic that you can do with lisp." You probably meant to contrast ML's static typing (not strong typing) with Lisps's dynamic typing. See "What To Know Before Debating Type Systems": https://cdsmith.wordpress.com/2011/01/09/an-old-article-i-wrote/ https://cdsmith.wordpress.com/2011/01/09/an-old-article-i-wr...
- ohazi 9y agoSure, I meant static types + Hindley-Milner type inference, leading to a "type system that I like and feel comfortable with" (per your link), i.e. a stronger type system.
- julian_1 9y agoFor another (type-theory) perspective - a 'dynamic language' can be automatically considered weakly typed if it can return an runtime exception due a failure to perform a runtime type coercion, or because the typesystem is not expressive enough to include a proof of totality. That makes the whole dynamic/static versus strong/weak distinction kind of meaningless. > The functional and imperative languages are weakly typed, i.e. the result of computing the value of an expression e of type T is one of the following: [...] http://wiki.portal.chalmers.se/agda/pmwiki.php?n=ReferenceManual.IntroWhat http://wiki.portal.chalmers.se/agda/pmwiki.php?n=ReferenceMa... As a matter ordinary meaning, I also feel it makes sense to talk about more strongly typed languages, because they can express 'stronger' guarantees about behavior. Eg. a proof that the code cannot deadlock.
- shalabhc 9y ago> more rigorously enforced at compile time 'Compile time', like everything in the artificial science of computing, is a made up thing. We might reconsider if it's a useful idea to keep. Why must there be a specific point in time, when we verify interconnections within a little bundle of code, but later when the bundle of code integrates with a larger system we are completely fine with very different, loosely coupled connections? The internet is dynamically typed. I just don't see static verification scaling to that level. But verification is still great - so maybe we need a way to verify connections between components as and when they bind. If we build a good model for this late bound 'negotiated safe' binding, the static model might become unnecessary (because you can do the verification whenever you choose, or at multiple times and different scales, as the 'bundle of code' integrates with larger and larger systems.)
- Silfen 9y ago"Compile time" is artificial, but the difference between static and dynamic is natural (in some sense, I realize these words are quite slippery). It emerges from the underlying mathematics. There's a real difference between correctness properties that I can prove without running my program and correctness properties that will introduce failures at runtime.
- shalabhc 9y ago> It emerges from the underlying mathematics. Which mathematics? (Lisp has its own math, for instance.)
- mjburgess 9y agoWhat on earth are you talking about? > The internet is dynamically typed. That's an incoherent claim. Dynamic typing is where types belong to values. Static typing is where they apply to terms. Really to call the former "typing" is misnomer. It's an abuse of the word "type" to mean "memory mode". It has not much relationship to typing in the logic/math/philosophy of logic sense in which types are sets and type relationships are those between sets. It is the Curry-Howard isomorphism (https://en.wikipedia.org/wiki/Curry%E2%80%93Howard_correspondence https://en.wikipedia.org/wiki/Curry%E2%80%93Howard_correspon...) which defines the correspondance between types in computer science and mathematics. This is "static" only because the "dynamic" alternative isnt really an alternative at all, and really just a different kind of thing all together.