Star Script

Simplify Web Application Development

Star Script is live on MyEzApp.com

Star Script is now live on the myezapp web site. You don’t have to install any software to try it out. There are also several applications available for you to use. Once you install the applications in your account,  you will have the complete source code. You can tinker with the source code as you wish. Try it out and have fun!

Why would average people want to program?

A reader asked on Reddit, why would average people want to program? It is a very good question. I think the reason people want to program is similar to that of cooking. You can always ask the same question, why would average people want to cook? Cooking requires a lot of special equipments, raw materials, skills. If you don’t cook well, it affects people’s health. It can be quite dangerous. It really should be handled by professionals. Plus, we have so many low-cost providers such as MacDonald. Sometimes, it is even cheaper buying than cooking yourself. Yet, a lot of people cook. In nearly every house, there is a kitchen. If you are selling a house without a kitchen? Good luck with that.

Below are some of the reasons people want to program:

– Lower cost: assume your spare time is free time

– Customization: not sweet enough? add more sugar.

– Healthy: nobody is peeking/selling my private data

– Special needs/tastes: I just like the cookie made by my grandma. Nobody makes better ones.

Of course, before people actual started programming, all of the above are just speculations. It needs to be proven in real world, not by words.

Reddit Discussion

There are a lot of interesting discussions on Reddit about star script. It is now ranked #2 controversal in the technology/programming section. I think I need to clarify the target user/use cases before the whole design would make sense.

Programming language can be used to do many things, from number crunching, system programming, to text processing, application configuration, etc. A lot of programmers, especially hackers tends to focus on the tough ones such as system programming and number crunching. For this type of tasks, being more disciplined is a blessing. A little mistake will render the entire calculation result useless or crash the entire system. However, when I designed Star Script, those use cases are not ranked high in my priority. I am having a mental image of an average person, who will use programming to do basic stuff such as text processing, simple calculation, assembling some components built by somebody else, etc. For those type of tasks, there is no need to be too disciplined. Being more tolerant makes learning and usage of the langauge smoother.

One of the most distinct feature of Star Script is its error detection and recovery capability. Try to detect and recover from all errors is very challenging. You have all kinds of errors, from syntax error, semantic error, to runtime error. The number of total possible errors are huge. It did not look possible at first and took me quite some time to figure out some very innovative approaches to reduce the complexity and make the total situation manageable. Now I am trying to give the best possible recovery response in every case. I hope I covered all of them. If I missed anything, please let me know. Thanks!

Interesting discussion on reddit

After releasing version 0.1, many people comments on reddit.

http://www.reddit.com/r/programming/comments/ovd2l/programming_language_for_the_masses_what_does_it/

Thanks for all the comments! It gives me opportunity to explain why the language is designed this way and also helps me improving it. Really appreciate!

Star Script 0.1 Released

Today, Star Script 0.1 version is released. Check it out and share your thoughts!

http://starsrc.org

Programming for the Masses

Programming for the masses requires a programming language for the masses.

What will this programming language look like?

  • Fault tolerant: ideally, the language should be able to process arbitrary input program, much like HTML
  • Smooth learning curve: ideally, no learning is required to start using the language; every feature can be learned lazily, when needed.
  • Intuitive syntax: ideally, the meaning of a program can be guessed by people without knowledge of the programming language
  • Strong component support:  ideally, people assemble applications much like what they do with furniture from IKEA; they don’t build from scratch
  • Declarative whenever possible: ideally, application can be built declaratively
  • Lean: as small as possible, but no smaller

Star Script is a programming language that tries to meet the above challenges.

Now Accepting Registration for Early Access

StarScript will be hosted in a new online service at myezapp.com. Now MyEzApp is accepting registration for early access. Check it out: http://launch.myezapp.com

Introducing Star Script (7): Component and Tag

Enabling users to easily create and use component is an important design goal of Star Script. It is so important that Star Script has special language syntax to support it. The syntax that helps with component construction and usage is called tag, similar to the tag syntax in HTML/XML.

Tags, AKA markup, is considered “declarative” way of programming and easier for non-programmers to pickup. That’s why Star Script chooses tag to represent component. Integrating tags into a programming langauge allows user to avoid programming in certain use cases, such as UI declaration, content authoring, object value initialization, etc. When properly implemented, it can promote component oriented programming and improve the usability of a programming language.

Currently, in most programming languages, tags are not natively supported. Usually, they are treated as text and processed using language specific DOM libraries. There are a few languages that supports XML literal such as E4X, JavaFX, and Visual Basic. The functionality of the tag in those languages are quiet limited. Tags in those languages are mostly designed as a shorthand for creating XML fragment or constructing objects.

Star Script adopted an approach that treat tag as a first class citizen of the programming language. Below are some of the design points:

  • Easy tag definition: tag can be defined either by a function or a class. Any function can be called using tag syntax.
  • Tag has well-defined life cycle: tags go through four stages of their life cycle definition, instantiation, configuration, and rendering
  • Tag can be nested within other tags
  • Tag can be nested within other language structure
  • Tag can be assigned to variable or returned from function

Let use a simple example to illustrate some of the above points.

func row(n as int)
  <tr>
    <td>n<td><td>n * n<td>
  </tr>
end
<table>
  for i = 1 to 2
    <row n=i/>
  next
<table>

The output of above program is

<table><tr>
     <td>1<td>
     <td>1</td>
   </tr><tr>
     <td>2<td>
     <td>4</td>
   </tr></table>

As you can see from the example, for-statement can be embedded inside the table tag, and row tag can be part of the for-statement body. for-statement will execute and call the row function three times, each time with different parameter. The row function will render one row of the table, each time it is called.

Introducing Star Script (6): Basic Examples 3

Example: Condition

if 2 > 1 then
  hey, "2 > 1"
end
hey, 2 > 1

Example: Multiple Branch Condition

if 1 > 2 then
  Oops! "1 > 2" ???
elseif 2 > 1 then 
  right "2 > 1"
end
right 2 > 1

Example: Function

func sum(n as int)
  var s = 0
  for i = 1 to n
    s = s + i
  next
  return s
end
sum(10)
55

Introducing Star Script (5): Basic Examples 2

Example: Table

<table>
  for i = 1 to 3
    <tr>
       <td style="border:1px solid black;">i "*" 2 =</td> 
       <td style="border:1px solid black;">i*2</td> 
    </tr>
  next 
</table>

Output

1 * 2 = 2
2 * 2 = 4
3 * 2 = 6

Example: DoWhile Loop

var i = 1 
DoWhile i <= 3 
  we are at line i \n
  i = i + 1 
End

Output

we are at line 1 
we are at line 2 
we are at line 3