views:

224

answers:

4

Javascript: The Good Parts is a great book. Often I find myself reading passages like the following from the perspective of a language designer:

undefined and NaN are not constants. They are global variables, and you can change their values. This should not be possible, and yet it is. Don't do it.

Takeaways:

  1. Don't change the value of undefined in my Javascript code.
  2. When designing a language, make its equivalent of undefined immutable.

A different more subtle example would be "for in shouldn't enumerate over prototype properties".

I want a book at talks about these issues of language design outside of the context of a particular language.

If you were trying to design the "perfect" OO language, what books would you read for guidance?

+4  A: 

You could take a page from the same place as Java, Ruby, Objective C, and others and check out Design Priciples Behind Smalltalk. Much of this is foundational material on communication between objects, rather than anything about Smalltalk specifically.

As far as really thoughtful books on langauge design, I think The Design and Evolution of C++ definitely deserves a mention. I hesitate since you say that you want the "perfect" OO language, and C++ is far from perfect. You could probably still learn a lot from it, though.

The points you bring up, though, seem like they have more to do with the Principle of Least Astonishment or the Rule of Least Surprise than with the design of language internals.

tgamblin
+3  A: 

The Design and Evolution of C++ is good.

Object-Oriented Software Construction is too.

They are rather language-specific (C++, Eiffel), but there are lots of language-agnostic lessons.

Brian
+5  A: 

The web site 'lambda the ultimate' is very much about programming languages, and they occasionally have some good resources, although they tend to be more interested in academic kinds of things. Functional programming is big there, for instance.

http://lambda-the-ultimate.org/node/3

http://lambda-the-ultimate.org/papers

http://lambda-the-ultimate.org/node/492

David N. Welton
+1  A: 

You could check out the design documents of  Perl6

Perl6 Synopsis

If you read Synopsis 6, you will find out that the addition operator is named:

  • infix:<+>
  • infix:«+»
  • infix:<<+>>
  • infix:{'+'}
  • infix:{"+"}

Which means you can create your own operators:

sub postfix:<!> ($n) { [*] 1..$n }
Brad Gilbert