-
Notifications
You must be signed in to change notification settings - Fork 12
/
README
150 lines (108 loc) · 4.76 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
_
___ ___| |
/ __|_ / |
\__ \/ /| |
|___/___|_|
Overview
========
szl is a tiny, embeddable scripting engine inspired by Tcl and shell. It's a
balanced mix of their key features: szl combines the simplicity of shell
scripting with the power of a dynamic, Tcl-like type system, minimalistic
syntax and programming language features missing in the shell, like exceptions
and OOP.
szl comes with a rich standard library that includes bindings for
permissively-licensed libraries. Therefore, it can run processes, parse text
with transparent Unicode support, manipulate data structures like dictionaries,
operate on binary data, interface with C code through scripts, multiplex
non-blocking I/O at scale, call REST APIs and much more, at a fraction of the
memory and size footprint of other scripting languages, while achieving
reasonable efficiency.
szl can be used both as a standalone (either interactive or non-interactive)
interpreter or as an integral part of other projects, via the libszl library. In
addition, the feature set and behavior of szl can be easily fine-tuned to meet
the size and memory consumption limitations under various usage scenarios and
hardware platforms.
___________________________________
/ \
| >>> $global msg {Hello, world!} |
| Hello, world! |
| >>> $load zlib |
| >>> $zlib.crc32 $msg |
| 3957769958 |
| >>> [$exec {uname -s}] read |
| Linux |
| >>> [$open /bin/gunzip rb] read 9 |
| #!/bin/sh |
| >>> $map i [$range 1 4] {$+ $i 3} |
| 4 5 6 |
\___________________________________/
For more information, see the user manual at http://dimakrasner.com/szl.
Building
========
On Debian (http://www.debian.org) based distributions:
$ apt-get install git gcc meson zlib1g-dev libcurl4-gnutls-dev libarchive-dev
libssl-dev libffi-dev
Then:
$ git clone --recursive https://github.com/dimkr/szl
$ cd szl
$ meson build
$ cd build
$ ninja
$ ninja install
By default, szl is built with core functionality built-in to the interpreter,
while a big part of the standard library resides in dynamically-loaded shared
objects. This way, the memory consumption of szl scripts that don't use the
entire standard library is lower.
However, in some use cases (for example, when szl is embedded into another
project), this is undesirable.
To build szl as a single executable file, with all extensions linked statically
into the interpreter:
$ mesonconf -Dbuiltin_all=true
In addition, built-in extensions can be chosen individually, e.g.:
$ mesonconf -Dwith_curl=builtin -Dwith_ffi=no
Embedding
=========
To embed szl into other projects, use the API defined in szl.h and link with
libszl.
The size and performance of szl can be tuned using advanced build options:
$ mesonconf -Duse_int=true
This build option replaces the large integer type used by szl to represent
integers, to the standard C int. This may improve performance under platforms
without native support for 64 bit integers, at the cost of a limited range of
valid integer values.
$ mesonconf -Duse_float=false
This build option changes the precision of floating-point numbers in szl from
double to single precision. This may improve performance under platforms without
native support for double-precision floating point numbers, at the cost of
precision.
$ mesonconf -Dwith_float=false
This build options disables support for floating-point arithmetic. This reduces
szl's size.
$ mesonconf -Dwith_unicode=false
This build options disables support for Unicode strings and cancels szl's
internal distinction between encoded byte strings and arrays of Unicode code
points. This reduces szl's size and may improve performance with zero side
effects, if szl is guaranteed not to perform any sort of Unicode string slicing.
Security
========
Support for dynamic loading of szl extensions can be disabled:
$ mesonconf -Dwith_dl=false
When dynamic loading is disabled, szl will refuse to load extensions, unless
they are linked statically into the interpreter.
This way, a szl interpreter embedded into another program does not make it
vulnerable to dynamic loader hijacking (e.g. LD_LIBRARY_PATH) during extension
loading.
Running
=======
To run an interactive interpreter:
$ szlsh
Or, to run a script:
$ szl $path
Or, to run a one-liner:
$ szl -c $snippet
Credits and Legal Information
=============================
szl is free and unencumbered software released under the terms of the MIT
license; see COPYING for the license text. For a list of its authors and
contributors, see AUTHORS.
The ASCII art logo at the top was made using FIGlet (http://www.figlet.org/).