this post was submitted on 19 Oct 2023
1716 points (98.8% liked)

Programmer Humor

32560 readers
304 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
top 50 comments
sorted by: hot top controversial new old
[–] xmunk@sh.itjust.works 178 points 1 year ago (7 children)

Speaking as a Senior Dev specialized in database access and design... you don't have to use all caps - SQL is actually case agnostic.

But... but my fucking eyes man. I'm old, if your branch doesn't have control keywords in all caps I'm going to take it out back and ol' yeller it.

There are few hills I'll die on but all caps SQL and singular table names are two of them.

[–] Nolegjoe@lemmy.world 71 points 1 year ago (5 children)

I'm a sql developer, and I am completely the opposite to you. I will find it incredibly difficult to read when everything is in caps

[–] Pechente@feddit.de 131 points 1 year ago (2 children)

You should do a project together

[–] agressivelyPassive@feddit.de 42 points 1 year ago (1 children)
[–] DmMacniel@feddit.de 30 points 1 year ago

The commit wars will be long and bloody.

[–] SorteKanin@feddit.dk 25 points 1 year ago (4 children)

Same, I prefer lower case. Every other language has keywords in lower case, why do you need to shout when writing sql?

[–] hikaru755@feddit.de 21 points 1 year ago* (last edited 1 year ago) (16 children)

I understand it as an attempt to get very basic, manual syntax highlighting. If all you have is white text on black background, then I do see the value of making keywords easy to spot by putting them in all caps. And this probably made sense back when SQL was first developed, but it's 2023, any dev / data scientist not using a tool that gives you syntax highlighting seriously needs to get with the times

[–] xmunk@sh.itjust.works 12 points 1 year ago* (last edited 1 year ago)

Partially, yes. I personally use an IDE with excellent syntax highlighting and those have been around for at least two decades. You are, however, often transplanting your SQL between a variety of environments and in some of those syntax highlighting is unavailable (for me at least) - the all caps does help in those rare situations.

More importantly though it helps clearly differentiate between those control keywords (which are universal) and data labels (which are specific to your business domain). If I'm consulting on a complex system that I only partially understand it's extremely helpful to be able to quickly identify data labels that I'm unfamiliar with to research.

load more comments (15 replies)
[–] Simulation6@sopuli.xyz 13 points 1 year ago (1 children)

Just some key words in uppercase (FROM, JOIN,WHERE,etc) so they pop out

load more comments (1 replies)
[–] neo@lemmy.comfysnug.space 10 points 1 year ago

THE DATABASE CAN'T HEAR ME IF I DON'T SCREAM

load more comments (1 replies)
[–] xmunk@sh.itjust.works 18 points 1 year ago* (last edited 1 year ago) (4 children)

Sorry, to clarify, not everything is in all caps. I'll append my prefered syntax below

WITH foo AS (
    SELECT id, baz.binid
    FROM
            bar
        JOIN baz
            ON bar.id = baz.barid
)
SELECT bin.name, bin.id AS binid
FROM
        foo
    JOIN bin
        foo.binid = bin.id

The above is some dirt simple SQL, when you get into report construction things get very complicated and it pays off to make sure the simple stuff is expressive.

[–] NedDasty@lemmy.world 14 points 1 year ago (3 children)

You indent your JOIN? Why on earth? It lives in the same context as the SELECT.

[–] xmunk@sh.itjust.works 9 points 1 year ago

I've seen both approaches and I think they're both quite reasonable. An indented join is my preference since it makes sub queries more logically indented... but our coding standards allow either approach. We've even got a few people that like

FROM foo
JOIN bar ON foo.id = bar.fooid
JOIN baz ON bar.id = baz.barid
load more comments (2 replies)
load more comments (3 replies)
load more comments (2 replies)
[–] erogenouswarzone@lemmy.ml 18 points 1 year ago (2 children)

The place I work decided to name all tables in all caps. So now every day I have to decide if I want to be consistent or I want to have an easy life.

[–] xmunk@sh.itjust.works 11 points 1 year ago (3 children)

Fuuuuck. That's why I love postgres... and fuck anyone that requires double quoted identifiers for special casing.

