Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
VikingofRock
Aug 24, 2008




Carbon dioxide posted:

Uh, just learn Japanese guys. It's not that complicated for 99% of usages. Yeah occasionally you'll need to do something complicated, but the idea that so many of you don't understand how to read/write Japanese is surprising to me, I thought that was a pretty rudimentary part of being a weeaboo.

これ、でも風刺じゃありません

VikingofRock fucked around with this message at 00:17 on Nov 16, 2017

Adbot
ADBOT LOVES YOU

PhantomOfTheCopier
Aug 13, 2008

Pikabooze!

Tomie knows me posted:

Now you have 2 problems.
It may be closer to 7.6 problems on average depending on the libraries used and the configuration.

code:

for i in range(len(arr)):
  cursor.execute("select * from tbl where id like %s and two other restrictions", arr[i])
  result = cursor.fetchall()
  if result == []:
    print "we don't care about %s" % arr[i]
  else:
    print "we care, add it to a different array"
    arrb.append(arr[i])

PhantomOfTheCopier fucked around with this message at 00:47 on Nov 16, 2017

The Phlegmatist
Nov 24, 2003

Dylan16807 posted:

Writing good SQL is often more an exercise in working around a really cranky JIT than code quality. Two queries that are fundamentally stating the same actions can have massive performance differences based in picky little things the query planner recognizes.

Or just what the DB optimizes for. I've fixed n+1 queries on MySQL and had performance drop as a result since MySQL decided to go ahead and optimize around an anti-pattern.

Back Alley Borks
Oct 22, 2017

Awoo.


MisterZimbu posted:

In my experience the DBA is either a goddamn genius or an incompetent buffoon who should have all their computers taken away. There's no in-between.

I think it's because of the fact that everyone who would be in-between is smart enough to know they are not nearly smart enough to be a DBA.

I can attest that when I finally tried to bone up on relational algebra and join algorithms, I immediately decided that there was no way in hell I was ever going to be good enough to make good databases.

KernelSlanders
May 27, 2013

Rogue operating systems on occasion spread lies and rumors about me.

Dylan16807 posted:

Writing good SQL is often more an exercise in working around a really cranky JIT than code quality. Two queries that are fundamentally stating the same actions can have massive performance differences based in picky little things the query planner recognizes.

Look up this thread. In no other language would we accept "but the compiler generated bytecode that did what I want" as justification for otherwise terrible code.


Rubellavator posted:

I once got really annoyed trying to figure out why my query wasn't using some index to join two tables and that was when I discovered that the optimizer actually uses different plans based on table statistics. For example, the table I was joining on only had 3 rows of test data so the optimizer ignores the index.

Isn't that exactly what you want though? It's like using an array rather than a hash set for a three element collection because if x in y is still faster to linearly search through an array than to compute the hash function even if asymptotically constant time is faster than linear.

Zaphod42
Sep 13, 2012

If there's anything more important than my ego around, I want it caught and shot now.

KernelSlanders posted:

Isn't that exactly what you want though? It's like using an array rather than a hash set for a three element collection because if x in y is still faster to linearly search through an array than to compute the hash function even if asymptotically constant time is faster than linear.

Yeah it is, he's just saying he didn't see it coming.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Carbon dioxide posted:

Uh, just learn Japanese guys. It's not that complicated for 99% of usages. Yeah occasionally you'll need to do something complicated, but the idea that so many of you don't understand how to read/write Japanese is surprising to me, I thought that was a pretty rudimentary part of being a weeaboo.

If you run an Import/Export business that specializes in stuff from Japan, that's good advice, yes.

If 1/4 of your job is talking to Japanese people who don't know English, it's still good advice if you're at all interested in doing your job better.

NtotheTC
Dec 31, 2007


Munkeymon posted:

If 1/4 of your job is talking to Japanese people who don't know English, it's still good advice if you're at all interested in doing your job better.

What if your company has a translator and you can just give him the plain English version and he will translate it for the Japanese people and 99.9% of the time this is fine but just occasionally you need the translations urgently and so have to write it out yourself?

:itisanORManalogy:

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



NtotheTC posted:

What if your company has a translator and you can just give him the plain English version and he will translate it for the Japanese people and 99.9% of the time this is fine but just occasionally you need the translations urgently and so have to write it out yourself?

:itisanORManalogy:

Congratulations on your good fortune because translators that don't accidentally offend people constantly are hard to find.

Hughlander
May 11, 2005

NtotheTC posted:

What if your company has a translator and you can just give him the plain English version and he will translate it for the Japanese people and 99.9% of the time this is fine but just occasionally you need the translations urgently and so have to write it out yourself?

:itisanORManalogy:

Unfortunately then you’ll need to start over and rewrite the book he was translating from scratch when he starts taking months to translate when he translated in a few hours before.
:itsanORManalogy:

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

