Skip to content

Getting started

Julius Paffrath edited this page Nov 6, 2019 · 11 revisions

Hello, World! in jask

Everyone who is learning a new language should start with the traditionally Hello, World! program:

print("Hello, World!")

That's all! In jask you don't need to specify a main function or importing stuff. Invoke the jask interpreter and try it yourself!

Interactive and file mode

The jask interpreter can be used in two ways: The interactive mode and the file mode.
The interactive mode allows you to enter jask code on the fly, just like the Python interactive mode. To start the interactive mode, just invoke the jask interpreter:

java -jar jask.jar

You can exit the interactive mode with the keyword exit.
For interpreting jask files, pass the file and optional arguments to the interpreter:

java -jar jask.jar file.jask arg1 arg2 ...

Variables in jask

The jask language has the attempt to be easy readable. So storing data goes like this:

store DATA in VARIABLE

easy, right?
Currently, jask supports these types of data:

  • strings, like "Hello!" or "This is a string"
  • numbers, like 42 or 3.1415
  • boolean values, can be TRUE or FALSE
  • list variables, as explained here
  • dictionary variables, as explained here
  • struct variables, as explained here

Additionally every variable can be filled with NULL, which will mark the variable as empty.
A stored variable can change its content and its type at runtime. To change a variable, the keyword assign is used:

assign DATA to VARIABLE

Before assigning data to a variable, the variable needs to be stored:

store "A string" in myVar
assign 100.32 to myVar

Time for a few operators!
Assigning allows you to apply basic operators on your variables. See the following example:

assign 100 plus 200 to num
assign 100 minus 200 to num
assign 100 times 200 to num
assign 100 divide 200 to num

assign "Hello " plus "World!" to str

Want to continue? Have a look at the other articles Control flow, Functions and List variables in jask!