All Projects → denkspuren → consize

denkspuren / consize

Licence: other
Consize is a concatenative programming language

Programming Languages

clojure
4091 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to consize

wok
Compiler that has been integrated into Okami now
Stars: ✭ 21 (-22.22%)
Mutual labels:  concatenative, concatenative-language, concatenative-programming-language
malluscript
A simple,gentle,humble scripting language for mallus, based on malayalam memes.
Stars: ✭ 112 (+314.81%)
Mutual labels:  programming, interpreter
danube
The Danube Programming Language
Stars: ✭ 33 (+22.22%)
Mutual labels:  programming, interpreter
j2
j2 is a minimalist concatenative programming language that makes up for its simplicity by its ability to natively bind with C libraries' ABI *and types*, *without glue*
Stars: ✭ 37 (+37.04%)
Mutual labels:  interpreter, concatenative
charm
A [ functional stack ] based language.
Stars: ✭ 26 (-3.7%)
Mutual labels:  interpreter, concatenative-language
30-seconds-of-git
Short git snippets for all your development needs
Stars: ✭ 235 (+770.37%)
Mutual labels:  programming
vonuvoli-scheme
vonuvoli Scheme -- an R7RS interpreter written in Rust focused on systems programming and scripting (i.e. processes, file-system, etc.) with performance and safety in mind
Stars: ✭ 81 (+200%)
Mutual labels:  interpreter
psolving-paradigms
Common problems of dynamic programming methods and techniques, including prerequisites, for competitive programmers.
Stars: ✭ 34 (+25.93%)
Mutual labels:  programming
python-agentspeak
A Python-based interpreter for the agent-oriented programming language JASON
Stars: ✭ 32 (+18.52%)
Mutual labels:  interpreter
codemirror-blocks
A library for building language-specific, CodeMirror-friendly editors that are a11y-friendly.
Stars: ✭ 22 (-18.52%)
Mutual labels:  programming
semver-generator
Semantic version generator using git commit keywords and overrides
Stars: ✭ 26 (-3.7%)
Mutual labels:  programming
color-math
Expressions to manipulate colors.
Stars: ✭ 18 (-33.33%)
Mutual labels:  interpreter
FunctionLibrary
A library to learn Algorithms and Data Structures for newbies
Stars: ✭ 13 (-51.85%)
Mutual labels:  programming
openroberta-lab
The programming environment »Open Roberta Lab« by Fraunhofer IAIS enables children and adolescents to program robots. A variety of different programming blocks are provided to program motors and sensors of the robot. Open Roberta Lab uses an approach of graphical programming so that beginners can seamlessly start coding. As a cloud-based applica…
Stars: ✭ 98 (+262.96%)
Mutual labels:  programming
scilab
Open source, cross-platform numerical computational package and a high-level, numerically oriented programming language.
Stars: ✭ 52 (+92.59%)
Mutual labels:  programming
ilrx
I Love Ruby Examples
Stars: ✭ 35 (+29.63%)
Mutual labels:  programming
python hacks
Приёмы при написании python-программ
Stars: ✭ 69 (+155.56%)
Mutual labels:  programming
SBTCVM-Gen2-9
SBTCVM is a virtual machine implementation of a balanced ternary (base 3) computer. Features several compiled languages for ternary software development.
Stars: ✭ 32 (+18.52%)
Mutual labels:  programming
mlang
My toy programming languages
Stars: ✭ 36 (+33.33%)
Mutual labels:  interpreter
fcal
Extensive math expression evaluator library for JavaScript and Node.js
Stars: ✭ 86 (+218.52%)
Mutual labels:  interpreter

Consize

Consize is a concatenative programming language. It is a close relative to the Factor programming language. The word "Consize" is intentionally misspelled, it is a combination of the words "concatenative" and "size". Concatenative programs tend to be concise and small in size.

I designed Consize for research purposes and for educational purposes. For example, Consize is used in my masters course "Kernel Architectures in Programming Languages" (Kernel-Architekturen in Programmiersprachen) at the Department of Mathematics, Natural Sciences and Informatics, University of Applied Sciences Mittelhessen (Technische Hochschule Mittelhessen), Germany.

Consize comes with comprehensive documentation explaining the concatenative paradigm, the interpreter and the built-in library, the so called prelude. The documentation is written in German, since my German students are my primary target audience. Though English is the lingua franca in informatics, it is a barrier to learn new concepts of an uncommon programming paradigm in a foreign language. Nonetheless, I might consider rewriting the documentation in English. Until then consider using e.g. Google's website translator with the markdown variant of the documentation (thanks a lot to @Liverm0r for producing the markdown version for that purpose).

I feel always thrilled by the fact that the raw interpreter is no more than 150 lines of code written in Clojure. Basically, Consize is written in Consize and bootstrapped from a small image, which has also been produced by and with Consize.

Regarding conciseness: Consize has numerous words for functional programming, most words being composed of one, two or three lines of code; Consize comes with a unit test framework implemented in eight lines of code; you can set breakpoints and step through the code for debugging purposes implemented in three lines of code; serialization and producing image dumps comes also in some few lines. Do you have an interest in meta-programming? Not only has Consize a meta-protocol to handle unknown words, but continuations which allow you to manipulate the future of computations -- continuations are used to implement an ad hoc parser to extend the grammar of Consize.

Whet your appetite? You might head over reading the documentation first.

Enjoy,

Dominikus Herzberg, @denkspuren https://www.thm.de/mni/dominikus-herzberg

Installation

Consize is implemented in Clojure. Since Clojure depends on the Java Virtual Machine, the JVM, the first two installation steps are:

  1. Install the JVM on your computer. Visit java.com, download the installer and execute it.
  2. Go to clojure.org and install Clojure. Follow the instructions for your operating system, see "Getting started".

