Projects »

Humble programming language

This is a hobby project. I gather my ideas of what an ideal programming language (for me) would work like. The definition is nowhere near complete or consistent. If you have comments or suggestions send me an email.

Basic Concepts

Syntax

Code Structure

plain-text HTML
action
(command call)
(command arg1 arg2 ...)
  • command arg1 arg2
list
(array)
[item1, item2, ...]
  1. item1
  2. item2
  3. item3
dictionary {key1: val1, key2: val2, ...}
key1

value1

key2

value2

key3

value3

comments
(top level)

Humble supports literate programming.

All text that is at the top-most level of a file/page and is not an action, list or dictionary is treated as comment.

comments
(inside code)
/* multiline
comment text */

Italic text denotes comments

// single-line comment

// You should still start comment with "//" after executable code on the same line.

The rule of continuing lists vertically:

Code Equivalent
(print Hello World!)
  • print:
    1. Hello
    2. World!
(print (get-temperature) (get-wind-speed))
  • print:
    • get-temperature
    • get-wind-speed
(set arr [a,b,c])
  • set arr [ // note the "["
    1. a
    2. b
    3. c

Variables and Values

Unquoted strings separated by spacing are treated as string or number values. To get a value of a variable you can use $var which is a shorthand for (value var) or even ($ var).

Code Description
  • print Hello "World"

Executes command print with two string arguments "Hello" and "World".

  • set x 42
  • print x= $x

Sets the value of the variable x.

Should print out "x= 42".

  • set rect { h: 10, w: 20 }
  • set rect.h 15
  • set rect[w] 25
  • print $rect[h] x $rect.w

Creates an object rect with two properties (h and w).

Modifies the properties.

Prints out "15 x 25", using the values of the properties.

Namespaces

Dictionary notation is used to express namespaces:

Example

Code Equivalent
x

42

arr
  1. a
  2. b
  3. c
rect
h

10

w

20

area

(* $h $w)

  • set x 42
  • set arr [a,b,c]
rect
  • set h 10
  • set w 20
  • set area
    • multiply $h $w

Commands

I am still working on this part. This will probably change in the future.

Functions are called "commands" in Humble. This is due to a number of reasons which I will someday explain elsewhere.

Code Description
[x]
  • add $x 1

This creates an anonymous command that returns a value increased by 1

factorial
[0]

1

[x]
  • multiply:
    • $ x
    • factorial:
      • - $x 1

This creates a recursive command factorial.

(factorial 0) always returns 1.

Other calls to factorial multiply its argument with argument - 1.

Further questions

I am still experimenting with different notations for:

One idea I want to try out is to express plain-text Humble code as YAML. I'm guessing that adding action notation to it would be nough.

Related posts

  1. 2011-04-27 Notes from discussion on "Usefulness of inventing programming languages"
  2. 2011-04-12 Usefulness of inventing programming languages

About me

I am a web developer and a civic activist living in Vilnius, Lithuania.

lietuviškaiTinklaraštis lietuvių kalba.

 

Current projects:

ObjectFSdata access API for JavaScript and other scripting languages.

KąVeikiaValdžia.lt / PolicyFeeda government news aggregator and filter.

Humblea programming language expressed by bullet-lists and tables.

 

Meta

RSS

 

Ads