views:

138

answers:

7

I'm currently working on the topic of programming-languages and interpreter-design. I have already created several programming languages but couldn't reach my goal so far:

Create a programming-language which focuses on giving the programmer a good feeling when writing code in it. It should just be fun and/or interesting and in no case annoying to write something in it.

I get this feeling when writing code in Python. I sometimes get the opposite with PHP and in rare cases when having to reinvent some wheel in C++.

So I've tried to figure out some syntactical features to make programming in my new language fun, but I just can't find any.

  • Which concrete features, maybe mainly in terms of syntax, do/could make programming in a language fun?

Examples:

I find it enjoyable to program in Ruby because of it's use of code blocks.

  • It would be nice if you could include exactly one example in your answer
  • Those features do not have to already exist in any language!

I'm doing this because I have experienced extreme rises in (my own) productivity when programming in languages I love (because of particular features).

+2  A: 

Consistency.

Its the feeling that you already know something when you use an API or feature you've never used before. It also makes you more productive as you don't have to learn something new for the sake of it.

I think this is also one of the Ruby 'likes', in that if you follow the naming convention, things start to 'just work' without bindings and glue and suchlike.

For example, using the STL in C++, many of the algorithms are the same for all containers - even strings. That makes it nice to use... except for those parts that do not follow the same API (eg vector of bools) then the difference is more noticable.

gbjbaanb
I think VB 6 had that covered :-P
Jeremy Petzold
+1  A: 

A programming language should make it easy to write correct programs and difficult (if not impossible) to write incorrect programs. For instance, in Java

long x = 2000000000 + 2000000000;

overflows, while

long x = 2000000000L + 2000000000;

doesn't. Is this obvious? I don't think so. Does anyone ever want something to overflow? I don't think so.

Joonas Pulakka
Hell, yeah! A programming language should have *exactly one* number type: `number`. `int`, `long`, `real`, `double`, `bigint`, `bigdecimal`, `fixnum` are *optimizations* and optimizations belong in the *optimizer*, not the programming language. As Gilad Bracha recently pointed out in his *Deconstructing Java* talk: "Java has 9 integer types: `byte`, `short`, `int`, `long`, `Byte`, `Short`, `Integer`, `Long` and `BigDecimal`. Not one of them behaves like an integer." (http://bracha.org/decon-java.pdf)
Jörg W Mittag
that is what Ada was created for.
Jeremy Petzold
exactly 1 number type.. you want BCPL! (the precursor to C)
gbjbaanb
+2  A: 

Two things to keep in mind are orthogonality and the principle of least surprise.

lhf
A: 

Hilarity.

http://lolcode.com/

webdestroya
-1 Not useful in a practical language.
George Edison
Ah, but it said "which is enjoyable and fun" :)
webdestroya
lolcode is not fun. Have you tried to write a graphical multi-threaded interface with it?
George Edison
I have not. It was also a joke. I don't think anybody would actually write a legitimate program in LOLcode.
webdestroya
@George Edison: True. But have you tried to write a graphical multi-threaded interface in any language? I have yet to find a language that that's a "fun" task in.
kyoryu
@kyo: It is actually pretty easy to do in Qt. I enjoyed it.
George Edison
@George Edison: Okay, granted, multitasking is much easier if you're using some kind of messaging metaphor. I'll give you that. So let's try, "without massive library support," - I still think C/C++ would fail :) (Maybe someone should write a messaging library for LOLCODE. It could be called OHAI).
kyoryu
+1 because lolcode IS fun and enjoyable, all boring objectivity put aside.
jcayzac
A: 
  • Follow common practices (like using + for addition, & for bitwise/logical and)
  • Group logicaly-similar code in namespaces
  • Have an extensive string processing library
  • Incorporate debugging facilities
  • For a cross-platform language, try to minimize platform differences as much as possible
George Edison
+3  A: 

You mentioned Ruby in your question. AFAIK, Ruby is the only programming language, for which Joy is an actual, stated, explicit design goal. (In fact, it is the only design goal.)

The reason that Yukihiro Matsumoto was able to design Ruby this way, is that he already knew and used tons of programming languages before he started designing Ruby and learned tons more in order to design Ruby. (Interestingly, he didn't know Python, and has said that he probably wouldn't have created Ruby if he did.)

Here's just a tiny fraction of the languages that matz has either used himself, or looked at for inspiration (or in some cases for inspiration what not to do):

  • CLU
  • Sather
  • Lisp
  • Scheme
  • Smalltalk
  • Perl
  • Python
  • Haskell
  • Scala
  • PHP
  • C
  • C++
  • Java
  • C#
  • Objective-C
  • Erlang

And I believe that this is one way that good programming languages can be designed (what Larry Wall calls postmodernist language design): Throw away everything that didn't work in the past, take everything that worked and combine that tastefully.

Of course, this requires that you actually know all those languages from which you want to "steal" and in particular, it requires that you know lots of very different languages with different paradigms, different concepts and different "feels", otherwise the idea pool from which you steal is rather small and inbred.

Jörg W Mittag
A: 

A language feature that appears simple and easy to learn surprises and delights the programmer with its unexpected power. I nominate Haskell type classes :-)

Norman Ramsey