• foo (unregistered)
    Alex Papadimoulis:
    if (sLogin == "O'Reily") sLogin = "O''Reily";


    Best one-liner evah!
    WTF? Why not prepare a statement and bind the variable?
  • mrsticks1982 (unregistered) in reply to Phil the ruler of heck
    Phil the ruler of heck:

    mrsticks1982 wrote the following post at 08-22-2006 11:18 PM:
    But you have to remember each language is created because it needed to meet some purpose.

    I'm not so sure about that.  Somehow there seem to be a couple billion programming languages too many out there for that statement to be true...

    Maybe some folks just had to invent their own programming language for the sheer fun of it, or something like that?



    argh ... i used an absolute word!!! I know must be punished by the lord of the geeks!
  • (cs) in reply to McTesty
    Anonymous:
    Specific example:  I created a site for a client in ASP.NET recently.  The site required a number of charts and graphs.  After showing the customer screenshots from the plethora of .NET charting options, he chose the one he liked the best, we purchased the package, and (almost) literally point and clicked our way to very attractive graphs.

    There was one hangup however.  The graphs (line graphs) needed a datatable with a row for each line on the graph.  Each of a variable number of columns contained the data for the y point of a particular point along the line.  The database however simply one record for each score.

    Example, we needed data to look like (commas separate columns):
        1) 10, 20, 30, 40
        2) 10, 10, 30, 60
    (this would graph two lines, each with 4 points)

    but the data would have been stored in many different rows (with additional data about the datapoint), like
        1) 1, 10, 2004-01-01
        2) 1, 20, 2004-01-02
        3) 1, 30, 2004-01-03
        4) 1, 40, 2004-01-04
        5) 2, 10, 2004-01-01
        6) 2, 10, 2004-01-02
        7) 2, 30, 2004-01-03
        8) 2, 60, 2004-01-04
    where the first column is the line on the graph the data belongs to, the second is the value, and the third is a date that translated into the x axis information (obviously this is grossly simplified.).

    The solution is easy.  In ASP.NET create a class that selects the data into datatables (since you can't write a query to return the data in the format we needed).  Then, run through the datatable and load the values into another table as necessary.  We even stored the final results in the Session to speed up reload times.  Just a few lines of C# were needed in all, and the problem was solved.
    Actually, that sounds like a lot of work.  Maybe I'm misunderstanding the question, but why not just do this?  (This is pseudocode)

    <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.
  • (cs) in reply to masklinn

    masklinn:
    Unless people are used to writing XML/XHTML, that is.

    But not if they're used to writing HTML.

  • (cs)

    p.s. This entire thread should be today's WTF.

  • (cs) in reply to masklinn
    masklinn:
    Anonymous:
    Russ:

    Granted, CF on Wheels is still very early beta, but it probably already rivals RoR. 


    I give up... you are certifiably retarded. One word for you: ActiveRecord

    (edit timeout on previous post)

    Just watched the CF on Wheels introductory video... sweet mother of god, these guys don't try to compete with Rails, they try to redo rails in CF instead of ruby, they're replicating every single method name they can find to implement the same feature in CF as well as reimplementing the features found in Rails...

    I must say it's the first time i've seen something that retarded in a long time.


    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
  • foo (unregistered) in reply to Blah
    Anonymous:
    No troll, serious question. I'm curious as to why people seem to dislike PHP so much? There have been a few anti-PHP posts in this thread.

    I'm not a web person but I do use PHP for personal stuff. I'm not even a professional coder, but I do code asm and C(++), which is why I started using PHP, having a passing similarity to C and fairly easy to hack something together.

    So why is PHP disliked?



    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.
  • BRiaN (unregistered) in reply to Russ
    Anonymous:
    Actually the best way of doing it is to use a real web programming language like ColdFusion...


    Heh, and therein lies the WTF.
  • Anonymouse (unregistered) in reply to Newt
    Anonymous:
    John Bigboote:
    Anonymous:

    so of course the fix was to put:

    if (sLogin == "O'Reily") sLogin = "O''Reily";
    if (sLogin == "Robert O'Hare") sLogin = "Robert O''Hare";

    maybe we could create a funcion to look for "O'" and replace it with "O''"!!!

    done!



    D'oh!

     

    Don't you mean :

    D''oh!

     

    This is by far the best comment yet in this thread

  • Tox (unregistered) in reply to Russ

    Personally, I haven't looked into Ruby yet, and although I've heard good things, I have doubts on whether it has half the functionality offered by ColdFusion.  So even If I concede this point, there are not a lot of platforms out there that can outperform ColdFusion, especially since it's a J2EE platform now.  If I have a problem with the performance, I can always throw together a java class that does what I need, and call it nativelly from coldfusion. 

    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!

  • Fred (unregistered) in reply to Russ

    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...

  • McTesty (unregistered) in reply to mratzloff
    mratzloff:
    Actually, that sounds like a lot of work.  Maybe I'm misunderstanding the question, but why not just do this?  (This is pseudocode)

    <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.


    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.
  • Anonymous (unregistered) in reply to GrandmasterB
    GrandmasterB:

    Anonymous:

    Personally, I haven't looked into Ruby yet,

    I've looked in to it.  eh, nothing special that cant be done in any other language.  I really dont get the over-zealousness of it's deciples one the net.  It's practically cult-like.



    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.
  • McTesty (unregistered) in reply to foo
    Anonymous:
    Anonymous:
    No troll, serious question. I'm curious as to why people seem to dislike PHP so much? There have been a few anti-PHP posts in this thread.

    I'm not a web person but I do use PHP for personal stuff. I'm not even a professional coder, but I do code asm and C(++), which is why I started using PHP, having a passing similarity to C and fairly easy to hack something together.

    So why is PHP disliked?



    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.


    To get true MVC separation with PHP you should use one of the many freely available PHP template packages.  Problem solved.
  • Anonymous (unregistered) in reply to ammoQ
    ammoQ:
    First, a very important message (some have made similar statements, but IMO not clear enough):

    <font size="+3">Forget escaping. Use parametrized queries. Always.</font>

    Some database systems (e.g. Oracle) will hate you, really really hate you, and let you feel that, if you execute thousands of queries that only differ in the literal values. This hurts in term of performance, especially for very simple queries (like querying a single row by the primary key). Reason: The overhead for doing a hard parse is more relevant if the actual execution is fast.

    About Coldfusion: Using a proprietary language or tool (like ColdFusion, VB6, Delphi or Oracle Forms) inevitably leads you to a point where you have no other option than rewriting the whole project from scratch. Unless the project has a limited lifespan because of external circumstances, always use tools/languages that do not depend on the survival or goodwill of a single company. COBOL is really awfull, but you still get compilers for it.


    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.
  • Philbert Desanex (unregistered) in reply to Anonymous

    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.

  • (cs) in reply to Anonymous
    Anonymous:


    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.


    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.
  • (cs) in reply to Webzter
    Anonymous:

    ammoQ:
    Webzter:

    There's the "classic" MVC pattern in the GoF book.

    Really? In my copy of the GoF book, the MVC design is mentioned, but not explained in detail like the other design patterns.

    Really? In my copy of the GoF book the wax eloquently about the Observer pattern and then start off the "known uses" section by talking about how "the first and perhaps best-known example of the Observer pattern appears in Smalltalk Model / View / Controller". Granted, it's probably not as clear cut as you're looking for, and others have expounded much further (another great read would be Pattern Hatching by Vlissides), but I'll stand by my original statement in con  text.



    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.
  • (cs) in reply to Blah
    Anonymous:
    No troll, serious question. I'm curious as to why people seem to dislike PHP so much? There have been a few anti-PHP posts in this thread.

    I'm not a web person but I do use PHP for personal stuff. I'm not even a professional coder, but I do code asm and C(++), which is why I started using PHP, having a passing similarity to C and fairly easy to hack something together.

    So why is PHP disliked?

    1. PHP is ugly, it seems like the devs of PHP knew some Perl and C and took some features without realizing why they existed in the first place ($ prefix anyone?). This trend keeps on giving with PHP5's OO model: somewhat feels/looks like Java's OO, which is stupid as Java is a statically explicitely typed language while PHP is a dynamically weakly typed one.
    2. PHP is weakly typed, as in "1" == 1 is true. I dig dynamic typing (à la Python, Ruby or Erlang), I dig implicit typing (be it static inferred -- Haskell -- or dynamic -- Python / Ruby / Erlang again), but weak typing is a Bad Thing, no matter how you take it, for anything above a few dozen lines. It enables the languages to do dangerous and stupid things, and to have many random and more or less undefined behaviours, usually without any gain at all.
    3. PHP has no namespaces, I like namespaces, they provide tidy spaces to group related stuff together. Namespaces are great. PHP has no namespaces. Bad.
    4. Three-fucking-thousand functions in a single global namespace... WTF?
    5. Oh, and 12 versions of the same function to do very slightly different things? Come on! Why do I use eregi if I want an case-insensitive ereg, ever heard of arguments? PHP has 16 functions for sorting alone! 8 for splitting!
    6. Completely, utterly, explicitely nonsensical and inconsistent function naming:
      • stream_get_line, set_error_handler, php_uname but jddayofweek, imagetypes, stripslashes? Guys, either you use underscore-separated words or you don't, but just pick one!
      • Sometimes the order is object-verb (base64_decode, iptcparse, str_shuffle, var_dump), other times it's verb-object (create_function, recode_string)
      • 2 or to? No one really knows, e.g., ascii2ebcdic, bin2hex, deg2rad, ip2long but cal_to_jd (jdto*, *tojd), strtolower, strtotime
      • Not to mention i seem to recall very strange spellings in PHP's function names (not taking in account "2")
    7. Function return values are completely inconsistent as well.
    8. All functions are defined as global objects too
    9. Therefore no function-as-first-class-objects, no closures, and no anonymous functions
    10. You couldn't have them anyway since PHP doesn't really have scopes, either lexical or dynamic
    11. And PHP has an awful support of recursion
    12. fucking magic quotes
    13. fucking register_globals
    14. No real arrays/lists, you get hashes, and "arrays"/"lists" are just hashes with an integer key
    15. PHP doesn't deprecate/remove allegely dangerous functions (escape & mysql_escape_string vs mysql_real_escape_string)
    16. last, but not the least, we had to wait until PHP5 to finally get a somewhat consistent DB interface bundled with PHP (PDO)... Perl's DBI is 12 years old...
    17. Anonymous:
      GrandmasterB:

      Anonymous:

      Personally, I haven't looked into Ruby yet,

      I've looked in to it.  eh, nothing special that cant be done in any other language.  I really dont get the over-zealousness of it's deciples one the net.  It's practically cult-like.



      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.

      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?

  • (cs) in reply to masklinn

    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!

  • Russ (unregistered) in reply to Jeff
    Anonymous:

    Actually the best way of doing it is to use a real web programming language like ColdFusion, which will do all the escaping for you.  The best, best way is to do it in coldfusion with parametarized queries, but even if the coder is not smart enough to use them, this kind of issue just wouldn't even come up.   


    That's odd.... CF will always escape the characters for you?  What would it do if you actually needed those characters unescaped?

    Most web development languages I've dealt with (currently .Net platform) have classes that will handle escape characters and/or HTMLEncoding for you, so I guess I don't get what you mean by CF being a "real" web programming language (given that it's actually scripting like ASP).

     

    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)

     

     

  • (cs) in reply to ammoQ
    ammoQ:

    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.


    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.
  • Russ (unregistered) in reply to Webzter
    Anonymous:

    Anonymous:
    As a professional web developer I've found Cold Fusion to have serious limitations.

    Specific example:  I created a site for a client in ASP.NET recently.  The site required a number of charts and graphs.  After showing the customer screenshots from the plethora of .NET charting options, he chose the one he liked the best, we purchased the package, and (almost) literally point and clicked our way to very attractive graphs.

    There was one hangup however.  The graphs (line graphs) needed a datatable with a row for each line on the graph.  Each of a variable number of columns contained the data for the y point of a particular point along the line.  The database however simply one record for each score.

    Example, we needed data to look like (commas separate columns):
        1) 10, 20, 30, 40
        2) 10, 10, 30, 60
    (this would graph two lines, each with 4 points)

    but the data would have been stored in many different rows (with additional data about the datapoint), like
        1) 1, 10, 2004-01-01
        2) 1, 20, 2004-01-02
        3) 1, 30, 2004-01-03
        4) 1, 40, 2004-01-04
        5) 2, 10, 2004-01-01
        6) 2, 10, 2004-01-02
        7) 2, 30, 2004-01-03
        8) 2, 60, 2004-01-04
    where the first column is the line on the graph the data belongs to, the second is the value, and the third is a date that translated into the x axis information (obviously this is grossly simplified.).

    The solution is easy.  In ASP.NET create a class that selects the data into datatables (since you can't write a query to return the data in the format we needed).  Then, run through the datatable and load the values into another table as necessary.  We even stored the final results in the Session to speed up reload times.  Just a few lines of C# were needed in all, and the problem was solved. 

    I am curious Russ, how would you have approached this problem in CF?

    PS.  We had control of the database, we could alter the schema if necessary.  However, the customer would be providing us data bi-monthly in the previous format, so if your solution involves changing the schema, you would also need data transformation logic somewhere to put the data into the new schema.

    Funny. I recently completed a rewrite from a ColdFusion site to ASP.NET 1.1. The hardest part of the entire contract was the graphing piece... and it wasn't because of the difficulty in drawing graph points (the problem / solution was much like you show above), the biggest issue was in making the new chart on the newest version of ChartFX look exactly like the ancient version of ChartFX; along with debugging the logic in ColdFusion that drew the chart (reams of bizarre logic). I'll withold judgement on ColdFusion, though, it was written against some wacky database structures (I normalized one table from 126 columns down to 3). The CF code certainly wasn't the easiest to follow... HTML interspersed with code all over the place, reminded me very much of classic ASP development before we figured out how to approach that in a sane way...but, again, I'm guessing the fault was more with the implementer than the language. 

     

    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. 

     

  • (cs) in reply to Russ
    Anonymous:

    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.

    The fact that you value your time more than you value the speed of the final application tells us quite a bit, I guess.

    Anonymous:

    And lets not forget, CF is cross platform, unlike ASP.NET. 



    Again, you don't know what you're talking about.

    http://www.mono-project.com/ASP.NET
  • [ICR] (unregistered) in reply to Russ

    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);

  • (cs) in reply to masklinn
    masklinn:
    1. PHP is ugly, it seems like the devs of PHP knew some Perl and C and took some features without realizing why they existed in the first place ($ prefix anyone?). This trend keeps on giving with PHP5's OO model: somewhat feels/looks like Java's OO, which is stupid as Java is a statically explicitely typed language while PHP is a dynamically weakly typed one.
    2. PHP is weakly typed, as in "1" == 1 is true. I dig dynamic typing (à la Python, Ruby or Erlang), I dig implicit typing (be it static inferred -- Haskell -- or dynamic -- Python / Ruby / Erlang again), [snip]
    Definitely some valid complaints.  Your list looks long but basically boils down to:

    1. No namespaces--definitely a problem with PHP.  Looks like they're going to add them in the upcoming PHP 6, but they should have been in version 5.
    2. Ugly language--yes.
    3. No deprecation--no, a lot of stuff was deprecated in 5.  And in 6, register_globals, magic_quotes, etc. will be removed entirely.

    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.
  • (cs) in reply to obediah
    obediah:
    ammoQ:

    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.


    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.


    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.
  • (cs) in reply to mratzloff
    mratzloff:
    You missed lambda functions, by the way.

    Didn't, item 9 "functions as first-class objects", "anonymous functions" and "closures".

    mratzloff:
    Or, more likely, the person who originally wrote it missed them.

    I originally wrote it, and I didn't miss them.

    mratzloff:
    Being weakly-typed is an advantage in many situations

    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

    mratzloff:
    Neither have private or protected variables and methods natively (if at all) unlike Java, PHP, and others.

    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.

  • (cs) in reply to ccjx
    ccjx:
    Anonymous:

    smbell:
    This is why, IMO, all programmers should have to start with assymbly as their first language. They can then graduate up to higher level languages.

    If you understand the way the machine works, you understand the code you are writing. For example, take the following Java code.

    int x = 2;
    int x = x++ + 3;
    System.out.println(x);

    If you understand what happens under the covers you won't be surprised when it prints out 5 instead of 6.

    In C++

    <font color="#0000ff" size="2">int</font><font size="2"> x = 2;
    x = x++ + 3;
    </font><font size="2">cout << x;</font>

    <font size="2">actually has the output 6 on my system, kindof like I though it would.
    Although, isnt using post increment with other operators like that undefined behavior in c++? (Im not quite sure on this point actually) Oh well.. ;) You said java so I guess this is moot.</font><font size="2"></font>



    Erm.. yea.. it's supposed to print 6. The first code will throw a compiler error.. I'm pretty sure smbell meant to write:

    int x = 2;
    int y = x++ + 3;
    System.out.println(y);

    Which would have returned 5. He probably wanted to demonstrate the difference between that and this:

    int x = 2;
    int y = ++x + 3;
    System.out.println(y);


    That code would've returned 6.

    But this is seriously a basic programming textbook test question and I think most developers would increment before adding.. right..?

    You can try it in C++:

    <font color="#0000ff" size="2">int</font><font size="2"> x = 2;
    </font><font color="#0000ff" size="2">int</font><font size="2"> y = x++ + 3;
    </font><font size="2">cout << y;</font>


    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).

  • (cs) in reply to Russ
    Anonymous:
    GrandmasterB:

    Anonymous:
    Name one other programming language that even comes close to CF in terms of RAD. 

    ASP & PHP

    I can develop apps 20 times faster in either than in Cold Fusion

     

    'Course, I've never used Cold Fusion.  Nor do I give a rats ass if something is buzzword-compliant ('RAD') or not.

     

     



    Lets see... How about a small example.  Get a list of users from the database and output firstname, lastname and username.  Here is the code in CF
    <cfquery name="qryUsers" datasource="#request.mydsn#">
    select firstname, lastname, username from users
    </cfquery>
    <cfoutput query="#qryUsers#">#firstName# #lastName# #userName#<br></cfoutput>


    Now lets see how long and convoluted a similar example in php/asp is going to be. 

    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.

  • (cs) in reply to Russ

    Anonymous:

    Actually the best way of doing it is to use a real web programming language like ColdFusion, which will do all the escaping for you.  The best, best way is to do it in coldfusion with parametarized queries, but even if the coder is not smart enough to use them, this kind of issue just wouldn't even come up.    

    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...

  • (cs) in reply to nsimeonov

    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.

  • Alan (unregistered) in reply to obediah
    obediah:
    iwpg:

    What do you mean, "fixed"?  It wasn't broken to begin with.



    It isn't valid XHTML1.1   I'm not much of a web person, so I don't know exactly what that implies, I was just told to close all my tags, and it seems to make the validator happy.

    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

  • This isn't java (unregistered) in reply to Jud

    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. 

  • Dick Wolf (unregistered) in reply to Russ

    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.

  • (cs) in reply to ammoQ
    ammoQ:
    obediah:
    ammoQ:

    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.


    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.


    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.


    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.
  • Sarah (unregistered) in reply to Russ

    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.

  • (cs) in reply to masklinn
    masklinn:
    no anonymous functions

    You wish... please try not to vomit all over the carpet when you read this: create_function.

  • Rob (unregistered) in reply to McTesty
    Anonymous:
    As a professional web developer I've found Cold Fusion to have serious limitations.

    Specific example:  I created a site for a client in ASP.NET recently.  The site required a number of charts and graphs.  After showing the customer screenshots from the plethora of .NET charting options, he chose the one he liked the best, we purchased the package, and (almost) literally point and clicked our way to very attractive graphs.

    There was one hangup however.  The graphs (line graphs) needed a datatable with a row for each line on the graph.  Each of a variable number of columns contained the data for the y point of a particular point along the line.  The database however simply one record for each score.

    Example, we needed data to look like (commas separate columns):
        1) 10, 20, 30, 40
        2) 10, 10, 30, 60
    (this would graph two lines, each with 4 points)

    but the data would have been stored in many different rows (with additional data about the datapoint), like
        1) 1, 10, 2004-01-01
        2) 1, 20, 2004-01-02
        3) 1, 30, 2004-01-03
        4) 1, 40, 2004-01-04
        5) 2, 10, 2004-01-01
        6) 2, 10, 2004-01-02
        7) 2, 30, 2004-01-03
        8) 2, 60, 2004-01-04
    where the first column is the line on the graph the data belongs to, the second is the value, and the third is a date that translated into the x axis information (obviously this is grossly simplified.).

    The solution is easy.  In ASP.NET create a class that selects the data into datatables (since you can't write a query to return the data in the format we needed).  Then, run through the datatable and load the values into another table as necessary.  We even stored the final results in the Session to speed up reload times.  Just a few lines of C# were needed in all, and the problem was solved. 

    I am curious Russ, how would you have approached this problem in CF?

    PS.  We had control of the database, we could alter the schema if necessary.  However, the customer would be providing us data bi-monthly in the previous format, so if your solution involves changing the schema, you would also need data transformation logic somewhere to put the data into the new schema.


    *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.
  • (cs) in reply to Alan
    Anonymous:
    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.


    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.
  • (cs) in reply to Blah
    Anonymous:
    No troll, serious question. I'm curious as to why people seem to dislike PHP so much? There have been a few anti-PHP posts in this thread.

    I'm not a web person but I do use PHP for personal stuff. I'm not even a professional coder, but I do code asm and C(++), which is why I started using PHP, having a passing similarity to C and fairly easy to hack something together.

    So why is PHP disliked?



    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...
  • ... (unregistered) in reply to TeeSee

    "x = x++;"

    Is undefined in C++.

  • BruteForce (unregistered) in reply to smbell
    smbell:
    ccjx:
    Anonymous:

    smbell:
    This is why, IMO, all programmers should have to start with assymbly as their first language. They can then graduate up to higher level languages.

    If you understand the way the machine works, you understand the code you are writing. For example, take the following Java code.

    int x = 2;
    int x = x++ + 3;
    System.out.println(x);

    If you understand what happens under the covers you won't be surprised when it prints out 5 instead of 6.

    In C++

    <FONT color=#0000ff size=2>int</FONT><FONT size=2> x = 2;
    x = x++ + 3;
    </FONT><FONT size=2>cout << x;</FONT>

    <FONT size=2>actually has the output 6 on my system, kindof like I though it would.
    Although, isnt using post increment with other operators like that undefined behavior in c++? (Im not quite sure on this point actually) Oh well.. ;) You said java so I guess this is moot.</FONT><FONT size=2></FONT>



    Erm.. yea.. it's supposed to print 6. The first code will throw a compiler error.. I'm pretty sure smbell meant to write:

    int x = 2;
    int y = x++ + 3;
    System.out.println(y);

    Which would have returned 5. He probably wanted to demonstrate the difference between that and this:

    int x = 2;
    int y = ++x + 3;
    System.out.println(y);


    That code would've returned 6.

    But this is seriously a basic programming textbook test question and I think most developers would increment before adding.. right..?

    You can try it in C++:

    <FONT color=#0000ff size=2>int</FONT><FONT size=2> x = 2;
    </FONT><FONT color=#0000ff size=2>int</FONT><FONT size=2> y = x++ + 3;
    </FONT><FONT size=2>cout << y;</FONT>


    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).

    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.

  • Chris (unregistered) in reply to Russ

    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.

  • (cs) in reply to iwpg
    iwpg:
    masklinn:
    no anonymous functions

    You wish... please try not to vomit all over the carpet when you read this: create_function.

    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.

  • Marc (unregistered) in reply to Russ
    Anonymous:

    ColdFusion runs on top of J2EE sort of like JSP.  It also allows you to call java classes nativelly.  So basically it's JSP that's a little slower, but lets you develop applications a lot faster.


    So CF doesn't scale?
  • (cs) in reply to Alan
    Anonymous:
    obediah:


    It isn't valid XHTML1.1   I'm not much of a web person, so I don't know exactly what that implies, I was just told to close all my tags, and it seems to make the validator happy.

    GOD! No!

    Bad designer. BAD designer.

    Thanks! That's the best complement I've had all day.  I hate, despise, and loathe all things html, javascript, and CSS - actually all things UI.


    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.

    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.

      

    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.

    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.

  • Russ (unregistered) in reply to Marc
    Anonymous:
    Anonymous:

    ColdFusion runs on top of J2EE sort of like JSP.  It also allows you to call java classes nativelly.  So basically it's JSP that's a little slower, but lets you develop applications a lot faster.


    So CF doesn't scale?


    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. 


  • Russ (unregistered) in reply to Chris
    Anonymous:
    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.



    You sound more like an idiot.  If you hate coldfusion so much, why did you keep learning it and become an expert at it?
  • Russ (unregistered) in reply to olddog
    olddog:

    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.



    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?  

Leave a comment on “Poor Mr. O'Hare ”

Log In or post as a guest

Replying to comment #:

« Return to Article