There have been multiple accounts created with the sole purpose of posting advertisement posts or replies containing unsolicited advertising.

Accounts which solely post advertisements, or persistently post them may be terminated.

programmer_humor

This magazine is from a federated server and may be incomplete. Browse more on the original instance.

gravitas_deficiency , in no.. just no

I want to hate this. I really do. But the problem is… I think I like it.

naonintendois ,

But how do I know if the WHERE clause is AND or OR?

gravitas_deficiency ,

Fair. The constraint nodes should probably exist under an And node.

lorty ,
@lorty@lemmygrad.ml avatar

This needs a bit of work but it could be interesting

mindbleach , in The Holy Trinity of JavaScript

“The trinity makes as much sense as Javascript” is a vulgar condemnation of Christian dogma.

leftzero , in no.. just no

Of course not… where’s the damn <From> tag…?

cupcakezealot , in no.. just no
@cupcakezealot@lemmy.blahaj.zone avatar

please kindly send all javascript into the sun and explode it

kpw , in no.. just no

The most offensive thing here is the amount={5} attribute. What is it? It's not XML.

MostlyHarmless ,

It’s JSX. It’s used to embed markup into javascript

sndrtj ,

It’s to embed Javascript into embedded markup in Javascript

zqwzzle , (edited ) in The Holy Trinity of JavaScript

=== is just == with extra steps

thanks_shakey_snake ,

It’s actually the other way around. == has to perform type coercions as part of its equality algorithm, whereas === does not, so == has more steps.

Primarily0617 , in no.. just no

if you don't believe that adding more structure to the absolute maniacal catastrophe that is sql is a good thing then i'm going to start to have doubts about your authenticity as a human being

GBU_28 ,

Huh? Sql is one of the most powerful, action packed (as in you can move lots of shit with few commands) languages out there.

It’s transferable and ubiquitous.

Primarily0617 ,

powerful isn't the same as well-structured

it was written to be a language that anybody could read or write as well as english, which just like every other time that's been tried, results in a language that's exactly as anal about grammar as C or Python except now it's impossible to remember what that structure is because adding anything to the language to make that easier is forbidden

when you write a language where its designers were so keen for it to remain human readable that they made deleting all rows in a table the default action, i don't think "well structured" can be used to describe it

GBU_28 ,

Disagree, the difference between “week structured” and needing to know the rules of the verbs is pretty big, to me.

QuazarOmega , (edited )

Me trying to remember on whose output data having, count, sum, etc. work

Once you know functions you would have no reason to go back.
I propose we make SQL into this:


<span style="color:#323232;">const MAX_AMOUNT = 42, MIN_BATCHES = 2
</span><span style="color:#323232;">
</span><span style="color:#323232;">database
</span><span style="color:#323232;">    .from(table)
</span><span style="color:#323232;">    .where(
</span><span style="color:#323232;">        (amount) => amount < MAX_AMOUNT,
</span><span style="color:#323232;">        table.field3
</span><span style="color:#323232;">    )
</span><span style="color:#323232;">    .select(table.field1, table.field3)
</span><span style="color:#323232;">    .group_by(table.field1)
</span><span style="color:#323232;">    .having(
</span><span style="color:#323232;">        (id) => count(id) >MIN_BATCHES
</span><span style="color:#323232;">        table.field0
</span><span style="color:#323232;">    )
</span>

(Sorry for any glaring mistakes, I’m too lazy right now to know what I’m doing)

…and I bet I just reinvented the wheel, maybe some JavaScript ORM?

xep ,
QuazarOmega , (edited )

Thanks for the suggestion! It looks interesting, not quite what I expected looking at that file*, but that may very well be better

Edit: other examples seem a bit more similar to mine, cool!

rubythulhu ,

most languages have some first or third party lib that implements a query builder

expr , (edited )

Because you never learned SQL properly, from the sound of it.

Also, ORMs produce trash queries and are never expressive enough.

QuazarOmega ,

Because you never learned SQL properly, from the sound of it.

