npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

lunalang

v1.0.2

Published

[![Contributors][contributors-shield]][contributors-url] [![Forks][forks-shield]][forks-url] [![Stargazers][stars-shield]][stars-url] [![Issues][issues-shield]][issues-url] [![MIT License][license-shield]][license-url] [![Linkedin][linkedin-shield]][

Downloads

9

Readme

NOTE: This README.md file temporarily placeholdes the repo, please be patient for the author to document Luna and refer to the code below at the meanwhile.

Luna 🌙  ―  A High-Level Programming language.

Contributors Forks Stargazers Issues

MIT License Linkedin Discord

  • ✅ Added support for asyncronous lambda expressions.
  • ✅ Added "use" statements: use(external as custom) from 'file.lnx'
  • ✅ Improved speed & performance ⚡.
  • ✅ Added embed statements, you can now embed code from other files inside your main file: embed "path/to/file.ln";
  • ✅ Added TapStatements, to execute files without the need to import (performance optimisation): tap "exec/this/code.ln";

Luna is a high-level programming language. It is designed to provide an elegant and productive coding experience for developers. Luna offers a clean and intuitive syntax, making it easier to write efficient and readable code. The language supports a variety of programming paradigms, including procedural, object-oriented, and functional programming styles. Luna is built with a focus on simplicity and productivity, aiming to streamline the development process and enhance developer experience. It provides powerful abstractions and built-in libraries to facilitate common programming tasks.

Luna is an interpreted programming language, which means that code written in Luna is executed directly by an interpreter rather than being compiled into machine code. Here's a high-level overview of how Luna works:

  1. Parsing: When you write Luna code, the interpreter first parses it to understand its structure and syntax. This involves breaking the code into tokens and building an abstract syntax tree (AST) representation.

  2. Semantic Analysis: After parsing, Luna performs semantic analysis. This phase involves analyzing the AST to enforce language rules and perform type checking. The interpreter verifies that the code follows the correct usage of variables, functions, and types, ensuring its correctness.

  3. Execution: Once the code passes semantic analysis, the Luna interpreter begins executing the code line by line. It evaluates expressions, assigns values to variables, and executes control flow statements such as conditionals and loops. During execution, Luna can interact with input and output streams, read from files, and perform other operations as needed.

  4. Runtime Environment: Luna provides a runtime environment that includes built-in functions, libraries, and data structures. Developers can utilize these features to perform common tasks without having to implement them from scratch.

Luna's interpreter handles the execution of code dynamically, allowing for flexibility and quick development cycles. This dynamic nature makes it suitable for scripting tasks and rapid prototyping. It also supports concurrency and asynchronous programming using mechanisms like coroutines or event-driven programming.

Overall, Luna aims to provide an elegant and productive programming experience, enabling developers to write clean and expressive code while leveraging the power of the underlying interpreter to execute their programs efficiently.

Most developers choose us because of the Following Reasons:

  • Luna offers a clean and intuitive syntax that promotes readability and ease of understanding.
  • The language prioritizes simplicity and productivity, allowing developers to write code more efficiently.
  • Luna provides powerful abstractions and built-in libraries, reducing the need for extensive boilerplate code.
  • It supports multiple programming paradigms, including procedural, object-oriented, and functional programming.
  • Luna's focus on elegance and flexibility makes it an excellent choice for building a wide range of applications, from web development to system programming.

Luna's functioning follows a precise sequence: first, the written code undergoes tokenization, breaking it into individual tokens. These tokens are then parsed to form statements, which are organized into an Abstract Syntax Tree (AST). This AST is then preprocessed, embedding any inline code fragments. The interpreter then steps in, evaluating the AST and executing the embedded code, resulting in a final result object known as a Runtime Value. This sequential process ensures that the code's logic is accurately understood, processed, and executed, producing the desired outcomes in Luna's unique programming environment.

Luna Diagram representing the Architecture Overview

Red flags 🚩:

Luna is 7.28x slower than Python (exactly 7.28060546875x)

Relation between the runtime of Luna $(t_{l})$ and the runtime of Python $(t_{p})$ and the Luna-Python Time Scalar $(\Delta_{l,p} \approx 7.28060546875)$

Like so: $t_{p}(t_{l}) = \Delta_{l,p} * t_{l}$

Luna has a max of recursive function call of $n = 2428 \pm \Delta R, \ \ \Delta R \in \mathbb{Z}, \ \ |\Delta R| \approx 1$

UPDATE 🔥: When Compiled, Luna gets 20x faster than Python ⚡!


luna:~$ npm i -g lunascript  # Installation (API & CLI)...
luna:~$ luna --help          # Show Help Menu...
import { Luna, ... } from 'lunascript';

let script = `
  name = input("What's your name? ");
  print("Hello, {name}!")
`;

let luna = new Luna();
let output = luna.run(lunascript);

console.log(output); // object {RuntimeValue}

✱ Functions in Luna:


fn read book {

  print("Reading {book}...")
}

read("Luna Docs") # Reading Luna Docs...

✱ Functions with default values:


fn sum x=(1) y=(1) {
  if isdef x && isdef y: x + y
  else null
}

print(sum(2, 4)) # 6

✱ Constant Definition:


# Defining a constant
pi: const = 3.141

fn area r {
  pi * r ** 2
}

print(area(2))

✱ Reactivity in Luna:


# Reactivity

a = "foo"

b: react<a> = lambda {
  a.replace("o", '')
}

print(b) # "f"

a = "Hellooo" # // Reactivity... b's function got triggered

print(b) # "Hell"

✱ Anonymous functions Assignment:


# User defined function:
fn sum x y {
  x + y
}

# Function assigned to variable
sum = fn sum x y {
  x + y
}

# Anonymous function:

a = lambda x y {
  x + y
}

✱ Actions in Luna 🌙

# Note:
a = "foo"

# is same as:

a: var = "foo"

# Those are called Actions, and the variable's action is "var" by default...

# Constant:
a: const = 2.718

a = 2 # NameError: Assignment to constant variable 'a'.

✱ Use-case of Luna's Reactivity feature:

# Reactivity

x = 1

doubled: react<x> = x * 2

x = 2

print(doubled)   // Output: `4`

✱ Export variables & functions:


// Export function:
out fn sum x y {
^^^
   return x + y  
}         

// Export variable (using the out action):
x: out = 5
   ^^^        

✱ Importing variables & functions:


// Import a module:
use "maths.lnx" as math;

// Import specific components:
use (cos, sin as Sinus, tan, PI as pi) from "math.lnx";   // Modules have extension ".lnx"...


// Call a file without importing it:
tap "file.ln";

// Embedding a file into the current code (code-preprocessor):
embed "file.ln";

✱ Implementing Math in Luna:

$$\Huge e^x = \sum_{n=0}^{\infty} \frac{x^n}{n!}$$


# The Maclaurin series of the exponential function e^x:

use (fact as factorial) from "factorial.lnx"

fn expo x {
  precision = 100
  result = 0

  n = 0
  while n < precision {

    result += x**n / factorial(n)

    n += 1
  }

  result
}

print(expo(0)) # 1

✱ Implementing Luna's reactivity with Math:

$$\Huge \psi(\theta) = \frac{e^{2\theta}}{log(4\theta)} + \theta^2 + 2\theta!$$


use (E as e, factorial, Log as log) from "math.lnx";

theta = 1

psi_theta: react<theta> = (e ** 2 * theta) / log(4 * theta) + theta**2 + factorial(2 * theta)
print(psi_theta)   // Output: `15.2729565249...`

theta = 2
print(psi_theta)   // Output: `68.4570428413...`

You can check Luna documentation here (GitHub).

You can check Luna Application Programming Interface (API) here (GitHub).

Copyright (c) 2022 Luna (https://www.github.com/rhpo/luna) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Written by @rhpo with ❤️.