dynamic languages n.
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

  • 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)‏

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

Dynamic Languages

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

Dynamic vs. Static Languages

Dynamic Language Runtime (DLR)‏

Use Cases for Script Hosting

DLR Hosting API

Sample: Boo

Sample: IronRuby

Sample: IronPython


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


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


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


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


Represents source code

Provides means for code execution and compilation

Created from ScriptEngine or ScriptScope instances


“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)


def audience(self):

return self._audience


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

“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


Boo in 60 Seconds

import System

class Message(object):

def constructor(message):

_message = message


_message as string


_audience as string

def show_message(message_formatter as callable):

print message_formatter(_message, _audience)


Boo in 60 Seconds

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

m.show_message def(message, audience):

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


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

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







“It's Always Sunny

At the Fairfield/Westchester Code Camp”