#1
  1. Put a potato on it!
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2008
    Location
    Maryland
    Posts
    304
    Rep Power
    970

    Question Coldfusion doesn't have nulls?


    Something I learned in the past week is that Coldfusion does not have a null data type. I hadn't noticed the lack of code checking for null values in our applications because I figured that strings, integers and queries had been deliberately used according to their original design. My OOP isn't great - I've gotten very used to PHP's conventions - but the lack of this type is very strange to me.

    I'm wondering if anyone that's written Coldfusion for awhile has any ideas as to why they omitted nulls? I realize that CF9 now has a javacast() method which is really useful and before that you just made do by checking for empty strings or "undefined" variables. But this seems like such a strange choice to make in the language that I really can't wrap my head around it.

    This person had one answer at least: http://www.bryantwebconsulting.com/blog/index.cfm/2005/5/18/coldfusion_doesnt_need_nulls

    I'm happy to move this into the dev lounge, but I thought that it would be appropriate here because I'm targeting CF veterans.
    "Those who can make you believe absurdities can make you commit atrocities."
  2. #2
  3. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,263
    Rep Power
    968
    Because CF is typeless it is very difficult to have a null data type in a way that would make any sense. That said, until the ORM integration (via Hibernate) there was really no need for null anyway. And even with Hibernate, it is limited to checking for a null association, etc.

    Is there something specific you want to do that you think you need a null for?
  4. #3
  5. Put a potato on it!
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2008
    Location
    Maryland
    Posts
    304
    Rep Power
    970
    Mostly I was just confused by the lack of it. I didn't run into needed a null until I was calling a method of the java inetAddress class which needed a null passed in as a parameter value. After trying to pass null in and getting errors that Coldfusion didn't understand what that was, I looked on Google, found out why the errors were happening and then stumbled upon javacast().

    At any rate, thank you kiteless for the answer. I'm sure that when I've been writing CF for a few years these things will be more obvious to me, but I really appreciate your help!
    "Those who can make you believe absurdities can make you commit atrocities."
  6. #4
  7. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,263
    Rep Power
    968
    Sure. The idea of adding null has been thrown around for years but it seemed to conflict with the goal of simplicity. They added JavaCast for exactly the reason you describe (to let you pass it to Java objects).

    I hope you enjoy using CF! Thanks.

IMN logo majestic logo threadwatch logo seochat tools logo