#.think.in
learn.create.enjoy

#.think.in infoDose #29 (11th May - 15th May)

May 31, 2009 07:44 by brodie

 

Announcements/Events

Development

Web/Silverlight

WPF

WCF

Architecture

Utilities


Tags:
Categories: Links
Comments (0)

#.think.in infoDose #28 (29th Apr - 8th May)

May 31, 2009 07:40 by brodie

Announcements

Development

WPF

WCF

Utilities

Web/Silverlight

Architecture

Books

Code: The Hidden Language of Computer Hardware and Software, by Charles Petzold

Singularity Watch

Other


Tags:
Categories: Links
Comments (0)

#.think.in infoDose #27 (20th Apr - 28th Apr)

May 27, 2009 20:41 by brodie

I've changed jobs recently and my working habits have changed slightly, so bear with me as I get these link posts back on track :-)

 

Architecture

Development

Web

Utilities

Singularity Watch

Books

Other


Tags:
Categories: Links
Comments (0)

#.think.in infoDose #26 (14th Apr - 17th Apr)

May 27, 2009 20:38 by brodie

Development

Web

Silverlight/WPF

UI Design

Utilities

Books

image 

Other

Quotes

"People who cease to grow can't inspire others. Leadership begins with challenging oneself." ~Daisaku Ikeda


Tags:
Categories: Links
Comments (0)

IronPython In Action

May 25, 2009 10:39 by tarn

While twittering (or tweeting) about an IronPython presentation I was doing, @voidspace messaged me asking if I might mention his book. I’d contacted Michael Foord a while back about some code I was playing around with. I also knew of him from his blog, his prolific contribution to IronPythonURLs and as the co-author of the new book IronPython in Action. He’s so all over everything IronPython he even reads this blog.

imageMainly because I was too cheap to buy myself a copy it, I hadn’t read his  book. I was wrapped when he offered to get me a copy if I’d review it on this blog. I wanted to read it as I was learning IronPython and I knew it would be a good book, I’d read chapters 1 and 7 which are online. I happily recommended it in my presentation, here’s what I thought about the book.

IronPython in Action is a fantastic resource for anyone learning IronPython and for anyone wondering what this dynamic language IronPython is all about and whether they should learn it. It feels nicely balanced for both .NET users looking to learn about IronPython, and for Python users looking to learn about IronPython on .NET.

I prefer software books that have plenty of discussion and can be read from start to finish otherwise I end up skipping through chapters I never go back too. I found this book well written and fun to read with interesting insight all the way through. There is enough about the python language and .NET to get you through the book, and rather than being a reference book it instead provides information on how to learn more.

The book is divided into four main sections. The first section Getting Started with Iron Python contains a good introduction and history of IronPython on the .NET Framework.

The Core Development Techniques section is a walkthrough of building a simple Windows Forms application. I think this section is fantastic as the text places high value on Agile Development philosophy, using a Model-View-Controller pattern and Test Driven Development. I think these are exciting ways to develop software on the .NET framework. There is also a really good section discussing the difficulties, pitfalls and work-arounds using IronPython and dynamic programming languages generally on the .NET framework.

The third section IronPython and Advanced .NET contains chapters about using the major pillars of the .NET framework with IronPython. It has chapters on WPF, Powershell, ASP.NET, Databases, Webservices and Silverlight. It really is amazing how much of the framework can be used in IronPython.

The final section Reaching Out with IronPython has fantastic chapters on extending IronPython with C#/VB and embedding an IronPython Engine in C#/VB applications to provide extensibility.

I highly recommend this book, I enjoyed reading it and learned a lot from it. If you’re looking for a little more insight, the forward by Jim Hugunin frames the language, the technology and author well.


Tags:
Categories:
Comments (2)

IronPython Presentation

May 11, 2009 10:25 by tarn

I’m doing an introduction to IronPython presentation at the Victoria .Net user group tomorrow, I’ve been attending the user group for about a year and I’m pretty excited about presenting. I think python is a fantastic language and it’s great to be able to build software on the .Net framework with it.       

The Slides

Introduction

I wanted to start with the second slide and have a photo of a pub on the contact slide but decided to get through this before trying out PowerPoint jokes.

Why Python

I just plan to discuss Why I started using Python. The cartoon is, of course, XKCD.

Python

Basic information about the language and its background. Would have liked to have added meta programming or at least “..” to the paradigms.

I think it’s a fantastic language so I’ll mention it’s expressive, fun, productive or whatever adjectives I’ve got in my head at the time.

People using Python

I really want to demonstrate that Python is real language, being used by real people, to write real code. 

I probably should also have mentioned Google App Engine here which I’ve been tinkering with a bit recently and think is pretty cool.

IronPython

The Python language on .Net. Most of the demo is doing cool stuff in .Net with the Python language. I think it goes further than this and allows developers to use their own paradigms and patterns to do .NET development.

C# and IronPython comparison

I saw this example in the awesome Iron Python in Action book. I included it as it’s a great introduction IronPython code, as it clearly and simply shows differences on similarities with C#.

Dynamic Language Runtime