Check, if Clojure can be executed on your computer. Open a command shell (on Windows, the powershell is used) and try, if Clojure starts up. Be patient on a slow computer.

PS C:\Users\Dominikus> clj
Clojure 1.10.3
user=>

If Clojure is running on your computer, that's great. Proceed with the installation of Consize. To quit Clojure press the Control key Ctrl (or Strg on a German keyboard) and C. If Clojure does not work on your computer, consult an expert or get some help on the Web.

For Consize, either clone the GitHub repository or download the code as a zip-file and unzip it. Change to /src in the consize folder. The following files are essential:

  • consize.clj -- that's the Consize VM implemented in Clojure
  • bootimage.txt -- required by Consize to process the prelude
  • prelude-plain.txt -- the prelude provides a basic infrastructure for programming in Consize.
  • prelude.txt -- a serialized version of the prelude, which is faster to load
  • prelude-test.txt -- a suite of test cases checking if everything is working properly

Type the following in your command line:

clj -M consize.clj "\ prelude-plain.txt run say-hi"

For shorter start-up time, you might also run:

clj -M consize.clj "\ prelude.txt run say-hi"

Be careful to correctly reproduce the above line. On a slow computer you might need to wait some few seconds to see Consize displaying:

This is Consize -- A Concatenative Programming Language
>

Excellent, you are done. You successfully installed Consize!

Some First Steps in Consize

For example, type in

> 2 3 +
5
> clear

> 2 5 [ 1 + ] bi@
3 6
clear

To define the factorial function:

> : ! ( n -- n! ) dup 0 equal? [ drop 1 ] [ dup 1 - ! * ] if ;

> 4 !
24
> 6 !
24 720

Run the suite of unit tests to check if everything works as expected.

\ prelude-test.txt run

To quit Consize type exit.

Read the documentation to understand how Consize works and how programming in Consize is done.

If you are interested in doing some research on concatenative programming, see my announcement (in German): Compiler-Optimierung durch partielle Interpretation umgesetzt für die konkatenative Sprache Consize; this might result in a beautiful master thesis ;-)

For your convenience, you might want to create a batch file on Windows or a shell script on Linux/OS X. On Windows my batch file named consize.bat looks like this:

@echo off
powershell clj -M consize.clj "\ prelude-plain.txt run say-hi"
pause

All I have to do is to click on consize.bat and Consize is started.

How to Extract the Prelude from the Documentation?

The prelude is a Consize program extending Consize considerably for practical use. Without the prelude there is no interactive console to interact with (called the REPL, Read Evaluate Print Loop), there are no means to define new words etc. You wouldn't have much fun with Consize without the prelude.

The prelude is written as a literate program (see literate programming), that means the code is embedded in its documentation. Literate programming is a technique to keep the documentation and the code in sync.

Have a look at Consize.Prelude.tex and watch out for lines starting with either >> oder %>>; the %-sign marks a comment in LaTeX. All these lines make up the prelude (with the marking prefix removed).

To extract the prelude from the documentation, you do not need a special program, Consize has the word undocument for that.

There is no need to extract the prelude if you are not interested in updating and/or extending Consize. Consize is delivered with "batteries included", i.e. with a prelude and a tiny bootimage. So you might stop here and just enjoy running and using Consize.

Run Consize and type the following in the REPL; the word slurp reads a file, the word spit writes a file.

> \ ../doc/Consize.Prelude.tex slurp undocument \ new.prelude-plain.txt spit

You will find a file named new.prelude-plain.txt in your /src directory. You can restart Consize with the new prelude. Leave Consize with entering exit and restart Consize on the command line interface:

> clj -M consize.clj "\ new.prelude-plain.txt run say-hi"

To produce an image of the current status of the dictionary, type

This is Consize -- A Concatenative Programming Language
> get-dict \ new.prelude-dump.txt dump

The image file new.prelude-dump.txt loads faster than the plain source code file new.prelude-plain.txt. The reason is that the source code requires syntactic preprocessing to fill the dictionary with word definitions whereas the image file just reconstructs the dictionary.

It's a good idea to verify whether something is broken. Run the test suite with each version of the Prelude, new.prelude-plain.txt and new.prelude-dump.txt. Start each version separately, run the tests, exit for testing the other version.

> clj -M consize.clj "\ new.prelude-plain.txt run say-hi"
This is Consize -- A Concatenative Programming Language
> \ prelude-test.txt run
> clj -M consize.clj "\ new.prelude-dump.txt run say-hi"
This is Consize -- A Concatenative Programming Language
> \ prelude-test.txt run

If you want to, you can also generate bootimage.txt. The bootimage is a dump of a minimalistic directory that includes all the word definitions required to load the prelude. To produce the bootimage type the following in the REPL; take care, the current version of the bootimage gets overwritten by that -- you might create a copy beforehand.

> bootimage

After that, run both versions of Consize again (plain file and image file) and run the test suite one more time. If there are no problems, you are almost done.

Delete the old versions of the prelude and rename the ones you have created:

  • rename new.prelude-plain.txt to prelude-plain.txt
  • rename new.prelude-dump.txt to prelude.txt

Congratulations, you are done!

By the way, did you notice that we had to use a running version of the prelude and the bootimage to extract a new version of the prelude from the documentation and generate a fresh bootimage afterwards? This is a typical process for image-based self-referential implementations. Otherwise you would have to extract the prelude by hand and to generate the bootimage by hand -- which I did for the very first incarnation of the bootimage.

Generate the Documentation

If you have no interest in updating the documentation, skip this section!

To produce the PDF document yourself, install a TeX distribution on your computer such as MikTeX for Windows. Start the compilation process with Consize.tex. On Windows you might use TeXworks for that purpose, which is released with MikTeX.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].