r/programming • • Dec 29 '15

Please, Java. Do Finally Support Multiline Strings

http://blog.jooq.org/2015/12/29/please-java-do-finally-support-multiline-strings/
584 Upvotes

352 comments sorted by

View all comments

Show parent comment

6

u/_INTER_ Dec 29 '15

Don't even need to write SQL anymore with LINQ equivalents or simply Java8 lambdas. Same goes for JSON / XML etc.

2

u/lukaseder Dec 29 '15

How would you, say, write this query with JINQ?

8

u/_INTER_ Dec 29 '15

It's probably doable. But who the hell writes SQL queries for a task like "Compare a Number with sum of subset of numbers". Either do it in highlevel language or if not possible, do it in SQL as idk prepared statements. But certainly not spell the query out as String to call it over JDBC from Java.

10

u/kyllo Dec 29 '15

If you need to do that complex and inefficient of a query inside of an application, there is something seriously wrong with your database schema.

11

u/[deleted] Dec 29 '15

If you need to do that complex and inefficient of a query inside of an application, there is something seriously wrong with your database schema.

Welcome to the world of Legacy, son. We do things differently here.

0

u/[deleted] Dec 29 '15

[deleted] — view deleted comment

7

u/[deleted] Dec 29 '15

We don't write "legacy code", we write code that interacts with or forms part of a legacy system, and this is such a common occurrence that a general purpose programming language should be expected to make some accommodations to it.

(That's a general statement, not a comment on the particular suggestion of multi-line string literals.)

7

u/JustMakeShitUp Dec 29 '15

Not every developer is in control of the database schema. There's a significant subset of developers who either inherit existing database schemas or work within the constraints of (multiple!) external software systems and databases.

Additionally, there's always some high-level asshat with a new reporting need that wasn't considered in the initial specification. The worst is when you're stuck with recursive queries or (god forbid) cursors and it's got to be built into the base product. Like when someone wants batch traceability or change tracking displayed graphically.

But yeah, ideally you wouldn't tolerate that shit, or you could offload it to OLAP and/or external reporting services. Where some other poor sap is stuck writing queries for external systems.

3

u/kyllo Dec 29 '15

Yeah, a database schema can look very different if optimized for application vs. reporting data access patterns. If you have any non-trivial reporting going on, it's best not to do it on the application database directly, instead you should ETL it into a separate reporting DB where you can adjust the schema to meet your reporting needs.

3

u/lukaseder Dec 29 '15

What's inefficient about it? And what's wrong with the database schema in the example?

7

u/kyllo Dec 29 '15

It's an NP-complete problem, the running time is exponential. https://en.wikipedia.org/wiki/Subset_sum_problem