Download presentation
Presentation is loading. Please wait.
Published byともあき ちゃわんや Modified over 6 years ago
1
Giuseppe Attardi Dipartimento di Informatica Università di Pisa
Advanced Programming Giuseppe Attardi Dipartimento di Informatica Università di Pisa
2
Run-time Environments
3
Run-Time Environments
Java Virtual Machine .NET Common Language Runtime Provide a virtual execution environment Exposes a structure organized into elements Not a simple abstraction of physical resources
4
Controlling execution
Avoid damages Install/uninstall is a nightmare Component software?
5
Benefits Programmers Tool Developers Administrators and Users
Use of library and tools Shorter integration time Higher productivity Tool Developers Avoid the need to care about infrastructure and interoperability Administrators and Users Benefit from packages solutions Independence from processors or OS
6
Common Language Infrastructure
Exposes all items in a unified type system Packages elements in self-describing units Loads and resolves interdependencies at runtime Exposes information that allows verifying the type-safety Execution Engine enforces politics Metadata available at runtime enables dynamic and extensible solutions
7
Question Is it feasible to build a runtime common to all programming languages?
8
More in detail Prolog PHP 3 LISP How to implement logic variable?
Can one use the Warren-Abstract-Machine? PHP 3 Why assignment has unusual behavior? LISP How to handle multiple-values?
9
Prolog example append(X, Y, Z) :- append(NIL, Y, Y) :-
append([A . X], Y, [A . Z] ) :- append(X, Y, Z). :- append([a . b . c], [d . e], R) R = [a . b . c . d . e]
10
Prolog backtrack :- append(X, Y, [a . b]) :- append(X, NIL, [a . b])
X = [a] Y = [b] X = [a . b] Y = NIL
11
PHP Assignement $str = ‘Ciao.’; $str2 = $str;
$str{strlen($str) – 1} = ‘!’; echo $str2; $var = $othervar Performs copy of the value of $othervar $var = &$othervar Assignment by reference
12
Control Can we implement tail-recursion in C?
How to handle synchronization? Function pointers? How to invoke an arbitrary function given a list of arguments?
13
General Function Invoker
invoke(fun, argn, arglist) { if (n==0) return f(); else if (n==1) return f(arg[0]); else return fun(arg[0], arg[1], .. , arg[n-1]); }
14
Basic Data Types Strings in C, Pascal and C++ are different
Array in row or column order?
15
Language Interoperability
C# and Cobol bark at each other
16
C# dog using System; public class Dog {
public virtual void RollOver () { Console.WriteLine("Scratch my tummy."); Bark(); } public virtual void Bark () { Console.WriteLine("WOOF WOOF (C#)");
17
Cobol BigDog 000010 CLASS-ID. BigDog INHERITS Dog.
ENVIRONMENT DIVISION. CONFIGURATION SECTION. REPOSITORY. CLASS Dog. OBJECT. PROCEDURE DIVISION. METHOD-ID. Bark OVERRIDE. PROCEDURE DIVISION. DISPLAY "WOOF WOOF (COBOL)". END METHOD Bark. END OBJECT. END CLASS BigDog.
18
Barfing dogs public class Demo { public static void Main() { Dog d = new Dog(); BigDog b = new BigDog(); d.RollOver(); b.RollOver(); } }
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.