49
1/20 Problems Tao He [email protected] @SELAB, SYSU 2010,May About 90 minutes

Problems

  • Upload
    elfinhe

  • View
    190

  • Download
    2

Embed Size (px)

Citation preview

Page 1: Problems

1/20

Problems

Tao [email protected]

@SELAB, SYSU2010,May

About 90 minutes

Page 2: Problems

2/49

Themes

Hackerdom Programming Languages

Page 3: Problems

3/49

Fascinating Problems

“The world is full of fascinating problems waiting to be solved.”

Eric Raymond, How to become a hacker

Eric Raymond. How To Become A Hacker. http://catb.org/~esr/faqs/hacker-howto.htmlEric Raymond. The Cathedral and the Bazaar. http://catb.org/esr/writings/homesteading/

Page 4: Problems

4/49

Hacker

Not Cracker, But Creator Eager to Communicate

Page 5: Problems

5/49

FLOSS community

Not only Free Source But an Efficiency Way

to Communicate, Study and Work Tashi

“Talk is cheap. Show me the code.” Linus

FLOSS: Free-Libre and Open Source Software

Page 6: Problems

6/49

IF NOT OPEN?

Information Inequality Esoterica

Design Patterns No Feedback

Herbert Schiller. Information Inequality: The Deepening Social Crisis in America, Routledge 1995, ISBN 0415907659

Page 7: Problems

7/49

KISS: Keep It Simple and Stupid

“Perfection (in design) is achieved not when there is nothing more to add, but rather when there is nothing more to take away.”

Linux Fid Process Memory

Design Patterns

Page 8: Problems

8/49

Tools

Everything

Page 9: Problems

9/49

Tools

Lingoes

Page 10: Problems

10/49

Tools

Wakoopa

Page 11: Problems

11/49

Tools

SuperMemo

Page 12: Problems

12/49

Thank you!

Page 13: Problems

13/49

Themes

Hackerdom Programming Languages

Page 14: Problems

14/49

Why we use Programming Languages?

For customers To meet their requirements. ( For example , OA

systems) For machine ( Von Neumann Architecture )

Instruction flow Data

Strange, isn’t it ?

Page 15: Problems

15/49

Other Problems

Common Elements in High-Level Languages?

Dynamic ? Syntax, Semantics and Pragmatics ? Semantics and Logic?

Page 16: Problems

16/49

Assembler Language

Page 17: Problems

17/49

Assembler Language

Macro of Machine Code While Programming

Registers Data Seg Code Seg Stack Seg

Von Neumann Architecture Instruction fetch Instruction execute

Page 18: Problems

18/49

We have Data Seg already.Why we need Stack Seg ?

Modules But Stack is manual

Page 19: Problems

19/49

Why we need Modules ?

Recursion Reusability Scope Encapsulation

Page 20: Problems

20/49

Stacks and Modules’ Disadvantages

Time Space: Stack Overflow

Page 21: Problems

21/49

The C Programming Language

Page 22: Problems

22/49

What’s NEW in C

Expressions (Formal Languages, Automaton ) For Instruction

Arithmetic Expressions ( 3+2-5*3 ) Control Flow Expressions ( for, if…else…, ) Function Expressions

For Data Type System

Atom Structure

We have a Compiler now

Page 23: Problems

23/49

Advantages from Expressions

Human For Instruction

Arithmetic Expressions ( 3+2-5*3 ) Control Flow Expressions ( for, if…else…, ) Function Expressions

For Data Type System

Atom Structure

Page 24: Problems

24/49

Advantages from Compiler

Expressions Modules : Stack is Automatic Code Optimization ( Inline, Tail Recursion )

Page 25: Problems

25/49

Compile-time vs. Run-time in C

Compile-time Type Information Function Information

Run-time null

Page 26: Problems

26/49

The C++ Programming Language

Page 27: Problems

27/49

What’s NEW in C++?

Paradigms Class Member Functions Inheritance Hierarchies Virtual Function & Virtual Inherit Template

Page 28: Problems

28/49

Paradigms in C++

Procedural ADT OO

Page 29: Problems

29/49

Class Member Functions

Special Code ___ClsA_Func2(..., ClsA *this)

Page 30: Problems

30/49

Inheritance Hierarchies

Almost Compile-time Virtual: Run-time

Page 31: Problems

31/49

C++ want to be as Efficiency as C

It’s all right for Procedural and ADT But not for OO with Virtual No Run-time Hierarchies Meta-data for

Polymorphism

Page 32: Problems

32/49

Virtual Function: Virtual Function Table

Page 33: Problems

33/49

Inheritance

Single Inheritance Multiple Inheritance Single Virtual Inheritance Multiple Virtual Inheritance

Page 34: Problems

34/49

Virtual Inheritance: Virtual Base Table

Page 35: Problems

35/49

Compile-time vs. Run-time in C++

Compile-time Inheritance Hierarchies Information Function Information

Run-time ( Dynamic ) Virtual Function Table Virtual Base Table

Page 36: Problems

36/49

Cross-Platform in C++?

Source-Level: Yes Cross-Platform is Manual for different OS API

Execution-Level : No

Page 37: Problems

37/49

What is not Efficiency C++?

Run-time Virtual Function Virtual Inheritance

Virtual Base Class without Virtual Function and Data will be optimized.

Java can Multiple Implement Interfaces.

Compile-time Inheritance Hierarchies

Page 38: Problems

38/49

The Java Programming Language

Mark Stoodley. Issues in static and dynamic native Java code compilation. http://www.ibm.com/developerworks/java/library/j-rtj2/index.html

Page 39: Problems

39/49

What’s NEW in Java?

JVM Dynamic Compilation

Page 40: Problems

40/49

虚拟机的好处有什么?

跨平台:在 OS与字节码间隔了一层。实现了程序员无负担的跨平台。

动态编译:许多信息不必在编译后确定,为动态特性提供可能,稍后详细说。

运行时维护着类型信息,甚至可以加载新的类型。( CORBRA依赖这个实现。)

Page 41: Problems

41/49

Java编译执行的过程是怎样的? 

编译后产生一个基于堆栈的字节码 JRE在不同的 OS上提供支持 起初的 JRE是解释执行的,效率低下。

获取待执行的下一个字节码。解码。从操作数堆栈获取所需的操作数。按照  JVM 规范执行操作。将结果写回堆栈。

Page 42: Problems

42/49

Java如何解决执行效率低下问题?

Page 43: Problems

43/49

JIT是怎样运行的呢?

每次按照一个 function来编译 转成中间表示,并优化,转成可执行码 编译线程和执行线程 分析框架 Profiler观察程序行为

例如热点 function内部对象维持一个池。

Page 44: Problems

44/49

动态编译的优点有什么?

学习程序的行为并优化频繁执行的 function——热方法 arrayCopy方法,拷贝大段内存,特殊指令例如类层次结构,多态的优化。

(大多数虚调用都有其固定的一个目标, JIT因此生成的代码比虚表调用代码的效率会更高。)

Page 45: Problems

45/49

动态编译的缺点有什么?

初始编译会影响启动时间。 运行时编译,行为分析需要花费时间。 运行效率达到稳定需要时间。 GUI不能忍受动态编译和 GC带来的延迟。

Page 46: Problems

46/49

Java如何解决实时的需求?

AOT( Ahead-of-time)编译器预先编译成为可执行码

Page 47: Problems

47/49

Page 48: Problems

48/49

Java适合怎样的应用呢?

Java比较时候需要长期运行的应用, Web服务器 Daemon服务

Page 49: Problems

49/49

Thank you!