- 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
Best one-liner evah!
WTF? Why not prepare a statement and bind the variable?
Admin
argh ... i used an absolute word!!! I know must be punished by the lord of the geeks!
Admin
<font face="Courier New" size="2">data = new array
while ( result = results.fetchRow() ):
data[result.UserId][] = result.SomeValue
for ( userId in data ):
print userId, ") ", data[userId].join(", "), "\n"</font>
(or whatever you needed to do with the data after putting it into an array)
As I said, I'm not a big fan of ColdFusion, but it (and really, any Turing language) should be able to do something similar to this easily.
Admin
But not if they're used to writing HTML.
Admin
p.s. This entire thread should be today's WTF.
Admin
I agree! And it confused the hell out of me. If they want people to use it, don't have your screencasts assume you know the language, thats how Rails got success
Admin
Bad MVC sep.
Let's say you have to write a web app that shows data from a database. So you start by showing HTML. Next you separate out style elements into CSS. You want some glitz or Ajax-goodness so you throw in some Javascript. Now you need to get your data so you use SQL. Next you need those asynch messages going so now we're into XML. Let's see, how many of tools have we just used?
HTML, XML, Javascript (with Ajax techniques), CSS, and SQL ... and incidentally all of this while using PHP.
Are you a database person? A web designer? A middleware coder? You are doing the jobs of at least three people. How well are you doing? Do you think you are capable of being stellar at the jobs of three different people? Maybe you can be... but then there are the people who end up in our Daily WTF files. These people are a double threat, they are arrogant and incompetant, they think they can do a better job on all three fronts at the same time than anyone-else.
These are the people that inspired the MVC design pattern... separate Model (SQL) from View (HTML, CSS, Javascript) from Controller (PHP, Perl, Python... or Java, C#) now you can still have people that slide around and do wonderfully at all three jobs or have people that shine at SQL, people that are stellar at design, and talented Java programmers making Web Services.
Remember Michael Jordan didn't shine at Baseball... he was stellar in a Basketball court... and MVC is about letting Gretzky play Hocky, Babe Ruth play Baseball, and Jordan play Basketball. PHP can be used in the same way but unfortunately it is far too tempting to let Jordan play on the ice... and get hurt.
I also hate ASP and JSP too by the way... for exactly the same reasons. PHP is great for a one-person shop... but if you want a team you need to leverage team work. PHP encourages far too many bad habits... just like Python and Perl.
Admin
Heh, and therein lies the WTF.
Admin
This is by far the best comment yet in this thread
Admin
J2EE & Performance? You're joking right?
J2EE & "native calls"? Sounds to me like buying handcrafts in a Walmart on an aboriginal resort.
How about I say, if I have a problem with the performance of PHP, which interacts with the OS more natively, I can always write a PHP extension?
The last time I worked on a J2EE job I almost ran out of toilet paper, as it was used as zillions of layers of class wrappers. Java's not object oriented, but class oriented. A Java application is like the Christmas gifts I've been getting - wrapped in fancy sheets but contains useless stuff.
Let the Java-Flaming begin!
Admin
One thing that no one has mentioned in the CF flame throwing that is going is that the above code sample doesn't do a lick of good if you don't set up the dsn via an application server. That's right... an application server. I realize you can connect via connection strings, but name 10 cf developers that know that AND use it...
Admin
Actually, the code is exactly as simple as the pseudocode that you offer, except instead of printing, the data needed to be arranged into a DataTable object for use by the graph object.
To summarize, the issue was this: the graph object needs a datatable object in order to function properly. Each row in the data table represented one line on the graph. The columns in each row represent the Y values for a point on the line that will be graphed. However, the data in the database was stored in a format that could not be transformed into this format using only an sql query, since it would require taking one column, and placing it in the result set in a variable column. This is a case where using the ASP.NET codebehind is much simpler than the CF solution. It is possible to do using CF tags, but would be much messier than the C pseudocode you have demonstrated.
Further, the problem was made even simpler because the customer was able to select the graphing package with the default styling he liked the best - we didn't have to spend lots of time styling the graph object.
Admin
I think Ruby appeals to programmers who deep-down know that they don't really have any idea how to program decently. By adopting Ruby, they can insulate themselves from criticism from other developers who don't know Ruby syntax and don't want to waste any time learning it.
My favorite aspect of Ruby is the fact that it has typing shortcuts that replace the already-nearly-unreadable-but-still-in-English-at-least-sort-of syntax.
You mean you didn't know that the line:
bob = {}
is shorthand for creating a new hash map? You must be a total idiot.
Admin
To get true MVC separation with PHP you should use one of the many freely available PHP template packages. Problem solved.
Admin
Aw, man! Does this mean .NET is verboten?
I think relying on Microsoft's survival is like betting on Brasil to qualify for the world cup.
Admin
OTOH, relying on Microsoft's goodwill is like betting on Canada to qualify for the world cup. Ever try migrating an ASP/VB6 web solution to ASP.NET/C#? It's pretty much a rewrite.
Admin
MS survival is not the same as the survival of .NET. Just consider the fate of VB6.
That said, since .NET is standardized and alternative implementations - i.e. mono and portable.net - exist, chances are that .NET projects might survive even if MS droped support for .NET.
Admin
Sorry, but if you were a newbie and knew _nothing_ about MVC, the GoF book would not be enough to understand it. Observer is not the same as MVC.
Admin
Ok, you hate Ruby's syntax, and probably Python's and Perl's as well. That's fine and that's your right, but do you have any criticism worth reading?
Of course you probably don't, or you wouldn't have posted as an anonymous troll would you?
Admin
Oh, by the way the point of such shortcuts (which are called "literal notations" btw) is not to create empty containers, but to create filled ones, such as
foo = {:bar => "buzz", :bizz => "foobar", :stuff => "thing}
instead of dozens of lines of verbose useless affectations. Even Java and C# have literal notations for strings and arrays, look them up!Admin
If you read further, I've clarified that CF only escapes single quotes in queries, not everywhere, and that if you want to escape it elsewhere, there are simple functions provided (HTMLEncodedFormat)
Admin
If you are a total newbie, the GoF book is only good as a sleeping aid. I think you have to experience the miracle of refactoring to a pattern to get a grasp on just how useful it is to become familiar with them. In my limited experience, no one is interested in learning about patterns until they have had the pleasure of re-inventing an anti-pattern or two on their own.
Admin
Well for one thing, I wouldn't use some retarded third party control to do the graphing. CF comes with a graphing engine (although I don't have much experience with it).
With your data schema, I would've created a query that returns each of the following as a single comma delimted column per row. I would then pass the appropriate parameters to the graphing engine.
1) 10, 20, 30, 40
2) 10, 10, 30, 60
If the graphing engine was retarded to the point where each one had to be a column, I would create a function that converts from a list to a query (since you can create queries with CF on the fly), and then I can cache that query in session if I want to.
There seriously isn't anything that CF can't do that other languages can. Other languages might have tools that make certain things faster, but CF has a lot of tools that make 80% of your workload faster.
And lets not forget, CF is cross platform, unlike ASP.NET. And unlike PHP, it was designed by a good team, so it doesn't suck ass as much.
Admin
The fact that you value your time more than you value the speed of the final application tells us quite a bit, I guess.
Again, you don't know what you're talking about.
http://www.mono-project.com/ASP.NET
Admin
For ASP.NET (bearing in mind I've only done a little in it, so this may not be the best way):
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="DataSource1">
<ItemTemplate>
<%#DataBinder.Eval(Container.DataItem, "firstName")%>
<%#DataBinder.Eval(Container.DataItem, "secondName")%>
<%#DataBinder.Eval(Container.DataItem, "userName")%>
<br>
</ItemTemplate>
</asp:Repeater>
The syntax is slightly more verbose, especialy for the databinding, but it does mean that I can easily refer to lots of different bindings in the same output.
I agree that CF is probably slightly shorter with respects to databinding, but it is just as clean, just as readable and just as powerful.
Using one example is not a good way to cite the RADness of a language. Any differences that can be gleaned from this example can be magiced away with a good IDE. For instance, because of my IDE it only too ~25 keypresses and ~10 clicks.
I've tried CF a little bit, but I never really liked it. I love ASP.NET but because the servers are currently too expensive I'm mainly stuck with PHP, which whilst okay the lack of OOedness means I often end up writing bad code (it was one of the earliest languages I learnt, so I have some bad habbits in it);
Admin
You missed lambda functions, by the way. Or, more likely, the person who originally wrote it missed them.
Being weakly-typed is an advantage in many situations, and in any event one can use the === comparison operation to check for matching type as well as value.
I like PHP's implementation of arrays/hashes (14). Besides being different from other languages, I haven't come across any real-world problems that have occurred as a result of it.
Either way, I really couldn't care less if a language is ugly. Perl is a hideous-looking abomination, but it's widely used (and useful). Python looks better but has plenty of problems as well. Neither have private or protected variables and methods natively (if at all) unlike Java, PHP, and others.
The issue is whether it is an effective tool for accomplishing the task, and PHP, Perl, Python all fit this bill, and in some cases Java, C#, ...
Ruby may have an elegant syntax (debatable), but there are practical reasons why it's not being widely used. For instance, I think the Rails "scaffolding" videos probably did more harm than good, because people get (overly-)excited about Rails and then, oops, they realize they have to learn Ruby.
Admin
OK, you are right. So let's put it another way: If you are an experienced programmer who (for some reason) has not learned yet how exactly the MVC design pattern works, the GoF book won't tell you eighter. You will learn that it makes use of the observer pattern, but that's it. Or yet another way to tell it: The GoF book might be the "official" reference for a lot of patterns, but MVC is definitely not among them.
Admin
Didn't, item 9 "functions as first-class objects", "anonymous functions" and "closures".
I originally wrote it, and I didn't miss them.
I'm very sorry but I never ever saw one. I saw advantages in being either dynamically or statically typed, in being explicitely or implicitly typed, but unless near metal-level (ASM or C) I never saw any advantage of weak typing
Which tends not to be an issue, Python works by considering that "we're all consenting adults" and "let's not be stupid here", you prefix something with an underscore you're telling users of your module "this is not part of the public interface, you shouldn't be using it, don't come crying if it breaks next upgrade", people can heed your advice and be safe, or they can need to access the inner workings of your modules and they've been warned. Kind-of #define private public, but less ugly.
There is always a way to get around that kind of limitations, and some people always need to do it. The only variance is how ugly/hacky it is to actually do it.
Admin
Nope.
What I meant was:
int x = 2;
x = x++ + 3;
System.out.println(x);
It's not about the post vs pre increment, it's about the x++ being a lost operation. What happens is the x is resolved to 2 and added to the 3 to make 5. Then the x is incremented to 3. Finally the value 5 is assigned to x (the ++ is lost).
Admin
Sorry if this post is outta sync with the current banter. I ran across the post and couldnt resist.
<?php
include ('userinfo.php');
echo unserinfo::query(array('firstname','lastname','username' ));
?>
- userinfo being a static class to handle db connection, authentication, and data access and output formatting.
Admin
Yeah right ... ColdFusion? .... real web programming language???
If someone doesn't have any clue about escaping and parametrized queries CF or any other tool wouldn't save the day... it may save an issue or two but I can bet you will see tons of WTFs in the rest of the sqls...
Admin
It's fun to revisit the reason why I didn't choose ColdFusion a long time ago. The price tag. Currently $5,999.00 USD. Although - all the Adobe bling is cool, that's a high price tag for something that isn't generally reguarded as an enterprise solution. None the less, Adobe is creating an impressive toolbox. Probably the best purchase was Macromedia.
It's hard to imagine that the Adobe toolbox would eclipse MicroSoft in the enterprise arena. I think that still puts ColdFusion in the "specialty" category along with PHP.
To me, the first criteria when choosing a platform for project development is simply: do I (A) need the expense of an on-going "enterprise solution" - or is this (B) a short-lived disposable pet project, likely to be discarded?
If it's (B) I'll save the money and use PHP.
Admin
GOD! No!
Bad designer. BAD designer.
XHTML 1.1 is not compatible with MSIE (not even the new one that will ship with Vista AFAIK). Not if you send it with the proper mimetype -- without which there is no point in trying to follow the standard anyway, as you are essentially sending invalid HTML with an XHTML doctype slapped on top of it.
If you're not sending it with the XHTML mimetype (application/xhtml+xml), but the HTML one (text/html) you have to use a HTML doctype. Even the "transitional" bs the W3C noted in the XHTML 1.0 specs is bad practice. It generates invalid HTML (because the slash would be parsed as a plaintext character and rendered outside the HTML element by a proper SGML-compliant parser -- which is a description that doesn't match most HTML parsers on the market -- and the space before the slash is only there so some browser's tagsoup parsers don't break) and invalid XHTML (because it's not sent with an XHTML mime type).
Either you use an output rewriter to turn the XHTML back into HTML for any browser that doesn't explicitly advertise its compatibility ("explicit" is the key here, MSIE claims to support "*/*", i.e. everything and then some) or explicitly prefers HTML over XHTML (Mozilla browsers did list application/xhtml+xml with a lower priority than text/html for quite some time) or you don't use XHTML in the first place. Otherwise you're just abusing standards for marketing buzzword compatibility.
Also, being a programmer isn't an excuse not to understand XHTML, XML or HTML. The basic concepts of syntax well-formedness and semantics should be familiar and the rest is mostly a question of looking things up (just like you're not expected to know every function in every programming language's standard libraries), although XHTML, HTML and their ilk tend to be so limited in vocabulary that you tend to memorise the elements and attributes rather quickly if you get to use it a lot.
Further, most web designers don't know their shit. The HTML layer of web applications should have much less to do with making the data look pretty than with structuring it in a way that makes sense and is actually useful -- CSS and images are all you should use for the presentation.
But tell that to a web designer who thinks web design is the same as using Adobe Photoshop's "export as web page" slice'n'dice functionality.
I'm not a designer, but I DO happen to know more about proper markup than most of them, judging by Google's Zeitgeist results on web standards.
CAPTCHA: paste
Admin
I have sort of a problem with stored procedures. You can't keep them in subversion.
just put your stored procedure in a text file and check that into the repository.
Admin
I have extensive development time with both ColdFusion and Ruby On Rails, and I would like to inform you that Ruby on Rails BEATS THE F**KING PANTS off ColdFusion in practically every respect WITH AN IRON CROWBAR OF SWEET JUSTICE.
Damn ColdFusion to hell.
Admin
I have to partially correct myself: In the introduction part of the book, MVC is looked at in more detail. Still it's not one of the "official" design patterns in the book.
Admin
That's a developer talking alright. As a sysadmin, people like you make me scream. Do you have ANY IDEA what it costs to run yet another server? In my experience, CF sites are painfully slow to use unless you throw lots of hardware at them. I don't like PHP either, mind you.
Yay, save on up front development costs, and have to pay extra server maintenance and sysadmin wages for years. Congratulations, you've saved money (not).
I agree that websites shouldn't be coded in C anymore (except for highly specialised apps), but that doesn't mean that fastest development is best.
Admin
You wish... please try not to vomit all over the carpet when you read this: create_function.
Admin
*blinks* Did the charting app not have hooks for you to give it your own data acquisition function/class? I had to modify an app using some random open-source Java charting library a while ago to use a different data format; it was simply a case of writing an input filter for it. And it was a bloody old version; for various reasons, updating wasn't an option.
Admin
IE will render an image/gif as HTML if it looks like HTML. I don't see why it wouldn't support the XHTML mime type.
Anyway, the real WTF is that the OS doesn't store MIME types.
Admin
The key is "fairly easy to hack something together".
When I write code that I'm going to let other people play with, I want it to be watertight. PHP has a lot of features that simply aren't nice. Was it "a" == 1? Maybe it was 0. Sure, a lot of other languages have niceities like "a" + 1 + "b", but those are well-defined, and I think it's an overloaded + in both Java and .NET, not an implicit cast from int to string.
Now, in PHP, I can do if (1) and if ("a") and if (null) and even if ($somearray). This is even worse than C - the whole point of having a bool type is to avoid WTFs like this. Forcing me to stick an is_bool() or die() in so that it tells me if my code sucks is a WTF, and doing so duplicates code - if I change the condition on the if, I have to change the argument it is_bool(). I don't think it has any sort of exception handling either, so die() is dangerous.
It's just not good for code that has to be rock-solid in any sense of the word. I'd much rather write a C/Java app that interfaces with PHP through a TCP connection, leaving the PHP only for display. And that's just not right.
And I'm not sure, but I have the suspicion that it has to re-parse the input every time it loads the page (though I haven't checked). This is silly for a web-server. And I'm not sure if there are any good ways to share data between pages at all (session data does not count, since it only shares within the same session).
And other things I hate about PHP...
Admin
"x = x++;"
Is undefined in C++.
Admin
Well, in c++ it is not lost. ;) I tried it to be sure, but then again, that may very well be dependant on what compiler you are using.
I'll have to check out java to be sure about that one. Been a year or two since I played around with that language.
Admin
Well, I am an expert in ColdFusion and let me just say, it is the worst language I have ever used! If you want to do real web development you dont use ColdFusion.
Admin
glhfds
WHAT THE HELL IS THAT?
I guess I should thank you for correcting me and teaching me that PHP has anonymous functions since PHP4.0.1, but I fear I just can't right now, gotta go gouge my eyes out.
Admin
So CF doesn't scale?
Admin
It look looks list that's what we're doing now. It doesn't seem to be causing problems for anyone, but I'll keep this in mind as a possible cause for future problems.Thankfully, I don't use it a lot. And I agree that it's something I should know. But, I could easily rattle of a dozen other things I should know that are more important. Regardless, thanks for the response, I"m never opposed to having information handed to me.
Admin
It scales very well. With the $5000 enterprise version you can set up multiple instances, and set them up to do session sharing. Then you can set up as many boxes as you need, and have them all share the sessions, and put a loadbalancer in front of it.
I agree that $5000 per server is a bit costly, but we're talking about an enterprise application. I'm sure that each one of us worth our salt makes more then $5000 per month, so if it can save a month of development time, it's worth it. (Or be able to complete the project with a lot less people).
For smaller sites you have a lot of other options. There's standard edition for CF (somewhere between $600 and $1200), there are free alternatives such as bluedragon and railo. So if you're worried about a small site, you can get free cf platforms, if you're building something that's truly enterpise, you won't mind spending a few more thousand on the software, if it will let you use less skilled programmers and generally get your project done faster.
In this day and age, when it's hard to find competent programmers, I think these features outweight the price issue.
Admin
You sound more like an idiot. If you hate coldfusion so much, why did you keep learning it and become an expert at it?
Admin
Like I mentioned before, the standard edition is only $600-$1200, and there are free alternatives out there like BlueDragon and Railo. For an enterprise app, CF is not that expensive at $6000, how much is websphere again?