- 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
Admin
:p EBiggotry is the 2nd biggest activity on the daily wtf... though I wish it would go away.
I should point out (however) that Bob's comment was somewhat ambiguous... and he was not necessarily saying what you seem to have taken away from that message. I read it as (the quality of php is fully subject to the quality of the developer, unlike most other languages).. which I take to mean that PHP has a significant number of options that are unusual to find in programming languages (which is true) and bad programmers tend to be inconsistent. Inconsistency with php makes a much bigger mess than it does with more rigid languages.
That said... I disagree with your comment about "the right way". In the programming world, "the right way" is an amorphis ideal that is given form only by the collection of individuals who interact with it and the competence with which the technology is leveraged. Coupled with consistency and adherance to more publically accepted standards, there are still a hundred paths to the same door (as it were).
Still... I stand behind my previous comments that the programming language of choice for a developer says about as much about their competance, intelligence and ability as their height and eye color.
Admin
// TODO: Place a comment here.
Admin
Ah but by just using one letter repeated multiple times he can change the naming convention for all counters across the board by Find and Replace 'n'. Really it's very foresighted.
Admin
Goddamn it, Remy, I come here to see unicorns and now you're dissapointing me.
Admin
(CAPTCHA: vindico. I didn't even have to type it all, as my browser could remember it from last time I got the same.)
Admin
A "real" COBOL fanatic would have used thirty-two character variable names, at the least. Longer if the eighty-character punched cards had additional space before column seventy-two.
Ask me how I know.
Admin
The "COBOL" was the self-professed skill of the original author. That's the reference. Also, if you've done any COBOL, the block of declaration at the top is eerily reminiscent of the WORKING-STORAGE SECTION. Heck, at least this one is actually in the function!
But, even in COBOL, this is crappy COBOL; to determine an FY, you just need the cut-off date. Then, a quick comparison of the month in numeric format will render an easy answer (the year, or the year plus one). An up-to-20-iteration loop to figure that out? Just because the cycles are quick doesn't mean we should use more than we need. :)
To me, this illustrates perfectly the adage that "you can code crappy COBOL in any language".
Admin
"abcdefg" - 1 does not make much sense to me.
Admin
How'd I do?
Admin
Admin
Admin
Does it work? Does it do what it is supposed to do?
I am not sure what it means to subtract 1 from a string. I am surprised that compiles, even in VB.
Admin
except of course I forgot:
it makes no sense. It doesn't compile. It doesn't work with any business logic. And it doesn't exist. It's a made up WTF as usual.
Admin
So, I counted some WTFs in this snippet:
1: Variables. nn, nnn, nnnn are not used in any way. All the names are undescriptive. strYear2 could have just been passed into this function (bonus points would have been given for effort if it was abbreviated, but descriptive, for instance 'curFiscalYr'.)
2: Execution n = 20 ... Do Until n = 0 ... n = n - 1 ... Loop is a For loop that should have happened, but did not. :( Date2 and Date3 should be defined and used within the loop. Oh, and named something that makes sense, without performing mental mapping.
CAPTCHA: tristique - This code has a certain 'tristique'...ok, that sounded cooler in my head.
Admin
I don't get it. Where are the PICTURE clauses?
Admin
Which reminds you that you have indeed forked up.
Admin
'' VB.NET public Function FiscalYear(dateItem As DateTime) return IIF( dateItem.Month > 6, dateItem.Year +1, dateItem.Year ) End Function
''' Call with FiscalYear(DateTime.Now).ToString() to get string version
'' VB6 Function FiscalYear(dateItem As Date) FiscalYear = IIF( dateItem.Month > 6, dateItem.Year +1, dateItem.Year ) end Function '' call with cstr(FiscalYear(Now()))
''' THE REAL WTFs.... why return a string to represent an int? And this role can be performed with one line of code.
Admin
A new software developed in VB6 by a COBOL programmer... what can possibly go wrong?
Admin
Oh, I get it....nn, nnn and nnnn are never used? Or is it that they break the convention used for other variables, and should have been n1, n2, n3, n4 ?
Admin
on a totally unrelated note, I found some serious issues in a program I inherited the other day. I don't even know how it compiled for my predecessor:
Admin
Bad programmers can make any language look bad - and unfortunately a language that forced people to be good programmers wouldn't be very useful...(that's the job of the tertiary educators).
Coding Style speaks volumes, partly because you can see whether the mindset is thinking maintainability, partly because you can really see whether someone understands (or conversely has copied StackOverflow) based on the structure and commenting and partly (tying back into point 1) someone who structures code readably has probably learnt (likely the hard way) that they will need to be able to find bugs in it later.
Interestingly, you can often even pick the dick who thinks he's clever (and may be) by writing (possibly unintentionally) obfuscated code vs the dick who has no clue to what he's doing....
Admin
Admin
Admin
I code every language like I'm programming LISP. Or, worded another way, (like (code (languages)) LISP).
Admin
Admin
Seems more like the problem is the blind are leading the blind.
Admin
I am not biased I have 10 years of cobol under my belt and worked on the programming standard for cobol.
Cobol is a globally scoped programming language and while you can call other modules from one source to another and have good scoping rules it is universally never taught and frowned upon by the top coders. For any serious cobol program it is a minimum of 10,000 lines with declarations at the top and a hopefully a naming and grouping standard to keep them grouped for to you make sense of it.
While the language is not universally bad as a rule of thumb the application of it is.
I have taught new languages a few cobol coders in my time and it is always 'interesting' at first as they learn for the first time to modularise.
Admin
Except that the reason certain features were changed in PHP was that they were security holes.
Everyone who was writing to the spec was writing bad code. When they disallowed those constructs, they forced everyone to write better code.
So are you going to argue that PHP 4 is just as good as PHP 5.5? When the majority of code written in a language is shit, it means the language itself is flawed, and good coders will gravitate towards a better language.
If it's all just the fault of bad programmers, no one would ever bother fixing languages.
For example: Java was greatly improved by adding an Enum type. Why? The idioms actual programmers used were half-baked, and the Enum type meant that you didn't have to carefully study the perfect enumerated type class just to do something that should have been simple. That caused programmers to write better code.
But there are many things about PHP that are just fundamentally broken, like the awful type system, the awful object system, their love of global state and so forth. But there's a group-think among web developers that takes pride in a kludgey mess, and people who don't want to code that way don't use PHP. So the language and the larger community are responsible for the fact that it still sucks. What's sad is that all this web stuff will before long become fossilized like all the horrible awk and sed stuff.
Admin
I don't see why some pissants mind single-char variables for controlling short loops. They are insignificant in terms of the purpose of the loop - why bloat the code with a mile-long variable, just so that you can avoid seeing "n" or "i" or whatever?
Now, I can understand wanting something better than a bunch of different single-char loop-counters in nested loops, but otherwise - in a single-level loop - if you replace my i's with your dumb counter's, for no other apparent reason, expect them to be replaced back (for no other apparent reason).
Admin
http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/
This is pretty much the handbook behind why PHP is fundamentally broken. I am usually the first to jump to the defense of languages and am very willing to blame developers. However, with PHP it just isn't that simple.
You can develop well in PHP but it is a much harder task than basically every other language. This makes it a bad language. Your tools should assist you, not hinder you.
Admin
If you grew up on Fortran everyone knows that I thru N are integers, everything else is a real.
Admin
VB6 is an object oriented language?
Admin
Or he was one of those who picked it up during the Y2K bug and just never quit like he should have.
Captcha: damnum
Damnum! Damnum all to hell!
Admin
As the web developed to the point where CGI (Common Gateway interface, not any of the other CGIs) became cumbersome (C programmers using perl, anyone?) the like of PHP (and to a degree JavaScript) became real common. As a lot of traditional programmers were a little anti web development (a web page/site is something any idiot graphic designer can do, right?) a lot of roles in PHP were available, and not a lot of talent was really going for it (there were far more important things to do in the very trendy Java and C# became pretty popular for app development too) so a lot of "google'n'learn" types picked up the most basic ideas of PHP and made a career out of it....
This still doesn't make PHP itself crap. Nor does it make any of the other languages better...
I actually think modern languages over-simplify a lot of concepts. While this helps the experienced developer finish tasks more quickly, it often encourages inexperienced developers to right code that is memory (and often time) inefficient. In the old days (you know like before the 80s and 90s ;) ) the programmers would create their own little tools to auto-generate bits of code or simplify little tasks. That is, the individual would have an overhead of crafting their own tools to increase their efficiency. THis obviously would mean that projects take a little longer, because the effort to design these tools is absorbed somewhere, but it also generally meant a better result, because the programmer would have a better understanding of how any auto-generation occured and (more importanbtly) would have a far better understanding of how system resources work and are managed.
I often get on a hobby horse about inefficient code, and the usual response is "Who cares? We have shirtloads of resources these days". I find this attitude a bit scary - while our resources often can absorb a lot of inefficiency it's no excuse to produce crap. The system you desing for 10 users today might have 100 users tomorrow, and 1000 users next week. The only time you are allowed to write stuff inefficiently is when you are making an app for yourself that will only ever run on your desktop - and even then, why limit the number of programs you can have open at any given time?
Admin
Admin
Admin
Admin
I was really hoping that was a real domain.
Admin
One aspect of coding that should always be observed is that other coders should generally have as easy of a time maintaining your code as possible. The less time we spend trying to figure out whether a variable named nnnn is used, and if so then where... the more time we can spend on doing something useful with the software we are charged to maintain.
Admin
Is it just me, or are today's trolls more successful than usual?
Admin
Every programming language has it's own set of idomatic expressions.
Just don't bring them into another obviously different programming languages.
Admin
VB happily 'fixes' the types for you, and as expected is not a good idea. It will usually compile, and often fail when run. Consider:
Dim A As String A = 5 A = A - 1
VB convert the 5 to a string, and then converts A to an integer before doing the decrement.
Decent programmers force the type changes:
Dim A As String A = Str(5) A = Str(Val(A) - 1)
(In this simple case both bits of code with run identically.)
Programmers with a clue make A an integer in the first place.
Then you get stuff like this:
A = "1" + "1"
The result, of course, is 11. However:
A = "1" + 1
...is 2, either a string or integer depending on how A was declared. As a bonus the string has a space in from of it (a placeholder for the - sign), ie " 11", not "11". Most people use Format() instead of Str() to avoid that.
MS deprecated using + for string concatenation, replacing it with & instead to prevent this stuff.
As for the WTF, VB has a bunch of date calculation functions, again showing the real WTF is people, not the language.
Admin
It's an "enough rope to hang themselves with" language. VB and C++ fall into this category as well. While C++ gives Rube-Goldberg-like powers to the over engineering veteran, VB lets the amateur get their feet wet enough that they're soon neck deep, while PHP simply drowns the child given long enough.
One might attach the "easy to pick up, difficult to master" adage to PHP. Which is great for games, but not for writing manageable, secure websites.
Admin
Isn't there a strict mode you can set that requires variables be explicitly typed?
EDIT: Ah yes, Option Explicit is what it was called. It's been a long long while.
Admin
Agreed! It would be like a book having a table of contents that referred to chapters that didn't actually exist. It doesn't "break" the book, but it's certainly confusing to discover the mismatch. Or perhaps a more practical example would be finding extra parts after assembling your Ikea furniture, leaving you to wonder if they were necessary or not.
Admin
Remember the "triangle of requirements" (as I'm titling it just now). On each corner is marked "fast", "cheap" and "good" respectively. Now you have to pick a side. If you want it fast and cheap, it won't be good; If you want it fast and good, it won't be cheap, etc.
Optimization is good, but only when it's valuable. For example, a script that's run once a month and takes 1 second to complete does not need a developer spending months, days, or even hours optimizing it, since the value on the return is negligible. When someone disregards an optimization pass on their software, it's usually because it isn't worth it.
Optimization should be reactive. If a website only gets 5 visitors a day, it isn't valuable enough to warrant the optimization. However, if traffic increases to 50,000 visitors a day then the value of optimization increases and becomes worth pursuing. Software is never "done" and it's never perfect, so trying to pre-optimize often just leads to a lost of wasted time...far more than the optimizations would have saved.
Admin
This is nothing, and as other people have pointed out it doesn't look very much like COBOL.
Btw. it's spelled C O B O L (COmmon Business Oriented Language), not to be confused with COMAL (COMmon Algorithmic Language), which is a BASIC variant.
I once had to clean up code after an old COBOL coder, and it was a complete and utter mess. At the time I was lead developer/team leader in a small shop, and one of my colleagues was asked to implement something in Delphi (this was way back with Delphi 2, as far as I remember). The task involved reading a few input files, compute something, and then produce some output files.
So how did this genius solve this not too complicated problem? By reading and writing all kinds of temporary files with strange filenames and short unintelligble record names. There was no system in it at all, and I'm not even sure he had read any of the requirements. It looked like he expected to be able to reinvent JCL and COBOL in Delphi and mix it all together in something best described as spaghetti code.
We didn't understand why it didn't work as expected, and it was only when that guy left the company, we discovered this mess. I had to rewrite most of the code from scratch (and I believe my successor eventually moved the whole codebase to another platform).
PS: COBOL is actually not that bad. It's paid my salary for several years, and I occasionally still work with COBOL or something very similar.
Admin
Really weird, I used to use exactly the same "naming convention" when I started programming. When I was 6 years old.
This is the first time I see the exact same names. It's kind of weird. and sad.
Admin
please fix this goddamn "cant find brush for java" bug on the frontpage, it is fucking annoying.