Nano Script Specifications

A lightweight, simple language for programming.

.

.

.

Know More

Introduction


Greetings, Reader. Today I bring you my new random project: Nano Script.
Nano Script is a fantasy programming language that exists within the universe of my written works.

In it, it's a language developed by Nanosoft for its console, the NanoBoy.
So, uh, it's not real. Yet here I am creating a specification for it.

  x = 3
  y = 4
  dist = fn a, b
  
  print dist 3, 4 # Will print out '5'.

Nano Script is designed to be simple, compact, easy to understand, and very convenient.
It's not specifically writen with speed in mind, so its features may not make the most sense, instead,
it's written based on what looks the coolest to me specifically, only loosely trying to be practical.

Let's see what it's about!!!







Design Philosophy


Like I said -- looking cool from the perspective of me specifically, which means what I chose to include is quite arbitrary.
The syntax is based very loosely on Python, GDScript, CoffeeScript, Rust, C++, Lua and ASM.

  1. READABILITY
    The syntax is easy to read at a glance, and the symbols are intuitive.
    It feels logic and compact so you can look at it on small screens such as the NanoBoy's.
    I also chose to use indents instead of braces and line terminators, because it looks so clean.


  2. MIXED-LEVEL
    It should be powerful and largely declarative... you tell it what you want to happen. For that, I want its syntax to feel customizable and language-like, so you can have things like colour = albedo * normal dotted_with (light.position - position).


  3. EVERYTHING IS A NOUN
    Values or Behaviour, almost everything is a noun that can be set, retrieved, reassigned.
    Functions, the variables that contain your code's behaviour, can be interacted with as objects.


  4. PARADIGM-AGNOSTIC
    The features of the language don't force you to use them.
    You can program your entire codebase without using classes or signals if you want;
    they are here to help you, not to hold you hostage.


  5. EXTENSIBLE
    Libraries and your own codebase should look and behave like native code.
    You should be able to just plug in your libraries and immediately have extended functionality.
    For example, a library that allows you to create a window should behave something like this:

      Window = load('lib/Window.nsl')
      my_window = Window.create title:'My Window', size:v[640, 360]
      my_window.show Window.CENTERED
      

    It just works™.










Here's how the code for a little screen with a player should look like:

  with load('Game.ns')
  signal on_begin
  signal on_death
  
  player =
    position: v[0, 0]
    velocity: v[0, 0]
    sprite: load('img/player.png')
    💕: 3
    🛡️: 4
    items: ['Sword', 'Apple', 'Key']
    update: fn dt:float ->
      position += velocity * dt

  ready = fn -> on_begin()

  update = fn dt ->
    player.update dt
    player.velocity = Input.get_L_joystick_vector()
    if player.💕 <= 0
      on_death()

  draw = fn ->
    # Draw Player
    draw player.sprite, player.position









Syntax


Let’s take a closer look at how to write NanoScript code.

Features


Comments



# Comments are done with a single hash (#) for line comments...

###
Or three hashes for multiline comments!!!
###

Contact:

mrhenribraga@gmail.com
@mrpedrobraga