load more comments (3 replies)
load more comments (1 replies)
[–] eek2121@lemmy.world 9 points 1 year ago (1 children)

Singular table names? You savage…

[–] xmunk@sh.itjust.works 15 points 1 year ago (3 children)

It's an English literacy thing - we have several non-native English speakers and using only singular avoids making those folks' lives harder. Besides it's really nice to autopilot that categoryid is a foreign key to the category table. It also simplifies always plural words... I haven't yet written CREATE TABLE pants but if I ever do there's zero chance of me creating a pantid.

[–] eek2121@lemmy.world 11 points 1 year ago (1 children)

no underscores either? What are we, apes?

load more comments (1 replies)
load more comments (2 replies)
load more comments (4 replies)
[–] umbraroze@kbin.social 157 points 1 year ago (7 children)

Technically, SQL is case-insensitive.

Practically, you want to capitalise the commands anyway.

It gives your code some gravitas. Always remember that when you're writing SQL statements you're speaking Ancient Words of Power.

Does that JavaScript framework that got invented 2 weeks ago by some snot-nosed kid need Words of Power? No. Does the database that has been chugging on for decades upon decades need Words of Power? Yes. Words of Power and all the due respect.

[–] hakunawazo@lemmy.world 17 points 1 year ago

Reminds me a bit of Skyrim. You are... the query-born.

[–] manny_stillwagon@mander.xyz 9 points 1 year ago

I'm going to print this out and frame it on the wall of my office.

load more comments (5 replies)
[–] bappity@lemmy.world 72 points 1 year ago (1 children)

UM ACKSHULLY SQL ISN'T CASE SENSITIVE ☝️🤓

[–] Queuewho@lemmy.world 16 points 1 year ago (4 children)

Please tell that to the git overlords at my work. They won't approve a merge with even a single unnecessary capitalization.

load more comments (4 replies)
[–] rwhitisissle@lemmy.ml 49 points 1 year ago* (last edited 1 year ago) (13 children)

The phrase "SQL programmers" is so fucking weird. SQL isn't a programming language. It's a query language. You don't "program" things with SQL. You utilize SQL as a component of programs for data insertion and lookup, but the actual logic of execution is done in a programming language. Unless you're doing Oracle PL/SQL, in which case why are you giving money to Oracle?

Edit: Damn, this comment made people mad.

[–] oce@jlai.lu 41 points 1 year ago (1 children)

Your knowledge of data engineering may be limited. SQL is predominant in data processing nowadays. FOSS tools such as DBT allows to write efficient data processing pipelines with SQL and some YAML config without the need for a general purpose coding language.
Why would anyone want that? Because SQL has the interesting property of describing the result you want rather than describing how to compute it. So you can put inside the database, a query engine with decades of optimizations, that will make a much better job at finding the best execution plan than the average developer.
It also means it's easier to train people for data processing nowadays.

load more comments (1 replies)
[–] KarmaPolice@lemmy.world 38 points 1 year ago (1 children)

Most database engines support stored procedures. You don't need to give money to oracle, you can give it to Microsoft instead.

[–] fmstrat@lemmy.nowsci.com 18 points 1 year ago* (last edited 1 year ago) (1 children)

Or not at all? Postgres? MariaDB? I think I missed the /s. I'm slow hah

load more comments (1 replies)
[–] SomeNewThing@reddthat.com 34 points 1 year ago* (last edited 1 year ago) (1 children)

T-SQL is turing complete. While the MS SQL server has limitations on OS level operations, if you allow yourself some leeway with CLR wrappers for the win32 API, there's no reason I can think of you wouldn't be able to get the database engine to be a webserver reacting to incoming requests on port 80, or drawing GUIs based off of table state.

It's be slow and terrible, but doable.

load more comments (1 replies)
[–] Gentoo1337@sh.itjust.works 30 points 1 year ago (1 children)

I'm a markdown programmer and i disagree with this statement

load more comments (1 replies)
[–] fmstrat@lemmy.nowsci.com 30 points 1 year ago (4 children)

This doesn't make sense to me. SPs and functions are in every major database. If I wrote a bash script that runs like a program, and sounds like a program, did I program it? Script it?

And lots of systems have nested logic in the DB, optimization often leads to that to reduce overhead. Unless you're being lazy with an ORM like prisma that can't even join properly.

