https://github.com/ThakeeNathees/pocketlang Skip to content Sign up * Why GitHub? Features - + Mobile - + Actions - + Codespaces - + Packages - + Security - + Code review - + Issues - + Integrations - + GitHub Sponsors - + Customer stories- * Team * Enterprise * Explore + Explore GitHub - Learn and contribute + Topics - + Collections - + Trending - + Learning Lab - + Open source guides - Connect with others + The ReadME Project - + Events - + Community forum - + GitHub Education - + GitHub Stars program - * Marketplace * Pricing Plans - + Compare plans - + Contact Sales - + Education - [ ] [search-key] * # In this repository All GitHub | Jump to | * No suggested jump to results * # In this repository All GitHub | Jump to | * # In this user All GitHub | Jump to | * # In this repository All GitHub | Jump to | Sign in Sign up {{ message }} ThakeeNathees / pocketlang * Notifications * Star 553 * Fork 24 A small and fast programming language. thakeenathees.github.io/pocketlang/ MIT License 553 stars 24 forks Star Notifications * Code * Issues 14 * Pull requests 4 * Actions * Projects 0 * Wiki * Security * Insights More * Code * Issues * Pull requests * Actions * Projects * Wiki * Security * Insights master Switch branches/tags [ ] Branches Tags Could not load branches Nothing to show {{ refName }} default View all branches Could not load tags Nothing to show {{ refName }} default View all tags 2 branches 0 tags Code Clone HTTPS GitHub CLI [https://github.com/T] Use Git or checkout with SVN using the web URL. [gh repo clone Thakee] Work fast with our official CLI. Learn more. * Open with GitHub Desktop * Download ZIP Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Go back Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Go back Launching Xcode If nothing happens, download Xcode and try again. Go back Launching Visual Studio Code Your codespace will open once ready. There was a problem preparing your codespace, please try again. Latest commit @lukeed lukeed chore: include nodejs benchmarks (#125) ... 07321cc Jun 23, 2021 chore: include nodejs benchmarks (#125) * chore: include nodejs benchmarks; - Related #124 * chore: fix `factors.js` typo 07321cc Git stats * 186 commits Files Permalink Failed to load latest commit information. Type Name Latest commit message Commit time .github/workflows docstring for pocket functions implemented Jun 18, 2021 cli Native types & File object implementations. Jun 22, 2021 docs yet another docs update (#115) Jun 23, 2021 src add elem in map (#121) Jun 23, 2021 tests chore: include nodejs benchmarks (#125) Jun 23, 2021 .gitignore .DS_Store is usually from macOS & .idea/ is IntelliJ products (#123) Jun 23, 2021 AUTHORS AUTHORS: add alexcpatel to authors Jun 16, 2021 LICENSE initial commit Feb 7, 2021 Makefile class implemented Jun 21, 2021 README.md yet another docs update (#115) Jun 23, 2021 build.bat scons script removed and build scripts refactored Jun 17, 2021 View code What pocketlang looks like Try It Now Documentation Performance Building From Source GCC / MinGw / Clang (alias with gcc) MSVC Makefile Windows batch script For other compiler/IDE References README.md [117528974-88fa8d00-aff2-11eb-8001-183c14786362] Pocketlang is a small (~3000 semicolons) and fast functional language written in C. It's syntactically similar to Ruby and it can be learned within 15 minutes. Including the compiler, bytecode VM and runtime, it's a standalone executable with zero external dependencies 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 Crafting Interpreters 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 Try It Now You can try pocketlang on your browser. It's a WebAssembly build of the VM compiled using emscripten. Note that in the webassembly version of the language, some features (input, file handling, relative import, etc.) have disabled, has limited memory allocations, and the stdout calls might be slower. Documentation The pocketlang documentation is hosted at https:// thakeenathees.github.io/pocketlang/ which is built from the docs branch generated by a little python script at docs/generate.py. Note that the documentations are WIP and might not be up to date. Performance Pocketlang supports tail call optimization. When a function returns a call, the callee can re-use the caller's stack frame, this will optimize memory from O(n) to O(1) and for tail recursive it'll completely prevent stackoverflows and yet it's faster than tco disabled. All benchmarks below were executed 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 can be found at test/ benchmarks/ directory. They were executed using a small python script in the test directory. Building From Source It can be build from source easily without any dependencies, or additional requirements except for a c99 compatible compiler. It can be compiled with the following command. GCC / MinGw / Clang (alias with gcc) gcc -o pocket cli/*.c src/*.c -Isrc/include -lm MSVC cl /Fepocket cli/*.c src/*.c /Isrc/include && rm *.obj Makefile make To run make file on windows with mingw, you require make and find unix tools in your path. Which you can get from msys2 or cygwin. Run set PATH=;%PATH% && make, this will override the system find command with unix find for the current session, and run the make script. Windows batch script build You don't have to run the script from a Visual Studio .NET developer command prompt, It'll search for the MSVS installation path and setup the build environment. 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 us report by opening an issue. References * Bob Nystrom.(2021) craftinginterpreters [online] Available at www.craftinginterpreters.com/ (Accessed January 2021) * Mark W. Bailey, Nathan C. Weston (June 2001) Technical report. Performance Benefits of Tail Recursion Removal in Procedural Languages [online] Available at http://cs.hamilton.edu/~mbailey/ pubs/techreps/TR-2001-2.pdf * Leonard schutz.(2020) Dynamic Typing and NaN Boxing [online] Available at https://leonardschuetz.ch/blog/nan-boxing/ (Accessed December 2020) * Bob Nystrom.(2011) Pratt Parsers: Expression Parsing Made Easy [online] Avaliable at http://journal.stuffwithstuff.com/2011/03/ 19/pratt-parsers-expression-parsing-made-easy/ (Accessed December 2020) * Carol E. (Wolf of Pace University), P. Oser. The Shunting Yard Algorithm [online] Available at http:// mathcenter.oxford.emory.edu/site/cs171/shuntingYardAlgorithm/ (Accessed September 2020) About A small and fast programming language. thakeenathees.github.io/pocketlang/ Topics c language programming-language vm functional interpreter scripting-language bytecode-compiler Resources Readme License MIT License Releases No releases published Packages 0 No packages published Contributors 11 * @ThakeeNathees * @xSavitar * @TiagoCavalcanteTrindade * @ekinbarut * @Timwi * @tsujp * @lukeed * @dmitryguzeev * @alexcpatel * @Takashiidobe * @ntnlabs Languages * C 94.5% * Python 3.2% * Batchfile 1.2% * Other 1.1% * (c) 2021 GitHub, Inc. * Terms * Privacy * Security * Status * Docs * Contact GitHub * Pricing * API * Training * Blog * About You can't perform that action at this time. You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.