Skip to content

zcaudate/foundation-base

Repository files navigation

foundation

Installation

Currently clojars deploy is broken. To install jars to .m2 for use in other projects run:

git clone [email protected]:zcaudate/foundation-base.git
cd foundation-base
lein install

std.lang - A Playground for Languages

There are so many languages currently out there is the world. Every single one of them has their own quirks but each are inspired by one another.

std.lang creates an environment where multiple languages and multiple runtimes can be mixed, matched and integrated to get the basic minimum piece of code working.

When the benefits of repl driven development can be made available to any language, programming then becomes about the code itself and not everything around making the code work.

An example working with Javascript in emacs:

captured

Template Base Transpile

The best way to think about std.lang is that it is a convertor from lisp to algol. Algol languages syntactically is about 95% as another algol language. C is not that different from Js, is not that different from Python, is not that different from Solidity. There are differences in terms of types and keywords and whitespace/braces, but in general, the conventions are always present. std.lang provides a lisp dsl for these conventions as well as a method to write one's own grammer to target any language.

Furthermore, robust programs require more than just writing the function. Testing is paramount and there is so much pain when jumping from one language to another due to the fact that one has to relearn all the tooling of a language's eco system to be effective. The advantage of std.lang is to provide a common testing/maintainance strategy across all code → from C to bash to solidity. If a new language needs to be targeted, a grammar and a runtime specific to that language would be suffice to integrate that language into the existing clojure toolchain.

The generated code can be run independently of std.lang, using a language's native toolchain. std.lang only takes care of transpiling lisp to a target language, it doesn't try to do anything more than that. If a client asked you to do a C project. In the past you would probably say ‘no thanks’. But with std.lang, you write in lisp, test the functions in lisp and generate the c files. The client is happy because they get what they want, the lisper is happy because they get to write in lisp, test in lisp and have the same dynamic eval that a lisper expects.

Solidity examples

A runtime/workflow has been developed for live evaluation of solidity code. The tests are more important than the source files and can be walked through form by form. nodejs as well and the ganache, solc, ethers packages will need to be installed. Please see setup for the testing environment.

Dev prerequisites

There are a number of programs needing to be preinstalled for the java environment to shell out to. Not all of them will be needed on your own projects but they will be necessary for running tests in dev.

Please see setup for the testing environment which builds the docker container that is running the base tests. VNC is not needed for desktop testing.

std.lang - overview

std.lang started off as an experimental snippet generator to run bits of lua code on openresty. I was looking around for a lightweight alternative to clojure servers and made the decision because of this epic rant on Quora.

As features crept into the library, it slowly evolved into what it is now. More features were added to the project and it has evolved into a tool for exploration into multi-language/multi-runtime environment, allowing unprecedented control in code manipulation and testing:

  • A standard set of symbols for transpile
  • grammar spec for transpile to the following target languages:
    • lua (production ready)
    • js (production ready)
    • python (somewhat production ready)
    • r (experimetal)
    • c (gpu kernel code)
    • solidity (production ready)
    • bash (experimental)
    • go (seeking implementations)
    • ocaml (seeking implemenations)
    • haskell (seeking implementations)
  • Live eval through pluggable runtimes
    • os (js, python, R, lua, c)
    • graal (js, python)
    • nginx (lua)
    • evm (solidity)
    • jocl (c, gpu kernel)
    • websockets (js, lua, python)
    • browser (js, through chrome driver)
    • blender (python, seeking implementations)
  • xtalk (crosstalk), a template language transpiling across dynamic language targets (lua, js, python)
  • various helpers across different environments
  • js, lua and xtalk utility libaries.

std.lang - walkthroughs

Guided walkthroughs are provided for

std.lang - examples

License

Copyright © 2023 Chris Zheng

This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0.

This Source Code may also be made available under the following Secondary Licenses when the conditions for such availability set forth in the Eclipse Public License, v. 2.0 are satisfied: GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version, with the GNU Classpath Exception which is available at https://www.gnu.org/software/classpath/license.html.