Tricarbon: a Programming Language Proposal
A programming language is a tool. A programmer uses it to express a solution to a problem and in a perfect world each problem (or solution) domain has a fitting programming language that allows the programmer to state the solution in an efficient way. For a programmer, efficiency is very important; it will allow him to focus on the problem and its solution. Less efficient languages force the programmer to spend time on trivial matters or on problems that are introduced by the programming language itself.
Modern languages such as C# and Java are constantly evolving. In its 10 years and four (nearly five) versions, C# is a perfect example of a language that has been extended by its designers to accommodate the programmers that use it and make their work easier by providing new language constructs that remove the need for programmers to repeat themselves or spending too much time on language and platform problems.
When designing a new language (as with any system) we need to take a look at the programmers who will use it. Thinking about this set me on track of a new language.
Although we frown upon it and would never admit to do it ourselves, a very common practice among programmers is Googling, Binging or StackOverflowing for code. There are many arguments against this and I am sure you can think of many more than can I list here. In the courses I teach I try to teach the students to think for themselves but it can’t be denied that programmers gravitate to cloud-copied-code more and more. In their defense: Why spend hours on figuring out the problem and its solution while all the time the solution is right there, just a few clicks away?
The main issues I see with cloud-copied-code are:
- Unknown quality – A lot of code in the cloud is without unit tests, reviews or maintenance.
- Unknown ownership – A lot of code from the cloud is copied without understanding it. Once copied, the code is on its own.
- Unknown context – The code that is copied is copied out of its context into a different context. If the two contexts are not compatible, the code will not solve the problem and might introduce new problems.
Instead of trying to keep programmers from copying cloud code we might help them to cope with these issues by providing a new language. And as with any language I’ll first show you an HelloWorld program:
#Fragment From=http://helloworldsite.he.funpic.de/hello.htm#C#
This is a very basic construction but shows the general idea: the code does not leave the cloud, instead we refer to it. This solves the ownership issue. The owners of the site (or even contributors to the site) are still able to update the code and as soon as the programmer recompiles he uses a potentially updated version. Of course extra attributes can be added to the Fragment element to pinpoint specific lines in the page and to make that even better websites could adopt special markers in code that can be referred to in the Fragment element.
To solve the quality issues, we could refer to unit tests in a similar way:
#Fragment From=http://helloworldsite.he.funpic.de/hello.htm#C#
#UnitTest From=http://stackoverflow.com/questions/793850/hello-world-the-tdd-way/793904#793904
#EndFragment
Again websites could adopt special markers that point to unit tests.
The context issue can be solved by having sites with code annotate the code with comments that explain the context of the code. The programmer links to the context description and automatically sees the description in his code. As soon as the code is updated, contributors modify the description and all the programmer has to do is check whether or not the description still fits the purpose of the program.
As you can see I have placed the Fragment elements in C# pre-compiler directives. This allows the programmer to write code that glues the fragments (this glue could be shared on the web too).
The name of this language: C3 (cloud-copied-code) pronounced: Tricarbon
EDIT (in response to the questions Koos addressed in his comment)
Functional breaks in code updates will cause unit tests to fail. Perhaps not the unit test for that part but other tests will fail. This will notify the programmer of breaking changes.
Trusted providers could be registered and code snippets could be signed but I’d prefer to add system that shows the appreciation of the other programmers that use the snippet (comparable to voting for answers on Stack Overflow) which might give a better indication of quality.
All in all it isn’t that different from writing (or rather copying) all code locally.