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

23 of 128 comments (clear)

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

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

    4. 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!
    5. 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
    6. 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. ;)

  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.

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

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

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

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

  7. 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.
  8. 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.
  9. 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!
  10. 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.
  11. I don't understand... by Chris+Mattern · · Score: 4, Funny

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

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

  13. 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'!"
  14. 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!