www.steadman.info


VSI: A simple interpreted programming language

THE TEN SECOND INTRODUCTION

Take an IF statement, you have three things you need to know: a calculation which can result in True or False, a positive outcome and a negative outcome. So create a class with three elements to represent this.

A LOOP statement is similar, you need an expression, a positive outcome and a command to call when the loop is done.

By creating a classes and objects for concepts like commands and expressions you can quickly and intuitively build a useful and functional programming language.

ORIGINS

I was looking around the internet for the source code to a programming language. There's plenty out there, but they're complex. They're not written with the idea that anyone can come and understand whats going on.

VSI stands for Very Simple Interpreter. I developed it while aware that I wanted it to have an elegant design and code which was more accessible, even at the expense of runtime performance.

WHATS THE POINT?

EDUCATION

The source code for VSI is well structured and carefully formatted. Everything is nicely divided into directories and files to aid navigating around it.

Any decent programmer should be able to pick it up and quickly get a good idea of what its all about. Anything complicated is well commented.

LANGUAGE BRIDGE

VSI reads in text and turns it into an executable program. The objects represent fundamental concepts of a programming language which are independent of a programming language syntax.

Ultimately, it could read in one language and write out another, creating a bridge between languages and a way to keep code automatically compatible with the latest tools.

INSIDE THE SUBROUTINE

UML is the de-facto software design standard, but it doesn't look at the contents of a subroutine, it just gets to the function name and maybe a bit of pseudo-code.

VSI provides some real added value to software design.

FOUR MAJOR LANGUAGE ELEMENTS

COMMANDS

Commands deal with sequences and actions. IF and WHILE commands make logic decisions, CREATE defines a new data item.

Commands can be represented by flow diagrams.

EXPRESSIONS

Expressions perform all the maths in the language, creating or changing data items.

Simple expressions like A = B + C update values. Complex expressions like A = SQUAREROOT(B) trigger function calls and create a new layer in the program's context.

LIBRARY

The library is an almost-global item which contains classes. Classes contain routines. Routines contain a link to their commands and parameters.

The library is a hierarchical collection of the top-level language items.

CONTEXT

A Context is all the dynamic information. The routines, commands and expression items are all static, but the variables, expression results and execution pointer are dynamic.

Context objects have mostly setter and getter operations and are passed around.

DOMAINS: MANAGING THE LARGER ENVIRONMENT

The Core VSI language is not an entire application. Its one component which requires many others in order to operate. In order to reduce the complexity and inter-dependence of all the extra functionality, its broken down into domains which have their own relationships.

COMMON

The name Common should be information enough. The pervasive collections, types, constants and enumerations.

SERIALISATION

Serialisation is about turning a string of characters into a network of objects (and back). It requires a specific competition design-pattern to traverse through all the various challenges in understanding command sequences and expression precedence.

CORE LANGUAGE

The Core Language is all the functionality to run a program, covered above in the four elements.

EDITOR

The Core Language represents a network of objects and relationships. Its focus is on running programs. The Editor contains the routines to traverse these collections to insert, remove or retrieve items.

ANALYSIS

What is the cycolmetric-complexity of a routine? Which routines are most deeply nested and should be targeted for improvement?

VSI has a domain for analysis tools to examine its own code.

GUI

VSI has the beginnings of auto-generating its own flow-charts. The code required to manage this presentation is isolated from the other aspects.

In many use cases, VSI could work in the background with no user interface, so this is an optional element.
© 2014 Dave Steadman   // email