The Dynamic Language Runtime project is open source. Its quite well described here as: 

  • A dynamic type system
  • Dynamic method dispatch
  • Dynamic code generation

    IronLisp has been superseded by the IronScheme project.

  • Dynamic Typing

    This slide is just a brief overview of what duck typing is.

    It is great for writing test objects, but I have a slide for the later.

     

    Interactive Interpreter

    I think it’s awesomely cool, and I use it through the entire demo so I thought it might be worth warning people.

     

    The Demo

    The demo is a series of scripts run into the IronPython Interactive Console. I’ve uploaded the very small collection of scripts for this demo here.

    IronPython and the CLR

    Create a string, show how its methods can be reflected. Import the CLR and show how the .Net String methods are now available.

    # Introduction to IronPython and the CLR
    
    # Standard first Python console command
    2 + 2
    
    # Create a string
    s = 'Hello IronPython'
    
    # Inspect its methods, note that its only Python methods.  
    dir(s)
    
    # Python has a method to make the text uppercase
    s.upper()
    
    # Import the CLR
    import clr
    
    # Now look at the same objects methods,
    # We now see the .NET string methods!
    dir(s)
    
    # And can use them!
    s.ToUpper()

     

    Screen Shot

    Using a .Net Classes

    Create a WebClient object from the .Net framework to download an RSS feed. Use an xml2py module written by Harry Pierson to deserialise the RSS feed into an object graph. Then send the dates and titles to the Speech Synthesizer. I’ve seen this done before in an IronPython presentation, and just thought it was to much fun to leave out. 

    import clr
    
    # Create a WebClient and download a string of XML
    from System.Net import WebClient
    w = WebClient()
    xml = w.DownloadString('http://feeds.theage.com.au/rssheadlines/technology.xml')
    
    # Lets have a look at first 60 characters of the xml..
    print xml[0:60]
    
    # If bad stuff happens in the presentation..
    #xml = open('theage.rss').read()
    
    # Deserialize to objects using xml2py
    from devhawk import xml2py
    rss = xml2py.parseString(xml)
    
    # Print the results
    for post in rss.channel.item:
      print post.pubDate, post.title 
    
    # Import Speech  
    clr.AddReference('System.Speech')
    from System.Speech import *
    ss = Synthesis.SpeechSynthesizer()
    
    # Say titles and dates using the SpeechSynthesizer 
    for post in rss.channel.item:
      s = "%s. %s." % (post.pubDate[:16], post.title)
      ss.SpeakAsync(s)

     

    Screen Shot

    SQL

    I really don’t want to do this in the presentation. I did spend a fair amount of time playing round with asynchronous SQL queries for use in a WPF application, but it seemed too complicated for the demo so I’ve left it out. I use

    # import a simple wrapper around System.Data.SqlClient  
    # the wrapper is on my blog, I just wanted to show the AdventureWorks 
    # database, it seems a bit of .NET presentation tradition. 
    from demo import sql
    
    # setup a query on the AdventureWords database
    query = 'SELECT * FROM Production.Product'
    sql.connection = 'Data Source=localhost\SQLEXPRESS;Initial Catalog=AdventureWorks;Integrated Security=SSPI;'
    
    # execute the query
    products = sql.SqlQuery(query)
    
    # print some results
    for p in products[:5]:
      print p.Name

     

    WPF, Data Binding and Exec

    I think there is some pretty cool stuff in this demo. Although it takes a lot more to write real applications it does open new ways to develop and test .Net applications.

    # More pythonic way of getting the feed.. lets hope I have internet
    from devhawk import xml2py
    rss = xml2py.parse('http://feeds.theage.com.au/rssheadlines/technology.xml')
    
    # Importing avalon starts a new thread to run the WPF application
    # It sets up some dispatures so the console can talk to the GUI 
    from samples import avalon
    
    # Create a window, show it and load some XAML into it
    w = avalon.Window()
    w.Show()
    xaml = avalon.LoadXaml('demo.xaml')
    w.Content = xaml
    
    # Loading names is really cool, it traverses the control tree 
    # described in the XAML and creates a dictionary of names and 
    # controls. We can add those dictionary items to the local scope,
    # so we get the same effect as a generated designer files in
    # Visual Studio. 
    avalon.LoadNames(xaml,locals())
    
    # We can bind a Python list of Python objects to the ListView
    listView.ItemsSource = rss.channel.item
    
    # Create a button click callback that will execute the script
    # in the query TextBox.
    def OnClick(*args):
      try:
        exec (query.Text)
      except:
        print "Script threw an exception"
      pass  
    
    # Wire up the click event to our function  
    execute.Click += OnClick
      
    # We can now execute this on the client  
    listView.ItemsSource = [p for p in rss.channel.item if p.title.find('to') >= 0]

     

    Screen Shot

    More Slides

    Testing in Python

    It’s really cool you can do true test driven development in that you can write unit tests for classes and methods that haven’t yet been written. Some cool GUI testing is also possible using some the stuff in this presentation.   

    Tools / SDKs

    I’m not expecting to mention Python Studio or IpyDbg as I’ll probably be running out of time.
    I really should have included a link to python.org, I’ll make sure I mention it.
    You can get IronPython here and the Silverlight Dynamic Languages SDK

    Resources

    Dive Into Python – Free online, python for programmers.
    IronPython In Action – Python and everything .NET with TDD and MVC practices.
    IronPython Cookbook – Online collection of IronPython .Net scripts.
    IronPython Urls, MSDN,
    Devhawk – Harry Pierson, Program Manager at Microsoft.
    Voidspace – Michael Foord, Author IronPython in Action.

    Thanks

    By this stage I’ll almost certainly be running late, and probably be really worried about some minor disaster during the presentation.

    I hope it goes well and everyone takes something out of it, I look forward to hearing what you thought.


    Tags:
    Categories:
    Comments (0)