If it's a translator you know and work with a lot you know when to have them do the translation or if you need to do it yourself or if you need to get someone else to do it.

NtotheTC
Dec 31, 2007


Hughlander posted:

Unfortunately then you’ll need to start over and rewrite the book he was translating from scratch when he starts taking months to translate when he translated in a few hours before.
:itsanORManalogy:

Wait is this really a thing? To be fair I've only worked with one translator before and ok gently caress the analogy is dumb as hell.

But yeah I work with the django ORM and it's pretty much solid for day to day use, on the rare occasions where I do need to do a certain query in raw SQL it makes it pretty easy to drop down for that one query and you don't have to throw out the entire ORM...

Zaphod42
Sep 13, 2012

If there's anything more important than my ego around, I want it caught and shot now.
https://twitter.com/jetserge/status/852536709757710337

Oh my sweet Jesus

iospace
Jan 19, 2038



That's uh...

Jarring.

:dadjoke:

ChubbyThePhat
Dec 22, 2006

Who nico nico needs anyone else

iospace posted:

That's uh...

Jarring.

:dadjoke:

:catstare:

The Phlegmatist
Nov 24, 2003

...how the hell does that even happen? Including a metric poo poo ton of media in the jar file? Which is undoubtedly in their VC as well...

Zaphod42
Sep 13, 2012

If there's anything more important than my ego around, I want it caught and shot now.

The Phlegmatist posted:

Which is undoubtedly in their VC as well...

Hahahaha that was my next thought

KernelSlanders
May 27, 2013

Rogue operating systems on occasion spread lies and rumors about me.
At that point, I'd assume the jars themselves are checked in.

Horse Clocks
Dec 14, 2004


Can we agree that the DSLs that are just SQL are the real coding horror?

code:
select * from things where foo
Vs

code:
select(things).where(things.foo == True)
Ugh I’m mad just thinking about having to use them.

toiletbrush
May 17, 2010

NtotheTC posted:

Wait is this really a thing? To be fair I've only worked with one translator before and ok gently caress the analogy is dumb as hell.

But yeah I work with the django ORM and it's pretty much solid for day to day use, on the rare occasions where I do need to do a certain query in raw SQL it makes it pretty easy to drop down for that one query and you don't have to throw out the entire ORM...
ORMs can be excellent, but they're only a tool to avoid writing sql, not to avoid understanding it, and come with their own collection of traps and pitfalls.

SQL is no different from any technology a dev comes into contact with but doesn't necessarily directly develop in - if you don't at least take an interest in understanding it, you are bad.

Horse Clocks posted:

Can we agree that the DSLs that are just SQL are the real coding horror?
Totally but SQL query builders are soooo tempting + fun to write when some part of the app needs to be 'configurable by non-technical people'

Doom Mathematic
Sep 2, 2008
Query builders reduce the temptation to build SQL queries dynamically using string operations.

AskYourself
May 23, 2005
Donut is for Homer as Asking yourself is to ...

The Phlegmatist posted:

...how the hell does that even happen? Including a metric poo poo ton of media in the jar file? Which is undoubtedly in their VC as well...

It happen one jar at a time my friend, one jar at a time.

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

Doom Mathematic posted:

Query builders reduce the temptation to build SQL queries dynamically using string operations.

This. I enjoy writing SQL, but I'll put up with a lot if it gets me compile-time syntactic and semantic checking.

Hughlander
May 11, 2005

NtotheTC posted:

Wait is this really a thing? To be fair I've only worked with one translator before and ok gently caress the analogy is dumb as hell.

But yeah I work with the django ORM and it's pretty much solid for day to day use, on the rare occasions where I do need to do a certain query in raw SQL it makes it pretty easy to drop down for that one query and you don't have to throw out the entire ORM...

No I was being factious with the normal reasoning as to why you want to avoid an ORM to begin with. And honestly in a fashion I never experienced. The only time I would chose an ORM is purely to save the speed of development time on project that isn't core to what the team is doing. IE: One where performance characteristics of it will never matter. But then again most of my usages of databases or the past decade or so has either been massive de-noramlized NoSQL stores or tooling around ETL/BVT systems. For the former I don't know of an ORM that could handle it, for the later, I've used multiple ORMs.

KernelSlanders
May 27, 2013

Rogue operating systems on occasion spread lies and rumors about me.

Horse Clocks posted:

Can we agree that the DSLs that are just SQL are the real coding horror?

code:
select * from things where foo
Vs

code:
select(things).where(things.foo == True)
Ugh I’m mad just thinking about having to use them.

If the later is typesafe it's probably an improvements, but to the extent that

code:
things.filter(_.foo == true)
is better, I agree.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Hughlander posted:

No I was being factious with the normal reasoning as to why you want to avoid an ORM to begin with. And honestly in a fashion I never experienced. The only time I would chose an ORM is purely to save the speed of development time on project that isn't core to what the team is doing. IE: One where performance characteristics of it will never matter.

