pike upplysning
DESCRIPTION
Pike UppLYSning. [email protected]. Short History. LPC µLPC Cendio Roxen IS pelab. Evolved language. Pragmatic Lack of basic features Many complex/powerful features Skewed feature focus. Commercially Driven. Shorter development time Failure prevention measures - PowerPoint PPT PresentationTRANSCRIPT
Pike UppLYSning
Short History
LPCµLPCCendioRoxen ISpelab
Evolved language
PragmaticLack of basic featuresMany complex/powerful featuresSkewed feature focus
Commercially Driven
Shorter development timeFailure prevention measuresWide platform/system supportSkewed feature focus
Focus
Bitmap graphicsText processingNetworkDatabase
Pike vs. Other Languages
CJavaLISP
PythonC#
Source Code
du –hs : 27Mfind . | wc -l : 2680cvs annotate | wc -l : 610372Aprox. Development cost: $1 million
Hello world
int main(int argc, array argv)
{
write(“Hello world!\n”);
return 0;
}
Programming Paradigms
ImperativeFunctionalObject Oriented
Imperative Programming
Program blocks (if, for, while, case)Case fall throughLabeled breaksSymbol scopes (lexical closure)x,y;
Functional Programming
RecursionWell defined execution order
a = x() || y(); i = i++;
Infix operators are functions `+(1,2,3)
x?y:z
OO-programming
Multiple inheritanceNamed inheritanceOperator overloadingModifiersType comparisons are done according to
the implements-principle (looks-like).All programs are objects
Hello world, again
void create() {
write(“Hello world!\n”);
exit(0);
}
Code environment
C-like syntaxWhite space insensitiveCPP-like preprocessorVersion managementSymbols may use Unicode-characters.
Coding environment
Emacs cc-mode & font-lock-mode supports Pike.
Incremental Pike front end (Hilfe)Unused unbug
Datatyper
Simpe float, int, string, (type)
Complex array, multiset, mapping
Functional function, program, object
float
IEEE float-simulationNaN, InfSpecial compilation needed for double
precision.
int
Arithmetic: +, -, *, /, %Bitwise: |, &, ^, ~Logical: <, >, ==, <=, >=, !0 is false Pike has no maxint.
string
string a = “hello \n \” \007 \x4711 world”;string b = #”Line one and line two”;
Shared stringsCharacter range -0x80000000 – 0x7fffffffOperators: +, -, *, /, %, |, &, ^Index operators: [a], [a..b]
mapping
([ “a” : 12,
“b” : 22,
“c” : 18 ])
Operators: +, -, |, &, ^, ->, [a]m_delete, indices, valuesforeach(m; string index; int value)
arrays
Operators: +, -, &, |, ^Index operators: [a], [a..b]Aggregate operators: ->, ()Splice operator: @
Array mappings
map(words, sizeof);sizeof(words[*]);
map(words, `+, “\n”);words[*]+”\n”;
row1[*]+row2[*]
multiset
Unordered arraymultiset primes = (< 1, 2, 3, 5, 7, 11 >);
Funktions
int square(int x) {
return x*x;
}
int add(int first, int … rest) {
return `+( first, @rest );
}
Programs
class A {
int a;
void create(int _a) {
a = _a;
}
}
class A (int a) { }
Variabeltyper
Untyped variables (mixed)Simple variable types (int)Complex variable types (int|float)Specified variable types (int(0..1))
Specified types
object(Stdio.File) = Stdio.Filearray(int|string)function(int, void|string : void)array(mapping(string:int(0..127))|float)
Strict Types
Strict types (#pragma strict_types)Runtime type checking (pike –rt)Soft casts
int(0..30) y = fac(x);
int(0..30) y = [int(0..30)]fac(x);
Casts
(int)”3” 3
(int)”hej” 0
(int)”010hej” 10
(string)007 “7”
(array(int))({ “1”, “2”, “3” }) ({ 1, 2, 3 })
(array(int))”123” ({ 49, 50, 51 })
Memory Management
Automatic & adaptiveReference countAdvanced GC
Cyclic references Weak references Reference creation during destruction
Optimizations
Tree optimizationStrength reductionTail recursionPeephole optimizationNative machine code generation
Benchmark
Java Perl PHP Pike PythonAckermann 16.7 26.6 57.1 5.0 Boom!
Fibonacci 3.1 8.4 12.6 1.6 7.8Method call 2.3 7.7 2.8 8.3Nested loop 7.5 21.9 74.9 0.9 31.2Object inst. 3.7 21.8 3.9 11.0
Sieve 6.7 14.7 49.5 6.8 22.1String concat 2.8 3.0 4.1 3.2 5.1
Arrays 1.8 6.2 13.0 1.4 6.4Lists 5.8 4.2 2.8 6.1
Why?
Easy to learn (C/Java resemblance)Powerful data typesCompetitive speed and functionalityBug-suppressingUNIX-like abstraction“clean” code
Why not?
Non-standard language Less support/knowledge/documentation Less modules than some bigger languages
More Information
pike.ida.liu.se