dynamic languages n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Dynamic Languages PowerPoint Presentation
Download Presentation
Dynamic Languages

Loading in 2 Seconds...

play fullscreen
1 / 32

Dynamic Languages - PowerPoint PPT Presentation


  • 111 Views
  • Uploaded on

Extending .NET Applications Fairfield/Westchester Code Camp 2010 2010-11-06 John C. Zablocki Development Lead, MagazineRadar Adjunct, Fairfield University. Dynamic Languages. 8:30 AM. On a Saturday. Stamford, CT. Agenda. Dynamic vs. Static Languages Dynamic Language Runtime (DLR)‏

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Dynamic Languages' - nishi


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
dynamic languages

Extending .NET Applications

Fairfield/Westchester Code Camp 2010

2010-11-06John C. Zablocki

Development Lead, MagazineRadar

Adjunct, Fairfield University

Dynamic Languages
agenda
Agenda

Dynamic vs. Static Languages

Dynamic Language Runtime (DLR)‏

Use Cases for Script Hosting

DLR Hosting API

Sample: Boo

Sample: IronRuby

Sample: IronPython

Questions

static vs dynamic languages
Static vs. Dynamic Languages

Static Languages

Type safety

Compile-time checking

Runtime performance

Dynamic Languages

Late bound

Loosely typed

Highly expressive

dynamic language runtime
Dynamic Language Runtime

Language implementation services

Language interoperability

Shared dynamic type system

Runtime services

Fast dynamic code generation through various caching mechanisms

Utilities to allow statically typed objects to share in the dynamic message passing protocol

script hosting use cases
Script Hosting Use Cases

Why would you want to host a scripting language in your application?

Provide extensibility (the obvious answer)‏

Replace complicated XML configuration (e.g. NAnt, EntLib, etc.) with meaningful code

Remove clutter from core application logic (validation, sanity checks, etc.)‏

Maintain transient logic outside of core application code (rules processing)‏

hosting api
Hosting API

ScriptRuntime

Starting point for hosting

Represents global script state (referenced assemblies, available engines, etc.)

Bound scopes (named globals)‏

Constructed with ScriptRuntimeSetup, which uses configuration settings

hosting api1
Hosting API

ScriptEngine

Represents a DLR language implementation (PythonEngine, RubyEngine)‏

One engine, per-language, per-runtime

Methods to execute code and create ScriptScope instances

hosting api2
Hosting API

ScriptScope

Essentially represents a namespace

Unit of isolation within a runtime

Has language affinity

Variables may be set and retrieved at scope

ScriptRuntime.Globals is actually an instance of a ScriptScope

hosting api3
Hosting API

ScriptSource

Represents source code

Provides means for code execution and compilation

Created from ScriptEngine or ScriptScope instances

slide17

“The Gang Learns About

The (Iron)Python

Programming Language...”

the iron python language
The (Iron)Python Language

CLI implementation of the Python language

Hosted on CodePlex

Integration with many common Python libraries

Built on top of the DLR

ironpython in 60 seconds

from System import *

class Message(object):

def __init__(self, message):

self._message = message

def get_message(self):

return self._message

message = property(get_message)

@property

def audience(self):

return self._audience

@audience.setter

def audience(self, audience):

self._audience = audience

def show_message(self, message_formatter):

print message_formatter(self.message, self.audience)

IronPython in 60 Seconds
m message hello m audience world m show message lambda message audience s s message audience
m = Message(“Hello”)

m.audience = “World”

m.show_message(lambda message, audience: “%s, %s!” % (message, audience))

IronPython in 60 Seconds
slide23

“The Gang Learns

About The Boo

Programming Language...”

the boo language
The Boo Language

Object oriented, statically typed language built for the CLI

Has a Python-like feel (whitespace matters)‏

Supports Duck typing (dynamic-like behavior)‏

Flexible syntax, InteractiveInterpreter and extensible compiler makes boo a good choice for DSL implementations

slide26

Boo in 60 Seconds

import System

class Message(object):

def constructor(message):

_message = message

[Getter(Message)]

_message as string

[Property(Audience)]

_audience as string

def show_message(message_formatter as callable):

print message_formatter(_message, _audience)

slide27

Boo in 60 Seconds

m = Message("Hello", Audience: "World")

m.show_message def(message, audience):

print "${message}, ${audience}!"

resources
Resources

http://www.codevoyeur.com – my code

http://www.dllhell.net – my blog

http://www.linkedin.com/in/johnzablocki

http://twitter.com/codevoyeur

http://www.codeplex.com/dlr

http://www.ironpython.net

http://boo.codehaus.org

slide32

“It's Always Sunny

At the Fairfield/Westchester Code Camp”