Hacker News new | past | comments | ask | show | jobs | submit login

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"

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.




> 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


No 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).


> No syntax has intrinsic semantics. I don't think 'intrinsic semantics' is a meaningful combination of words.

I was just refuting the assertion that "S-expressions are about as semantically sane as you can get".

> Explicitly, in lisp, everything is a stack of instructions arranged in a tree.

I do not particularly care what data structure is internally used. That is the compiler's business, not mine. I want to reason about my code in terms of the semantics of the language I am using.

> By naming convention and documentation, we give the various functions semantics. ("With" macros being an example).

Names may be misleading, documentation may be incomplete, but types never fail to accurately guarantee properties about my code. Hence my preference for types.

http://tmorris.net/posts/2013-07-18-identifier-names.html


> I was just refuting the assertion that "S-expressions are about as semantically sane as you can get".

His comment was equally nonsensical. S-expressions are consistent and easy to parse, that is all.

> I do not particularly care what data structure is internally used. That is the compiler's business, not mine. I want to reason about my code in terms of the semantics of the language I am using.

>I do not particularly care what data structure is internally used. That is the compiler's business, not mine. I want to reason about my code in terms of the semantics of the language I am using.

Good, that data structure generally isn't used internally in the compiler (not efficient enough). I'm talking about the data structure that is used for the programmer's brain. The semantics and way of reasoning about the code is in terms of a very simple data-structure.

My business is the compiler's business.

> Names may be misleading, documentation may be incomplete, but types never fail to accurately guarantee properties about my code. Hence my preference for types.

Why would you write such shitty code? There are many ways of skinning that cat. You can use types, you can use tests, you can use assertions.

You could make it overly complicated and long. A stupid person is going to have a bad time writing code, no matter what language you hand them. Shitty code is shitty. This is a tautology comparing the language I'm currently into to a language I'm not currently into. Don't use it. You're good at writing Haskell, good for you.


I'm curious then what you mean by semantics, like the words used for library function names? I've always equated semantics and syntax, perhaps to my detriment.


Syntax is the presentation layer for semantics. Semantics are the content, meaning, and/or implications for what you convey via syntax. They're largely orthogonal.

  def add(x, y):
    return x + y

  (define (add x y)
    (+ x y))
These are similar semantically -- they each define a procedure that takes two parameters, adds them, and returns that result. Hand-waving how the language is actually implemented, they're morally equivalent, anyway. But syntactically they're fairly different.

Another example: https://en.wikipedia.org/wiki/Colorless_green_ideas_sleep_fu.... That sentence is semantically meaningless, but it has the correct syntax.

edit: fixed code formatting.


Is 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.


> 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. :-)


That'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://learnyousomeerlang.com


I 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.


Combine them both and you have a fantastic resource. They complement each other very well.


What makes it saner than clojure? The type safety?




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: