Skip to content

Social programming

Lately I’ve been finding myself amazed about the social turn that programming has taken in quite a while.

I started growing as a software developer thanks to the Internet, it and the people on mailing lists/forums/irc have shaped my skills, career and made me discover a lot of great things. I owe the Internet a lot. As Tim Bray says in his After Branding essay:

You are whatever the Net says you are. Deal with it.

It is pointless to start talking about what good open source and version control tools have done to the social side of programming because it’s there to see for everybody. Websites like Sourceforge and Freshmat were everything we talked about in the old days.

Nowadays Distributed version control is taking over and the reasons why are clear: we need to be more and more social and what better way to exchange knowledge than to distribute code?

If I could I’d change name of those tools to “social version control”.

What I love about sites like GitHub and Bitbucket is that they are trying to build real social networks around source code, every developer’s currency. I love it. The what is not new but it’s the how (like how easy it is to contribute) that changes everything.

I look forward to social programming.

ps. on Twitter there is an amazing community of software developers exchanging small tips or links every day. You MUST be on Twitter, really. I am.

Pinder, take two

Pinder is my Python client for the 37 Signals’s Campfire online chat.

With the excuse of learning Git (by the way GitHub is awesome!) I rewrote it from scratch following the official Campfire API.

Needless to say that it took me very little time. Git is damn fast, Python development is already fast, JSON is basically a standard and the API is easy and clean. I bumped into a couple of problems but I am confident they’ll be fixed soon.

You can find Pinder on my GitHub page.

Next year I’ll try to present a case here at the company I work to switch from Subversion to either Git or Mercurial.

What Matters Now

I just finished reading Seth Godin’s “What Matters Now” free ebook and I loved it.

He put together people who think, who have something to say and he made them share something.

Do yourself a favour and download it, it maybe give you some inspiration for a new year’s endeavour.

Erlang talk

This morning I gave my talk about Erlang to a room full of Pythonistas (even people standing!) and it went pretty well considering the fact that was my first talk ever. I already posted the slides online on SlideShare.

http://www.slideshare.net/rhymes/erlang-and-python

Offline

Tomorrow evening I’m leaving for a trip to London (yes, again!). Just vacation by the way.

I’ll be back on the 6th of May.

PyCon Tre is coming, in fact I’ll be in Florence from the 7th of May to the 10th to attend it. This year I’m going to speak for the first time. I submitted a talk about Erlang and Python but then I pretty soon realized that it should have been about Erlang and the outside world because there’s no direct connection between the two :-)

Anyway, I know that few people of the non-italian community will be there (Guido, Fredrik, Raymond, Anna, and many more) so I’ll see you all in Florence on the 8th!

PyCon Italy Tre is ready to rock.

The third edition of the PyCon Italy is ready, we’ve finally published the schedule!

It will be held in Florence as last year, on the 8th, 9th and 10th of May!

We’ve received several talk proposal, we let the community vote to create a chart and we created the schedule including regular talks, sponsored ones and talks by invited guests. Talking about the invited guests: this year we have the pleasure to be joined by Guido Van Rossum (with two keynotes and a QA session), Alex Martelli (talking about software abstractions), Raymond Hettinger (AI with Python and descriptors), Fredrik Lundh (with the first talk ever about Unladen Swallow!) and Antonio Cangiano (talking about how to get rich with Python ;-) !

Remember that as last year all the talks will have simultaneous translation between english and italian and viceversa so you’ll be able to attend the conference and understand everything.

If you are interested in sponsoring, donating or any kind of help for the conference please contact me or write to the board of organizers at info at pycon.it

Hope to see you there!

The first Django book “made in Italy” is out

Marco Beri, one of the organizers of PyCon Italy, published the first book in Italian about Django 1.0. It has been reviewed, among others, by Antonio Cangiano! This is great news for the chances of widespread adoption of Django in Italy!

Blog feed changed

FeedBurner has changed, so has my feed, please update: http://feeds2.feedburner.com/ASongForTheLovers

PyCon Italia Tre is ready to go

The website of the Italian Python Conference, PyCon.it, has been launched. Apart from the schedule and new stuff (that I’ll talk about in another detailed post) the big, big news is that this year Guido van Rossum himself will be there to host a keynote.

I’m thrilled about this because it also means that PyCon Italy is really growing. Last year we had around 300 people and Alex Martelli, Brad Fitzpatrick and Raymond Hettinger among others. This year Guido agreed to come so I hope I’ll see at least all the Italian Python community there!

See you on the 8th, 9th and 10th of May, 2009.

IronPython in Action, book review

I’ve been actively developing with .NET in 2003-2004 but for some reasons I left the whole bandwagon.

