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."
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.
...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.
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
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.
I think that description might have been CleverBot making an attempt on the Turing Test. What the hell?
Comment of the year
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?
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.
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.
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!
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.
How will getting the Amulet of Yendor get me type safety?
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.
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'!"
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!