Commit 3a8b08cc authored by Nicolas Lenz's avatar Nicolas Lenz
Browse files

Add article: Language Design: Machine or Human?

parent 05cdb7b8
Pipeline #847 passed with stage
in 10 seconds
title: "Language Design: Machine or Human?"
date: 2021-02-11
tags: [Computer Science, Programming Languages, Language Design]
abstract: When designing a computer language, be it for programming, data exchange, document markup or configuration, the first thing you should do is decide as to whether your language is meant for use by humans or by machines. Well, obviously, every language will be used by both, but still, who is your main target audience?
This question is important because depending on your answer, there are a few specific contradicting design principle that you should follow.
### Easy to Parse **vs.** Easy to Read
It should be easy to write parsers for machine language. The syntax should therefore be very explicit and the grammar simple without syntactic sugar. A good example is [JSON](): There are booleans, numbers, strings, lists and dicts, each with a clearly distinguishably syntax without exceptions. That's it. I can write a parser for it in very little time. Another example is [Scheme]() or [Lisp](): Its exhaustive bracketing makes it easy to parse^[Take a look at [Write Yourself a Scheme in 48 Hours](!] as there is, among other things, no operator precedence to consider, but it makes it harder to read.
However, a language that is easy to parse through a machine is not necessarily easy to read for a human. JSON is easy to parse, but [YAML](^[Note that YAML is *not* a good language. It has a [lot of problems](, but in its basic form it's easy to read. Take a look at [strictyaml]( if you want something better.] is easier to read, as it has pretty syntactic sugar (e.g. you can often leave out the quotes), less syntactic noise and enforces using line breaks. Things that make it harder to parse, but easier to read.
### Easy to Generate **vs.** Easy to Write
Here, the same principles as above apply. A machine language should be minimal without syntactic sugar. A machine doesn't care about having to write a lot of quotes, for example. A human, on the other hand, does – JSON and YAML are again good examples.
### Low-level **vs.** High-Level
A machine-focused language should be simple and low-level. The obvious example would be assembler languages. They directly model how the machine works. Human-focused languages however should not focus on how the machine works, but rather on how their human user thinks. This is why we have high-level programming languages that keep you from having to think of memory allocation, pointers and pushing bytes around.
## Conclusion
Know who your language's target audience is and design it with them in mind.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment