4 ms·
> You have not reached Lisp enlightenment yet. I want a semantically sane language. What do I care what code Lisp macros can autogenerate if nobody can make su
by catnaroek 13y ago
> You have not reached Lisp enlightenment yet.
I want a semantically sane language. What do I care what code Lisp macros can autogenerate if nobody can make sure it makes any damn sense?
- JackMorgan 13y agoSo, a language where, say, blocks are started sometimes with parameters that are delimited with pipes, and sometimes the bodies need a terminating end keyword, other times they need wrapping curly brackets. If you want an explicit lambda, you have to wrap that whole block in curly brackets with a lambda keyword. Classes and functions need an end delimiter but not an explicit start delimiter; if statements however need both a start and end delimiter in "if x then y else z end" Ruby is not semantically sane, it's insane in a way we have all gotten used to. (If you don't know ruby, try to rewrite this for your ALGO language of choice, I picked ruby for its simplicity) S-expressions are about as semantically sane as you can get, it's just most of us have a <5 year head start with the craziness of c-style languages.
- catnaroek 13y ago> So, a language where, say, blocks are started sometimes with parameters that are delimited with pipes, and sometimes the bodies need a terminating end keyword, other times they need wrapping curly brackets. If you want an explicit lambda, you have to wrap that whole block in curly brackets with a lambda keyword. Classes and functions need an end delimiter but not an explicit start delimiter; if statements however need both a start and end delimiter in "if x then y else z end" You are talking about syntax here. > Ruby is not semantically sane, it's insane in a way we have all gotten used to. I hate Ruby even more. It is just as semantically insane as Lisp, and the syntax is worse. > (If you don't know ruby, try to rewrite this for your ALGO language of choice, I picked ruby for its simplicity) Ruby is not simple. It is full of corner cases and redundant constructs. It is hard to make any sort of reasonable guarantee about a Ruby program without resorting to some heavy testing. And no matter what nice property you might have wrestled out of the system, someone else can destroy it anyway by means of monkey patching. > S-expressions are about as semantically sane as you can get S-expressions are syntax with no intrinsic semantics. > it's just most of us have a <5 year head start with the craziness of c-style languages. What about Haskell? (And, in general, languages that have a denotational semantics that makes equational reasoning feasible.) For more details, see: https://news.ycombinator.com/item?id=6954348 https://news.ycombinator.com/item?id=6954348
- JackMorgan 13y agoIs Haskell the semantically sane language you prefer? Fascinating. The best Haskell book I can find is next for me as soon as I finish SICP, any suggestions? I'd love it if the book had homework like SICP.
- catnaroek 13y ago> Is Haskell the semantically sane language you prefer? One of them. > The best Haskell book I can find is next for me as soon as I finish SICP, any suggestions? I liked Learn You a Haskell for Great Good, but that is maybe just because I am a childish person. :-)
- chilldream 13y agoI started Learn You a Haskell a couple days ago on a lark and I'm also loving it. I've also heard a lot of praise for Real World Haskell which I plan to look at next.
- charlieflowers 13y agoCombine them both and you have a fantastic resource. They complement each other very well.
- millerm 13y agoThat's a great book! It also inspired "Learn You Some Erlang for Great Good" too. Both are available online for free! http://learnyouahaskell.com http://learnyouahaskell.com http://learnyousomeerlang.com http://learnyousomeerlang.com
- JackMorgan 13y agoWhat makes it saner than clojure? The type safety?
- ohyes 13y agoNo syntax has intrinsic semantics. I don't think 'intrinsic semantics' is a meaningful combination of words. Explicitly, in lisp, everything is a stack of instructions arranged in a tree. The instructions are either functions that manipulate the input data, or functions that manipulate the underlying tree of instructions. By naming convention and documentation, we give the various functions semantics. ("With" macros being an example).
- kroger 13y agoYou can always macroexpand a macro to know precisely how it's defined and it's going to be executed [1]. If you use emacs+slime it's as easy as putting your cursor before an expression and tying a keybinding [2]. But in the reality using macros is no more complicated than using functions. [1] http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/fun_macroexpa_acroexpand-1.html http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec... [2] http://www.common-lisp.net/project/slime/doc/html/Macro_002dexpansion.html http://www.common-lisp.net/project/slime/doc/html/Macro_002d...
- catnaroek 13y ago> But in the reality using macros is no more complicated than using functions. Do I have any guarantee that the resulting macro-expanded code semantically makes sense? (e.g., a guarantee that it will typecheck)
- kroger 13y agoLisp macros receive as input valid s-expressions, that don't need necessarily to be valid common lisp code, such as (my-macro (2 + 2)) and output valid lisp code during macro expansion time. The macro my-macro could expand the code to something like: (+ 2 2) Some Lisp compilers such as CMUCL will issue a warning if you try to use wrong type (it has type inference), such as in this simple example: (defmacro foo () `(+ 1 "foo")) (defun bar () (foo)) You can see the compiler notes here: http://imgur.com/3vlQm6G http://imgur.com/3vlQm6G
- sixthloginorso 13y agoWhat's semantically insane about Lisp? I find it has very clean semantics; it is strongly typed, its scope is perfectly lexical (sans a explicit caveat), programs are commonly written in a way that preserves referential transparency (in the FP sense, anyway), with pockets of imperative mutation here and there. The limited dynamic scope may be somewhat unpleasant though, but that's its flexibility. As for macros, they are merely functions that transform expressions. They can be somewhat unpleasant to read, but they are basically that.
- catnaroek 13y ago> What's semantically insane about Lisp? Unityping. Now every useful function is automatically not total! > I find it has very clean semantics; it is strongly typed Of course it is strongly typed! All expressions have type Univ. > programs are commonly written in a way that preserves referential transparency All my C++ programs are commonly written in a way that preserves referential transparency, and clearly distinguishes between objects that are meant to be mutated (non-const) from those that are not meant to (const). That still does not make C++ a pleasant language to program in. > The limited dynamic scope may be somewhat unpleasant though, but that's its flexibility. Spooky action at a distance. Me no like. :-( > As for macros, they are merely functions that transform expressions. They can be somewhat unpleasant to read, but they are basically that. Will the result typecheck?
- sixthloginorso 13y agoMeh. The only total languages are used for formal verification, you'll always have to settle for less to get Turing-completeness. > Of course it is strongly typed! All expressions have type Univ. Have you used PHP? You'll come to appreciate the differences between the different "unityped" languages. > All my C++ programs are commonly written in a way that preserves referential transparency, and clearly distinguishes between objects that are meant to be mutated (non-const) from those that are not meant to (const). That still does not make C++ a pleasant language to program in. Does that say anything about Lisp? Nope, not at all. It isn't like C++ is comparable to Lisp, despite the efforts put by C++ programmers to wrest safety from a language designed as a superset of the language of cowboy-coders par excellence, its true nature as an imperative language with raw pointers may rear its head at any point. Not to say that Lisp has had more facilities up to this point than C++ to write referentially transparent programs. > Spooky action at a distance. Me no like. :-( Depends on the Lisp. Common Lisp's global variables are mutable and dynamic. Me no like either. In Racket and Clojure you can declare variables to be explicitly dynamic, and they can be rebound within special blocks, locally, sort of. Not that it's something anyone should use frequently. > Will the result typecheck? Does the if keyword typecheck?