290 likes | 310 Views
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.
E N D
PWB521 Next-Generation PowerScript Lanuage Xue-song WuStaff Software Engineerxue-song.wu@sybase.com08/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 The differences among them • Type system – static or dynamic • Garbage collection • Compiled or Interpreted • Scripting Language or non-scripting language • Is every thing an object? • Syntax • Efficiency
Mainstream Languages The commonalities among them • Object orientation • Module, package, namespace • General-purpose language • Rich built-in data types • Open to C/C++
Mainstream Languages Why are they successful • 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.
Mainstream Languages Keys to success • 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.
PowerScript What PowerScript is and what it is not • 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
PowerScript The strength of 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
PowerScript Programming Languages Table Source: http://www.theadvisors.com/langcomparison.htm Note: Python and Ruby are not in the original table
PowerScript The weakness of 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”)
PowerScript The direction • 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.
PowerScript The direction in one statement • PowerScript will be a productive general-purpose high-level object-oriented programming language for developing enterprise applications.
New Language Features Package • 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.
New Language Features Declare a package Usage 1 Package mypackage Usage 2 Package FirstLevelPackage.SecondLevelPackage
New Language Features Import a package 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
New Language Features Parameterized constructor • 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)
New Language Features Interface • 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.
New Language Features Declare an interface Public interface IEmployee function string getName() subroutine adjustSalary(real adjustment) event companyClosed() End Interface IDeveloper extends IEmployee subroutine assignProject(string projectName) end
New Language Features Use an interface • 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
New Language Features Other features • User-defined enumerations • Class methods • Bit-wise operations • New data types • Hashtable • List • Regular expression • …
Complier Framework Why compiler 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.
Complier Framework Architecture .NET Importer IImporter Compiler Framework IEmitter .NET Emitter IPSVisitor .NET Compiler IPreprocessor Preprocessor Preprocessor
Complier Framework What does the compiler framework do • 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.
Complier Framework Make use of the compiler 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 • …
Complier Framework Pre-processor • 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 • …
Next-Generation PowerScript Langauge Going forward… • 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
SDN Presents CodeXchange Share PowerBuilder 9 Code and Tools • 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