pike upplysning

35
Pike UppLYSning [email protected]

Upload: zorion

Post on 05-Jan-2016

27 views

Category:

Documents


2 download

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 Presentation

TRANSCRIPT

Page 1: Pike UppLYSning

Pike UppLYSning

[email protected]

Page 2: Pike UppLYSning

Short History

LPCµLPCCendioRoxen ISpelab

Page 3: Pike UppLYSning

Evolved language

PragmaticLack of basic featuresMany complex/powerful featuresSkewed feature focus

Page 4: Pike UppLYSning

Commercially Driven

Shorter development timeFailure prevention measuresWide platform/system supportSkewed feature focus

Page 5: Pike UppLYSning

Focus

Bitmap graphicsText processingNetworkDatabase

Page 6: Pike UppLYSning

Pike vs. Other Languages

CJavaLISP

PythonC#

Page 7: Pike UppLYSning

Source Code

du –hs : 27Mfind . | wc -l : 2680cvs annotate | wc -l : 610372Aprox. Development cost: $1 million

Page 8: Pike UppLYSning

Hello world

int main(int argc, array argv)

{

write(“Hello world!\n”);

return 0;

}

Page 9: Pike UppLYSning

Programming Paradigms

ImperativeFunctionalObject Oriented

Page 10: Pike UppLYSning

Imperative Programming

Program blocks (if, for, while, case)Case fall throughLabeled breaksSymbol scopes (lexical closure)x,y;

Page 11: Pike UppLYSning

Functional Programming

RecursionWell defined execution order

a = x() || y(); i = i++;

Infix operators are functions `+(1,2,3)

x?y:z

Page 12: Pike UppLYSning

OO-programming

Multiple inheritanceNamed inheritanceOperator overloadingModifiersType comparisons are done according to

the implements-principle (looks-like).All programs are objects

Page 13: Pike UppLYSning

Hello world, again

void create() {

write(“Hello world!\n”);

exit(0);

}

Page 14: Pike UppLYSning

Code environment

C-like syntaxWhite space insensitiveCPP-like preprocessorVersion managementSymbols may use Unicode-characters.

Page 15: Pike UppLYSning

Coding environment

Emacs cc-mode & font-lock-mode supports Pike.

Incremental Pike front end (Hilfe)Unused unbug

Page 16: Pike UppLYSning

Datatyper

Simpe float, int, string, (type)

Complex array, multiset, mapping

Functional function, program, object

Page 17: Pike UppLYSning

float

IEEE float-simulationNaN, InfSpecial compilation needed for double

precision.

Page 18: Pike UppLYSning

int

Arithmetic: +, -, *, /, %Bitwise: |, &, ^, ~Logical: <, >, ==, <=, >=, !0 is false Pike has no maxint.

Page 19: Pike UppLYSning

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]

Page 20: Pike UppLYSning

mapping

([ “a” : 12,

“b” : 22,

“c” : 18 ])

Operators: +, -, |, &, ^, ->, [a]m_delete, indices, valuesforeach(m; string index; int value)

Page 21: Pike UppLYSning

arrays

Operators: +, -, &, |, ^Index operators: [a], [a..b]Aggregate operators: ->, ()Splice operator: @

Page 22: Pike UppLYSning

Array mappings

map(words, sizeof);sizeof(words[*]);

map(words, `+, “\n”);words[*]+”\n”;

row1[*]+row2[*]

Page 23: Pike UppLYSning

multiset

Unordered arraymultiset primes = (< 1, 2, 3, 5, 7, 11 >);

Page 24: Pike UppLYSning

Funktions

int square(int x) {

return x*x;

}

int add(int first, int … rest) {

return `+( first, @rest );

}

Page 25: Pike UppLYSning

Programs

class A {

int a;

void create(int _a) {

a = _a;

}

}

class A (int a) { }

Page 26: Pike UppLYSning

Variabeltyper

Untyped variables (mixed)Simple variable types (int)Complex variable types (int|float)Specified variable types (int(0..1))

Page 27: Pike UppLYSning

Specified types

object(Stdio.File) = Stdio.Filearray(int|string)function(int, void|string : void)array(mapping(string:int(0..127))|float)

Page 28: Pike UppLYSning

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);

Page 29: Pike UppLYSning

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 })

Page 30: Pike UppLYSning

Memory Management

Automatic & adaptiveReference countAdvanced GC

Cyclic references Weak references Reference creation during destruction

Page 31: Pike UppLYSning

Optimizations

Tree optimizationStrength reductionTail recursionPeephole optimizationNative machine code generation

Page 32: Pike UppLYSning

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

Page 33: Pike UppLYSning

Why?

Easy to learn (C/Java resemblance)Powerful data typesCompetitive speed and functionalityBug-suppressingUNIX-like abstraction“clean” code

Page 34: Pike UppLYSning

Why not?

Non-standard language Less support/knowledge/documentation Less modules than some bigger languages

Page 35: Pike UppLYSning

More Information

pike.ida.liu.se