Skip to content

manojuppala/noobscript

Repository files navigation

NoobScript 🚀

A beginner-friendly programming language that compiles to JavaScript

NoobScript is designed to make programming accessible to complete beginners by using simple, readable syntax that resembles natural language.

Philosophy

"Teach programming concepts, not syntax."

NoobScript removes the complexity of brackets, semicolons, and confusing symbols, allowing beginners to focus on learning programming concepts like variables, loops, functions, and classes.

Features

Simple Syntax - No curly braces, semicolons, or complex punctuation 📝 Readable Code - Keywords that feel like natural language 🎯 Beginner-Friendly - Clear error messages ⚡ Fast - Compiles directly to modern JavaScript 🌐 Universal - Runs anywhere JavaScript runs (Node.js, browsers, Bun, Deno) 🎨 Rich Features - Objects, booleans, null, break/continue, while loops, and more!

Quick Start

Installation

Install globally from npm:

npm install -g noobscript

Or clone from source:

git clone https://github.com/manojuppala/noobscript.git
cd noobscript
npm install

Your First Program

Create a file hello.noob:

print "Hello World"

Run it:

noob run hello.noob

Or build it to JavaScript:

noob build hello.noob
# Creates hello.js
node hello.js

Try the Examples

Run any of the included examples:

noob run examples/fizzbuzz.noob
noob run examples/calculator.noob
noob run examples/complete-showcase.noob

Getting Started Guide

Step 1: Hello World

The simplest program prints text:

print "Hello, World!"

Step 2: Variables

Store values in variables (no declaration needed):

name = "Alice"
age = 25
score = 95.5

print name
print "Age: " + age

Step 3: Constants

Values that never change:

constant PI = 3.14159
constant MAX_USERS = 100

print PI

Step 4: Making Decisions

Use if and otherwise for conditions:

age = 20

if age >= 18
  print "You can vote!"
otherwise
  print "Too young to vote"
end

You can also use natural language:

score = 95

if score is greater than 90
  print "Excellent!"
end

Step 5: Loops

Repeat a fixed number of times:

repeat 5 times
  print "Hello!"
end

Loop through a range:

for i from 1 to 10
  print i
end

Loop through items:

fruits = ["apple", "banana", "orange"]
for fruit in fruits
  print fruit
end

While loops:

count = 5
while count > 0
  print count
  count = count - 1
end

Step 6: Functions

Define reusable code:

function greet(name)
  print "Hello, " + name
end

greet("Alice")
greet("Bob")

Functions can return values:

function add(a, b)
  return a + b
end

sum = add(10, 20)
print sum  # 30

Step 7: Arrays and Objects

Arrays:

numbers = [1, 2, 3, 4, 5]
print numbers[0]  # First element

for num in numbers
  print num
end

Objects:

person = {
  name: "Alice",
  age: 30,
  city: "New York"
}

print person.name
print person.age

Step 8: Classes

Object-oriented programming:

class Animal
  function speak()
    print "Some sound"
  end
end

class Dog extends Animal
  function speak()
    print "Woof!"
  end
end

Complete Language Reference

Data Types

Numbers:

age = 25
price = 19.99
negative = -10

Strings:

name = "Alice"
greeting = 'Hello World'
combined = "Hello " + "World"

Booleans:

isActive = true
isComplete = false

Null and Undefined:

value = null
notSet = undefined

Arrays:

numbers = [1, 2, 3, 4, 5]
mixed = [1, "hello", true, null]

Objects:

person = {
  name: "Alice",
  age: 30,
  active: true
}

Variables and Constants

Variables:

name = "Alice"
age = 25

Constants:

constant PI = 3.14159
constant MAX_SIZE = 100

Type Annotations (Optional):

name: text = "Alice"
age: number = 25
score: number = 95.5

Operators

Arithmetic:

sum = 10 + 5
difference = 10 - 5
product = 10 * 5
quotient = 10 / 5
remainder = 10 % 3
power = 2 ** 3      # Exponentiation (v1.1.0)

Increment/Decrement (v1.1.0):

counter = 5
counter++    # Increment (now 6)
counter--    # Decrement (now 5)

Comparison:

10 > 5      # Greater than
10 < 20     # Less than
10 >= 10    # Greater than or equal
10 <= 10    # Less than or equal
10 == 10    # Equal to
10 != 5     # Not equal to

Logical:

true and false    # Logical AND
true or false     # Logical OR

Natural Language:

if age is greater than 18
if score is less than 50

Print Output

print "Hello World"
print name
print 42
print "Score: " + score

