r/programming • • Jun 11 '16

My Increasing Frustration With Clojure

http://ashtonkemerling.com/blog/2016/06/11/my-increasing-frustration-with-clojure/
176 Upvotes

225 comments sorted by

View all comments

Show parent comments

0

u/uututhrwa Jun 12 '16

I can't ensure 100% that a function does take care of all the cases, and I might indeed need to use something like the algebric data types if I really need to ensure correcntess, but I don't see how those techniques have any application with data retrieval specifically (bad sql commands will easily fail anyway), and they can also be difficult to use for some "data driven" parts of a program that might parse user input from somewhere and use it as a command, like with the order by key example I wrote above.

1

u/[deleted] Jun 13 '16

bad sql commands will easily fail anyway

Ur/Web prevents bad SQL at compile time, using knowledge of your database schema. At runtime, bad SQL is never something to worry about.

1

u/uututhrwa Jun 14 '16 edited Jun 14 '16

Yeah by fail anyway easily I mean that the bad sql commands that can be adequately checked by a static typing system will just crash right away by the dbms anyway and not propagate errors making bug discovery and fixes rather trivial. While the really hard to track errors will usually be logical and I can't see how static types in sql commands will help much in avoiding those.

And like I said how the fuck is this gonna work with queries that are data driven? Is Ur/WebR or whatever the fuck is called running type analysis inside database tables or json strings? Is it reading the user's mind preemptively? Is it running inside the fucking Matrix?

Compile time SQL sounds like the usual pointless useless laughable god damn dumbass fizzbuzz enterprise edition bullshit of the IT industry.

1

u/[deleted] Jun 14 '16

running type analysis inside database tables or json strings?

  • The type checker knows your database schema. If you want to change the schema, you recompile your application, which re-type-checks the code against the new schema.

  • The type checker doesn't really process SQL strings, that would be awful! Instead it processes SQL syntax trees.

1

u/uututhrwa Jun 14 '16 edited Jun 14 '16

Static query construction using syntax trees? Don't nearly all ORM frameworks (Enity, Nhibernate etc.) do this to some extent? I can't say it's that useful, in fact I am usualy trying to bypass it. It can even get very wrong when it's done "high level" (with lazy loaded object members instead of relational queries), for example you might get n+1 selects out of nowhere.

I've also seen some version of the first with this library http://fsprojects.github.io/FSharp.Data.SqlClient/ and it's still not particularly important imo.

1

u/[deleted] Jun 14 '16 edited Jun 14 '16

Don't nearly all ORM frameworks (En[t]ity, N[H]ibernate etc.) do this? I can't say it's that useful, in fact I am usualy trying to bypass it.

It isn't pleasant with just nominal record types, because it forces you to define a struct/class/whatever for each relation schema (column set) a query could possibly return, or even worse, just treat every row as an array of Objects, which you then need to downcast, whether the downcasts are manually written by you, or generated by some wizard. Structural record types and row polymorphism are what makes type-checking arbitrary queries a breeze in Ur/Web.

1

u/uututhrwa Jun 14 '16

But that's not why I am trying to bypass it, it's because most generic code on data records should treat the column names as dynamic "keys" (and like I said if it's high level OO based you can get errors or significant performance degradation where you don't expect it)

1

u/[deleted] Jun 14 '16 edited Jun 14 '16

But that's not why I am trying to bypass it, it's because most generic code on data records should treat the column names as dynamic "keys"

Then the problem is with your insufficiently flexible database schema. Application-level hacks won't fix it.

1

u/uututhrwa Jun 14 '16 edited Jun 15 '16

I am not sure what that has to do with what I was saying. Some simple to describe cases of the above that I can remember were for loading ID, [text description] fields for comboboxes across entities, constructing filters, and loading some 1:n and m:n entities in some specific way across many cases of "parent" entities. The equivalent purely static code had a lot more repition.

edit: In fact it boggles the mind that after the above discussion you would tell me about "insufficient flexible schema" and link to an article about database normalization? Hello? What the fuck does this have to do with anything, are you on mind altering drugs? Did you have a stroke???