Getting high performing queries is just as difficult as any other programming language, and should be treated as such. Even Lemmy's huge performance increases to .18ish came from big PG optimizations.

[–] mbp@lemmy.sdf.org 11 points 1 year ago

It seems to be about yelling at others that "you're not a real programmer!!!" mixed with being so "technically correct" my eyes can no longer roll the same way they used to.

load more comments (3 replies)
[–] corship@feddit.de 23 points 1 year ago* (last edited 1 year ago) (7 children)
[–] traches@sh.itjust.works 10 points 1 year ago (1 children)
load more comments (1 replies)
load more comments (6 replies)
[–] dan@upvote.au 21 points 1 year ago* (last edited 1 year ago) (2 children)

You don't "program" things with SQL

Why not? It sounds like you haven't written any OLAP queries :)

I've written ETL data pipelines using a system similar to Apache Airflow, where most of the logic is in SQL (either Presto or Apache Spark) with small pieces of Python to glue things together. Queries that are thousands of lines long that take ~30 minutes to run and do all sorts of transformations to the data. They run once per day, overnight. I'd definitely call that programming.

Most database systems support stored procedures, which are just like functions - you give them some input and they give you some output and/or perform some side effects.

load more comments (2 replies)
load more comments (6 replies)
[–] Cold_Brew_Enema@lemmy.world 40 points 1 year ago (2 children)

As a senior query writer, I use caps for begin and end and some other commands, but all caps makes my head hurt. It's like the sql is screaming at me. I think it's more important to have good looking queries with proper indentation.

load more comments (2 replies)
[–] AlexWIWA@lemmy.ml 22 points 1 year ago (1 children)

Writing SQL on Mac sucks so bad. I hate their caps lock time out

[–] icedterminal@lemmy.world 23 points 1 year ago (2 children)

macOS has a caps lock timeout? The fuck...

[–] st0v@lemmy.zip 19 points 1 year ago (5 children)

capslock drains the battery too quickly

load more comments (5 replies)
[–] AlexWIWA@lemmy.ml 10 points 1 year ago (11 children)

Timeout was the wrong word. It has to be held for like a quarter second or something like that. It's annoying as hell.

load more comments (11 replies)
[–] HiddenLayer5@lemmy.ml 21 points 1 year ago* (last edited 1 year ago) (2 children)

MySQL gives you a half-hearted "Bye" when you exit the console.

[–] dan@upvote.au 17 points 1 year ago

My favourite MySQL error is "MySQL server has gone away", like MySQL decides "nah I don't want to run this" and runs off.

(it happens when no data is sent over the connection for a while, like if the query is taking too long to run and times out)

load more comments (1 replies)
[–] VantaBrandon@lemmy.world 20 points 1 year ago (1 children)

I know a Perl programmer who exclusively writes all SQL in pure lowercase with atypical indentation.

He's also a die-hard InfoWars follower, apparently his go to source, so... maybe there is a connection there.

load more comments (1 replies)
[–] Random_user@lemmy.world 15 points 1 year ago (1 children)

Wait, you guys aren't just writing code and then hitting the FORMAT button?

load more comments (1 replies)
[–] uis@lemmy.world 13 points 1 year ago (1 children)
load more comments (1 replies)
[–] MargotRobbie@lemm.ee 13 points 1 year ago

THANKS, NOW I DON'T HAVE TO HOLD DOWN THE SHIFT KEY WHEN I TYPE ANYMORE!

[–] revlayle@lemm.ee 11 points 1 year ago (6 children)

I never use all caps when I write SQL, not sure why people insist on it so much

load more comments (6 replies)
[–] Album@lemmy.ca 11 points 1 year ago (6 children)

If you guys think that's cool you should see what I can do with a double negative.

load more comments (6 replies)
[–] tentaclius@lemm.ee 10 points 1 year ago (3 children)

Nobody knows (/s) but you don't have to write keywords in upper case (for most DB's default settings anyway).

[–] dylanTheDeveloper@lemmy.world 12 points 1 year ago

You can even write them sarcastically like this:

sElEcT * fRoM dUaL

load more comments (2 replies)
load more comments
view more: next ›