Strict Programming Language

Strict Programming Language

  • Docs
  • API
  • Blog

›API

Documentation

  • Overview
  • Getting Started
  • Everything you need for the Weekly Kata
  • Coding Style
  • Code Validations
  • Naming
  • Using APIs

API

  • Keywords
  • For

Future

  • Concurrency
  • Microservices
  • Types

Keywords

Strict doesn't need a lot of keywords, most code is only valid written in one way. Switching arguments or changing code style will make the code usually not longer compile (or at least not behave the same way). Strict keywords are most similar to the go language, Python and C#. For details check the grammar strict.iro file.

You will understand any .strict code you read, writing code is much harder due to all the strict rules ^^

Loops and control flow

  • for
  • in (part of for loop syntax)
  • if
  • else

Comparsions and Operators

  • is (any equal comparsion)
  • not (negation)
  • to (type conversion)
  • and, or (english words instead of strange C operators)
  • +, -, *, /, ^, %, <, >, <=, >=, xor (for math)
  • ? (conditional operator to use if else expression in one line followed with else keyword)
  • () for lists/arrays, which includes method parameters and method call arguments, there is no empty list (), it is never written and just None. Thus method and method calls must not use empty ().

General

  • has (used to define member either as component or trait)
  • return
  • constant and = to assign initial value
  • mutable and = to assign initial value

Buildin Types

Everything in Strict.Base is always available, everything else you can just import

  • Any
  • App
  • Number
  • Text
  • Boolean
  • Directory
  • Character
  • Log
  • Method
  • Output
  • Stacktrace
  • System
  • List
  • Input
  • Iterator
  • Mutable
  • Range
  • Error
  • HashCode
  • File
  • Type
  • Enum
  • Generic
  • Member
  • Dictionary

Assignments

Assignments can be done only once for a constant type member/variable/parameter and which is during constant declaration.

constant number = 5
constant text = "Hey"

For mutable member/variable/parameter, the value can be reassigned as many times as required. Only mutable types can even change their state, and they are rarely used (linked lists or counts). In this example count, list and index are all mutable, the compiler can still optimize index away, but count and list will prevent this code from running automatically in parallel like all immutable code will do in any loop.

let count = Count(0)
let list = List(Number)
for index in Range(0, 10)
  count.Increase(1)
  list.Add(count)

Comments

Any comment is considered bad. Only add comments to methods to explain functionality or link to more information, comments for members, types, inside methods are all not allowed. Like in C, Java or C# comments start with //, no other type of comment is allowed, multiline comments are not needed, if your comment is more than 3 lines, the compiler will refuse it.

Everything is an expression

All statements are expressions in Strict, in fact any expression can be put into a line of code, can be a parameter, part of a if statement or for loop, etc. If an expression stands on its own and returns a value, it must be true, otherwise it will cause a runtime, test and even compiler error immediately.

File Structure

A Strict package folder looks like this (folder must match project name):

  • build.yml (package meta data, autogenerated if missing: author, creation date and special build settings if needed)
  • README.md (description, must start with project name header, should contain usage examples of the package and maybe a quick overview of types available, only allowed in main folder)
  • .gitignore (is usually empty, but if you really need to exclude files, do it here)
  • .editorconfig (defaults to tabs with 2 spaces and the default styling used for Strict, this way all editors will behave the normal way)
  • any other file MUST be a .strict file, which defines a type each (class or trait)
    • SubFolder can contain more .strict files

Examples

https://github.com/strict-lang/Strict.Base

https://github.com/strict-lang/Strict.App

https://github.com/strict-lang/Strict.File

https://github.com/strict-lang/Strict.Math

and more at https://github.com/strict-lang

Last updated on 2/28/2023 by MuraliTandabany
← Using APIsFor →
Strict Programming Language
Docs
Getting StartedCoding StyleAPI Reference
Community
Stack OverflowProject ChatTwitter
More
HelpGitHubStar
Copyright © 2023 strict-lang