Recently I’ve had the opportunity to read Michael Foord’s upcoming book: IronPython in Action and let me say that I found it extremely interesting, and I suggest it to everybody needing (or wanting) to work with .NET from a dynamic perspective or to .NET developers interested in the world out there.

The book covers a lot of ground, sometimes deeply, sometimes just in the surface but it seems to talk about everything there’s to know to make that ground solid enough to build something lasting.

From the Python introduction to IronPython extension, from IronPython embedding to XML, Visual Studio, testing, metaprogramming, Windows Presentation Foundation (the .NET new UI), system administration, ASP.NET, databases, Silverlight and much more.

Let’s go through the chapters themselves.

Chapter 1: A New Language for .NET

This chapter is an introduction to IronPython, .NET and our beloved interactive interpreter. One of the things I enjoyed discovering throughout the book is the extent of the language support in the .NET framework. Who knew Microsoft could have promoted it as a full citizen!

You can use IronPython in Visual Studio, ASP.NET, Silverlight, XNA (Microsoft’s new gaming platform), the Robotics Kit and many more places. Since .NET libraries are all written with the same bytecode (called IL) pretty much every door is open.

IP’s license is opensource and approved by the OSI, the development is done in public so there’s no need to worry about the future of the language.

There are two versions of IP: 1 and 2. I’d stick with version 2 because support Python 2.5 features. Recently there’s been some new development about the next version and support for Python 2.6. The second version also ships the Dynamic Language Runtime (DLR), a specific runtime dedicated to dynamic languages. It seems Jim Hugunin was definitely right after all.

IP 2 should work in Mono too (by default requires .NET 2) but I didn’t succeed to do so and soon gave up anyway because I planned to use my Windows virtual machine on Mac OS X.

The book as a nice series of reasons why a Python developer should try IP:

  • IronPython has no GIL for multithreaded applications
  • Extending IP through C# is easier than extending Python through C
  • Applications can be sandboxed
  • You can leverage two Window’s GUI toolkits for desktop apps: Windows Forms and WPF
  • .NET has a huge number of libraries available
  • Silverlight allows the developer to code inside the browser in IP

IP is a full citizen of the platform, and the interactive interpreter can be used to explore at runtime the whole framework while developing. That’s a huge advantage over C# developers ;-)

Chapter 2: Introduction to Python

The second chapter is an overview of Python. I posted a detailed summary in Italian on my old .NET blog just to help .NET developers (at least those who read the blogs of the Italian .NET user group) to understand what’s Python all about.

Chapter 3: .NET Objects & IronPython

How to use .NET from IP? That’s what this chapter is all about. After the intro there’s a whole Windows Forms example showing the important parts. Notice that creating a desktop application take something like this:

    >>> import clr
    >>> clr.AddReference('System.Windows.Forms')
    >>> from System.Windows.Forms import Application, Form
    >>> form = Form()
    >>> form.Text = 'Hello World' # set the title
    >>> Application.Run(form) # main loop

You can either choose to write the interface manually or use Visual Studio to design it and load it from the application.

Note that .NET objects are inheritable from IP, so that’s a go!

I remember the old days of C# where I had to declare each and every type up front and it feels nice to be able to use the same libraries and classes without all the verbosity.

Chapter 4: Writing An Application and Design Patterns with IronPython

Finally with the fourth chapter I can get my hands dirty and start delving into the process of writing a real application in IP.

The application is a Windows Forms based multiple document editor, MultiDoc. You can find all the book source code online.

The chapter starts talking about Python protocols, duck typing, magic methods to help understand what’s going on underneath and how to leverage Python features for the application at hand.

The choice is perfect because in a few line of code Michael Foord can throw in a lot of features, functionalities and patterns (like MVC, command, observer and others).

It’s shown that there’s some overlap sometimes between Python features and .NET’s and Michael Foord wisely suggests to choose considering needs, portability and pure taste.

I personally found amusing the fact that you can add event handlers for GUI applications like this:

  button.Click += lambda sender, event: command.execute()

Chapter 5: First Class Functions in Action with XML

MultiDoc in this chapter gains XML supports. There’s an introduction to first class functions, higher order functions and decorator. Functions are used as event handlers.

The command pattern is used to implement some functionalities for the application.

Chapter 6: Properties, Dialogs and Visual Studio

The chapter starts with an introduction to Python properties used to augment a partial implementation of the observer pattern to synchronize parts of the application. Cool.

After that Visual Studio is fired up to design a dialog to embed in the application.

Chapter 7: Agile Testing – Where Dynamic Typing Shines

