Functional, Verbose, Sensical: A Programming Language Proposal
Published: 2019-02-25 12:25:23

---
title: Functional, Verbose, Sensical: A Programming Language Proposal
published: true
description: 
tags: 
cover_image: https://thepracticaldev.s3.amazonaws.com/i/fc2hk1j4880o7n9yq8sk.jpg
---

A while back I wrote up [some quick thoughts](https://www.alexlockhart.me/2018/07/kewl-programming-language.html) on what a programming language would look like if it's identifiers could contain spaces. In my example program I also had the colon used for setting spaces and the single equals sign used for comparisons. The other day I had some ideas for a purely functional version of some of these same concepts.

Here are the features of the as of yet non existent programming language:
The only objects are modules, globals, functions and parameters.

1. No variables. This is a purely functional language.
1. Every global and parameter is a stream and so can have 0, 1, or more values.
1. Modules define, import, and export globals and functions.
1. Each module can have a single entry function which is the function that is run when the module is run.
1. Identifiers can contain spaces
1. Setting globals and parameter defaults uses a colon
1. Conditional equality expressions uses a single '='.
1. If statements are streamlined as shown below for easy conditional handling.
1. Each function can only contain a single expression making this language purely functional
1. Error handling is done using the if statement.
1. You can use values that might not exist and then handle the error cases further down the if statement.

Below is what a programming language with these features might look like. As this programming language does not exist I could not add syntax highlighting. However I posted this [same example code on my blog](https://www.alexlockhart.me/2019/02/functional-verbose-sensical-programming.html) and was able to manually add in syntax highlighting there.

```
module age groups {
  import print from command line output;
  import error from command line output;

  max baby age: 2;
  max kid age: 12;
  max teenager age: 17;

  function tell the user they are a baby {
    print('You are a baby')
  }

  function tell the user that they are a kid {
    print('You are a kid')
  }

  function tell the user that they are a teenager {
    print('You are a teenager')
  }

  function tell the user that they are an adult {
    print('You are an adult')
  }

  export function tell the user what age group they are in (age) {
    ? age <= max baby age :
      tell the user they are a baby
    ? age < max kid age :
      tell the user that they are a kid
    ? age < max teenager age :
      tell the user that they are a teenager
    ? has one value(max teenager age) :
      tell the user that they are an adult
    ? has multiple values(max teenager age) :
      error('Please provide only one age')
    ? no values(max teenager age) :
      error('No age was provided')
    : // this would be the else case, but based upon the above statements it should never be reached.
  }
}

module my program {
  import tell the user what age group they are in from age groups;
  import the users age from command line arguments;

  entry function run the program {
    tell the user what age group they are in(the users age)
  }
}
```

Check out [my blog](https://www.alexlockhart.me/) for more of my musings upon technology and various other topics.