Star Script

Simplify Web Application Development

Introducing Star Script (3): Intuitive Syntax

Star Script targets casual programmers. Casual programmers don’t want to learn and remember too many things. Therefore, Star Script has a requirement that its syntax has to be intuitive. What does intuitive mean? It means for people who have never used Star Script before, when they look at a Star Script program for the first time, they can roughly guess what it means.

Based on this requirement, Star Script adopted the below syntax design:

  • No hard-to-guess symbols: Star Script does not use symbols like @ # $ % & in the syntax. I cannot guess what they mean in Perl, PHP, etc. I have to read tutorial first to understand it. Not only that, I always confuse its meaning when switching from one language to another. If I don’t use those languages for a while and try to pick them up later, I have to read tutorial again. This is not acceptable for a casual programmer. So those symbols are out. Star Script does use symbols such as +, -, *, / in the expression. They are considered intuitive for most people.
  • Do not require statement separator: many programming languages uses some kind of statement separator, such as semi colon, line break, etc. Statement separator is a concept you have to teach to get a user started using a language. To teach this concept, you have to introduce the concept of statement first. To teach the concept of statement, you have to show some examples such as if statement, for loop, etc. To make things clear, sometimes you have to teach the user how to distinguish between statement and expression, so they don’t put statement separator inside an expression accidentally. That is a lot of learning. So, it is out. Star Script will automatically separate statements. You can put them in one line or multiple lines without using semi colon. It’s all up to you. It is just formatting.
  • No general block enclosure: in C-like languages, you have curly braces “{” and “}” to indicate a statement block. In LISP, you have many many parentheses “(” and “)”. If you use those languages for a long time, you probably get used to it and no longer feels anything. If you are a casual programmer, those syntax is a major deterrence. It makes the language reads like formulas. And formulas are reserved for mathematically inclined people. For all other people, it just looks scary. So, it is out. You may wonder if casual programmer should at least be mathematically inclined. They may. But I don’t want to limit casual programmers to only mathematically inclined people. On the other hand, those enclosures can be designed away. This removes one concept people have to learn to get started. Why not?
  • Avoid inventing new keyword: a lot of casual programmers are actually expert in one or two programming languages. They are only casual for the other 100+ programming languages. We should leverage their existing knowledge to reduce learning curve if possible. So, I looked around and decided to borrow some keywords from C/Java/JavaScript, some from Basic. It makes users of those languages easier to get started. But there is no strict rule why Star Script picks this one and not that one. The picking is mainly based on taste.
  • Case insensitive: this is debatable. I personally like case-sensitive programming languages. It allows you to reuse the same word for different purposes. You just need to use different case. But, from my gut feeling and readings on the internet, it seems casual programmers like case-insensitive languages more, because natural languages are mostly case-insensitive. For natural language, cases are for formatting mostly. It does not change the meaning of the word. The most it does is to increase the volume of your SHOUT. So, case-insensitive is more intuitive, thus, Star Script is case-insensitive.
  • Intuitive formatting preservation: formatting characters will be ignored within a statement structure. But it should be preserved when you are generating output. Star Script tries to handle formatting as intuitive as possible. The goal is, when you feel a formatting character should be ignored, it should be ignored. When you feel a formatting text should be preserved, it should be preserved. It is a very high bar. I don’t think Star Script get it 100% right. But I hope it is close.
  • Multi-line string literal: I am not sure why major programming languages does not support multi-line string literal. For languages that uses line return as statement separator, they have an excuse. For languages that use semi colon as statement separator, I don’t see any good reason not to have multi-line string literal. Multi-line string literal is very convenient if you are processing a very long piece of text, such as a template. Neither adding \r\n everywhere, nor breaking down one string into multiple strings are convenient. Star Script supports multi-line string literal.
  • Array index starts with 1: in C-style programming languages, array index always starts with 0. There are many technical benefits with this approach. However, it is not intuitive. Given somebody without much programming experience, I am sure, teaching them to start counting from 1 is easier than teaching them to start from 0. The major downside for starting index from 1 is that, for experienced programmers, their brains have already being fixed by the C-style languages and they may feel counting from 0 more intuitive. Sorry, that’s what I have to say to them.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: