Slashdot Mirror


Type Safety Coming To DB Queries

An anonymous reader writes "A new type-safe query language for the popular full-text search platform Solr, called Slashem (a Rogue-like), has just been released. Slashem is implemented as a domain-specific language in Scala, providing compile time type-safety, allowing you do things like date range queries against date fields but keeping you from trying to do a date range query against a string field. Hopefully this trend catches on, resulting in fewer invalid queries exploding at runtime."

128 comments

  1. Gibberish - wrapped up as geekspeak by Anonymous Coward · · Score: 4, Insightful

    It's rogue-like and the link to define "rogue" is to a fucking github page that says "lift/mongodb query dsl".

      For fuck's sake... this tells people NOTHING. It's a completely useless article submission.

    1. Re:Gibberish - wrapped up as geekspeak by bondsbw · · Score: 0

      Did you seriously miss the "Read more" link right next to "A Lift/MongoDB query DSL"?

      Perhaps the problem is you, not the link.

      --
      All my liberal friends think I'm a conservative, all my conservative friends think I'm a liberal.
    2. Re:Gibberish - wrapped up as geekspeak by MagicM · · Score: 1, Flamebait

      If you're on Slashdot, you shouldn't need a link to tell you what Rogue-like means.

    3. Re:Gibberish - wrapped up as geekspeak by Anonymous Coward · · Score: 0, Troll

      Are you a bit retarded? I have to ask because... anyone who thinks that making people click through two links and spend 10 minutes trying to digest a page of poorly written shit... JUST TO FIND OUT WHAT THE FUCK THE ARTICLE IS ABOUT IN THE FIRST PLACE... must be sub-normal.

      No offence you understand. You're just stupid, and you need to be told so.

    4. Re:Gibberish - wrapped up as geekspeak by JustOK · · Score: 1

      maybe there was a type mis-match in your query.

      --
      rewriting history since 2109
    5. Re:Gibberish - wrapped up as geekspeak by Samantha+Wright · · Score: 5, Funny

      This exactly.

      The server hits you with its internal schema!
      You cast SELECT * FROM ut_f81 INNER JOIN ut_f81 alt_ut_f81 ON alt_ut_f81.globalid = ut_f81.rrn / 2 WHERE (SELECT * FROM ut_f81 INNER JOIN ut_f81 alt_ut_f812 ON alt_ut_f812.globalid = alt_ut_f81.rrn / 2 WHERE (SELECT * FROM ut_f81 INNER JOIN ut_f81 alt_ut_f813 ON alt_ut_f813.globalid = ut_f81.rrn / 2 WHERE (SELECT 1 FROM ut_f81) = 1) = 1) = 1
      The server freezes, taking all of your work with it!

      Do you want your possessions identified?

      --
      Bio questions? Ask me to start a Q&A journal. Computer analogies available for most topics!
    6. Re:Gibberish - wrapped up as geekspeak by Anonymous Coward · · Score: 0

      Is that "Slashdot", meaning what it used to be, or "Slashdot", meaning what it has become? If you want your old family of adroit cognoscenti, you might look in some dark net chat groups. You ain't gonna to find them here anymore.

    7. Re:Gibberish - wrapped up as geekspeak by Anonymous Coward · · Score: 0

      Sadly, you described the vast majority of slashdot users. Even worse, if when you read this, you don't think, "he's right", then you're the reader is also likely, "fucking stupid."

    8. Re:Gibberish - wrapped up as geekspeak by Anonymous Coward · · Score: 0

      Wrong roguelike, actually. AKA "what the hell were these guys thinking when they named slashem, a roguelike, when there's already Slash'Em, a Rogue-like"?

    9. Re:Gibberish - wrapped up as geekspeak by Hylandr · · Score: 1

      You call us F*ing stupid, but yet you're the only one that had difficulty figuring it out...

      - Dan.

      --
      ~ People that think they are better than anyone else for any reason are the cause of all the strife in the world.
    10. Re:Gibberish - wrapped up as geekspeak by Darinbob · · Score: 2

      I know what the rogue game is, and I know what rogue-like games are. I am utterly and completely baffled how this applies to databases and the link was not informative (it was the opposite of informative because now I think I know even less than I did before I tried to read it).

    11. Re:Gibberish - wrapped up as geekspeak by SQLGuru · · Score: 1

      And here I was expecting Slash'em and Rouge-like to refer to the text based dungeon explorer games......so get off my digital lawn.

    12. Re:Gibberish - wrapped up as geekspeak by LordLimecat · · Score: 2

      Roguelike was a joke I think, and probably shouldnt have been added to the submission.

      Not being either a programmer or a database admin, I still think I grasped the point-- that there is a new language out for database queries which prevent you from making invalid database queries because of wrong types (string vs binary).

      I dont think it was awful as submissions go, but I suppose they could have clarified what a database is, what type-safe is, and what a query is.

    13. Re:Gibberish - wrapped up as geekspeak by Anonymous Coward · · Score: 0

      You're fucking stupid if you censor your own posts on an Internet forum, you fucking stupid fuckface.

    14. Re:Gibberish - wrapped up as geekspeak by zindorsky · · Score: 1

      Wait guys. Someone named "Samantha" just made an awesome SQL + Nethack joke and no one here has proposed to her yet. What the hell is Slashdot coming to?

      Samantha Wright, will you marry me?

      --
      If the geiger counter does not click, the coffee, she is not thick.
    15. Re:Gibberish - wrapped up as geekspeak by Samantha+Wright · · Score: 3, Interesting

      That's probably because everyone else on the entire internet has already proposed. I think it's bad luck to try the same pickup line twice on the same woman.

      ...while it's flattering, I don't think my girlfriend would be too happy.

      --
      Bio questions? Ask me to start a Q&A journal. Computer analogies available for most topics!
    16. Re:Gibberish - wrapped up as geekspeak by bondsbw · · Score: 1

      You're the one who can't read, therefore I'm stupid.

      Makes sense.

      If you're a moron.

      --
      All my liberal friends think I'm a conservative, all my conservative friends think I'm a liberal.
    17. Re:Gibberish - wrapped up as geekspeak by bondsbw · · Score: 1

      "Rogue is a type-safe internal Scala DSL for constructing and executing find and modify commands against MongoDB in the Lift web framework."

      First line in the readme.

      If you don't understand that, and can't use that page and Google to help you understand, then you need to move on to the next article. Your comment is pointless. Learn how to research things for yourself.

      It would be like me seeing a summary article about gravity waves, and clicking a link to the Wikipedia entry on general relativity, and complaining because the first sentence doesn't tell me everything I need to know to understand how one relates to the other.

      --
      All my liberal friends think I'm a conservative, all my conservative friends think I'm a liberal.
    18. Re:Gibberish - wrapped up as geekspeak by Darinbob · · Score: 1

      Wikipedia would tell you what gravity waves are. The links did not tell anything about rogue-like. Besides 99.95% of slashdot knows that rogue-like refers to games. So we're all going to look at this and think about games and try to read further instead of moving on.

    19. Re:Gibberish - wrapped up as geekspeak by evilviper · · Score: 2

      This is not gibberish by any stretch. I understood every bit of the summary upon first read (while jet-lagged and half-asleep) found the links directed me to the follow-up info I would want. and with my only point of reference being that I happen to have a basic understanding of what Solr is (ie. search engine, in java).

      Consider that:
        a) not every /. story needs to be relevant and comprehensible to you.
        b) summaries don't need to be book length and include an intro to computer science. /. used to be a hang-out of highly technical people, and have stories based on that, not appeal to everyone who knows how to pronounce "Linux".

      Anyhow, if you think the summary can be done better, then do it. Write a more approachable summary that doesn't balloon out, or become information-free. Otherwise, STFU while the adults are speaking....

      --
      Slashdot gets worse every day... Pipedot: News for nerds, without the corporate slant
    20. Re:Gibberish - wrapped up as geekspeak by Anonymous Coward · · Score: 0

      By now we have all learned through bitter experience that 99.9% of females on slashdot are transsexuals.

    21. Re:Gibberish - wrapped up as geekspeak by Per+Wigren · · Score: 1
      --
      My other account has a 3-digit UID.
    22. Re:Gibberish - wrapped up as geekspeak by Anonymous Coward · · Score: 0

      The only important point is that MongoDB is Web Scale. Is "Rogue" Web Scale? If it it Web Scale I will use it.

    23. Re:Gibberish - wrapped up as geekspeak by geminidomino · · Score: 2

      Maybe we all know better than to marry a woman who can compose such Lovecraftian monstrosities in the guise of SQL queries. ;)

    24. Re:Gibberish - wrapped up as geekspeak by Anonymous Coward · · Score: 1

      Oh well... if you could understand it half-asleep and jet-lagged... it must be ok.

      People like you are the reason normal people hate IT. If you can look at that article submission and think "that's fine as it is" and write the post you just did without a trace of irony ... then you are an immature socially retarded halfwit.

      Clue: "highly technical"l doesn't mean an in-depth knowledge of every bit of web 2.0/nosql bullshit with ironic names that only about 3 people (including its creator) give a shit about.

    25. Re:Gibberish - wrapped up as geekspeak by bondsbw · · Score: 1

      The Rogue link in the summary explains EXACTLY what Rogue is. It is a domain specific language for database commands.

      Are you seriously getting this worked up over using the term "Rogue-like" instead of "similar to Rogue"? Do I get worked up over Slashdot articles that say Microsoft is a monopoly, simply because there is a popular game called "Monopoly" I like to play?

      Give me a break.

      --
      All my liberal friends think I'm a conservative, all my conservative friends think I'm a liberal.
    26. Re:Gibberish - wrapped up as geekspeak by Securityemo · · Score: 1

      Nobody is assumed to have knowledge about "every bit of web bullshit". However, everyone in the audience is assumed to know how to look up and comprehend basic information about anything computer or IT related, should they wish. What are you so agitated about?

      --
      Emotions! In your brain!
    27. Re:Gibberish - wrapped up as geekspeak by Anonymous Coward · · Score: 0

      "Web scale" being a code word for: about as useful at holding onto data as an alzheimer's patient.

    28. Re:Gibberish - wrapped up as geekspeak by Motor · · Score: 1

      Nobody is assumed to have knowledge about "every bit of web bullshit".

      Well actually, the author of the submission did.

      No-one is talking about an encyclopedia entry - just a bit of context for those of us who don't spend our time fetishising the latest nosql data bucket with holes in it.

      --
      We all know that crap is king
      Give us dirty laundry!
    29. Re:Gibberish - wrapped up as geekspeak by Anonymous Coward · · Score: 0

      I think this is supposed to be a really, really nerdy pun, Or someone who's neck deep in nerdiness and uses words he doesn't fully grasp the meaning of.

    30. Re:Gibberish - wrapped up as geekspeak by Mitchell314 · · Score: 1

      Maybe because this isn't an elevator, and I'll be damned if I'm sharing my precious coffee with anybody. :D

      --
      I read TFA and all I got was this lousy cookie
    31. Re:Gibberish - wrapped up as geekspeak by evilviper · · Score: 1

      This is /.
      "Normal people" don't belong here.
      No prereq knowledge is required to comprehend the summary.

      I see you didn't bother to come up with a better one, as I suggested.

      --
      Slashdot gets worse every day... Pipedot: News for nerds, without the corporate slant
    32. Re:Gibberish - wrapped up as geekspeak by starsky51 · · Score: 1

      I dont think it was awful as submissions go, but I suppose they could have clarified what a database is, what type-safe is, and what a query is.

      To be fair, the title of the story was 'Type Safety Coming To DB Queries.' If you don't know what four of those six words mean, then it probably isn't for you.

      --
      There are 2 types of people in this world. Those who understand ternary and those who don't.
    33. Re:Gibberish - wrapped up as geekspeak by Meski · · Score: 1

      He's an AC, you need to make allowances for them. Like the ones you make for your easily bewildered uncle.

  2. Slashem, a roguelike by Xgamer4 · · Score: 5, Insightful

    ...Well, there's a namespace collision. There's Slashem and roguelike as referenced in the summary, and Slash'em and Roguelike as-in the Nethack-based game and the game genre. There's no way that wasn't intentional, and whoever's brilliant idea it was needs to be shot.

    1. Re:Slashem, a roguelike by roman_mir · · Score: 0

      In both comments, yours above, and mine there is reference to shooting stuff. So is it possible I may be onto something when I say xml makes people angrier and more violent?

    2. Re:Slashem, a roguelike by Xugumad · · Score: 1

      I'm personally of the opinion that the only way they could make me trust anything they've ever touched with data, less, would be to call it "Willloseyourdata" or similar. This makes GIMP look like a masterpiece of software naming.

  3. Confusing much? by Aladrin · · Score: 3, Informative

    http://en.wikipedia.org/wiki/Roguelike

    Rogue-like has already been used. It's very confusing to say your DB query language is like a video game.

    --
    "If you make people think they're thinking, they'll love you; But if you really make them think, they'll hate you." - DM
    1. Re:Confusing much? by Anonymous Coward · · Score: 0

      Never mind how confusing it is to name the shit after games that have LONG existed and are WELL known by the target audience.

      Where'd taco go? I want our /. back.

    2. Re:Confusing much? by Osty · · Score: 3, Informative

      Worse, Slash'EM is already the name of a (real) rogue-like (game). Obviously these guys are trying for a witty or clever play on "rogue-like" and "slashem", but it just comes off as confusing and lame.

    3. Re:Confusing much? by Anonymous Coward · · Score: 0

      IT IS OK. Everything will work out and both these projects will thankfully die. Hopefully something useful will be reincarnated with a better name like PreGreSQL or something.

    4. Re:Confusing much? by FhnuZoag · · Score: 1

      The submission is quite humorous as a joke about the need for type safety though, though not really encouraging of trust for the devs.

  4. Great more training wheels by Dunbal · · Score: 1

    10 GOTO 10

    --
    Seven puppies were harmed during the making of this post.
  5. Only a minor problem by Tablizer · · Score: 0

    Type-related problems in queries are generally pretty easy to catch in early testing. I don't put much stock in such technology and wish they would spend their efforts elsewhere. However, I imagine there are some niches where it makes a net positive difference.

    1. Re:Only a minor problem by Anonymous Coward · · Score: 1

      "Early Testing"? It should be caught while typing it or at least while proofreading it. Shitty code should not even make it to the "run" stage.

    2. Re:Only a minor problem by Tablizer · · Score: 1

      Only if they can find a way to do such without bloating up the code with verbose declarations.

    3. Re:Only a minor problem by Tablizer · · Score: 1

      So far I haven't seen a way to do such without verbose type or language constructs. They make code more bureaucratic in my experience. Bureaucratic code can be harder to read and maintain in many situations.

      (I posted a similar response before, but for some reason it got "lost". My apologies if this is a dupe.)

  6. LINQ by bondsbw · · Score: 4, Interesting

    The title is incorrect; type safety is already available in DB queries, at least on Windows clients. You can use LINQ directly in C# and VB, or standalone via LINQPad.

    I'm all for new languages... but IMHO, I think LINQ is better. It looks more like SQL for all of us who already know SQL. It reads in the most logical order for word completion (select is after from/where, not before). And it's very carefully built on top of pure functional structures (SelectMany is equivalent to monadic Bind).

    --
    All my liberal friends think I'm a conservative, all my conservative friends think I'm a liberal.
    1. Re:LINQ by shutdown+-p+now · · Score: 3, Interesting

      The difference between this and LINQ is that LINQ is more or less hardwired. Sure, it is just syntactic sugar for a bunch of method calls, and those methods can do anything they want, so there are many extensibility points; but you cannot add a new LINQ keyword from a C# library, for example - you're stuck with "select", "join", "orderby" etc.

      This one, on the other hand, only uses existing Scala constructs, with no need to alter the language itself.

      But, yeah, I wouldn't call it such a big difference in practice, so it's certainly not a first.

    2. Re:LINQ by moorster · · Score: 1

      LINQ is awesome! I agree that there are some subtle differences between the queries that you would write in LINQ and the queries you would write in Slashem. The great thing about LINQ is that it's available right there in your main C# codebase and you can use it to query XML files, databases, and even your own arrays and collections of objects. It has changed how I code and drastically improved my coding efficiency.

    3. Re:LINQ by AndrewNeo · · Score: 1

      You are most certainly not stuck (unless you're using query syntax, instead of method syntax) because all LINQ methods are just extension methods. A LINQ provider could easily add new ones.

    4. Re:LINQ by AndrewNeo · · Score: 1

      I really miss LINQ (especially LINQ-to-objects) when I write in other languages.

    5. Re:LINQ by shutdown+-p+now · · Score: 1

      unless you're using query syntax, instead of method syntax

      That was specifically what I was referring to when I said "keywords". Sure, you can add your own methods, but it's not really LINQ (Language INtegrated Query) then, isn't it? It's just a method that takes an expression tree.

      Scala is rather more flexible with regard to syntax, specifically so as to enable expressive DSLs, so there's no real need for a hardcoded set of keywords for sequence comprehensions like LINQ.

    6. Re:LINQ by Anonymous Coward · · Score: 0

      You don't need to resort to Windows development to get typesafe SQL queries. Squeryl is a Scala DSL that predates both Rogue and Slashem.

  7. WTH? by Blakey+Rat · · Score: 4, Funny

    I think that description might have been CleverBot making an attempt on the Turing Test. What the hell?

    1. Re:WTH? by Xugumad · · Score: 1

      I'm beginning to suspect there's a serious flaw in the Turing test, and it's humanity.

    2. Re:WTH? by FilthCatcher · · Score: 2

      Whoah! It's just occurred to me that although I've been lurking around here for quite a few years, I've never actually seen any of you...

  8. Reinventing the wheel by loufoque · · Score: 1, Insightful

    The domain-specific language should just be SQL itself, rather than some weird variant which is then used to generate some weird language with XML crap in it.

    Embed SQL into the host language using a DSEL (domain specific embedded language), type-check it, then convert the AST to a the equivalent SQL string and send it to a server.
    That's the right thing to do.

    And it's trivial to do in a language like Scala or C++ (which is personally think is ironically more suited for DSELs than Scala).

    1. Re:Reinventing the wheel by isj · · Score: 1

      Interesting. What is your opinion on embedded SQL? (as i Pro*C/C++ or equivalent)?

      I never completely understood most of my colleagues' preference for JDBC-like access to a database, when embedded SQL catches most errors much earlier (t compile-time). Sure, it is kind of ugly, but JDBC-like access with its many getString()/getNumber()/... isn't pretty either.

    2. Re:Reinventing the wheel by Anonymous Coward · · Score: 0

      LINQ2SQL has all sorts of flaws, but it's MS' take on this. They actually provide relational algebra constructs in the language, then provide a library that interacts with that syntax to access databases. It's clever, though it tends to have all the traditional ORM issues.

      Certainly better than whatever this is, however.

    3. Re:Reinventing the wheel by shutdown+-p+now · · Score: 2

      And it's trivial to do in a language like Scala or C++ (which is personally think is ironically more suited for DSELs than Scala).

      How would you do it in C++? Are you proposing a pure library solution (which I can't quite comprehend how you intend to implement), or a preprocessor?

    4. Re:Reinventing the wheel by CastrTroy · · Score: 1

      I very much agree with this. IDEs and compilers should just add support to embed SQL directly in the code. Just as other languages allow you to embed Fortran, Assembly, and other languages. In VB.Net you can embed XML Literals which vastly simplifies creating xml documents. If they just let you type SQL inline and type check it, maybe even verify table and column names against the database schema, then things would be great. We wouldn't even need linq, or entity framework. If they were really smart, they could let you write SQL against your objects, arrays, and anything else in your code, just as you can do with Linq, and we wouldn't have to learn another way of doing things, since just about every competant developer already knows SQL.

      --

      Anthropic principle: We see the universe the way it is because if it were different we would not be here to see it.
    5. Re:Reinventing the wheel by bug_hunter · · Score: 3, Informative

      Solr serves a different purpose to SQL. It is optimised for searching using text indexing with fancy ways of matching, weighting results when finding matches. Solr is actually a separate non-SQL database that you keep in sync with your real database. I've found it fits its purpose very well, and you rarely worry about the XML as library support handles it.
      SQL is great if you already know exactly what you're looking for. Solr is great if a human is performing a search.

      --
      It's turtles all the way down.
    6. Re:Reinventing the wheel by mcrbids · · Score: 1

      Parameterized queries require pre-registration with the database engine, and have a host of other gotchas. EG: No dynamically created SQL queries.

      Remembering to escape every variable also has it's own gotchas, including the inevitable security hole when you mistook public data as trusted source data.

      So we rolled our own variation of parameterized queries, that includes references to the table/field in question so that type analysis can be done on input prior to parsing the query statement. It's highly effective, and reads like SQL, while being highly effective at stopping injection attacks cold.

      The simple idea is that they query and the input are maintained separately all the way down to the DB abstraction layer. You *never* create the actual query outside the DB abstraction layer!

      I wonder why this type of approach isn't more common?

      --
      I have no problem with your religion until you decide it's reason to deprive others of the truth.
    7. Re:Reinventing the wheel by loufoque · · Score: 2

      C++ supports domain-specific embedded languages, which blur the distinction between libraries and compilers.
      DSELs in C++ are implemented through expression templates, Boost.Proto formalizes the way to define grammars and tree transformations for such things.

    8. Re:Reinventing the wheel by dkf · · Score: 2

      Parameterized queries require pre-registration with the database engine, and have a host of other gotchas. EG: No dynamically created SQL queries.

      No. That's just your sucky database client library. OTOH, if you've got a parameterized query then you absolutely should be able to cache it so that you can reuse it, avoiding a recompile of the query where not necessary. Some client libs can handle that for you automatically, others are more intrusive. (Some languages even have wrapping layers available that make nasty low level libs much more palatable.)

      That the language is SQL or something else, that's wholly independent really.

      Remembering to escape every variable also has it's own gotchas, including the inevitable security hole when you mistook public data as trusted source data.

      Now that is very true. If you're thinking about doing that, STOP! and consider whether it is at all possible for you to do it a different way. If you're thinking about allowing arbitrary users to type in full SQL queries, take great care to document that you're doing it (and that they need to be executed in a very limited database account) so as to avoid amazing amounts of trouble. (Also consider psychiatric assistance.)

      --
      "Little does he know, but there is no 'I' in 'Idiot'!"
    9. Re:Reinventing the wheel by Anonymous Coward · · Score: 0

      That's just your sucky database client library

      They've gotten a lot better since I started complaining about them (That was back when a one-off query took dozens of calls to bind_params and queries were parameterized by order alone, meaning that if someone wanted to come along and narrow their tshirt search by size AND color, then you had to have an entirely different search_database_by_size_and_color() leading to a very dailywtfian explosion of 50 different functions for every possible combination) because despite the fact that languages since perl have had hashes or associative arrays, it wasn't until very recently that anyone thought "gee, I could pass an associative array with all the parameters."

      They still have a long way to go. It only takes two lines to write $result=db_query("select * from customer where id=".$customerid); $row=db_get_row($result) When we can $row=db_param_query_single_row_as_array("select * from customer where id=:customerid",$_POST); my job will be done.

    10. Re:Reinventing the wheel by shutdown+-p+now · · Score: 1

      I don't see how you could possibly implement "SQL itself" as a DSL in C++ templates. Boost.proto or not, your syntax options are still constrained by what C++ has to offer.

    11. Re:Reinventing the wheel by loufoque · · Score: 1

      Of course, it must be valid C++ syntax. But that's hardly a serious limitation.

      select >> "*" >> from >> "t" >> where >> "foo" == "bar"

      is a possible syntax. You could also use '.', '[]', or whatever you think is nice.

    12. Re:Reinventing the wheel by MoNsTeR · · Score: 1

      Parameterized queries require pre-registration with the database engine, and have a host of other gotchas. EG: No dynamically created SQL queries.

      This is a feature, not a bug.

      Build all your queries as parameterized queries (or better yet, stored procedures) and you will never have "type safety" problems. In fact the posting barely makes sense to me. How would you ever end up trying to date-range a string field? That query would never run! Oh right, there are still idiots out there that build queries at runtime. Well, don't fucking do that!

      Besides, parameterized queries are 100% immune to SQL injection. You'd think people would care more about that these days.

  9. I like these training wheels by CheeseTroll · · Score: 1

    Because as someone who writes SQL queries all day long and thinks this is silly, I now have a reason to feel superior. :-)

    --
    A post a day keeps productivity at bay.
    1. Re:I like these training wheels by Anonymous Coward · · Score: 0

      That's why I don't cover my rotating blades. Haven't needed it yet. No, the missing hand was on purpose, I swear!

    2. Re:I like these training wheels by sgt+scrub · · Score: 1

      as someone who writes SQL queries all day long

      Cool. Maybe you can help me with something. I have a table (time_stamp | direction | bytes). I use the data to draw two lines. An out line and an in line. Each point of the line is a sum of bytes over 10 seconds for a range of time. Is there a way to return a series of sums without using code to decrement variables and run a query for each sum? ie. return a sum per 10 seconds over 60 seconds. Or basically, replace the code below.

      int start_time=-60, end_time=-50;
          for (i=0;i6;i++) {
          query = "select direction, sum(bytes) as b from packets where time_stamp between datetime('now', start_time, 'localtime') and datetime('now', end_time, 'localtime') group by direction;"
          runQuery(query);
          start_time=start_time+10;
          end_time=end_time+10;
      }

      --
      Having to work for a living is the root of all evil.
    3. Re:I like these training wheels by MoNsTeR · · Score: 1

      You need a subquery that generates the iterative values for you.  Oracle provides a concise way to do this right in your query:

      select x.start_time
           , p.direction
           , sum(p.bytes) as b
        from (select -60+10*(level-1) as start_time
                from dual
              connect by level <= 6
             ) x
           , packets p
      where p.time_stamp >= x.start_time
         and p.time_stamp <  x.start_time+(10/24/60/60)
      group by x.start_time
              , p.direction

      If your RDBMS doesn't have an equivalent to CONNECT BY LEVEL, you will either need to put your values in a table (think a reusable "integers" or "dates" table), or do something like (select -60 as foo from dual UNION ALL select -50 from dual UNION ALL select -40...and so on).

    4. Re:I like these training wheels by sgt+scrub · · Score: 1

      Very nice. Thank you!

      --
      Having to work for a living is the root of all evil.
  10. call for timothy to resign from slashdot by Anonymous Coward · · Score: 0

    nuff said

  11. Dumbing it down by Wolfling1 · · Score: 0

    This appears to be more of the 'nanny state' mentality that Microsoft is shoving down our throats.

    When a coder (or more accurately a DBA) puts dates in a string field, they usually have a good reason to do so. Preventing them from doing a date range query on their string field reduces their ability to function efficiently. Sure, it is elegant, but elegant usually means bigger, fatter and slower.

    This is the old case of narrowing the band of opportunity so that the lowest performers can't make the obvious mistakes. When will they realise that they are also stifling the highest performers? Give us some credit folks. We're not all first year out of college. /rant

    1. Re:Dumbing it down by Stone+Rhino · · Score: 2

      There are a couple of problems with this:

      1. Everybody thinks they're the highest performers. You have to be smart enough to know when you're being dumb, and most of the dumb performers aren't smart enough to realize it.

      2. You assume there's a good reason for doing things a certain way, and that reason hasn't been invalidated. Programmers used COBOL, FORTRAN, and Assembly for a good reason, and now very few programmers use them, for smaller good reasons. This is a move to a higher level language. People did raw pointer math in C, in part because it was fast and in part because there wasn't a better way to do it. Now we have higher-level languages that handle that material, and they are slower to run, but much faster to code.

      The basic fact about higher level, more insulated languages is that programmer time is much more expensive than computer time, and programmer mistakes are even more expensive. The narrowing opportunity that this produces means less ability for high-performance, hacky, unmaintainable code that no one else is smart enough to understand, but much more opportunity for building powerful applications. The explosive growth of web apps is directly tied to the power of the languages they're built on.

      I know nothing about this particular implementation, but the concept of protecting the programmer from himself is actually a sound one, and I think you need to avoid being so defensive about it.

      --


      Remember, there were no nuclear weapons before women were allowed to vote.
    2. Re:Dumbing it down by shutdown+-p+now · · Score: 1

      When a coder (or more accurately a DBA) puts dates in a string field, they usually have a good reason to do so. Preventing them from doing a date range query on their string field reduces their ability to function efficiently.

      A proper implementation of something like this wouldn't prevent you from doing a range query on the string field - it would, however, require that you write an explicit cast from string to date before you can apply date operators to it. The output SQL might not have anything corresponding to such a cast if it's not needed; its whole point is to indicate that you really know what you're doing to the type checker.

      Static typing is almost always a good thing in big projects, and database queries are no exception.

    3. Re:Dumbing it down by InsertCleverUsername · · Score: 3, Insightful

      This appears to be more of the 'nanny state' mentality that Microsoft is shoving down our throats.

      Sheesh... I was going to moderate a few items in this thread, but I just have to reply to your ignorant excuse to bash M$ --like they invented type-safety.

      This is the old case of narrowing the band of opportunity so that the lowest performers can't make the obvious mistakes. When will they realise that they are also stifling the highest performers? Give us some credit folks. We're not all first year out of college.

      Really? Technologies that help minimize errors through convention are a bad thing? So if you're in a shop that saves countless hours of time and debugging using a modern ORM like Hibernate, that makes you some sort of slack-jawed moron because "real" programmers do everything in assembly and don't need no stinkin' oversight, static code analysis, testing, or code review, right? Sheesh... Remind me not to hire you to code any systems where human safety is on the line. Most employers --even for inconsequential crap-- would rather have working apps than theoretically pure code; they can buy another rack of servers for what a good developer earns, so in most cases they really don't give a damn about efficient code.

      Besides, even if you think type-safety = training wheels, if you've been coding long enough, you'll see idiots and geniuses get slapped by typos and inadvertent mistakes. Only an amateur thinks they're immune to error and that things like type-safety just cramp your style. And real programmers can go around these things off when they need to, but take advantage of lower bug counts the rest of the time.

      --
      Ask me about my sig!
    4. Re:Dumbing it down by Chris+Mattern · · Score: 1

      When a coder (or more accurately a DBA) puts dates in a string field, they usually have a good reason to do so.

      How I wish I had your faith in the average DBA.

    5. Re:Dumbing it down by Aighearach · · Score: 1

      People did raw pointer math in C, in part because it was fast and in part because there wasn't a better way to do it.

      I disagree, I think they did it because they were suffering from NIH and refused to select a library that did hid that nonsense in a safe place.

    6. Re:Dumbing it down by FlyingGuy · · Score: 1

      No idiot, they did pointer match because it was blindingly fast and it had nothing to do with NIH, it had to do with good solid programming using the machine as efficiently as possible. I they build "web languages" that way today fucking /. it would not take for fucking ever and a rack full of servers ,to do anything.

      --
      Hey KID! Yeah you, get the fuck off my lawn!
    7. Re:Dumbing it down by FlyingGuy · · Score: 1

      You'll see idiots and geniuses get slapped by typos and inadvertent mistakes

      And you think this bit of crap will prevent that? Sheeeesh are you really that naive?

      --
      Hey KID! Yeah you, get the fuck off my lawn!
    8. Re:Dumbing it down by FlyingGuy · · Score: 1

      How your average DBA wished they had any faith in the piss pore excuse for programmers they see these days.

      --
      Hey KID! Yeah you, get the fuck off my lawn!
    9. Re:Dumbing it down by bytesex · · Score: 1

      That is the thing. More modern programming languages aren't easier - they've just got more clear-text primitives and fewer possibilities. But possibilities are just confusing (it is reasoned), and more typing is caught by using auto-completion on eclipse.

      --
      Religion is what happens when nature strikes and groupthink goes wrong.
    10. Re:Dumbing it down by Wolfling1 · · Score: 1

      The problem with these 'higher' programming languages is that they are the house built upon the sand.

      The folks that build the microprocessors have everyone else by the balls, and we don't even know it.

      Introduce true multi-core processors, and where is your VB? Where is your Python? Your Java? Your Eclipse?

      Introduce Quantum computing, and all the high level languages need to be thrown out because they will be incapable of expressing a functional solution to a problem on these new platforms.

      All that this is doing is breeding a generation of programmers who are too lazy to manage their typecasting properly because the auto-completion does it for them.

      To me, this is about the distinction between 'business programming' and 'computer science'. In business, you want your development platform to compensate for the McDonald's grade programmers you hire (because they're cheap). In science, you want freedom to innovate and explore.

      This technology has its place, and it is at the boring end of the spectrum.

    11. Re:Dumbing it down by InsertCleverUsername · · Score: 1

      You'll see idiots and geniuses get slapped by typos and inadvertent mistakes

      And you think this bit of crap will prevent that? Sheeeesh are you really that naive?

      Clearly you're right. There is no amount of idiot-proofing that can't be overcome by a determined idiot, so having tools/languages/methodologies that help prevent errors is just a horrible idea. Type-safety, enumerations, compiled code, etc. are really bad ideas that add nothing to the quality of our code. We should all be using scripting languages programmed on punch cards so our code will be the bestest evar. Avoidable run-time errors like type mismatches that crash production systems are a good thing --don't you love surprises?

      --
      Ask me about my sig!
    12. Re:Dumbing it down by sgt+scrub · · Score: 1

      Unless your working with sqlite3 where the date field is a string. Being forced to use date or datetime to examine the text field so the engine compares entries with the correct string format isn't much different from this approach.

      --
      Having to work for a living is the root of all evil.
    13. Re:Dumbing it down by FlyingGuy · · Score: 1

      Nope I sure don't, but I also do not like having to include 500 megs of code to be able to do anything.

      Is there no fucking end to this "nanny state and let's put rubber baby buggy bumpers and fucking everything" just so some god damn fucking moron can play at being a programmer?

      The world has sharp corners how about having an attention span great then that of gnat and pay attention to what you are doing? Now there's a novel concept!

      But oh no, lets take a perfectly serviceable, and quite excellent language like SQL and wrap it in 500 megs of dumb down code so that idiots can play at being a programmer. How many people bitch on moan about the Linux kernel not being written in a language that is all warm and fuzzy so that joe sixpack can write drivers for it without knowing a thing about hardware and memory allocation and utilization?

      --
      Hey KID! Yeah you, get the fuck off my lawn!
    14. Re:Dumbing it down by badkarmadayaccount · · Score: 1

      The type safety is compile time. After compilation, it's as if it doesn't exist. Oh, and Glasgow Haskell and Gambit-C Scheme would like to have a word with you. Right after Ada, Eiffel and Modula-3 are done with you.

      --
      I know tobacco is bad for you, so I smoke weed with crack.
    15. Re:Dumbing it down by InsertCleverUsername · · Score: 2

      Nope I sure don't, but I also do not like having to include 500 megs of code to be able to do anything.

      Look... If you're writing high-performance device drivers, cutting edge physics simulation engines, or the like, my hat's off to you --that's serious code where every cycle counts. For the other 99.9% of us, ruthless efficiency isn't our highest priority anymore; we are being paid to be productive and not screw up. If a complex app takes one hour to debug rather than one month, I have more time and money. Smart people use productivity tools to their advantage.

      Is there no fucking end to this "nanny state and let's put rubber baby buggy bumpers and fucking everything" just so some god damn fucking moron can play at being a programmer?

      Admittedly things like M$ VB have lowered the bar and many employers don't know good developers from bad, but saying that easier to use technologies are bad is Luddite thinking along the lines of saying that people being able to place their own phone calls or take their own photos is somehow a bad thing. Besides, if you don't like the safeguards on newer systems, nobody is preventing you from continuing to write everything in assembly, COBOL, or binary if you like.

      The world has sharp corners how about having an attention span great then that of gnat and pay attention to what you are doing?

      "attention span great then that of gnat"?

      Wow, look at that. If this were code, you'd have three errors in under six words --and there's more nitpicking material where that came from. I'm guessing that without a spell checker (another one of those damned, meddling, nanny state things!) you might have made even more errors. Back in the good old days when I wrote code in scripting languages, simple mistakes often wouldn't be caught until a user hit a particular piece of code. I much prefer finding obvious problems at compilation --or not even making those mistakes thanks to things like code auto-completion (or training wheels, as you might say). My tools aren't dumbed-down, they're smart enough that I can worry about the big ideas instead of investing mental energy in double-checking my data types and other distractions.

      --
      Ask me about my sig!
  12. the more xml by roman_mir · · Score: 1

    The more xml I see the more I want to shoot something.

    We are going in a weird direction, I am not saying it's right or wrong, but it's weirdly unpleasant and doesn't add simplicity to development, though of-course it depends what kind of development this is compared to. But I swear, the more levels of indirection is added with everything that cannot be simply executed in a debugger, the harder it's becoming to figure out what's happening quickly.

    The point is that it seems to me that all these tools with multiple levels of indirection are aimed at more and more specialization, which may be fine with infinite resources on projects, but it's probably not fine in economic times, when fewer people are expected to handle more stuff.

    1. Re:the more xml by FlyingGuy · · Score: 1

      XML, the answer to the question nobody asked.

      --
      Hey KID! Yeah you, get the fuck off my lawn!
    2. Re:the more xml by badkarmadayaccount · · Score: 1

      I think the solution is compiling in most of the stuff. XML -> S-Expressions -> Lisp

      --
      I know tobacco is bad for you, so I smoke weed with crack.
  13. solution in search of a problem by Anonymous Coward · · Score: 1

    Type errors in Solr queries don't strike me as a burning problem.

  14. Real developers are fed up with this shit. by Anonymous Coward · · Score: 0

    Don't worry, real developers have had just about enough of the Ruby on Rails/server-side JavaScript/DSL/Node.js/NoSQL/github know-nothings. They're starting to get shunned, and it's picking up steam.

    There have been too many failed projects, too many unmaintainable systems, too many poor-performing applications, and too much data loss from this crowd. Everybody can and will make mistakes, and we do tolerate them now and then, but with these people it's one filthy fuck-up after another.

    What's worse is that their chosen technologies are merely a half-assed way of avoiding the proper solution (which often takes some time and effort to learn).

    Using Ruby on Rails is merely an excuse to avoid learning how to do proper web development. Server-side JavaScript is merely an excuse to avoid learning a real programming language that's suitable for back-end development, such as Java, C#, C++, Python or even goddamn Perl. DSLs are just an excuse to waste time building useless and unmaintainable libraries rather than doing real software development. Node.js is just an excuse to avoid learning how to use real web servers or application servers. NoSQL is just an excuse to avoid learning SQL and the proper use of relational databases. Github is just an excuse to avoid doing any sort of open source project management, including the basic task of preparing periodic releases.

    It's only a matter of time before these fools have been completely run out of the industry. We'll go back to using real programming languages, real servers, real database systems, and get back to getting real work done.

    1. Re:Real developers are fed up with this shit. by Aighearach · · Score: 1

      You're so scared of us, you've gone coward.

      Be afraid, be more afraid.

    2. Re:Real developers are fed up with this shit. by Anonymous Coward · · Score: 0

      Oh no! People are using new technologies that I don't approve of! Quickly, start crying on the internet.... before it's too late...

  15. And why does... by wisnoskij · · Score: 2

    playing on words to make the most confusing and least informative summery possible make sense?
    I am sure people will go away with from this article thinking that this DB thing actually has something to do with randomly generated dungeons.

    I know, how about we use alliteration in all of /.s articles from now on, at least that would be better then actually trying to confuse people.

    --
    Troll is not a replacement for I disagree.
    1. Re:And why does... by Anonymous Coward · · Score: 0

      I am sure people will go away with from this article thinking that this DB thing actually has something to do with randomly generated dungeons.

      Yeah, and you should have seen how confused I was when Infocom released Cornerstone.

  16. LINQ by moorster · · Score: 1

    I've been using LINQ for years and it's great. It's just like this Slashem concept but it's built-in to a manistream language: C#/VB. With LINQ you write your queries inline with the rest of your C# or VB code. They're not in a quoted string or separate resource file. You get the full syntax highlighting and intellisense as well as the red squiggly underline when you've done something wrong. They are type-safe and they play nicely with the language's collection classes. LINQ-to-Entities and LINQ-to-SQL are the variants that query databases (MySQL, Oracle, SQL Server, etc.). There are other variants like LINQ-to-XML and LINQ-to-Objects that can perform traditional relational queries against XML files or against your own objects and collections. You can mix and match these types of LINQ queries effortlessly. It's so powerful, easy to read and convenient that it has fundametally changed how I code.

  17. How about content safety, instead... by davecason · · Score: 1

    I'd like some tools help with the generic of bad ideas like: deletes with no where usage of with grant option on objects grants of public to individual objects inserts of text into numeric fields (where we started) lots of joins without lots of index usage

  18. I don't understand... by Chris+Mattern · · Score: 4, Funny

    How will getting the Amulet of Yendor get me type safety?

    1. Re:I don't understand... by Anonymous Coward · · Score: 0

      I am not sure but getting the "Amulet of Yendor" sounds pretty cool and it may actually work.

    2. Re:I don't understand... by Anonymous Coward · · Score: 0

      It gets you type danger, unless you have enough scrolls of genocide to remove the right types.

      On an unrelated note, I'm developing a database called powder with a command language called angband. :P

    3. Re:I don't understand... by Anonymous Coward · · Score: 0

      You must first acquire the Amulet before you can escape() the dungeon instance.

  19. SQLJ by Anonymous Coward · · Score: 0

    Doesn't SQLJ accomplish this for Java?

  20. Databases are already strongly typed by dodobh · · Score: 1

    What is missing is the lack of ability of modern programming languages to grab type information from the database and generate new types on the fly.

    Database types are per column, *AND* per tuple.

    Every SQL query results in a new type, or an instance of a known type.

    General purpose programming languages need to support sets as a first class object, as opposed to iterable collections. Do that, and you don't need hacky ORMs. But then, most modern "OO" languages aren't designed to be extensible.

    --
    I can throw myself at the ground, and miss.
    1. Re:Databases are already strongly typed by rycamor · · Score: 1

      Bingo. Exactly what I have been saying for years, but... we both know that this sort of idea is far too sensible and boring for the 'concept du jour' programming community.

  21. Too much football today... by Anonymous Coward · · Score: 0

    I totally read that headline wrong.

  22. type-safe binding to PostgreSQL for OCaml by Anonymous Coward · · Score: 1

    PG'OCaml has been doing this for years: http://pgocaml.berlios.de/
    "Moreover, it uses the describe feature of PostgreSQL to obtain type information about the database. This allows PG'OCaml to check at compile-time if the program is indeed consistent with the database structure. This type-safe database access is the primary advantage that PG'OCaml has over other PostgreSQL bindings for Ocaml."

  23. Already been done!!! by Ramin_HAL9001 · · Score: 1

    This is nothing new.

    A good database engines already has type checking, and so as long as your query language is type-safe and respects the types built-in to the database engine, then your query language will also be type safe. So all you need to do is write a library that can execute queries in a language like Haskell or Scala which makes use of static type checking, and you have got statically type-checked database queries.

    Haskell has had its own database query library for years now, which works with several back-end databases including SQLite and MySQL.

  24. Catch on? Like this? by Sxooter · · Score: 1

    select 1 where '2001-01-02 00:00:00'::text between '2001-01-01 00:00:00'::timestamp and '2001-01-05 00:00:00'::timestamp;
    ERROR: operator does not exist: text >= timestamp without time zone
    LINE 1: select 1 where '2001-01-02 00:00:00'::text between '2001-01...
                                                                                                            ^
    HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.

    Hey whadya know, postgres has been doing this for years now.

    --

    --- It is not the things we do which we regret the most, but the things which we don't do.
  25. Type safety schizofrenia by zarlino · · Score: 1

    So everybody hypes languages that are not type safe (JS, Python, PHP, etc.) and at the same time type safe SQL is considered interesting. Make up your minds!

    --
    Check out my cross-platform apps
  26. Yeah, hope this catches on by yacc143 · · Score: 0

    Wonder how static typing manages to keep the developer from querying the day-of-death field instead of the day-of-birth field he wanted in the first place.

    Hmmm, it does not, but most developers don't bother with this edge case bug, I mean the compiler catches it if I use the data wrongly, right?

  27. Don't use MySQL by WaffleMonster · · Score: 1

    You know what would really be cool is a boost style dimensional analysis system bound to schema meta data. Otherwise is it really necessary to invent a new a new language to introduce strict mode to existing query languages?

  28. Pointless by treerex · · Score: 1

    I'm not sure I understand the point of this extension: compile time type safety for internal (i.e., compiled) queries against a full-text database. Seems like a nice POC that has really no use in real life. The "rogue-like" moniker escapes me completely: is this some reference to database technology I'm not aware of? I just found it confusing.

  29. Solution looking for a problem by sproketboy · · Score: 1

    Let me get this strait. You have a feature and you need to write some SQL queries. So you use a "type safe" language to do it. Compile. Commit. What? You never actually run the query? You're QA never runs the query?

    You're worried that someone will put a string into a date query? Ever heard of parametrized queries?

    Queries are a run time operation. Compile time safety buys you nothing except bad coding practices and a false sense of security.

    1. Re:Solution looking for a problem by PPH · · Score: 1

      You're worried that someone will put a string into a date query?

      Exactly. Compile time safety is worthless if your db app allows 'somebody' to put something into a field. The only way this (compile time) will buy you anything is if you can restrict all access to records to prevent wrong types from sneaking in. And this includes the administrative CLI that someone could use to manually poke garbage in.

      Run time safe apps need to handle type mismatches gracefully. A string where a date is expected in a query can be handled in a number of ways, depending on the needs of the app. But the development environment must allow for the cases in which such errors will slip in.

      --
      Have gnu, will travel.
    2. Re:Solution looking for a problem by badkarmadayaccount · · Score: 1

      Are you advocating dynamic typing?

      --
      I know tobacco is bad for you, so I smoke weed with crack.
    3. Re:Solution looking for a problem by PPH · · Score: 1

      I don't think so. In the above example, the field in question is type string, but the app expects a date. Or its such a crappy db that its possible for some app to shove a string into a date field without throwing an exception. Neither of these cases involve dynamic typing. But both need run time checking.

      Dynamic typing (to me) means that I should expect any possible type in each field and be able to deal with each one. All I'm saying is that an app needs to be able to handle two cases: the expected type, and some other crap. And handle them gracefully.

      The world would be a nice place in which to build apps if everyone touching your database would agree to (or could be forced to) use a type safe development environment. Good luck with that.

      --
      Have gnu, will travel.
    4. Re:Solution looking for a problem by badkarmadayaccount · · Score: 1

      Well, the code generation stage of your compiler could enforce it, using semantics gained from, you guessed it - the type system.

      --
      I know tobacco is bad for you, so I smoke weed with crack.
  30. ORM does this by Anonymous Coward · · Score: 0

    Been doing this with GORM/Hibernate for awhile; all my HQL queries are checked prior to compile and throw errors if the types don't match. This really is nothing new or extraordinary... at least for Java devs.

  31. Type safety for DB is great by phy_si_kal · · Score: 1

    This is good news. In related news, the recently released Opa also provides compile-time type safety for the DB, but it goes even further by providing type safety for the whole web application.

  32. Slashdot, a website by Anonymous Coward · · Score: 0

    ...Well, there's a namespace collision. There's slash and dot as referenced in the site's name, and / and . as in the characters commonly used in URLs. There's no way that wasn't intentional, and whoever's brilliant idea it was needs to be shot.

    FTFY