- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
At least they're consistent! unlike php:
output is "2"
Admin
All this crap about overpaid consultants, is just that... Crap (and bitterness/envy too). Anytime I hear this, it always brings to mind the argument that VB (.NET) is SOOO much worse than C#.
Also, these are usually the comments of a FTer who is too weak-kneed to do the independant thing, and that's FINE (honeslty)! If your lifestyle wouldn't support it (kids, house, etc.), then do what is right for you. Just don't go that route and then thumb your nose at someone who does go independent. And remember folks, that 100 or 200 /hr (probably not directly into his pocket, but the company he works for most likely) is all that a contractor will EVER see. No bonus, no vacation pay, no sick days, no medical coverage, etc.
And one more thing, at the end of the day there are crappy consultants and there are crappy FTers as I have worked with both types (I am a consultant). Your tax status doesn't make you a good/bad developer.
Admin
I could probably defend function #2 using keywords such as: encapsulation, logic containment and future feature planning.
However my bet is that this one is some kind of ghost code. Either that or heavy case of idiocy.
Admin
The catch is that the fact that the client is billed $200 per hour does not mean that the programmer is paid $200 per hour. I used to be a consultant, and I on occassion was called on to assist in contract negotiations so that I saw the rates the company was charging, and let's say that they were charging a lot more for my time then they were paying me. I don't recall it hitting $200 per hour, but I think the rule of thumb was that they billed about twice what they paid you.
Some of this is quite reasonable. After all, the company pays me when I'm on vacation, but they can't bill the client for my vacation time. They have to pay taxes on my salary. They supply me with medical benefits. All of that costs and the money has to come from somewhere. Plus they have to have marketing and human resources people who presumably want to be paid too, but they can't directly bill the client for them, so it all gets billed in to the rates.
But double? That seems excessive.
Admin
In a strongly-typed language, if I want to know that data type of a variable, I look for the declaration and it tells me the data type. Period. In a weakly-typed language, I have to study every place in the code where the variable is set. As most of them are likely set from other variables, I have to check where those are set, and so on and so on. If there's a variable that sometimes contains a string and sometimes contains an integer, then to know the data type at any given point in the code I have to study every possible path to that point. And please, don't tell me that you shouldn't use the same variable to contain different data types. The question isn't what you should do but what the previous programmer actually did.
Admin
I believe a good compiler will actually recognize this and remove it from the compiled code. In the end you get the parameter with no function overhead.
Admin
On the flip side, in a weakly-typed language, it's far easier to reuse an algorithm for something other than its original intended purpose. It's also much easier to write unit tests, because you don't have to jump through hoops to make your mocked out test object look enough like the real thing to allow a call the the code under test using the test object.
An example: Let's say you have some method to multiply everything in an array by 2. Simple enough, right? But in a strongly typed language, you're likely to end up with different code to do the same thing on integers, on floats, on Integer wrapper objects, on Double wrapper objects, on objects that represent an amount in US currency, or on something you hadn't even thought up that's capable of being multiplied by 2.
You're right that the challenge in weakly-typed languages is figuring out what you actually got handed to a particular method. But it does give you a ton of flexibility.
Admin
But how do you increment by 11?
Admin
How to sort an array:
Admin
Admin
Someone told me this kind of thinking has its uses:
Admin
I believe that your belief is liberal in its optimism.
Admin
We need to enhance this process with the cloud.
Admin
That first one reminds me of some of the crappiest code I ever had to become a software maintenance field service engineer for:
int IncrementInteger (int i) { /* Function name: IncrementInteger : : : 63 more lines of mandatory function header boilerplate : : */
return i++; }
... or whatever the syntax is. Long time since I wrote code.
Admin
A no-op is an operation that does nothing. There is nothing in the definition of "no-op" about how much overhead it should or should not have. A no-op can even have side effects; This is often exploited in microprocessors to byte-align instructions.
Admin
Much better, assures O(n) running time.
As for the WTF itself, the first one isn't so bad. The second one is just pure WTF. I can maybe understand a function where you were too lazy to use a refactoring tool to fix every single call and just went "return input;", but this is just absurd.
Admin
Sure, that would seem silly if you're used to Java but at least PHP's concatenation operator always means concatenate and its addition operator always means add. They are not interchangeable and they don't do different things depending on the operands' types.
Admin
I do not see any sparks. The result is 9. Note: If there is a leading zero, octal interpretation is taken into consideration. Finding a non-octal character, like '8' in this case, makes parseInt drop the octal alternative. Your example does not make sense unless you go and make the string consist of three numeric characters each representing a number lower than 8. Such a string would be '017', for example.
As for dynamic typing and auto-casting I can only quote a piece I posted here before:
Admin
They probably got paid per line of code.
Admin
Admin
May I present:
Disclaimer: I do not take any responsibility for damages caused by this code. Use at your own risk. Plea: Do not use.
Admin
Sorry, forgot to clear things up:
For those among us who have never touched PHP and never will.Admin
The IncrementByOne actually makes sense when you run JavaScript since there is no real typing of variables and was the input value stored in a text field between the iterations it was actually a text string.
However I would have done parseInt(input, 10) to make sure since the regular parseInt(input) function thinks it's octal if the value is preceded by a zero.
Admin
Admin
So here are the WTFs I see: 1)
So, you contracted them to do work with the understanding that you would have to customize the work you contracted them to do? What idiot writes your contracts?
Admin
Shouldn't you be storing individual elements in the cloud, then each time you need to do a comparison, fetch each of the elements from the cloud to do the comparison, write them back into their new positions?
Admin
If they didn't want to keep octal compatibility, would they have used this instead?
CAPTCHA: similis - Because it's similar.
Admin
It's not that anything you're saying about weakly-typed languages is wrong; it just doesn't make sense from a development perspective. Why is the flexibility you describe a top priority? How often do you write code to be used for something other than the actual reason you're writing it in the first place? Is it really expected of us developers to write code that does things we don't intend?
I never go about designing software this way. I write code with an intended purpose in mind. If someone wants to use it for something else, it's their concern. I can't be bothered to try hopelessly to satisfy business requirements that don't exist. That only slows down development for me.
As for your example, I have to question whether this overly-complex situation is a fault of the language, or a fault of the design. Why so many data types that need to be multiplied by 2 while in arrays? Why do the arrays need to store them as different types? Certainly there may be other solutions that depending on weak-typing to just magically solve your problems (even for objects that you hadn't even thought up that's capable of being multiplied by 2).
Don't get me wrong, I'm a big fan of weakly-typed languages; there are some tasks that weakly-typed languages are fantastic for. But the above defense of them is just nonsense.
Admin
I think I'm looking for
Thus double plus ungood is equivalent to "double plus plus ungood."Admin
Add to this the unreliability of obtaining work may mean up to 6 months a year without income, plus having to buy all your own training, software, hardware, etc, to stay on top of things. It's a mugs game compared to being in the permanent workforce.
On top of this, consultants are sometimes sabotaged by jealous colleagues and scapegoated (hired only to take the blame for a project that was always intended to fail).
Admin
How the hell......................??????????????? Also, generates 13 undefined variable and undefined constant messages.
Admin
Admin
Admin
Admin
Yes. And you're totally right about the quality of code being dependent on the geographical location of the coder. You probably ought to draw a map of all that and share it with us.
Admin
Of course, this has nothing to do with dynamic typing. It is no problem to define in a statically typed language an operator string operator + (string, number) that return a string concatination. On the other hand, there are dynamically typed languages like Smalltalk, where '111' + 1 raises an error.
Admin
Note that I neither support the statement "PHP is the Answer to Life, Universe and Everything!" nor "PHP is the root of all evil!". In my opinion, PHP can be used in a good way, and might be helpful at times, but it is by far not the best (not even script) language out there. The root of all evil, however, sits in front of the computer and/or in that person's environment. I, for example, have been given a book as a present that suggests using PHPs ability to parse variables inside of strings, e.g.
$root = "bar"; $tree = "foo$root";
wherein$tree == "foobar";
would evaluate as true. I'm happy to have learned about this possibility's downsides; luckily I never even used it. So, do not always see the scripter/programmer as the only one at fault, but also his environment.Admin
Admin
The problem isn't dynamic typing, it's weak typing.
Python is a dynamic language but throws an error if you attempt to add an int to a string. The same operator is used for adding ints, floats or Decimals, and concatenating strings, sets or lists. You can even overload operators where appropriate. Python has strong typing.
In PHP and JavaScript this doesn't quite work. If you slap random values together, you might end up with very different types depending on what the language decides you intended. The concatenation operator in PHP is based on the language's desperate attempts to avoid ambiguity.
Admin
Desperate, and yet failed. See examples a few comments before. They probably said "ah, that cannot fail" and used it. What is next, if at all? Comma? Underscore? Colon? Two colons? Spaces? Who knows ... Ah, I know the best alternative! Circumflex ftw!
PS: It was about time to register...
Admin
Admin
At least now you know why they don't want to deliver their source code. Though it's definately "Enterprise release standard" and might be supportable by their $200/hr consultants.
:-D
Admin
Will above code work with jQuery ? Pls post example .
Admin
You've reinvented the speed-up loop: http://thedailywtf.com/Articles/The-Speedup-Loop.aspx
Admin
At least it's clear. captcha: eros
Admin
Admin
I routinely expect the code written by developers I work with to do things other than what they intend. (Not mine, of course!)
Admin
How about option 3 - student? I'm still working on my bachelor's degree in Computer Science. I visit this website because I enjoy learning about software development, and I posted my opinion. If it's based on incorrect information (which is debatable - I disagree with you), I'd appreciate being corrected.
...but please, continue to be obnoxious - nobody should ENJOY learning.
Admin
He lives in Donzerly near the lighthouse.
Admin
J2EE?