You might be right, though, to be fair, I also keep forgetting syntax of stuff when I don’t use it very often (read SQL (._.`))

Also, ORMa produce trash queries and are never expressive enough.

I meant to say that I would like the raw SQL syntax to be more similar to other programming languages to avoid needing to switch between thinking about different flows of logic

emptyother ,
@emptyother@programming.dev avatar

ORMs produce good queries if you know what you do. Which requires proper knowledge of SQL, unfortunately.

drathvedro ,

No. The arrow function in where eliminates any possibility of using indexes. And how do you propose to deal with logical expressions without resorting to shit like .orWhereNot() and callback hell? And, most importantly, what about joins?

cupcakezealot ,
@cupcakezealot@lemmy.blahaj.zone avatar

but sql doesn’t need to be structured that’s what abstraction layers and models are for

Lem453 ,

SQL is literally structured query language

expr ,

SQL is incredibly structured. It’s also a very good language, and developers need to stop piling on junk on top of it and producing terrible queries. Learn the damn language. It’s not that hard

sbv , in The Holy Trinity of JavaScript

Sorry, 0 == ‘t’? What?

Limitless_screaming , (edited )
@Limitless_screaming@kbin.social avatar

that's not "t", it's "\t" which is just a tab. There's also "\n" for newline.

MinekPo1 ,
@MinekPo1@lemmygrad.ml avatar

yeah but why is a single character string containing a tab equal to zero ???

Limitless_screaming , (edited )
@Limitless_screaming@kbin.social avatar

That would be weird if a string containing a space wasn't equal to 0 " " == 0, but that's not the case in JS. If you think that "" and " " being equal to 0 is weird then I agree, but since they are, you should expect "t" and "n" to equal 0 too.

Ephera ,

The == operator in JS will try to cast the things being compared and do all kinds of ‘smart’ assumptions about what equality means. This is why everyone uses === instead…

8bitguy ,

Unless you enjoy inviting the chaos.

Sonotsugipaa ,
@Sonotsugipaa@lemmy.dbzer0.com avatar

It still makes no sense though

Limitless_screaming ,
@Limitless_screaming@kbin.social avatar

If " " wasn't equal to 0, it wouldn't make sense, but since a string containing a space equals 0, you'd expect the same to apply to a string containing a tab or a newline. (or at least I'd expect that)

FaceDeer ,
@FaceDeer@kbin.social avatar

I admit I have never dabbled in javascript, despite being a proficient programmer. I now dread to ask... would any string that contains only whitespace == 0? " \t\n \t " for example?

Limitless_screaming ,
@Limitless_screaming@kbin.social avatar

Yes, it would. Just like a string of spaces " " == 0, but it isn't that bad; === is Javascript's version of == in other languages, and, thus, you should be using it if you don't want that wonkiness.

== is just for convenience, like when you want to make sure that the user didn't leave the form empty and the button shouldn't be greyed out, and other UI stuff. Without these kinds of features JS wouldn't be used in so many toolkits.

atx_aquarian ,
@atx_aquarian@lemmy.world avatar

Ok, I always mistakenly assumed === was the identity operator in JS, too. TIL, thanks! As much as we like to poke fun at JS, every time I’m taught the rationale behind some aspect of it, I find it redeeming and even a little endearing.

bitcrafter ,

The explanation given to you makes it sound like == was deliberately designed to be a more convenient version of ===, but what actually happened was that == used to be the only equality operator in JavaScript, which meant that if you didn’t want it’s auto-coercing behavior then you needed to go out of your way to add additional type checks yourself. Because this was obviously a tremendously inconvenient state of affairs, the === operator was introduced later so that you could test for equality without having to worry about JavaScript doing something clever underneath the hood that you weren’t expecting.

masterspace ,

The explanation given to you makes it sound like == was deliberately designed to be a more convenient version of ===

I mean technically == was deliberately designed to be a more convenient version of other languages’ == operator… Just specifically more convenient for light UI stuff since that was all JavaScript was supposed to be used for at the time (or all they thought it would be used for).

But give programmers a way to write and execute a small script and someone will eventually use that to try and write an emulator that emulates the computer it’s running on, so the web evolved into more complicated applications, and then that convenience turned out to be wildly inconvenient, not to mention horribly unexpected for programmers coming from other languages, so then they added the triple equality to match other languages.

sbv ,

It’s a slash-t in the comment. Maybe kbin has different rendering rules for comments?

https://sh.itjust.works/pictrs/image/7026f17a-f237-49d3-8d80-28632876acdb.png

Limitless_screaming , (edited )
@Limitless_screaming@kbin.social avatar

Oh, in that case I replied to @MinekPo1 with my answer to that. BTW can you see the slash in: t and "t".

sbv ,
Limitless_screaming , (edited )
@Limitless_screaming@kbin.social avatar

My bad. I just edited it. "t" t It's displaying correctly on Lemmy.world. So it seems like another Kbin only issue.

jtk ,
@jtk@lemmy.sdf.org avatar

Yeah, it’s true. I knew all the other ones, had to put that one in the dev tools console to believe it. I was just happy to know === continues to be sane in that comparison.

Blackmist ,

You have to remember that the underlying principle of JavaScript seemed to be “never throw an error”, even if what it’s being told to do is weapons grade bollocks.

tiny_electron , in The Holy Trinity of JavaScript

This never gets old lmao

JoYo , in no.. just no
@JoYo@lemmy.ml avatar

still more readable than sqlalchemy exceptions

cmdrkeen , in no.. just no

Honestly not the worst thing I’ve seen.

xmunk ,

I’d like you to think for a moment about CTEs, the HAVING clause, window functions and every other funky and useful thing you can do in SQL … Now just think, do you think that this syntax supports all those correctly?

cmdrkeen ,

Probably no better or worse than any other ORM written in a more traditional language. Worst comes to worst, you can always escape to plain SQL.

Primarily0617 ,

sql syntax doesn't support even itself correctly i fail to see your point

TheFerrango , in no.. just no

Sharepoint queries are written in something very similar 🤢

I still have nightmares from the one time I had to use that.

Witchfire , in no.. just no
@Witchfire@lemmy.world avatar

Honestly more readable than a lot of SQL I’ve read. It even has hierarchical grouping.

somePotato ,

I was disgusted by the XML at first, but it’s a readable query returning a sane JSON object.

Meanwhile, I’m mantaining Java code where the SQL is a perfectly square wall of text, and some insane mofo decided the way to read the resulting list of Object[] 🤮 is getting each column by index… so I’d switch to SQXMLL in a heartbeat.

blackbrook ,

Check out JOOQ.

shotgun_crab ,

JOOQ made me realize that most ORMs suck

valen , in Multifactor auth done right
@valen@beehaw.org avatar

Something you only know in a parallel dimension.

Lime66 , in Programming Languages as Essays

TS: "You can’t just say ‘any’ and end the essay expecting I know what the fuck your talking about

  • All
  • Subscribed
  • Moderated
  • Favorites
  • [email protected]
  • random
  • lifeLocal
  • goranko
  • All magazines