
Ask HN: Which programming language do you think offers the best support for SQL? - jennoo
I find that a language as Go feels really tedious working with SQL, Java on the other end of the spectrum has many options but they feel pretty bulky. Whats your language of choice for a relatively simple CRUD app which uses SQL?
======
davismwfl
Honestly I've never found a programming language where SQL didn't have some
tedious tasks. There are always lots of little edge cases and error handling
etc that never seems to be fully covered by the libraries. That said, for a
CRUD type app, I usually default to node.js unless the requirements would
exclude it for some reason, then I'd move to Go, but generally I avoid writing
new Java anymore, not that I think Java is bad or evil, I just prefer other
languages.

For node we use the pg-format package to format most of our queries and then
the standard pg package to execute queries. It is honestly one of the easier
and cleaner ways methods I've used. I am not a big fan of ORM's and find a lot
of them add way to much complexity for too little benefit, so I am a big fan
of either stored procedures/functions or straight (but safe) query building.

I have written code in node.js, Go, C & C++, Java and Python to manipulate
data in different sql databases and they all have some form of tedious tasks
in relation to the SQL integration.

~~~
jennoo
I also try to avoid ORM's but ditching them makes mapping to struct/objects
cumbersome. How you deal with mapping joins in Go and node.js?

~~~
davismwfl
I find having results in object form for CRUD API's most of the time is
unnecessary, and this is a lot of what happens and people use ORM's for.

When I do need the data in object form I use what is probably an unpopular
method for a lot of people, that is I build a serialize/deserialize solution
(or use one already built). It isn't hard in either node.js or Go. It can add
some fragility into the codebase, however, depending how it is implemented.
Frankly though, I like this because essentially this is what an ORM would do
too, just an ORM would be trying to build the query, guess on keys, indexes
etc and then still serialize and deserialize my data, which again may not be
ideal because of generic choices it has to make.

Also, a fairly common pattern for CRUD APIs is I do not need to map the
returned data into an object ever, I simply need a json object to return. And
at least when using postgres I can use jsonb_agg and to_jsonb to help make
life really easy. MySQL has similar json functions. When doing updates the
submitted json data is used to build the query so there is no need to really
have things in native object form.

Hopefully that all makes sense.

------
smt88
I've never encountered great database mapping. I like .NET's type-safe query
builder, but it's still very limited once you get beyond the absolute basics.

You may be interested in [https://hasura.io](https://hasura.io)

~~~
davismwfl
I have to agree here, when I was working in C# and in the Microsoft stack it
is pretty nice. But I still remember it had some tedious tasks around data
mapping etc. C# was one place were I did use an ORM I liked, specifically
dapper, it wasn't perfect, but damn it was fast and easy to use.

------
chmaynard
Great question. General-purpose programming languages and query languages have
entirely different objectives and don't mix well. In practice, SQL is a high-
level messaging protocol used to communicate between two processes (client <->
server) or two modules within a single process (client <-> embedded DBMS).

I worked with several operating systems that included a native programming
language and a built-in DBMS: DEC-MUMPS (MUMPS) and IBM OS/400 (RPG). The
facilities for database queries in these languages were much better than
embedded SQL.

~~~
jennoo
Yes, lately I have noticed that always feels a bit cumbersome working with it.
Where those built-in DBMS SQL or NoSQL?

------
Grazester
That's easy, .NET using C# entity framework.

