Live data from Hacker News

Learn SQL Once, Use It for 30 Years

fagnerbrack.com

121–130 of 243 posts

Re: Learn SQL Once, Use It for 30 Years

#121

I think the pretext of this articles is ridiculous. Yes, SQL is based around relational algebra, but all programming languages are built on a theoretical foundation. And SQL is very much a "fad" language - it just somehow managed to stick around. The goal was not some sort of mathematical purity, but rather to built a natural language data interface (sounds like something currently very hyped?) and it failed spectacu…

> it just somehow managed to stick around.

We're kind of stuck with it, unless someone does for SQL what Kotlin tried to do for Java. I wonder what it would even look like, or if the real answer is to take the WASM spec, and make one for SQL itself, so you can write queries in any language, compile them to "WASM-DB" or whatever, then those get converted over to standard SQL, until databases support "WASM-DB" or whatever language.

Would love to see what something like this could look like and if it would be worthwhile? For me WASM opens us up to not having to write front-end JS and being able to do front-end and back-end both in your native programming language (like Blazor does for C#).

Re: Learn SQL Once, Use It for 30 Years

#122
post #30

> If you are a junior developer, “learn SQL properly” is the most valuable 40 hours you can spend. Not a tutorial. Not an ORM. Actual SQL: joins, subqueries, window functions, query plans. That investment pays you back at every job, in every stack, for decades This is the power of low-level reasoning. Today, even for a junior developers, even if they have AI that solves syntax problems, SQL teaches you to reason and…

The breakthrough for me was thinking in terms of sets and not in terms of "how would I do this imperatively." If you see SQL where someone wrote a SELECT and is then using a cursor to loop through those results and do other queries, you've found the person who is still thinking imperatively.

A thousand times this. I've resolved performance issues in so many stored procedures written by programmers who don't grasp set theory and reach for the CURSOR early and often.

The quote that comes to mind: "His pattern indicates two-dimensional thinking."

Re: Learn SQL Once, Use It for 30 Years

#123
post #30

> If you are a junior developer, “learn SQL properly” is the most valuable 40 hours you can spend. Not a tutorial. Not an ORM. Actual SQL: joins, subqueries, window functions, query plans. That investment pays you back at every job, in every stack, for decades This is the power of low-level reasoning. Today, even for a junior developers, even if they have AI that solves syntax problems, SQL teaches you to reason and…

> Not a tutorial. Not an ORM. Actual SQL

ah, this is an Ai article

Re: Learn SQL Once, Use It for 30 Years

#124

Earlier quoted context omitted.

The breakthrough for me was thinking in terms of sets and not in terms of "how would I do this imperatively." If you see SQL where someone wrote a SELECT and is then using a cursor to loop through those results and do other queries, you've found the person who is still thinking imperatively.

A thousand times this. I've resolved performance issues in so many stored procedures written by programmers who don't grasp set theory and reach for the CURSOR early and often. The quote that comes to mind: "His pattern indicates two-dimensional thinking."

I guess I think in 2.5D because I’ll often sketch an imperative, dumb query and then refine it once I know I’ve got the data I need. But I have a hard time starting with elegance. I use a baseball bat to shape the garbage can into the desired form

Re: Learn SQL Once, Use It for 30 Years

#125
post #30

> If you are a junior developer, “learn SQL properly” is the most valuable 40 hours you can spend. Not a tutorial. Not an ORM. Actual SQL: joins, subqueries, window functions, query plans. That investment pays you back at every job, in every stack, for decades This is the power of low-level reasoning. Today, even for a junior developers, even if they have AI that solves syntax problems, SQL teaches you to reason and…

> Not a tutorial. Not an ORM. Actual SQL ah, this is an Ai article

It's always AI until proven otherwise... even then I'm skeptical.

Re: Learn SQL Once, Use It for 30 Years

#126

Earlier quoted context omitted.

The breakthrough for me was thinking in terms of sets and not in terms of "how would I do this imperatively." If you see SQL where someone wrote a SELECT and is then using a cursor to loop through those results and do other queries, you've found the person who is still thinking imperatively.

A thousand times this. I've resolved performance issues in so many stored procedures written by programmers who don't grasp set theory and reach for the CURSOR early and often. The quote that comes to mind: "His pattern indicates two-dimensional thinking."

Also from that film comes the quote:

> I've done far worse than kill you. I've hurt you. And I wish to go on hurting you.

Which I believe is a paraphrase of the Oracle Master Agreement.

Re: Learn SQL Once, Use It for 30 Years

#127
post #38

I’ve always felt that SQL is somewhat easy to grasp for basic queries, but gets complex and difficult for even moderate to higher complexity use cases. My eyes glaze over when I read long stored procedures that someone else has written. Any recommended resources to go from beginner/beginner-intermediate to advanced?

My advice is: don't write complicated SQL. The best thing I learned about SQL is that it can do an awful lot of clever stuff but that the vast majority of the time you really don't need it. Learn the basics. Shrug the rest off.

This is the correct way. Much like any other kind of code, if you find yourself doing something "clever" it's time to think about whether you're really going down the right path.

Re: Learn SQL Once, Use It for 30 Years

#128
post #30

> If you are a junior developer, “learn SQL properly” is the most valuable 40 hours you can spend. Not a tutorial. Not an ORM. Actual SQL: joins, subqueries, window functions, query plans. That investment pays you back at every job, in every stack, for decades This is the power of low-level reasoning. Today, even for a junior developers, even if they have AI that solves syntax problems, SQL teaches you to reason and…

The breakthrough for me was thinking in terms of sets and not in terms of "how would I do this imperatively." If you see SQL where someone wrote a SELECT and is then using a cursor to loop through those results and do other queries, you've found the person who is still thinking imperatively.

SQL teaches Set based thinking.

Prolog teaches logical constraint based thinking.

ML/Lisp/etc teach functional thinking.

There is a lot of use in learning these other things beyond the standard imperative thinking from C/Python/Java/etc. Since some problems reduce their complexity significantly in one form or another.

Re: Learn SQL Once, Use It for 30 Years

#130
Yes yes, all fine and good. I love SQL, think it is incredible how relevant it still is as a high level language, and think it should be the basis of almost every data storage and retrieval system out there. And I love that the foundation is relational algebra, which is an extremely useful abstraction for data management.

But for the love of god, get rid of the ternary logic. It is only mathematically sound to the extent that mathematicians are masochists and will try to formalize anything regardless of how painful it is for normies. Boolean logic is good enough and doesn't feel like an exercise in retroactive continuity.

Post reply on HN