pikt
pikt copied to clipboard
:art: Image-based poetic programming language.
Ah a language to code by while listening to Pink Floyd - a guy from Reddit
This looks like it belongs on the list of those things I totally want to do if I ever become immortal - another guy from Reddit
Pikt is a pixel-based, Turing complete esoteric programming language that generates fast and lightweight programs out of aesthetically pleasant image sources. Indeed, Pikt's most interesting feature is flexibility: every keyword, statement, function, operator and so on is linked to one - or more - color, which can be easily customized via color schemes.
Pikt compiles executables via the Kotlin compiler, therefore compilation for both JVM and native* targets is available, along with runtime interpretation.
Make sure to check out the wiki to learn how to create your first Pikt program!
* Native support is limited due to the lack of Kotlin/Native libraries and is being discontinued.

A high-performance Fibonacci sequence algorithm.

A prime numbers algorithm.

An insertion sort algorithm.

A string reverser.

A tree that prints "A tree!".
These examples take advantage of custom color schemes.
Click on the examples for a breakdown/explanation.
Table of contents
- Properties
- Settings arguments
- Command arguments
- Building
- Roadmap
Properties
The following properties define parameters needed by Pikt.
Example: java -Dproperty=value -jar pikt.jar -argument.
-
-Dsourcesource image file; -
-Doutputoutput name without extension. It will takesourcename without extension if not specified; -
-Dcolorspath to the.propertiescolor scheme without extension.
Default values will be used if not specified (not recommended); -
-Dtargetscompilation targets divided by a comma. Can bejvm,windows,osxorlinux. Note that Windows and OSX executables can be generated only on those platforms. No compilation will be executed if not specified; -
-Dlibpath to JAR libraries, including the bundledstdlib.jarfile, divided by a comma. If not specified, points by default to./libraries/stdlib.jar; -
-Djvmcompilerpath to the Kotlin/JVM (kotlinc) executable compiler. Required iftargetcontainsjvmor if-interpretis used; -
-Dnativecompilerpath to the Kotlin/Native (kotlinc) executable compiler. Required iftargetcontains a native target; -
-Dprojectoptional path to a project info YAML configuration. -
-Dtaskoptional task name (defined within a project info configuration) to be executed.
Settings arguments
The following arguments enable settings that affect Pikt's behavior.
-
-interpretruns the generated code via the JVM compiler; -
-printoutputprints the generated Kotlin code; -
-nocompileprevents the generation of any executable file; -
-pixelinfoadds information about pixel coordinates to the output code as comments; -
-imgoutput=pathsets the output file for image-generating commands (see below). If not specified, defaults to the source image path followed by a suffix; -
-chainoutputenables output chaining for image-generating commands: the output of a command becomes the input for the next one. It requires-imgoutputto be set.
Command arguments
The following arguments execute tasks and exit when completed.
-
-downloadcompiler=type[,version]downloads the zipped Kotlin compiler for the given platform (jvm,windows,macos,linux).
versiondefaults to1.6.10. -
-createschemecreates a new color scheme with default values.
It automatically appends library colors too, i.e. as the stdlib scheme, loaded from-Dlib; -
-exportschemegenerates a useful color palette image out of the given color scheme; -
-recolorize[=method]creates a copy of the source image (that relies on the default scheme) and adapts it to a custom scheme (specified by-Dcolors).
methoddefines the way properties with more than one color are handled; it can be eitherfirst(default),lastorrandom; -
-standardizecreates a copy of the source image (that relies on a custom scheme) and adapts it to the default scheme; -
-compact[=size]creates a compacted copy of the source image.
Ifsizeis not specified, it will try to create a square-ish image with no whitespaces.
sizecan be defined viaw?h?, where bothwandhare optional (in case one is missing, it will be calculated the same way as before) (e.g.w10h5,w10,h5); -
-decompactcreates a decompacted copy of the source image with a statement per line; -
-standardecompactruns-standardize+-decompact; -
-colorswap=<swaps>swaps colors from the source image.
swapsis defined asfrom1:to1,from2:to2,...wherefromandtoare hexadecimal colors; -
-mask=pathcreates a masked copy of the source image, loading the mask image frompath; -
-strconvert=stringconverts a string into a sequence of RGB (grayscale) values supported by Pikt and prints them out.
See Hello world! for further information.
For instance,-strconvert="Hello Pikt!"prints:
RGB: 72 101 108 108 111 32 80 105 107 116 33
H e l l o P i k t !
-welcomeruns-createscheme,-exportscheme(both oncolors) and-downloadcompiler=jvm. Its output is already zipped in the downloadable archive.
Building
The downloadable archive is already built off the latest GitHub commit.
If you wish to build it yourself from source just run mvn clean install.
As a bonus tip, consider setting your run configuration to execute mvn clean install -pl stdlib -am in order to compile the standard library before launching Pikt.
If you are using IntelliJ IDEA consider importing configuration templates from the runConfigurations folder.
Roadmap
Code
- [x] Variables
- [ ] Constants
- [x] Function calls (both as part of expressions and standalone)
- [x] Function definition
- [x] If / else / if else
- [x] Lambdas (code blocks)
- [x] Operators (equality, logical and arithmetic)
- [x] Loops
- [x] For-each
- [x] Indexed for (for-each +
rangefunction) - [x] While
- [ ] Try/catch
- [x] Structs
- [x] Standard library (work in progress, see CONTRIBUTING for contribution guidelines)
- [x] External libraries support (following certain standards, wiki in progress)
Generation
- [x] Compilation (JVM ~~and Native~~)
- [x] Interpretation (JVM)
- [x] Error handling
- [ ] Runtime information
