开发者

Guidelines for creating a programming-language enjoyable to write programs in? [closed]

开发者 https://www.devze.com 2022-12-29 13:03 出处:网络
Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing
Closed. This question is opinion-based. It is not currently accepting answers.

Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.

Closed 8 years ago.

Improve this question

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 (bec开发者_Python百科ause of particular features).


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.


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.


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


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.


Hilarity.

http://lolcode.com/


  • 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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消