GithubHelp home page GithubHelp logo

jarkonik / rocklang Goto Github PK

View Code? Open in Web Editor NEW
20.0 5.0 1.0 283 KB

JIT-compiled programming language. https://jarkonik.github.io/rocklang/

License: MIT License

Rust 100.00%
programming-language language scripting-language scripting script scripts interpreter rust rust-lang rust-language

rocklang's Introduction

Rock

โš ๏ธThe project is at a very early stage, lots of things will not work.

Github all releases Donate Continuous integration codecov Rocklang Discord License: MIT

JIT-compiled programming language.

Getting started

Linux

  1. Copy and paste the following command in a shell:
sudo sh -c 'curl -L https://github.com/jarkonik/rocklang/releases/latest/download/rocklang-ubuntu-latest -o /usr/local/bin/rocklang && chmod +x /usr/local/bin/rocklang'
  1. Create a file named main.rck in a directory of your choice, with following content:
print("Hello from rocklang")
  1. While being in the same directory, that you've created the source file in, run rocklang main.rck from a shell.
  2. You should see text Hello from rocklang printed in your terminal.

Windows

  1. Download and run the installer.
  2. Create a file named main.rck in a directory of your choice, with the following content:
print("Hello from rocklang")
  1. While being in the same directory, that you've created the source file in, run rocklang main.rck from PowerShell or Command Prompt.
  2. You should see text Hello from rocklang printed in your terminal.

MacOS

  1. Copy and paste the following command in a shell:
sudo sh -c 'curl -L https://github.com/jarkonik/rocklang/releases/latest/download/rocklang-macos-latest -o /usr/local/bin/rocklang && chmod +x /usr/local/bin/rocklang'
  1. Create a file named main.rck in a directory of your choice, with the following content:
print("Hello from rocklang")
  1. While being in the same directory, that you've created the source file in, run rocklang main.rck from a shell.
  2. You should see text Hello from rocklang printed in your terminal.

Example

Sample implementation of Sieve of Eratosthenes written in Rock

mem_set = (vec: vec, val: number, n: number): vec => {
	i = 0
	while i < n {
		vec_set(vec, i, val)
		i = i + 1
	}
	vec
}

sieve = (n: number): void => {
	v = vec_new()
	prime = mem_set(v, 1, n + 1)

	p = 2

	while p * p <= n {
		if vec_get(prime, p) == 1 {
			i = p * p
			while i <= n {
				vec_set(prime, i, 0)
				i = i + p
			}
		}

		p = p + 1
	}

	p = 2

	while p <= n {
		if vec_get(prime, p) == 1 {
			print(string(p))
			print("\n")
		}

		p = p + 1
	}
}

sieve(10)

Building from source

  1. Install Rust compiler that supports Rust Edition 2021, along with cargo tool, in your favorite fashion.
  2. Install llvm 13
  3. Run cargo build to build binaries or cargo run examples/sieve.rck to run a sample program.

License

This project is licensed under the terms of the MIT license.

rocklang's People

Contributors

jarkonik avatar joczkowski avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

joczkowski

rocklang's Issues

Passing new vecs as args in one line doesnt work

f = (v: vec): void => {}
f(vecnew())

results in

Call parameter type does not match function signature!
  %vecnew = call double* inttoptr (i64 94312092171168 to double* ()*)()
 double**  call void @fun(double* %vecnew)
LLVM ERROR: Broken function found, compilation aborted!

Copy vecs when assigning

not copying vecs when assigning causes double free, repro case:

mandelbrot = (): void => {
	acc = vecnew()
	if true {
		acc = acc
	}
}

mandelbrot()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.