Skip to content

natescode/silicon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The Silicon Language Specification

Table of Contents

Silicon

Silicon is a new programming language that emphasizes simplicity, extensibility and usability. It is extremely easy to learn and extremely difficult to use incorrectly. The main target is WASM. This is the specification, currently just the PEG grammar, for the language.

Goals

  • WASM compilation target
  • Full-Stack web dev
  • blazingly fast compilation
  • interpreted for fast dev cycles
  • Algebraic Data Types
  • Pattern Matching
  • 100% Type Inference (safety without type gymnastics)
  • Co-routines (no colored functions)
  • ARC (no GC)
  • 100% Web API compatability
  • 100% Node API compatability

Non-Goals

In my opinion, non-goals are just as important as goals. They prevent scope-screep and keep the language and toolchain great at specific use-case instead of mediocre at everything.

*Not a direct goal but other tools will be used **A future, much less important goal to think about

  • Native Compilation*
  • LLVM / other native backends*
  • Variadic functions * Silicon Dynamic
  • Function over-loading * Silicon Dynamic
  • Game dev
  • Systems dev (Yes, even though Silicon has no GC and is fairly "low-level". It is NOT anything like Zig nor Rust)
  • Operator overloading * use infix functions instead
  • Functionally Pure * functional, may have an effects system but it isn't Haskell nor purescript
  • Borrower Checker / compile-type memory safety**

SI puts the SI in Simple.

  • no unary operators
  • no operator precedence
  • no methods
  • no inheritance
  • no function / method overloading (TDNR so kinda @let x = 1; x.toString; @let y = $false; y.toString)
  • no modifiers (just annotations)
  • no garbage collector: reference counting / borrower checker (optional)
  • ONE function syntax @fn (named, anonymous, lambda)
  • ONE looping expression @loop (for, while and do/while)
  • ONE condition expression @wif (if and switch/case)

What SI DOES have

  • Traits (because they're awesome)
  • Annotations (for flexiblity)
  • UFCS (fake methods)
  • TDNR (fake overloading)
  • ADT (Algebraic Data Type;the best type of type)
  • SIMPLE and consistent syntax
  • coroutines: no locks, mutexes / semaphores or runtime to schedule concurrent tasks
  • Pattern matching
  • Full type inference!
  • Full lifetime inference!
  • Large standard library (many native libraryes from C, C++ and Rust)
    • Common integrations (SQL, websockets, graphql, ORMs, Kafka, Graphics etc)
  • Native dependency injection
  • Native testing (within the same file)
  • Great errors as values and error handling
  • Generics
  • Sinq (Silicon equivalent of C# LINQ)
  • Cross-platform!
  • Cross-compilation (thanks Zig cc!)
  • C interop!
  • 100% Web API coverage
  • 100% Node API coverage

Grammar

Silicon's grammar is extremely regular and straight forward. That does make it simple but simple is simply (pun intended) a by product of using a few simple grammar rules everywhere for everything.

My goal is to keep Silicon's grammar to around 100 lines of PEG grammar. It may grow but it should never be more than 150-200 LOC. 100-125 is more realistic.

Key Features

Silicon's goal is to only have the most expressive and versatile language features.

Influenced from: Ruby, Lua, Zig, Rust, LISP, ML

  1. ML Algebraic Data Types
  2. ML Function Definition Pattern Matching
  3. ML Hindley-Milner Type System: 100% Type Inference
  4. ML Effectful Type System: total, exception, timeout/nohault, pure(previous two), IO, random, parallel
  5. Lua Co-routines
  6. Lua (self)Embeddable as a Dynamically Typed Scripting Language
  7. Ruby Blocks: non-local returns, thread safe etc..
  8. WASM output: fast, safe, cross-platform, interop, ecosystem
  9. No GC: ARC, Generational References, manual or Lifetimes, MAYBE a tracing GC for the backend.
  10. JS 100% Web API and Node API compatability

Other features

  1. Very simple and regular grammar
  2. Easy and fast to parse
  3. Forced DI of I/O Functions
  4. UFCS (fake methods) & TDNR (fake overloading)
  5. LISP style macros / quotes?
  6. Language Interop via WASM and Zig. Uses many proven Native Libraries.
  7. Zig CC Cross-Compilation
  8. Rust borrower checker / lifetimes BUT without writing the lifetimes

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published