× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On 2/5/2011 1:00 AM, Mark Murphy/STAR BASE Consulting Inc. wrote:
I don't buy it. Here is why. You aren't going to be using PHP as a quick and dirty. Your application has to fit inside some pre-defined parameters to use PHP in the first place. It has to be a web app, the programming has to be done on the server side, and it isn't going to easily be called from Java or any other language unless you are just going out and getting a whole page. In that case the PHP script still isn't called from Java or RPG, it is called from the client. It is pretty clear cut whether or not PHP is going to be a good solution to your problem. Sure you are talking typing, and I am talking PHP, but I could make the same arguments about javascript. Static or dynamic typing is a property of the language, and you have to live with it. It isn't really a choice you make like whether to use the LDA in your RPG application. There are some parts of PHP such as certain global variables that you shouldn't use because they are a holdover from the early days of PHP, and I would not advocate using them either. There are better more secure ways now to do the same things within PHP.

You're saying that the decision to use dynamic typing can't be quick and dirty because it's so fundamental. Okay, I guess I can agree that the term may not be entirely applicable. It was an analogy, after all, and analogies are by their nature incomplete. I still consider the choice of dynamic typing to be one that lets you get things done more quickly now at a price of higher cost later, hence my use of the term quick and dirty.

At the end of the day, it really does boil down to whether you find dynamic typing acceptable. I don't for most programming, especially business programming, and because as you note dynamic typing is integral to PHP, I find PHP to be less appropriate for those tasks.


Static typing at least helps prevents some of the more egregious
mistakes programmers make, such as passing a string where a number is
meant to go.
It can, but some times it makes you jump through extra hoops. What if the value of that string is a number? Why not just let the language go about doing the appropriate casting to let me do arithmetic on it? I know the answer, always be explicit.

The whole issue of "self documenting code" and all that. I mean, you really are going against the common wisdom of the programming world with that <grin>. And honestly, it's not that many extra hoops, is it? If the variable is to be used in arithmetic equations, it should be a number. When you display it to a human being, you edit it into a character.

Heck, I seem to remember that the whole argument against the MOVE instruction was because you shouldn't treat a number as a character! <chuckle>


But, working in a dynamically typed language is a different culture, and the two may not always see eye to eye. You kind of discounted my point about Java collections by bringing up generics (I will have to educate myself about those) and by saying that the objects inside the collection are typed anyway. But the typing of an object in Java is no more static than the typing of an object in PHP. The PHP object knows what kind of object it is, and interfaces are available to say that the Copy function needs to be there. Yes, the compiler doesn't catch it, there is no compiler, the interpreter does catch it though and will report on it the same way that a compiler would.

Yes, read about generics. It takes a moment to get your head around and I'm not particularly thrilled with the syntax they used to implement it, but it really is a game changer. The typing is enforced in the compiler, not in the runtime, and so the class cast exception (the runtime version of using the wrong type of object) has become very rare in modern Java.


I know you may not entirely agree with my opinion on typing, but I
wasn't specifically trying to say that the LDA is the same as a dynamic
type. I was saying that someone who warns against the LDA as a
dangerous programming technique should also make a similar warning about
dynamic typing, which has at least as many potential pitfalls as the LDA.
In the end, I am ok with disagreeing on dynamic typing. In practice I don't see all the pitfalls that you do. I know what I can do, and what to look out for. I suppose just as you do with Java.

And despite my statements I'm not a pedant who insists that dynamic typing is evil in and of itself. I think it's very useful in those few instances where you need to dynamically alter classes that are provided by external sources. The perfect example is modifying the classes that make up an HTML document on the fly. You didn't write those classes and you don't have control over their initial definition, but you do need to extend and modify them at runtime. That's an excellent use of dynamic types, which is probably why JavaScript is so successful.

Would I want to maintain a business system where every object is dynamic? Not particularly. Having to check the contents of every variable whenever I wanted to use it is a little much for me. But in the end it's a programming decision.

Joe


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.