DALIS

From Esolang
Jump to: navigation, search

DALIS is a cloud based programming language created by David from David's Blog in 2011. The language is still evolving. DALIS programs usually run server-side, but interpreters are also being developed for the .NET Micro Framework and the PC command line.

It has been suggested that the syntax of DALIS programs is not very esoteric (it being influenced by BASIC). But hopefully it gains some credit for the unusual way in which DALIS programs are supposed to be executed. A single program could be interpreted by many separate instances of the interpreter, each running the program for a short timeslice before returning the program state to the client ready for the next timeslice.  The tongue-in-cheek acronym DALIS actually stands for DAvid's Language of Infinite Scalability.  David wants to see how this programming language will evolve as he begins to write programs with it.

Do not be surprised if David decides to write an interpreter in C, so that he can run DALIS programs on his PDP-11.

Execution

DALIS programs are supposed to be executed in little timeslices across a network, so a program will run for a while and then intermediate results will be returned to the browser ready for another timeslice. The main idea is to provide a cloud-based language that can be load-balanced across many servers. In this way the language interpreter is distributed. DALIS servers don't need any shared state or session data, so each timeslice of a single DALIS program can be processed by totally different machines.

Emerging concepts

Hopefully, creating a language that executes in this manner will allow some interesting concepts to evolve. For example, the TRANSPARENT keyword in DALIS tells a program not to interfere with the raw http content. It has allowed simple load-balancing programs to be written. Here is a trivial load-balancer written in DALIS which delegates programs onto other DALIS interpreters by means of the TRANSPARENT keyword.

TRANSPARENT
IF ISASSIGNED("arg0")
  IF (RANDOM > 0.5)
     newUrl = REPLACE arg0, "DALIS", "DALIS1"
  OTHERWISE
     newUrl = REPLACE arg0, "DALIS", "DALIS2"
  END
  IF ISASSIGNED("arg1")
     newUrl = REPLACE newUrl, "balance", arg1
  END
  IF RAWCONTENT = ""
     WRITE WEBGET newUrl
  OTHERWISE
     WRITE WEBPOST newUrl, RAWCONTENT
  END
END

It simply rewrites the URL and passes the raw http content to the new location. The limitation of programs marked as TRANSPARENT is that they only get a single timeslice, they are unable to resume execution since data simply passes through them unaltered.

Supported platforms

Cloud-based DALIS programs can run in most browsers, since a lowest common denominator approach has been chosen. DALIS programs have also been demonstrated to run on the following devices:

  • Amazon Kindle Keyboard
  • Sony PlayStation Portable
  • Apple iPad
  • Apple iPhone

Examples

This program will render the Mandelbrot set in a web browser using ASCII characters. It will likely take many timeslices before the fractal is complete, so is a good demonstration of DALIS in action. If you need to draw a fractal in realtime whilst sitting on the beach, you can run this code on your 3G enabled Kindle and let some remote server do all the hard work and simply return the results:

LOOP e= 1.1,d = 0, h = 0
  LOOP b=-2
     n = 0, h = 127
     LOOP r=0
        r = r*r-n*n+b
        n = 2*d*n+e
     REPEAT d = r, h=h-1 IF ((r*r)+(n*n) < 4) AND (h > 32)
     WRITE (h)
  REPEAT b = b+ 0.04 IF b < 1
  WRITE EOL
REPEAT e = e - 0.1 IF e > -1.2

The following program outputs a table of temperature conversions between Centigrade and Farenheit:

min = 30
max = 220
gap = (max-min) / 17
WRITE "deg F   deg C"+EOL
LOOP f=min
  c=(5/9)*(f-32)
  WRITE TEXT(f,1)+"    "+TEXT(c,1)+EOL
REPEAT f=f+gap IF f<(max+1)

This example shows an animated bouncing ball drawn using ASCII Art, it was written to demonstrate the use of WIPE (which erases all previous output) and REFRESH (which causes the current timeslice to end immediately so that results are returned to the client):

LOOP x=0, y=3, xdir=1, ydir=-1
 WIPE
 WRITE "-----------------------"+EOL
 LOOP y1=0
     line = "|"
     LOOP x1=0
       IF (x=x1) AND (y=y1)
         line = line+"O"
       OTHERWISE
         line = line+" "
       END
     REPEAT x1=x1+1 IF x1<21
   WRITE line+"|"+EOL
 REPEAT y1=y1+1 IF y1<11
 WRITE "-----------------------"
 x=x+xdir
 y=y+ydir
 IF (x>19) OR (x<1)
   xdir=xdir*-1
 END
 IF (y>9) OR (y<1)
   ydir=ydir*-1
 END
 REFRESH
REPEAT

External resources