This chapter is all about testing. We all know how testing is fundamental. Michael Foord uses the standard unittest module and his Mock library.

I really liked the monkey patching explanation combined to the method lookup rules in Python. It refreshed my memory and I guess it’s useful for newcomers.

The author also shows functional testing and user stories applied to the same GUI application.

I once developed a wxPython app in TDD (with Twisted in place too) and that thought me a lot of stuff about mocking and GUI testing.

Chapter 8: Getting deeper in IronPython: Metaprogramming, Protocols and More

I think this chapter is mandatory for a non-Python developer, or a beginner anyway.

It’s all about protocols in common Python code and in the standard library: basic procotols, generators, descriptors and so on.

I honestly didn’t know there was some kind of duck typing in C# too (see IEnumerable and foreach)

A good book on Python cannot ignore metaprogramming through metaclasses and I think Michael Foord does a good job explaning the how, what and why without giving an headache to the reader about the gory details. There’s plenty of documentation about the dark side of Python out there already.

The “more” part of the chapter’s title is: profiling through metaclasses, differences between .NET types and Python’s and more.

Chapter 9: WPF and IronPython

From now on the book goes in details about the .NET world seen from IronPython side. From chapter 1 to chapter 8 you build the solid ground, now it’s time to make it flourish.

One of the big parts of .NET is his UI support and Windows Presentation Foundation (WPF) is the king in the castle.

Michael Foord develops an example showing lots of stuff. It’s good to know that you can still leverage the tools to design the UI like mainstream .NET developers do.

Chapter 10: Windows System Administration with IronPython

We all know how versatile Python is. It can scale up and down easily. The activity of system administration can be very simplified with a dynamic language. Yes I’m talking to you Windows developers!

Please stop writing scripts with the DOS batch language, (Iron)Python is there to help you.

It really makes system administration on Windows shiny. The book teaches how to interface with WMI and PowerShell. Who new you could call IronPython from another shell language!

Chapter 11: IronPython and ASP.NET

ASP.NET is the web framework of .NET. IronPython can be used but there are some extensions to install to make it so.

I still find extremely odd the concept of viewstate: an encrypted serialization of the state of all the controls of an ASP.NET page that gets embedded in a hidden HTML element and passed back and forth each time. What!? :-)

The book shows a way to serialize Python objects inside there (beware, it can potentially make the HTML pages bigger and bigger).

Anyway I still find a lot of ASP.NET stuff very odd, like the limit of one web form per page.

I stated my opinion about ASP.NET (which I find one of the worst parts of .NET) a lot of time ago. Nice to see that almost nothing has changed :-)

Looking forward to see how ASP.NET MVC will be.

Chapter 12: Databases and Web Services

This chapter starts with the .NET data model and its interface to database systems. Michael Foord Christian Muirhead (the co-author) uses PostgreSQL to support the examples.

The second part is about the SOAP and REST capabilities of the framework. Consuming a SOAP webservice in .NET it’s really easy, altough the example parses a web service written in .NET itself.

I wonder if it’s all easy with a SOAP service exposed by other stacks.

Chapter 13: Silverlight: IronPython in the Browser

Microsoft some time ago released a plugin almost cross platform and almost cross browser called Silverlight.

Silverlight is useful if you want to develop applications inside the browser in a sandboxed environment.

Silverlight features: a slimmed version of WPF, full access to the DOM, access to JavaScript, cross domain requests, threading, asynchronous programming, client side storage and even media streaming with video brushing.

The chapter develops a Twitter client to show these features.

I’m still not really up to the idea that the future of web development should be inside these plugins, but it’s there if you want to use it.

Chapter 14: Extending IronPython with C# / VB.NET

This and the next chapter explain how to reach out the usual domain of IronPython and either extend it or embed it.

IronPython is theoretically extensible with any language of the .NET platform but for obvious reasons the book treats particularities of C# and VB.NET.

It deals with Python idioms and how to implement them, it deals with how to create mutable classes, how to implement keyword arguments and so on.

The really interesting part is the last one where it’s shown an example of a function to generate and compile at runtime a .NET assembly using code generation techniques.

Very funky!

Chapter 15: Embedding the IronPython Engine

With this last, advanced, chapter Michael Foord explains how to embed IronPython and so augment a .NET application. It can be used as a scripting engine, for plugins or to mix and integrate other languages (you can even interact with snippets of codes written in different languages!).

Conclusions

I personally found the book very enlightening and there’s much of interesting stuff in there for both Python and .NET developers. I guess it’s the first book on IronPython and anyway it’s a must have for everyone who needs to work on .NET.

It shows there are some unpolished parts with the integration and some differences between CPython and IronPython behavior but it can only become better in the future.