Comments

# This is a single-line comment
print "Hello"  # Comment after code

Conditionals

Basic If/Otherwise:

if age > 18
  print "Adult"
otherwise
  print "Child"
end

ElseIf Chains (v1.1.0):

if score >= 90
  print "Grade: A"
elseif score >= 80
  print "Grade: B"
elseif score >= 70
  print "Grade: C"
otherwise
  print "Grade: F"
end

Loops

Repeat Loop (Fixed iterations):

repeat 5 times
  print i  # i is the counter (0-4)
end

Range Loop (For):

for number from 1 to 10
  print number
end

for i from 0 to 100
  print i
end

Collection Loop (For-in):

fruits = ["apple", "banana", "orange"]
for fruit in fruits
  print fruit
end

While Loop:

count = 5
while count > 0
  print count
  count = count - 1
end

Loop Control:

# Break - exit loop early
for i from 1 to 10
  if i == 5
    break
  end
  print i
end

# Continue - skip to next iteration
for num from 1 to 10
  if num % 2 == 0
    continue
  end
  print num  # Only odd numbers
end

Functions

function greet(name)
  print "Hello " + name
end

function add(a, b)
  return a + b
end

greet("World")
result = add(5, 3)
print result

Arrays

numbers = [1, 2, 3, 4, 5]
fruits = ["apple", "banana", "orange"]

print numbers[0]

Objects

person = {
  name: "Alice",
  age: 25,
  city: "New York"
}

print person.name  # Alice
print person.age   # 25

Booleans and Null

isActive = true
isComplete = false
value = null
notSet = undefined

if isActive
  print "System active"
end

Break and Continue

# Break - exit loop early
for i from 1 to 10
  if i == 5
    break
  end
  print i
end

# Continue - skip to next iteration
for num from 1 to 10
  if num % 2 == 0
    continue
  end
  print num  # Only odd numbers
end

While Loops

count = 5

while count > 0
  print count
  count = count - 1
end

print "Done!"

Classes

Basic Class:

class Animal
  function speak()
    print "Some sound"
  end
end

Inheritance:

class Dog extends Animal
  function speak()
    print "Woof!"
  end
end

class Cat extends Animal
  function speak()
    print "Meow!"
  end
end

Pattern Matching (Match/Case)

status = "success"

match status
  case "loading"
    print "Please wait..."
  case "success"
    print "Operation completed!"
  case "error"
    print "Something went wrong"
  default
    print "Unknown status"
end

Exception Handling (Try/Catch)

try
  # Code that might throw an error
  result = riskyOperation()
catch error
  print "Error occurred:"
  print error
end

Async/Await

async function fetchData()
  data = await getData()
  return data
end

async function processData()
  result = await fetchData()
  print result
end

Nested Structures

Nested Objects:

user = {
  id: 1,
  profile: {
    name: "Alice",
    email: "alice@example.com"
  },
  settings: {
    darkMode: true,
    notifications: false
  }
}

print user.profile.name
print user.settings.darkMode

Nested Conditionals:

score = 85

if score >= 90
  print "Grade: A"
otherwise
  if score >= 80
    print "Grade: B"
  otherwise
    if score >= 70
      print "Grade: C"
    otherwise
      print "Grade: F"
    end
  end
end

CLI Commands

Build (Compile to JavaScript):

noob build <file>
# Example: noob build hello.noob
# Creates hello.js

Run (Compile and Execute):

noob run <file>
# Example: noob run examples/fizzbuzz.noob

Help:

noob help

Examples

The examples/ directory contains 22+ working examples demonstrating all features:

Basic Examples:

  • hello.noob - Hello World
  • variables.noob - Variables and constants
  • conditionals.noob - If/otherwise statements
  • loops.noob - All loop types
  • functions.noob - Function declarations
  • arrays.noob - Array operations
  • objects.noob - Object literals
  • booleans.noob - Boolean, null, undefined

Advanced Examples:

  • classes.noob - Object-oriented programming
  • match.noob - Pattern matching
  • types.noob - Type annotations
  • while-loop.noob - While loops
  • break-continue.noob - Loop control

New Features (v1.1.0):

  • power-operator.noob - Exponentiation with **
  • increment-decrement.noob - ++ and -- operators
  • elseif.noob - Multiple condition chains
  • modulo.noob - Remainder operations with %
  • advanced-loops.noob - Combining new features
  • new-features.noob - All new features demo

Practical Examples:

  • calculator.noob - Simple calculator
  • fizzbuzz.noob - Classic FizzBuzz
  • complete-showcase.noob - All features demo

