Title: Arial 28pt. - Downloads - Sybase

bricklayerbelchedInternet και Εφαρμογές Web

5 Φεβ 2013 (πριν από 4 χρόνια και 8 μήνες)

124 εμφανίσεις

PWB521 Next
-
Generation PowerScript Lanuage

Xue
-
song Wu

Staff Software Engineer

xue
-
song.wu@sybase.com

08/xx/2003

Agenda


Mainstream Languages


PowerScript


The strength of PowerScript


The weakness of PowerScript


The future of PowerScript


New Language Features


Package.


Parameterized Constructors


Interface.


Others


Compiler Framework


Architecture of the Compiler Framework.


PB compiler


.NET compiler


Preprocessor


Mainstream Languages


C++


Java


C#


SmallTalk


Eiffel


Perl


Python


Ruby





Mainstream Languages


Type system


static or dynamic


Garbage collection


Compiled or Interpreted


Scripting Language or non
-
scripting language


Is every thing an object?


Syntax


Efficiency


The differences among them

Mainstream Languages


Object orientation


Module, package, namespace


General
-
purpose language


Rich built
-
in data types


Open to C/C++


The commonalities among them

Mainstream Languages


C++: High performance, easy to call system functions, multi
-
paradigm programming, compatible with C, template, etc.


Java: Object
-
oriented, simpler than C++, “write once, run
everywhere”, etc.


Python and Ruby: object
-
oriented scripting language,
dynamic, productive (forgiving syntax), extensible, etc.


Why are they successful

Mainstream Languages


A language should be either efficient or productive, or ideally
both efficient and productive.


Provide ways to deal with complexity.


Extensible.


Syntax should be simple.


Keys to success

PowerScript


A productive language


A interpreted language, similar to Java and C#


A higher level language than Java and C#


Object
-
oriented


Supports garbage collection


Not a scripting language (in a sense)


Not regarded as a general
-
purpose language



What PowerScript is and what it is not

PowerScript


Productive


Rich set of system classes and system functions


DataWindow, DataBase drivers


Embedded SQL


Simple syntax


Less lines of code


Application server integration


Sybase EAServer


Third party application servers


Extensible via C++


PBNI


The strength of PowerScript

PowerScript

Programming Languages Table

Language

Level

Average source statements per
function point

C++

6.00

53

DELPHI

11.00

29

EIFFEL

15.00

21

JAVA

6.00

53

PowerBuilder

20.00

16

Visual Basic 5

11.00

29

Python

15.00?

21?

Ruby

15.00?

21?

Source:
http://www.theadvisors.com/langcomparison.htm

Note: Python and Ruby are not in the original table


PowerScript


Not a general
-
purpose language


Lack of some data types


List


Hashtable





Not easy to write reusable modules using PowerScript itself


Need migration when upgrading to higher version of PB


Does not support package


Some syntax issues


Employee me = create Employee(“xxx”)


The weakness of PowerScript

PowerScript


Better support for team programming efforts


Package


Interface


Even lighter syntax to make programming easier


String str = “This is the first line” +

// no need of &

“This is the second line”


General
-
purpose language


Easily extensible


C++


PowerScript itself


Support both Java and .NET


No need to do migration


Tools for supporting AOP, Design Patterns, Refactoring, Unit
Test, Design by Contracts, etc.

The direction

PowerScript


PowerScript will be a productive general
-
purpose high
-
level
object
-
oriented programming language for developing
enterprise applications.

The direction in one statement

New Language Features


A language feature that allows programmers to organize their
program into sets of modules
.


Help avoid name conflicts.


Support team programming efforts.


Package can be nested
.



Package

New Language Features

Usage 1

Package mypackage


Usage 2

Package FirstLevelPackage.SecondLevelPackage


Declare a package

New Language Features

Usage 1

import system


Usage 2

// import a package (actually a .NET namespace)

import system.text.regularexpressions as st


Regex r = create st.Regex(“abc”)

Match m = r.match("123abc456")

String str

If m.success then


str = “The position of abc is at ” + string(m.index)

end if

Import a package

New Language Features


A language feature that allows programmers to define
constructors with parameters
.


Constructor(string name, int id)


With parameterized constructors, you can create an instance
in several different ways.


Employee e = create employee(“xxx”, 123)


Parameterized constructor

New Language Features


An interface declaration introduces a new reference type
whose members are abstract methods
.


Interfaces can help reduce the couplings between classes
and packages, and improve testibility.


A class can implement more than one interfaces.


Interface

New Language Features

Public interface IEmployee


function string getName()


subroutine adjustSalary(real adjustment)


event companyClosed()

End


Interface IDeveloper extends IEmployee


subroutine assignProject(string projectName)

end

Declare an interface

New Language Features


A class can implement one or more interfaces
.


Interfaces can be used as parameters or return values.


Class Page implements IPrintable


public subroutine print()


public subroutine addItem(IItem item)


Public function IItem getItem(int x, int y)

End


Use an interface

New Language Features


User
-
defined enumerations


Class methods


Bit
-
wise operations


New data types


Hashtable


List


Regular expression





Other features

Complier Framework


To lay a solid foundation for writing the PB p
-
code compiler,
.NET compiler, and Java compiler.


To be able to write utilities, e.g. cross
-
referencing tool, based
on the compiler framework.



Why compiler framework



Pre
-
processor
Parser
Java byte
-
code
generator
P
-
code
generator
.NET IL
generator
Other tools
Instrumented
PS code
PS code
AST
Complier Framework

Architecture

Compiler

Framework

.NET Importer

.NET Emitter

IImporter

IEmitter

.NET Compiler

IPreprocessor

Preprocessor

Preprocessor

IPSVisitor

Complier Framework


Syntactic analysis


Parse the given source code and generate an Abstract Syntax Tree (AST).


Contextual analysis


Identification


Resolve the identifiers, load other classes if necessary.


Type checking


to ensure there is no type error.


What does the compiler framework do

Complier Framework


The compiler framework provides an interface IPSVisitor for
traversing the AST tree.


With the visitor interface and the AST tree, many things can
be done:


Emit PB p
-
code


Emit .NET MSIL


Emit Java byte code


Create a cross
-
reference database


PBDoc like javadoc


Refactoring


Reverse engineering





Make use of the compiler framework

Complier Framework


A pre
-
processor can introduce some keywords to the
PowerScript language.


A pre
-
processor is responsible for translating the keywords
into “real” PowerScript code.


Examples:


Design by Contract


Aspect
-
Oriented Programming




Pre
-
processor

Next
-
Generation PowerScript Langauge


Continue to be a productive language


A general
-
purpose language


More object
-
oriented


A high
-
level language but can do low
-
level things


Support both .NET and Java


Extensible


Lots of utilities

Going forward…

Next
-
Generation PowerScript Langauge

Q & A

SDN Presents CodeXchange


New SDN feature enables community collaboration


Download samples created by Sybase


Leverage contributions of others to exploit PBNI (i.e. PBNI CommonDialog,
PBNI OLEObject utilities)


Contribute your own code or start your own collaborative project with input
from other PowerBuilder experts


Any SDN member can participate


Log in using your MySybase account via SDN


Join the collaboration already underway


http://powerbuilder.codexchange.sybase.com or via SDN at
www.sybase.com/developer


SDN & CodeXchange at TechWave


Technology Boardwalk


Sybase Booth Theater



Share PowerBuilder 9 Code and Tools