A lightweight, fast embeddable scripting language.
Go to file
2021-06-03 07:40:07 +05:30
build Merge pull request #37 from ThakeeNathees/bug-fixes 2021-06-02 19:53:04 +05:30
cli more comments written throught out the source 2021-06-03 07:40:07 +05:30
docs more comments written throught out the source 2021-06-03 07:40:07 +05:30
src more comments written throught out the source 2021-06-03 07:40:07 +05:30
test more comments written throught out the source 2021-06-03 07:40:07 +05:30
.gitignore yet another import statement refactor 2021-05-19 18:56:36 +05:30
LICENSE initial commit 2021-02-07 13:17:58 +05:30
README.md Merge pull request #36 from ThakeeNathees/docs-improve 2021-06-02 09:24:28 +05:30

Pocketlang is a small (~3000 semicollons) and fast functional programming language written in C. It's syntactically similar to Ruby and it can be learned in less than an hour. Including the compiler, bytecode VM and runtime, it's a standalone executable with zero external dependecies just as it's self descriptive name. The pocketlang VM can be embedded in another hosting program very easily.

The language is written using Wren Language and their wonderful book craftinginterpreters as a reference.

What pocketlang looks like

# Python like import statement.
from lang import clock as now

# A recursive fibonacci function.
def fib(n)
  if n < 2 then return n end
  return fib(n-1) + fib(n-2)
end

# Prints all fibonacci from 0 to 10 exclusive.
for i in 0..10
  print(fib(i))
end

Performance

All the tests are ran on, Windows10 (64bit), ASUS N552VX, Intel Core i7-6700HQ 2.6GHz with 12GB SODIMM Ram. And the language versions are: pocketlang (pre-alpha), wren v0.3.0, python v3.7.4, ruby v2.7.2.

preformance

The source files used to run benchmarks could be found at test/benchmarks/ directory. They were ran using a small python script in the test directory.

Building From Source

It can be build from source easily without any depencency, or additional requirenments except for a c99 compatible compiler, (and an optional build system). It can be compiled with the following command.

GCC

gcc -o pocket cli/*.c src/*.c -Isrc/include -lm -Wno-int-to-pointer-cast

MSVC

cl /Fepocket cli/*.c src/*.c /Isrc/include && rm *.obj

For other compiler/IDE

  1. Create an empty project file / makefile.
  2. Add all C files in the src directory.
  3. Add all C files in the cli directory (not recursively).
  4. Add src/include to include path.
  5. Compile.

If you weren't able to compile it, please report by opening an issue. In addition you can use some of our build scripts (Makefile, batch script for MSVC, SCons) in the build/ directory. For more see build from source docs.

References