This is why it's good to know SQL to some extent AND to know your ORM.

I use the Django ORM extensively because it's so easy, but Django makes it easy to fall back to SQL when it makes sense...and they encourage you to do so. In doing so you can get the speed of development benefits along with the speed of execution benefits.

To me the most useful part of an ORM isn't to avoid writing SQL, it's all the stuff around that like mapping to objects and managing life cycles.

DELETE CASCADE
Oct 25, 2017

i haven't washed my penis since i jerked it to a phtotograph of george w. bush in 2003

Doom Mathematic posted:

Query builders reduce the temptation to build SQL queries dynamically using string operations.

so do prepared statements, and without having to translate your sql into some other framework's "native syntax" that almost does what you want but not quite

nielsm
Jun 1, 2009



DELETE CASCADE posted:

so do prepared statements, and without having to translate your sql into some other framework's "native syntax" that almost does what you want but not quite

How would you write a prepared statement that can check for any combination of 20 different search parameters, each of which may have various types of criteria configured (e.g. prefix match vs. present in a given set)?

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

nielsm posted:

How would you write a prepared statement that can check for any combination of 20 different search parameters, each of which may have various types of criteria configured (e.g. prefix match vs. present in a given set)?

Theoretical answer: SQL is Turing compete so there's guaranteed to be a way.

Practical answer: optional search parameters can be represented as (@searchParam IS NULL OR [column] =@searchParam). Multiple possible patterns, same, just use OR and make the unused patterns false through additional parameters.

Absurd Alhazred
Mar 27, 2010

by Athanatos

nielsm posted:

How would you write a prepared statement that can check for any combination of 20 different search parameters, each of which may have various types of criteria configured (e.g. prefix match vs. present in a given set)?

This looks like something you hire a lawyer for.

Edit:

https://twitter.com/fasterthanlime/status/931452702458081280

Absurd Alhazred fucked around with this message at 17:39 on Nov 18, 2017

Xarn
Jun 26, 2015
So much wrong in single tweet :v:

lifg
Dec 4, 2000
<this tag left blank>
Muldoon
I once heard someone say that the entire history of C++ is the history of an attempt to get a string type to work.

SupSuper
Apr 8, 2009

At the Heart of the city is an Alien horror, so vile and so powerful that not even death can claim it.

lifg posted:

I once heard someone say that the entire history of C++ is the history of an attempt to get a string type to work.
https://msdn.microsoft.com/en-us/library/aa300688(v=vs.60).aspx
http://en.cppreference.com/w/cpp/string/basic_string
http://icu-project.org/apiref/icu4c/classicu_1_1UnicodeString.html
http://doc.qt.io/qt-5/qstring.html
http://static.cegui.org.uk/docs/0.8.7/classCEGUI_1_1String.html
https://docs.unrealengine.com/latest/INT/Programming/UnrealArchitecture/StringHandling/FString/
...

The search continues.

hackbunny
Jul 22, 2007

I haven't been on SA for years but the person who gave me my previous av as a joke felt guilty for doing so and decided to get me a non-shitty av
In a project at work, I have three string types (and conversions between the three) in the same Objective C++ source file: NSString, std::string and a counted string type from a third party library, plus of course std::string_view

Soricidus
Oct 21, 2010
freedom-hating statist shill
the russians used a pascal

PhantomOfTheCopier
Aug 13, 2008

Pikabooze!

nielsm posted:

How would you write a prepared statement that can check for any combination of 20 different search parameters, each of which may have various types of criteria configured (e.g. prefix match vs. present in a given set)?
As a coder, I would start by questioning your whole design. Since "20 questions is enough" to narrow down the database of the whole universe to a single entity (caveats), wtf are you even doing?

As a user, I would take myself elsewhere. "You mean I have to fill out all this Every Time? But I just want to X!"

Good products, and, by introspection, good programs and databases are built with the proper balance of well-placed optimizations. Rarely is the proper decision to do it all in the database. Rarely is the proper decision to do it all in the program.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Soricidus posted:

the russians used a pascal

KernelSlanders
May 27, 2013

Rogue operating systems on occasion spread lies and rumors about me.

Soricidus posted:

the russians used a pascal

http://wiki.freepascal.org/Character_and_string_types

:shudder:

Loezi
Dec 18, 2012

Never buy the cheap stuff

Soricidus posted:

the russians used a pascal

:eyepop:

Adbot
ADBOT LOVES YOU

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



PhantomOfTheCopier posted:

wtf are you even doing?

What the spec asked for :geno:

quote:

As a user, I would take myself elsewhere. "You mean I have to fill out all this Every Time? But I just want to X!"

Part of the spec is to remember the last search problem solved :smuggo:

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply