A programming language for training discipline?


This evening, I had a fun interaction with Samir Talwar on twitter about comment syntax:

Samir: Help me out with some science, people. Which is the best comment syntax?

Alex: No syntax available for comments? 😀

Samir: You and @rachelcdavies should get together and write your own language that just yells “WRITE A TEST” whenever anyone tries to comment some code.

Alex: :)) Actually, when you write explanation text, I would uncomment it automatically after 5 seconds. When you comment code, it should be automatically deleted in 5 seconds.

This made me think: could we build a programming language whose sole purpose would be to train discipline?

Here are some features I would built into it:

  1. Any line of code that is not covered by a test is automatically deleted in 5 seconds
  2. All tests run automatically after each change
  3. Comments are temporary. If you comment code, it is deleted in 5 seconds. If you comment text, it is uncommented in 5 seconds. See 1 and 2 for what happens next.
  4. Functions are limited to 6 lines of code
  5. Objects have to be defined as one of: data object (only data members, automatically public), entity (same but with an automatic id) or service (immutable data, all functions return values)
  6. An object has maximum 6 methods
  7. There’s no inheritance. Or, perhaps there’s only interface inheritance, and only one level of inheritance accepted

A few ideas that sound more difficult to implement, or with unclear advantages:

  1. When a test fails, you can only change the lines of code that you changed since the last test passed, or add new lines of code
  2. After a test passes, automatically commit with the message “Implemented feature <test name>”
  3. When all tests pass, you can modify any line of code
  4. All names have to be part of a glossary composed of 80% domain terms and 20% technical terms. I’m unsure whether to allow prepositions or not.
  5. When you’re done, a narration is built from your code by using the names and function calls, and sent automatically to your colleagues for review

I could probably come up with more ideas, but it’s late and it’s time to stop.

What would you add?

Add comment

alexbolboaca.ro Reflections on design, craft and software

A new home for merging ideas about design

It is my strong belief that software design can learn a lot from other design disciplines. I wrote blog posts, a book and did talks on this topic, and it was time to group them all together. These ideas have now a new home: https://codedesigner.eu. My plan is to add more blog posts there, and to involve other people doing work in this area.