Ironpython Und Die Dynamic Language Runtime (DLR) Softwareentwicklung Mit Python Auf Der Microsoft Windows Plattform

Total Page:16

File Type:pdf, Size:1020Kb

Ironpython Und Die Dynamic Language Runtime (DLR) Softwareentwicklung Mit Python Auf Der Microsoft Windows Plattform IronPython und die Dynamic Language Runtime (DLR) Softwareentwicklung mit Python auf der Microsoft Windows Plattform Klaus Rohe ([email protected]) Microsoft Deutschland GmbH Einige Anmerkungen • Kein Python Tutorial: • Es werden einige Unterschiede von Python zu C# / Java dargestellt • Die Eigenschaften, Beispiele und Demos beziehen sich auf die Version IronPython 2.0 Beta 4. Die endgültig freigegebene Version von IronPython 2.0 kann andere Eigenschaften besitzen und sich anders verhalten. Herbstcampus 2008 – Titel des Vortrags 2 Agenda • Python • IronPython & die Dynamic Language Runtime • Benutzung von .NET Bibliotheken in IronPython • ADO.NET • WPF • Einbetten von IronPython in Applikationen • Interoperabilität • IronPython & Cpython • Interoperabilität CPython - .NET Herbstcampus 2008 – Titel des Vortrags 3 Historie von Python • Anfang der 1990er Jahre von Guido van Rossum am Zentrum für Mathematik und Informatik Amsterdam als Nachfolger für die Lehrsprache ABC entwickelt • Wurde ursprünglich für das verteilte Betriebssystem Amoeba entwickelt: http://www.cs.vu.nl/pub/amoeba/ • Der Name der Sprache bezieht sich auf die britische Komiker Gruppe Monty Python Herbstcampus 2008 – Titel des Vortrags 4 Charakterisierung von Python (1) • Python-Programm wird interpretiert • Unterstützt mehrere Programmierparadigmen: • Prozedural • Objektorientiert • Funktional • Klare, einfache Syntax • Portabel, verfügbar auf allen Plattformen mit C-Compiler • Windows, Mac OS, UNIX, LINUX, … • Leicht erweiterbar mit C/C++ Bibliotheken • Z. B. Bibliothek für Win32 und COM Herbstcampus 2008 – Titel des Vortrags 5 Charakterisierung von Python (2) • Python wird als dynamische Programmiersprache bezeichnet: • Python besitzt dynamische Typprüfung Herbstcampus 2008 – Titel des Vortrags 6 Python Datentypen W Object a c h s e None Boolean n d e K int, float, long complex str, unicode o mp l e x list tuple set dict i t ä t functions classes modules exceptions type Herbstcampus 2008 – Titel des Vortrags 7 Vordefinierte Datentypen in Python Typ Beispiele str ‘hello world’, “Python” unicode u’a unicode string’ int -3, 3, 4711 long 6624737266949237011120128L, 7L float 0.0, -3.1, 2e100, 2.76e-10 complex 8j, 2 + 3j list [], [1, 2, 3, 4, 5], [1.0, “xxx”, 3] tuple (), (1,), (1, 2, 3) dict {}, {'a': 12, 'b': 'xxx'} set set(), set([1, 2, 3, 4]) NoneType None bool True, False Herbstcampus 2008 – Titel des Vortrags 8 Eigenarten der Python-Syntax • Python erzwingt eine sehr lesbare Formatierung der Programme. • Ohne „Tabs“ Syntaxfehler! „Tabs“ Herbstcampus 2008 – Titel des Vortrags 9 Python: funktional und dynamisch # Generierung von Funktionen aus lambda-Ausdrücken def funcgen(varlist, expr): lambdastr = 'lambda ' i = 0 for v in varlist: if i == 0: lambdastr = lambdastr + v else: lambdastr = lambdastr + ',' + v i = i + 1 lambdastr = lambdastr + ': ' + expr print lambdastr return eval(lambdastr) g = funcgen(['x', 'y'], '(x + y) ** 3') Herbstcampus 2008 – Titel des Vortrags 10 Gründe für Python • Warum Python? • Einfach zu lernen und zu benutzen • => steile Lernkurve • Erlaubt schnelle Entwicklung und Prototyping • => geringe Entwicklungszeit • Viel Frameworks und Klassenbibliotheken • Web-Anwendungen (Django, …) • Technisch-wissenschaftliche Anwendungen (PIL, Scipy, Sympy, …) • Skriptsprache für Anwendungen wie: GIMP, Blender, ArcGIS, … Herbstcampus 2008 – Titel des Vortrags 11 Python Implementierungen • Das original Python wird auch als CPython bezeichnet (in C implementiert) • Jython eine Implementierung von Python in Java für die Java JVM • http://www.jython.org/Project/contributors.html • PyPy ist eine Implementierung von Python in Python • http://codespeak.net/pypy/dist/pypy/doc/home.html • IronPython Implementierung von Python in C# für .NET Herbstcampus 2008 – Titel des Vortrags 12 Etwas Statistik TIOBE Programming Community Index for September 2008 • A mainstream languages • B < 0.7% http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html Herbstcampus 2008 – Titel des Vortrags 13 Agenda • Python • IronPython & die Dynamic Language Runtime • Benutzung von .NET Bibliotheken in IronPython • ADO.NET • WPF • Einbetten von IronPython in Applikationen • Interoperabilität • IronPython & Cpython • Interoperabilität CPython - .NET Herbstcampus 2008 – Titel des Vortrags 14 IronPython: ein Rückblick How coTuhled s Mpeiecdro osfo tfht e current have scsryestweemd iusp s oso l obwa dalsy to render that thet hCeL cRu rirs efnatr iwmoprlseem entation thauns ethlees sJ VfoMr afonry thing beyond dynamdiecm laonngsturaagtieosn? purposes. Let me check this out. I will write a short paper - “WhTyh .eN CELTI i sis a, bteyr dreibsilge n, not pfrlaietnfodrlmy tfoo dr ydnyanmamici cla nguages. Protolatynpgeusa gweesr"e built, but ran way too slowly. InfoWorld, Aug. 2003 Jim Hugunin John Udell Herbstcampus 2008 – Titel des Vortrags 15 IronPython Versionen • IronPython 1.x • Aktuelle Version: IronPython 1.1.2 • IronPython 2.0 • IronPython 2.0 ist mit der Dynamic Language Runtime (DLR) implementiert • Aktuelle Version: IronPython 2.0 Beta 4 • http://www.codeplex.com/IronPython Herbstcampus 2008 – Titel des Vortrags 16 IronPython (1) • IronPython ist als zip-File, msi-Installationspaket oder als Quellcode erhältlich. • Verzeichnisstruktur IronPython 2.0: Herbstcampus 2008 – Titel des Vortrags 17 IronPython (2) • ipy.exe: • Ausführen von IronPython-Skripts mit interaktiver Console • ipyw.exe: • Ausführen von IronPython-Skripts ohne interaktive Console • Umgebungsvariable: • IRONPYTHONPATH: • Suchpfad für Python-Module • IRONPYTHONSTARTUP: • Suchpfad für Startup-Module Herbstcampus 2008 – Titel des Vortrags 18 IronPython Ausführungsmodell .NET Python Calls Calls Python Code Framework Libraries Libraries Compiled by IronPython Engine C a l Produces l s Assembly (in memory) Executed by .NET Runtime Herbstcampus 2008 – Titel des Vortrags 19 Entwicklungsumgebung: IronPython Studio • Download: http://www.codeplex.com/IronPythonStudio • Mit dem VS 2008 SDK implementiert Herbstcampus 2008 – Titel des Vortrags 20 IronPython performance: Pystones/second • Venerable benchmark • Dhrystone in Python • In Lib/test/pystone.py • Only benchmark that ships with Python • Simple but non-trivial • ~200 lines of code • Most basic Python ops • Very little OO • 32-bit Vista Enterprise Service Pack 1.0 • .NET 3.5 SP1 (2.0.50727.3053) • AMD x64 X2 4200+4.00 GB RAM • IronPython 2.0 Beta 4 Pystones C python 2.5.2 51275,5 IronPython 2.0 B eta 4 81788,3 Ipy / C py = 1,595 Herbstcampus 2008 – Titel des Vortrags 21 Demo: IronPython • Commandozeile: • IronPython Console: ipy.exe • IronPython Skriptr ausführen: ipyw.exe • IronPython Studio Herbstcampus 2008 – Titel des Vortrags 22 Dynamic Language Runtime (1) • Plattform zur Implementierung von dynamischen Sprachen auf .NET • Basiert auf Erfahrungen von Jim Hugunin‘s bei der Implementierung von IronPython 1.0 auf .NET • Die DLR ist ein Aufsatz auf dem .NET Framework und wurde in C# implementiert. IronPython IronRuby … Dynamic Language Runtime (DLR) .NET Framework 2.0 Herbstcampus 2008 – Titel des Vortrags 23 Dynamic Language Runtime (2) • Nutzt die Dienste und Eigenschaften des .NET Frameworks: • Garbage collector • Just-in-time Compiler (JIT) • .NET Bibliotheken • Werkzeuge • Vereinfachte Beschreibung der DLR: • Gegeben ist ein abstrakter Syntaxbaum (AST). Die DLR führt die Operationen und Konstrukte des Syntaxbaums aus, unter Berücksichtigung der Operationen und Regeln, welche für die Sprache definiert sind. Basisoperationen werden auf CLR Default-Operationen zurückgeführt (Integer-Operationen, …) Herbstcampus 2008 – Titel des Vortrags 24 Dynamic Language Runtime (3) Python Quellkode • Python Quellkode wird in einen „Python“-AST transformiert Python Abstract Syntax Tree • „Python“-AST wird in DLR-AST transformiert DLR Abstract Syntax Tree • DLR-AST wird in IL (Intermediate Language) übersetzt, mittels IL Code CODEDOM, und von der CLR ausgeführt. .NET CLR Herbstcampus 2008 – Titel des Vortrags 25 Zusammenfassung DLR • Die Dynamic System Runtime (DLR) ist die Grundlage für die effiziente und performante Implementierung dynamischer Sprachen mit .NET • Die DLR bietet Werkzeuge: • Zum eigentlichen Implementieren der Sprache, wie Erzeugen von Abstrakten Syntaxbäumen und effiziente Codegenerierung für die .NET CLR • Erzeugung von „Sprach unabhängigen“ ASTs • Einbetten der Sprache in eigenen Applikationen (Skriptconsolen, …) • Die Implementierung der DLR befindet sich in den Assemblies: • Microsoft.Scripting.dll • Microsoft.Scripting.Core.dll Herbstcampus 2008 – Titel des Vortrags 26 Agenda • Python • IronPython & die Dynamic Language Runtime • Benutzung von .NET Bibliotheken in IronPython • ADO.NET • WPF • Einbetten von IronPython in Applikationen • Interoperabilität • IronPython & Cpython • Interoperabilität CPython - .NET Herbstcampus 2008 – Titel des Vortrags 27 .NET Bibliotheken in IronPython (1) • In IronPython können sämtliche Klassenbibliotheken des .NET Frameworks benutzt werden. • In IronPython können die .NET Namensräume von geladenen Assemblies wie Python-Pakete behandelt werden Herbstcampus 2008 – Titel des Vortrags 28 .NET Bibliotheken in IronPython (2) • .NET Assemblies werden wie folgt bekannt gemacht: import clr clr.AddReference("System.Data") • IRONPYTHONPATH muss die Verzeichnisse enthalten, in denen sich die referenzierten Assemblies befinden • clr ist ein in IronPython eingebauter Modul, der Methoden zum Referenzieren von .NET Assemblies bereitstellt. • clr.References gibt eine Liste aller existierenden Referenzen aus. Herbstcampus 2008
Recommended publications
  • Lap Around the .NET Framework 4
    Lap Around the .NET Framework 4 Marc Schweigert ([email protected]) Principal Developer Evangelist DPE US Federal Government Team http://blogs.msdn.com/devkeydet http://twitter.com/devkeydet .NET Framework 4.0 User Interface Services Data Access ASP.NET Windows Windows (WebForms, Entity Presentation Data Services Communication ADO.NET MVC, Dynamic Framework Foundation Foundation Data) Windows WinForms Workflow LINQ to SQL Foundation Core Managed Dynamic Parallel Base Class Extensibility LINQ Languages Language Extensions Library Framework Runtime Common Language Runtime ASP.NET MVC 1.0 (Model View Controller) A new Web Application Project type Simply an option Not a replacement for WebForms Builds on top ASP.NET Manual vs. Automatic Transmission Supports a clear separation of concerns Supports testability Supports “close to the metal” programming experience ASP.NET MVC 2 Visual Studio 2010 Included Visual Studio 2008 (Service Pack 1) Download Both versions built against .NET 3.5 What’s New in MVC 2? Better Separation of Concerns (Maintainability) Html.RenderAction() Areas Easier Validation (Maintainability/Productivity) Data Annotations Client Validation Helper Improvements (Maintainability/Productivity) Strongly-Typed Helpers Templated Helpers ASP.NET 4 Web Forms? Support for SEO with URL Routing Cleaner HTML Client ID improvements ViewState improvements Dynamic Data Improvements Chart Controls Productivity and Extensibility Rich Client Ajax supports both MVC & Web Forms WPF 4 Calendar, Data Grid, DatePicker Ribbon (separate download)
    [Show full text]
  • Ironpython in Action
    IronPytho IN ACTION Michael J. Foord Christian Muirhead FOREWORD BY JIM HUGUNIN MANNING IronPython in Action Download at Boykma.Com Licensed to Deborah Christiansen <[email protected]> Download at Boykma.Com Licensed to Deborah Christiansen <[email protected]> IronPython in Action MICHAEL J. FOORD CHRISTIAN MUIRHEAD MANNING Greenwich (74° w. long.) Download at Boykma.Com Licensed to Deborah Christiansen <[email protected]> For online information and ordering of this and other Manning books, please visit www.manning.com. The publisher offers discounts on this book when ordered in quantity. For more information, please contact Special Sales Department Manning Publications Co. Sound View Court 3B fax: (609) 877-8256 Greenwich, CT 06830 email: [email protected] ©2009 by Manning Publications Co. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in the book, and Manning Publications was aware of a trademark claim, the designations have been printed in initial caps or all caps. Recognizing the importance of preserving what has been written, it is Manning’s policy to have the books we publish printed on acid-free paper, and we exert our best efforts to that end. Recognizing also our responsibility to conserve the resources of our planet, Manning books are printed on paper that is at least 15% recycled and processed without the use of elemental chlorine.
    [Show full text]
  • Expression Trees 1 Dynamic Language Runtime Overview 5 Creating and Using Dynamic Objects 9 Early and Late Binding 17 Execute Ex
    Expression Trees 1 Dynamic Language Runtime Overview 5 Creating and Using Dynamic Objects 9 Early and Late Binding 17 Execute Expression Trees 19 Modify Expression Trees 21 Use Expression Trees to Build Dynamic Queries 23 Debugging Expression Trees 26 Expression Trees (Visual Basic) https://msdn.microsoft.com/en-us/library/mt654260(d=printer).aspx Expression Trees (Visual Basic) Visual Studio 2015 Expression trees represent code in a tree-like data structure, where each node is an expression, for example, a method call or a binary operation such as x < y . You can compile and run code represented by expression trees. This enables dynamic modification of executable code, the execution of LINQ queries in various databases, and the creation of dynamic queries. For more information about expression trees in LINQ, see How to: Use Expression Trees to Build Dynamic Queries (Visual Basic) . Expression trees are also used in the dynamic language runtime (DLR) to provide interoperability between dynamic languages and the .NET Framework and to enable compiler writers to emit expression trees instead of Microsoft intermediate language (MSIL). For more information about the DLR, see Dynamic Language Runtime Overview . You can have the C# or Visual Basic compiler create an expression tree for you based on an anonymous lambda expression, or you can create expression trees manually by using the System.Linq.Expressions namespace. Creating Expression Trees from Lambda Expressions When a lambda expression is assigned to a variable of type Expression(Of TDelegate) , the compiler emits code to build an expression tree that represents the lambda expression. The Visual Basic compiler can generate expression trees only from expression lambdas (or single-line lambdas).
    [Show full text]
  • A Multi-Programming-Language, Multi-Context Framework Designed for Computer Science Education Douglas Blank1, Jennifer S
    Bryn Mawr College Scholarship, Research, and Creative Work at Bryn Mawr College Computer Science Faculty Research and Computer Science Scholarship 2012 Calico: a multi-programming-language, multi- context framework designed for computer science education Doug Blank Bryn Mawr College, [email protected] Jennifer S. Kay James B. Marshall Keith O'Hara Mark Russo Let us know how access to this document benefits ouy . Follow this and additional works at: http://repository.brynmawr.edu/compsci_pubs Part of the Computer Sciences Commons Custom Citation Douglas Blank, Jennifer S. Kay, James B. Marshall, Keith O'Hara, and Mark Russo. Calico: A Multi-Programming-Language, Multi- Context Framework Designed for Computer Science Education. (2012). SIGCSE 2012 (Raleigh, NC). This paper is posted at Scholarship, Research, and Creative Work at Bryn Mawr College. http://repository.brynmawr.edu/compsci_pubs/53 For more information, please contact [email protected]. To appear in the Proceedings of the 43rd ACM Technical Symposium on Computer Science Education, SIGCSE 2012 Calico: A Multi-Programming-Language, Multi-Context Framework Designed for Computer Science Education Douglas Blank1, Jennifer S. Kay2, James B. Marshall3, Keith O'Hara4, and Mark Russo1 1Computer Science 2Computer Science 3Computer Science 4Computer Science Department Department Department Program Bryn Mawr College Rowan University Sarah Lawrence College Bard College Bryn Mawr, PA (USA) Glassboro, NJ (USA) Bronxville, NY (USA) Annandale-on-Hudson, NY (1) 610-526-6501 (1) 856-256-4593 (1) 914-395-2673 (1) 845-752-2359 [email protected] [email protected] [email protected] [email protected] ABSTRACT these contexts are often tied to a specific programming environ- The Calico project is a multi-language, multi-context program- ment, which limits their availability to only those willing to work ming framework and learning environment for computing educa- in that programming environment.
    [Show full text]
  • Pro DLR in .NET 4
    Pro DLR in .NET 4 Chaur Wu Pro DLR in .NET 4 Copyright © 2010 by Chaur Wu All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. ISBN 978-1-4302-3066-3 ISBN 978-1-4302-3067-0 (eBook) Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1 Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights. President and Publisher: Paul Manning Lead Editor: Jonathan Gennick Technical Reviewer: Scott Isaacs Editorial Board: Steve Anglin, Mark Beckner, Ewan Buckingham, Gary Cornell, Jonathan Gennick, Jonathan Hassell, Michelle Lowman, Matthew Moodie, Duncan Parkes, Jeffrey Pepper, Frank Pohlmann, Douglas Pundick, Ben Renow-Clarke, Dominic Shakeshaft, Matt Wade, Tom Welsh Coordinating Editor: Jennifer L. Blackwell Copy Editor: Sharon Terdeman Compositor: Bytheway Publishing Services Indexer: Brenda Miller Artist: Integra Software Services Pvt.
    [Show full text]
  • Data Driven Software Engineering Track
    Judith Bishop Microsoft Research 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 C# 1.0 C# 2.0 C# 3.0 C#4.0 Spec#1.0 Spec# Code CodeCont .5 1.0.6 Contracts racts 1.4 Java 1.5 F# Java 6 F# in VS F# C Ruby on LINQ Python Rails 3.0 Firefox 2 Firefox 3 IE6 Safari 1 IE7 Safari 4 IE8 Safari 5 Windows Windows DLR beta Windows DLR 1.0 XP Vista 7 .NET Rotor Mono 1.0 .NET 2 Rotor 2.0 .NET 3.5 .Net 4.0 Mac OS Ubuntu Mac OS Mac OSX Mac OS X Linux X Intel Leopard XSnow. VS 2003 VS 2005 VS2008 VS2010 Eclipse Eclipse Eclipse 1.0 3.0 3.6 Advantages Uses • Rapid feedback loop (REPL) • Scripting applications • Simultaneous top-down and • Building web sites bottom-up development • Test harnesses • Rapid refactoring and code • Server farm maintenance changing • One-off utilities or data • Easy glue code crunching C# 1.0 2001 C# 2.0 2005 C# 3.0 2007 C# 4.0 2009 structs generics implicit typing dynamic lookup properties anonymous anonymous types named and foreach loops methods object and array optional autoboxing iterators initializers arguments delegates and partial types extension COM interop events nullable types methods, variance indexers generic lambda operator delegates expressions overloading query expressions enumerated types (LINQ) with IO in, out and ref parameters formatted output API Serializable std generic Reflection delegates The dynamic language runtime (DLR) is a runtime environment that adds a set of services for dynamic languages – and dynamic featues of statically typed languages – to the common language runtime (CLR) • Dynamic Lookup • Calls, accesses and invocations bypass static type checking and get resolved at runtime • Named, default and optional parameters • COM interop • Variance • Extends type checking in generic types • E.g.
    [Show full text]
  • Optimizing Runtime Performance of Dynamically Typed Code
    Optimizing Runtime Performance of Dynamically Typed Code Jose Quiroga Alvarez PhD Supervisor Dr. Francisco Ort´ınSoler Department of Computer Science University of Oviedo A thesis submitted for the degree of Doctor of Philosophy Oviedo, Spain April 2016 Acknowledgements This work has been partially funded by the Spanish Department of Science and Technology, under the National Program for Research, Development and Innovation. The main project was Obtaining Adapt- able, Robust and Efficient Software by including Structural Reflection to Statically Typed Programming Languages (TIN2011-25978). The work is also part of the project entitled Improving Performance and Robustness of Dynamic Languages to develop Efficient, Scalable and Reliable Software (TIN2008-00276). I was awarded a FPI grant by the Spanish Department of Science and Technology. The objective of these grants is to support gradu- ate students wishing to pursue a PhD degree associated to a specific research project. This PhD dissertation is associated to the project TIN2011-25978 (previous paragraph). This work has also been funded by Microsoft Research, under the project entitled Extending dynamic features of the SSCLI, awarded in the Phoenix and SSCLI, Compilation and Managed Execution Request for Proposals. Part of the research discussed in this dissertation has also been funded by the European Union, through the European Regional Development Funds (ERDF); and the Principality of Asturias, through its Science, Innovation Plan (grant GRUPIN14-100). Abstract Dynamic languages are widely used for different kinds of applications including rapid prototyping, Web development and programs that require a high level of runtime adaptiveness. However, the lack of compile-time type information involves fewer opportunities for com- piler optimizations, and no detection of type errors at compile time.
    [Show full text]
  • Metaprogramming in .NET by Kevin Hazzard Jason Bock
    S AMPLE CHAPTER in .NET Kevin Hazzard Jason Bock FOREWORD BY Rockford Lhotka MANNING Metaprogramming in .NET by Kevin Hazzard Jason Bock Chapter 1 Copyright 2013 Manning Publications brief contents PART 1DEMYSTIFYING METAPROGRAMMING ..............................1 1 ■ Metaprogramming concepts 3 2 ■ Exploring code and metadata with reflection 41 PART 2TECHNIQUES FOR GENERATING CODE ..........................63 3 ■ The Text Template Transformation Toolkit (T4) 65 4 ■ Generating code with the CodeDOM 101 5 ■ Generating code with Reflection.Emit 139 6 ■ Generating code with expressions 171 7 ■ Generating code with IL rewriting 199 PART 3LANGUAGES AND TOOLS ............................................221 8 ■ The Dynamic Language Runtime 223 9 ■ Languages and tools 267 10 ■ Managing the .NET Compiler 287 v Metaprogramming concepts In this chapter ■ Defining metaprogramming ■ Exploring examples of metaprogramming The basic principles of object-oriented programming (OOP) are understood by most software developers these days. For example, you probably understand how encapsulation and implementation-hiding can increase the cohesion of classes. Languages like C# and Visual Basic are excellent for creating so-called coarsely grained types because they expose simple features for grouping and hiding both code and data. You can use cohesive types to raise the abstraction level across a system, which allows for loose coupling to occur. Systems that enjoy loose cou- pling at the top level are much easier to maintain because each subsystem isn’t as dependent on the others as they could be in a poor design. Those benefits are realized at the lower levels, too, typically through lowered complexity and greater reusability of classes. In figure 1.1, which of the two systems depicted would likely be easier to modify? Without knowing what the gray circles represent, most developers would pick the diagram on the right as the better one.
    [Show full text]
  • Discovering Ironpython
    PART I Introducing IronPython ⊲⊲ CHAPTER 1: Discovering IronPython ⊲⊲ CHAPTER 2: Understanding the IronPython Basics COPYRIGHTED MATERIAL 548592c01.indd 1 2/24/10 12:47:07 PM 548592c01.indd 2 2/24/10 12:47:08 PM 1 Discovering IronPython WHAT’S IN THIS CHAPTER? ➤➤ Understanding why you want to add IronPython to your developer toolbox ➤➤ Obtaining and installing IronPython on your machine ➤➤ Understanding some underlying basics of how IronPython works ➤➤ Using IronPython at the console and within a window ➤➤ Designing and building a simple application IronPython: It sounds like some kind of metal snake infesting your computer, but it isn’t. IronPython is the .NET version of the open source Python language (http://www .python.org/). Python is a dynamic language that can greatly enhance your programming experience, help you create applications in less time, and make the applications you create significantly more responsive to user needs. Of course, you’ve heard these promises before from other languages. This chapter helps you understand how IronPython delivers on these promises in specific situations. The smart developer soon learns that every language serves specific needs and might not work well in others. So this chapter isn’t here to blow smoke at you — ​once you complete it, you’ll understand the strengths and weaknesses of IronPython. Of course, you’ll need to obtain a copy of IronPython before you can use it because Visual Studio doesn’t include IronPython as part of the default installation. This chapter helps you get IronPython installed on your system and tells you about some options you may want to install as well.
    [Show full text]
  • NET Hacking & In-Memory Malware
    .NET Hacking & In-Memory Malware Shawn Edwards Shawn Edwards Cyber Adversarial Engineer The MITRE Corporation Hacker Maker Learner Take stuff apart. Change it. Put Motivated by an incessant Devoted to a continuous effort it back together. desire to create and craft. of learning and sharing knowledge. Red teamer. Adversary Numerous personal and emulator. professional projects. B.S. in Computer Science. Adversary Emulation @ MITRE • Red teaming, but specific threat actors • Use open-source knowledge of their TTPs to emulate their behavior and operations • Ensures techniques are accurate to real world • ATT&CK (Adversarial Tactics Techniques and Common Knowledge) • Public wiki of real-world adversary TTPs, software, and groups • CALDERA • Modular Automated Adversary Emulation framework Adversary Emulation @ MITRE • ATT&CK • Adversarial Tactics Techniques and Common Knowledge • Public wiki of real-world adversary TTPs, software, and groups • Lets blue team and red team speak in the same language • CALDERA • Modular Automated Adversary Emulation framework • Adversary Mode: • AI-driven “red team in a box” • Atomic Mode: • Define Adversaries, give them abilities, run operations. Customize everything at will. In-Memory Malware • Is not new • Process Injection has been around for a long time • Typically thought of as advanced tradecraft; not really • Surged in popularity recently • Made easier by open-source or commercial red team tools • For this talk, only discuss Windows malware • When relevant, will include the ATT&CK Technique ID In-Memory
    [Show full text]
  • The Microsoft .NET Framework Was from the Beginning Designed to Support Broad Range of Languages on a Common Language Runtime (CLR)
    The Microsoft .NET Framework was from the beginning designed to support broad range of languages on a Common Language Runtime (CLR). CLR provides shared services such as garbage collection, JIT and tools integration. The other benefit is that these languages can work together and use libraries written in any of them as well as .NET Base class library (BCL). The CLR didn’t have the support for dynamic languages. Their dynamic nature makes the compilation uneasy and places high demands on the language runtime. Unlike static languages as C# which don’t require runtime support other than CLR itself. How difficult was it to make the dynamic language on .NET can be seen in the open-source implementation of PHP language on .NET called Phalanger. Its code is really complex and hard to survey. This is a serious problem for an open-source project, because it’s hard to contribute. The new Dynamic Language Runtime (DLR) makes a difference. It adds a lot of support for dynamic languages on .NET, that makes implementing the dynamic languages much easier and it also enables the interoperability between the dynamic languages built on DLR and standard static languages on .NET. This work focuses on features of PHP dynamic language and discusses how they can be implemented in DLR. A part of this work is a pilot implementation of PHP language on DLR; the target of this implementation is to prove some new concepts, find advantages and disadvantages that DLR brings and serves as an example for implementing the dynamic language on DLR..
    [Show full text]
  • Warum Dynamische Sprachen ?? Wo Würde Ich Persönlich Sie Verwenden, Wo Nicht ;-)
    { Helden brauchen weniger } Frank Fischer Manager Evangelism and Marketing http://blogs.msdn.com/frankfi Microsoft Deutschland GmbH Jim Hugunin 100K 80K 60K 101K 90K 40K 80K 46K 50K 36K20K 0K Python Python Python IronPython IronPython IronPython 2.1 2.3 2.5 0.1 1.0 2.0alpha1 Jim Hugunin Principal Architect Microsoft Corp. Eine Geschichte zum Beginn… (hatten wir gerade) Was sind „dynamische Sprachen“ ?? Der Versuch einer Definition Warum dynamische Sprachen ?? Wo würde ich persönlich sie verwenden, wo nicht ;-) Was hat Microsoft damit zu tun?? Eine Geschichte zum Beginn… (hatten wir gerade) Was sind „dynamische Sprachen“ ?? Der Versuch einer Definition Warum dynamische Sprachen ?? Wo würde ich persönlich sie verwenden, wo nicht ;-) Was hat Microsoft damit zu tun?? Dynamic programming language is a term used broadly in computer science to describe a class of high level programming languages that execute at runtime many common behaviors that other languages might perform during compilation, if at all. These behaviors could include extension of the program, by adding new code, by extending objects and definitions, or by modifying the type system, all during program execution. These behaviors can be emulated in nearly any language of sufficient complexity, but dynamic languages provide direct tools to make use of them. Dynamic languages and dynamic typing are not identical concepts, and a dynamic language need not be dynamically typed, though many dynamic languages are dynamically typed. http://en.wikipedia.org/wiki/Dynamic_programming_language
    [Show full text]