Lapsang: does the world need yet another programming language?

! Warning: this post hasn't been updated in over three years and so may contain out of date information.

Lapsang logoIn every programmer, there is (or at least there ought to be) a budding language designer just waiting to get out. However, before you or I rush off and knock up yet another programming language, let’s take a quick trip to the world of the novel. Remember the phrase “everyone has a novel inside them”? It’s a often repeated phrase, yet to slightly misquote Russell Lynes, the true phrase probably ought to be “everyone has a novel inside them, and [in most cases] that’s the best place for it.” So maybe it’s a good thing that most programmers never express their inner language designer. Despite this, being a master of turning my back on good advice, I present to the world, Lapsang…

Well actually I don’t really present it, as it doesn’t exist. Lapsang is a name I came up with as a bit of a joke for a replacement language to Java nearly four years ago. Since then I have used it as an imaginary target language for various software engineering and craftsmanship thought experiments. During those four years (plus a few extra, but let’s not let mere details interfere with the story), I’ve watched my safe, simple world of waterfall-driven OO designs of heavily inherited classes, thousands of lines long, slowly crumble to dust. These days, we have whole new ways of doing software development: small, single-responsibility classes; design patterns; test-driven-development; design to interfaces; composition over inheritance; avoidance of mutability; functional programming and the like. The development world really has changed beyond all recognition, no?

Well actually, no, it hasn’t. What has really happened is that these ideas have been bolted on to often decades old languages. Functional programming for example, with its support of parallelism through the use of immutability and functions without side effects, is often touted as the next big thing. Yet the youngest of the true functional languages – Haskell – was conceived 25 years ago. Many programmers utilise some form of test-orientated development when writing their code, yet how many languages can you think of that directly support TDD? I counted a big fat zero, but I may have missed one. In every case I thought of, testing is achieved by bolting a framework on to the language as an after thought. The same goes for many more modern development ideas. We have sometimes exhumed long dead languages (eg Clojure, which is a form of Lisp, a language created in the 50s). Complex design patterns have been created for reluctant languages such as Java. In the case of C#, fashionable ideas have been added, such as lambdas, whilst leaving the collections they work on still highly mutable. Let’s not also forget that, despite these advances, the most popular language these days is JavaScript, a language that lacks so many of the ideas that constitute good program design, that many regard it is as little more than a toy.

So this has set me thinking: if I were to design a brand new language that truly embraced ideas like TDD, dependency injection, design to interfaces etc, what would it look like? The first problem I ran into is syntax. The moment I started writing example code that modelled these ideas, I had to express that code with a consistent syntax. Yet a syntax can make or kill a language instantly in the minds of many. So I tried to express them as a form of pseudocode, but that didn’t really work either. So in the end I threw out the consistent syntax idea and decided I would express each idea with a different syntax. No doubt some will see this as a mistake too, but I can’t hope to keep everyone happy all of the time, so I won’t lose any sleep over it if you don’t like the idea.

So back to Lapsang: what sort of language is it? Well it has the following features:

  1. For a unit of Lapsang code to compile, it must be tested. This is probably the most controversial feature, so I mention it first. If you don’t believe in the need to write unit tests, I’d suggest you stop reading now, as this language’s ideals are not for you. What this means in practice is that unit tests have to be a fundamental feature of the language, rather than a framework library that the code compiles against. The compiler runs the tests and profiles the code. Failed tests, or code not covered by those tests, are then both compiler errors.
  2. Lapsang mandates design to interfaces. To give an example of how thoroughly it mandates this pattern, code (outside of tests) cannot create an instance of another class, it must create an instance of an interface. Dependency injection is used to provide the desired class, that implements that interface, to that code at compile time/runtime.
  3. Lapsang supports classes, but doesn’t allow inheritance. I can’t decide yet whether it should allow inheritance within interfaces, but class inheritance is definitely out. Instead, composition is king. Any object (which includes interface references, functions and primitives) can have components added to it, even at runtime. Again, this pattern is baked into the language: Inversion of control/entity frameworks are not required to set up composed objects, at least at a basic level.
  4. Lapsang supports structured typing. This means that classes (and primitives and functions) do not need to pre-declare that they implement interfaces. Instead they implicitly implement an interface if they satisfy that interface’s contract.
  5. Lapsang encourages the use of immutable data types and functions/methods without side effects. Mutability is allowed, in recognition of the fact that its an essential feature at times, but such code has to be explicitly annotated as unsafe.

So that’s the plan. All I need do now is explain how such features might be achieved without making the language impenetrable to beginners. Watch this space…

4 thoughts on “Lapsang: does the world need yet another programming language?

  1. well, it’s a novel idea, personally I think you should go for it simply for the nice leaf logo.

    You’ll have to explain how the whole IoC works without turning programming the simplest of things into a nightmare.

    One more thing, just as 10 years experience doesn’t necessarily mean good experience, 100% test coverage doesn’t necessarily mean worthwhile coverage, all I’ll say on the matter 😉

    Sounds like it could be interesting, look forward to reading more blogs!

  2. Like you say so much has changed and I think it’s probably wise to assume it will probably continue to do so and so any language built for today’s ideas may be obsolete in a few years. Maybe this Lapsang utopia (of which I agree with every principal) should be an IDE rather than a language one that well enforce these things on whatever (perhaps with in reason) language you choose.

    A friend told me that IT pragmatists are more likely to win than utopianists and while your language sounds like a utopia I feel an IDE could be a pragmatists solution.

  3. You lost me at the first sentence, which is clearly complete nonsense.

    Oh, and the answer to the question in the title: no.

  4. “In every programmer, there is (or at least there ought to be) a budding language designer just waiting to get out”

    — I wonder what’s in every Boss 🙂

Comments are closed.