forked from perl11/potion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.p2
180 lines (134 loc) · 6.2 KB
/
README.p2
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
~ p2 ~
.ooo
'OOOo
~ p ooOOOo 2 ~
.OOO
oO %% a fast perl5
Oo
'O
`
(o)
___/ /
/` \
/v^ ` ,
(...v/v^/
\../::/
\/::/
p2 is a she. She is a perl5 and possible perl6/nqp backend, based
on why the luck stiff's potion. See README why potion is exciting.
parrot examples/benchmarks/fib.pir 28 1.746s
perl examples/benchmarks/fib.pl 28 0.439s
potion examples/benchmarks/fib.pn 28 0.013s
parrot examples/benchmarks/fib.pir 40 3m36.447s
perl examples/benchmarks/fib.pl 40 2m19.752s
potion examples/benchmarks/fib.pn 40 0m3.512s
Its exciting points for perl folks are:
* Should parse most of perl5, just some XS and B tricks not. Since
the original perl5 testsuite is not usable for other
implementations and compilers it needs to be adjusted. The perl6
testsuite is in a better shape.
* signatures, types, native threads for perl5
* Using most of Damian Conway's p5i recommendations:
i.e. classes are immutable and final by default.
See <http://web.archive.org/web/20040207072905/http://www.yetanother.org/damian/Perl5+i/>
* libp2 should be usable as a fast backend for nqp/perl6.
* Native and fast calling convention, no XS stack args on the heap.
XS is replaced by dlcall (dynamic ffi), and/or shared libraries with
normal function calls into the vm.
* int, str, num are objects, you can optionally type all args and lexical variables.
In fact everything is an object as in parrot, even the compiler, the parser, the vm.
* Sized arrays are non-autovivifying and initialized with undef, resp. if typed 0, 0.0, "".
my $a[3]; print $a[3] => compile-time error: array out of bounds
my int $i[3]; print $a[2] => 0
my num $n[3]; print $n[2] => 0.0
my str $s[3]; print $a[2] => ""
* A new pragma "no magic" applies to all visible objects in scope.
{
no magic;
use Config;
print $Config{'ccflags'};
}
=> compile-time error: Invalid use of tie with no magic
use
{
no magic;
use Config ();
print $Config::Config{'ccflags'};
}
instead.
* p6model: :multi, type-optimizer. Like Moose, just better and much faster
* smartmatch works because all data are typed objects
* Just-in-time compilation for x86, x86-64 and ppc done.
* Intermediate bytecode format and VM. Load and dump code. Decent
speed and cross-architecture. Heavily based on Lua's VM.
* A lightweight generational GC, based on Basile Starynkevitch's
work on Qish. <http://starynkevitch.net/Basile/qishintro.html>
The compiler will add hooks for objects leaving scope and add
DESTROY method calls if they are visible at
compile-time. Run-time created DESTROY method will not be
automatically called.
* Bootstrapped "id" object model, based on Ian Piumarta's soda
languages. This means everything in the language, including
object allocation and interpreter state are part of the object
model. (See COPYING for citations.)
* Interpreter is thread-safe and reentrant. I hope this will
facilitate coroutines, parallel interpreters and sandboxing.
* Small. Under 10kloc. Right now we're like 6,000 or
something. Install sloccount and run: make sloc.
* Reified AST and bytecode structures. This is very important to
me. By giving access to the parser and compiler, it allows people
to target other platforms, write code analysis tools and even
fully bootstrapped VMs. I'm not as concerned about the Potion VM
being fully bootstrapped, especially as it is tied into the JIT
so closely.
* Memory-efficient classes. Stored like C structs. (Although the
method lookup table can be used like a hash for storing arbitrary
data.)
* The JIT is also used to speed up some other bottlenecks. For
example, instance variable and method lookup tables are compiled
into machine code.
However, some warnings:
* Strings are immutable (like Lua) and byte arrays are used for I/O
buffers.
* No floating point support yet.
* No error handling yet.
* No signal handling yet.
~ thankyous ~
why the lucky stiff left the ruby community. potion was his last
public project. It's a work of art and mastership. I could not
think of anything better. I think it is better than go, if potion
would have had added autothreads and channels, float support and
exception handling.
Rob Pike for go, and the parrot community for parrot.
Larry Wall for perl5. We miss his leadership and technical excellence.
Without him nothing got done, and if something was done it was wrong.
Besides defined-or, which left Tom Christiansen behind.
why the lucky stiff thanks:
I am gravely indebted to Basile Starynkevitch, who fielded my
questions about his garbage collector. I favor French hackers
to an extreme (Xavier Leroy, Nicolas Cannasse, Guy Decoux,
Mathieu Bochard to name only a portion of those I admire) and
am very glad to represent their influence in Potion's garbage
collector.
Matz, for answering my questions about conservative GC and
for encouraging me so much. Potion's stack scanning code and
some of the object model come from Ruby.
Steve Dekorte for the Io language, libgarbagecollector and
libcoroutine -- I referred frequently to all of them in
sorting out what I wanted.
Of course, Mauricio Fernandez for his inspiring programming
journal housed at http://eigenclass.org/R2/ and for works
derived throughout the course of it -- extprot most of all.
Many of my thoughts about language internals (object repr,
GC, etc.) are informed by him.
Ian Piumarta for peg/leg. I use a re-entrant custom version
of it, but the original library is sheer minimalist parsing
amazement.
Final appreciations to Jonathan Wright and William Morgan
who pitched in, back in the wee hours of Potion's history.
Tanks.
~ license ~
See COPYING for legal information.
potion is an MIT license, which lets you do anything you want with this.
perl5 code is ARTISTIC and GPL dual licensed,
p2 and perl6 code is ARTISTIC 2 licensed.