Run any example:

noob run examples/power-operator.noob
noob run examples/elseif.noob
noob run examples/fizzbuzz.noob

Project Structure

noobscript/
├── src/                   # Compiler source code
│   ├── lexer/            # Tokenization
│   ├── parser/           # AST generation
│   └── generator/        # Code generation
├── bin/                   # CLI executable
│   └── noob.js           # Command-line interface
├── examples/              # Example programs
├── test.js               # Test suite
└── README.md

How It Works

NoobScript uses a three-stage compiler pipeline:

  1. Lexer - Tokenizes source code into meaningful units (keywords, identifiers, operators, etc.)
  2. Parser - Builds an Abstract Syntax Tree (AST) using recursive descent parsing
  3. Generator - Converts the AST into clean, readable JavaScript code

Example transformation:

NoobScript:

for i from 1 to 5
  print i
end

Compiles to JavaScript:

for (let i = 1; i <= 5; i++) {
  console.log(i);
}

Testing

Run the test suites to verify all features:

node test.js              # Core features
node test-advanced.js     # Advanced features (async, try/catch, match)
node test-new-features.js # New features (objects, booleans, null)

All tests should pass with ✓ marks.

Current Limitations

  1. Variable Reassignment in Nested Scopes: Reassigning variables inside loops/blocks may create new variables instead of updating existing ones. This is being addressed in future releases.

  2. No Type Checking: Type annotations are parsed but not enforced at compile time.

  3. Limited Error Messages: Error reporting is basic; more helpful suggestions coming soon.

Roadmap

Completed ✅:

  • Core compiler (lexer, parser, generator)
  • CLI tool (build, run)
  • All basic features (variables, loops, functions, classes)
  • Advanced features (async/await, pattern matching, try/catch)
  • Objects, booleans, null, undefined
  • Break/continue statements
  • While loops
  • 16 working examples
  • Comprehensive documentation

Future Plans 🚀:

  • Module system (import/export)
  • Language server (LSP)
  • VS Code extension with syntax highlighting
  • Web playground (try NoobScript in browser)
  • Formatter & linter
  • Better error messages with suggestions
  • Source maps for debugging
  • Variable scope improvements

Learning Resources

For AI Assistants:

  • See claude.md for comprehensive technical documentation
  • Contains architecture details, compiler components, and contribution guidelines

For Users:

  • Start with examples/hello.noob
  • Work through examples in order: variables → conditionals → loops → functions → classes
  • Try modifying examples to experiment
  • Check complete-showcase.noob to see all features at once

Contributing

Contributions are welcome! Feel free to:

  • Report bugs - Open an issue with details
  • Suggest features - Propose new beginner-friendly features
  • Submit pull requests - Improve code, docs, or examples
  • Add examples - Create new example programs
  • Improve documentation - Help make learning easier

Guidelines:

  • Keep syntax simple and beginner-friendly
  • Add tests for new features
  • Update documentation
  • Follow existing code patterns

Philosophy

NoobScript follows these core principles:

  1. Concepts Over Syntax - Focus on teaching programming fundamentals
  2. Clarity Over Brevity - Readable code is better than short code
  3. Natural Language - Use words that beginners understand
  4. Progressive Complexity - Start simple, add complexity gradually
  5. JavaScript Interoperability - Easy transition to JavaScript later

"If a beginner can understand it without learning programming punctuation first, NoobScript is doing its job correctly."

FAQ

Q: Who is NoobScript for? A: Absolute beginners who want to learn programming concepts without getting overwhelmed by syntax.

Q: Can I use NoobScript for real projects? A: NoobScript compiles to JavaScript, so it runs anywhere JS runs. However, it's primarily designed for learning.

Q: How do I transition from NoobScript to JavaScript? A: Check the compiled .js files to see how NoobScript code translates to JavaScript. The compilation is very direct and readable.

Q: Does NoobScript support all JavaScript features? A: Not yet. It supports core programming concepts. Advanced JavaScript features may be added in future versions.

Q: Can I mix NoobScript and JavaScript? A: The compiled JavaScript can be used with any JavaScript code. You can import the compiled modules into JS projects.

Acknowledgments

  • Built with JavaScript (ES6+)
  • Uses recursive descent parsing
  • Inspired by beginner-friendly languages like Python and Ruby
  • Compiles to modern JavaScript (ESM)

License

MIT


Made with ❤️ for beginners learning to code

Start your programming journey with NoobScript! 🚀

About

A beginner-friendly programming language that compiles to JavaScript

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors