Recommendations for making a programming language pleasant to write programs?

I am currently working on the topic of programming languages ​​and interpreter. I have already created several programming languages, but so far I have not been able to achieve my goal:

Create a programming language that focuses on giving the programmer a good feel when writing code in it. It should be just interesting and / or interesting and by no means annoying to write something in it.

I get this feeling when writing code in Python. I sometimes get the opposite with PHP and on the rare occasion that multiple wheels need to be reinvented in C ++.

So, I've tried to figure out some syntax features to make programming in my new language interesting, but I just can't seem to find it.

  • What specific features, perhaps mostly in terms of syntax, do / can make programming in the language fun?

Examples:

I enjoy programming in Ruby because of the use of code blocks.

  • It would be nice if you could only include one example in your answer.
  • These functions don't have to already exist in any language!

I do this because I have experienced extreme gains in my own productivity when programming in languages ​​that I like (due to special features).

+2


a source to share


7 replies


You mentioned Ruby in your question. AFAIK, Ruby is the only programming language for which Joy is a real, stated, explicit design goal. (Actually, this is the only design goal.)

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

Here are just a tiny fraction of the languages ​​Matz 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
  • FROM
  • C ++
  • Java
  • FROM#
  • Objective-C
  • Erlang

And I think this is one way to design good programming languages ​​(what Larry Wall calls postmodern language design): throw away everything that hasn't worked in the past, take everything that has worked, and combine it with taste.

Of course, this requires that you really know all those languages ​​that you want to "steal" from, and in particular, it requires that you know many different languages ​​with different paradigms, different concepts and different "feelings", otherwise a pool of ideas. from which you steal, rather small and inbred.

+4


a source


Consistency.

It feels like you already know something when you use an API or function that you have never used before. It also makes you more productive as you don't have to learn new things for it.



I think this is also one of those Ruby lovers, because if you follow the naming convention, everything starts to "just work" without bindings and glue, etc.

For example, using STL in C ++, many of the algorithms are the same for all containers - even strings. This allows you to use ... except for those parts that do not correspond to the same API (like vector bools), then the difference is more noticeable.

+2


a source


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

+2


a source


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

long x = 2000000000 + 2000000000;

      

overflows and

long x = 2000000000L + 2000000000;

      

no. It is obvious? I do not think so. Does anyone ever want to overflow something? I do not think so.

+1


a source


+1


a source


  • Follow common practices (e.g. using + for append and for bitwise / logical and)
  • Group logical code in namespaces
  • Has an extensive string handling library
  • Enable Debugging Tools
  • For a cross-platform language, try to minimize differences in platform capabilities as little as possible.
0


a source


A language function that seems simple and easy to learn surprises and delights the programmer with its unexpected power. I am assigning classes like Haskell :-)

0


a source







All Articles