Software - Written by typemismatch on Monday, April 21, 2008 22:48 - 0 Comments

Duck-typing is great! but also bad.

I haven’t yet posted my work on PHP so this is a little out of context however since it applies to many popular languages I’m just going to go ahead and post :)

Here is a brief description of what duck typing is - basically slang but a very nice feature of various programming languages. I personally like it and I suspect most others do simply because it saves key strokes, after almost 10 years of c# programming you get very tired of double declarations.

So I have recently been doing a lot of work with PHP and discovered a disadvantage of duck typing. Although the compiler and runtime environment may know what type a variable is, you as a programmer might not! This might not seem like a big problem if you wrote the entire program but if you’re working with someone elses code or writing plugins/modules for existing systems, you’ll find this kinda hard. If you see a variable called $params being passed into a function you could “guess” it is an array but it might be some custom class.

I use a nice PHP IDE (phpEd) and real debugger so I can get the information quickly if I want but still, it raised yet another issue in trying to understand what code is trying to do.

-c

  • Digg
  • del.icio.us
  • Facebook
  • Technorati
  • StumbleUpon


Leave a Reply

Comment

Most Popular Content

Electronics, iPhone - Aug 3, 2008 12:14 - 0 Comments

iPhone Battery Tip

More In Electronics


MultiCore - Jul 30, 2008 22:38 - 0 Comments

Here comes MultiCore

More In MultiCore


General, Software - Aug 15, 2008 18:54 - 0 Comments

Gadget Features!

More In Software