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, dynamically typed, Turing complete esoteric programming language able to generate fast and lightweight programs out of aesthetically pleasant image sources.
Indeed, Pikt's most interesting feature is flexibility: every keyword, statement, function and operator
is linked to one - or more - color, easily customizable via color schemes.
Pikt compiles executables via the Kotlin compiler, therefore compilation for both JVM and native* targets is available, along with runtime interpretation.
Want to create your first Pikt program? Check out the wiki!
A high-performance Fibonacci sequence algorithm.
A prime numbers algorithm.
A FizzBuzz 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.
The following properties define parameters needed by Pikt to run.
Syntax: java -Dproperty=value -jar pikt.jar -arguments.
-
-Dsourcesource image file; -
-Doutputoutput name without extension. Defaults to the value ofsourceif 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. Onlyjvmis supported, whilewindows,osxandlinuxcompilation is currently disabled. -
-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; -
-Dprojectoptional path to a project info YAML configuration. -
-Dtaskoptional task name (defined within a project info configuration) to be executed.
The following arguments enable settings that affect Pikt's behavior.
-
--interpretruns the generated code via the JVM compiler; -
--printoutputdisplays 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. -
--pl[=type]sets the active pixel logger type. A pixel logger is responsible for printing pixels on screen, for example in case of compile-time errors.
Available types:none,16,256,rgb,box.
Iftypeis not specified,256is used.Click to see more...
-
none: pixel logging is disabled (default). -
16: each pixel is a square whose color is approximated to the closest ANSI 16 color. -
256: each pixel is a square whose color is approximated to the closest ANSI 8-bit (256) color. -
rgb: each pixel is a square with its RGB color. Not all terminals support this. -
box: each pixel is an ASCII box with its hex code inside.
-
The following arguments execute tasks and exit when completed.
These are handy shortcuts that replace several manual actions, such as image transformations, while being unrelated to code generation and compilation.
-
downloadcompiler=type[,version]downloads the zipped Kotlin compiler for the given platform (jvm,windows,macos,linux).
versiondefaults to1.9.21. -
createschemecreates a new color scheme with default values.
It automatically appends library colors too, e.g. 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 with no whitespaces between pixels.
Ifsizeis not specified, it will try to create a square-ish image.
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 one statement per line; -
standardecompactrunsstandardize+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[=string]converts a string into a sequence of RGB (grayscale) values supported by Pikt and prints them out.
Ifstringis not specified, input is read from stdin.
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 ! -
welcomerunscreatescheme,exportscheme(both oncolors),downloadcompiler=jvmand creates a ready-to-use Hello World source. Its output is already zipped in the downloadable archive; -
helpshows these commands.
More in-depth information about image transformation commands can be found here.
The downloadable archive is already built off the latest GitHub commit.
If you wish to build it yourself from source simply run mvn clean install.
Tip: setting your run configuration to execute
mvn clean install -pl stdlib -amcompiles the standard library before launching Pikt, in case you need to make frequent updates to it.
If you are using IntelliJ IDEA consider importing configuration templates from the runConfigurations folder.
Code
- Variables
- Constants
- Function calls (both as part of expressions and standalone)
- Function definition
- If / else / if else
- Lambdas (code blocks)
- Operators (equality, logical and arithmetic)
- Loops
- For-each
- Indexed for (for-each +
rangefunction) - While
- Try/catch
- Structs
- Standard library (work in progress, see CONTRIBUTING for contribution guidelines)
- External libraries support (following certain standards, wiki in progress)
Generation
- Compilation (JVM
and Native*) - Interpretation (JVM)
- Error handling
- Runtime information
* Native support is limited due to the lack of Kotlin/Native libraries and is being temporarily discontinued. Bringing it back is planned in the long term.













