Pages

Tuesday, March 9, 2010

Ohh My..the web has ducks - You dont believe me, check out IronPhyton

Google's full of ducks, youtube is also full of ducks, i mean good web apps are ducks. To be more clear, they all use phyton, a dynamic language (am new at this, i guess php guys know better).But Python’s not the only game in town to use dynamic typing. However it did catch my eye and challenged my perspective as a programmer. “What is this? How does one accurately program anything in this fashion? Five hundred lines of code and not one duck! Python’s a liar.

Well the essence of duck typing is simple :
if it looks like a duck and quacks like a duck, it must be a duck
.
In a language that supports DuckTyping an object of a particular type is compatible with a method or function, if it supplies all the methods/method signatures asked of it by the method/function at run time.simple eh? Am not going to go in the details of this, check out this link for additional information on this subject

I know there are those of you who will be tend to raise issue with dynamic languages,
such as "What if it looks like a duck, quacks like a duck, but is really a dragon impersonating a duck? You don’t want a dragon in your pond.” -(Harris,2009). My answer blame pond keeper i.e the developer

Anyway am beginning to love this idea of dynamic languages. So i decided to start learning IronPhyton (i guess i love new tech stuff). Over the past 2 weeks i dug deep into the world of IronPhyton and read the following two books

1.Pro IronPython by Alan Harris -Short and to the point kind of book, good for someone with vb.net/c# background and people who want to code than do theory

2.ironPython in action by Michael J. Foord and Christian Muirhead -Too many stories but good for the reading, the authors try to explain the concepts from scracth (mo words, less coding i figured).
In all the above i would recommend you read Alan's book, although reading both will give u a more clear picture of all aspect you might want to learn about in ironPython

Am now convinced that if am going to adopt a dynamic language then phyton is the way forward and IronPhyton is the flavor that suites me best. I mean i can even program web apps and add scripting features (plug-in) to my c# applications

Below is an Example of a class defined in IronPhyton
class course:
"Contains the details of a given course"
name='course name'
number='0'
description='description'

#methods to set Course data
def setCourseName(self,name):
self.name=name
def setNumber(self,number):
self.number=number
def setDescription(self,description):
self.description=description

#methods to get Course data
def getCourseName(self):
return self.name
def getCourseNumber(self):
return self.number
def getDescription(self):
return self.description
def getCourseDetails(self):
return 'Name: ',self.name,' Number: ',self.number,' Description: ',self.description

0 comments:

Post a Comment