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
SimonChris
Apr 24, 2008

The Baron's daughter is missing, and you are the man to find her. No problem. With your inexhaustible arsenal of hard-boiled similes, there is nothing you can't handle.
Grimey Drawer

Thermopyle posted:

I don't understand what you're saying here.

Are you saying REST and GraphQL do not use a database to store their data?

I think the point is that databases have lots of nifty features, but most people only use them for simple data queries and re-implement those same features in various web development frameworks.

Adbot
ADBOT LOVES YOU

ChickenWing
Jul 22, 2010

:v:

as a midtier developer I'm gonna need y'all to shut the gently caress up about properly configuring databases, thanks and god bless

Khorne
May 1, 2002

quote:

I think that's called "software development." For example, every REST or GraphQL web app right now would have been faster and more secure as a database that properly uses authentication, authorization, triggers, relations and constraints. But once a problem is solved, you need to start coming up with more problems. So let's just use the database as a key-value store and rewrite all the rest in slow-as-hell, insecure-as-poo poo Rails.
Databases are very good and their features are underused and changing databases to k:v stores is bad but not what most people are doing. Placing k:v stores and REST apis in front of them is done for many sane business reasons. From a purely technical standpoint, there may be cases where the db way is justifiable. For most "public api" use cases, probably not.

And yeah, GraphQL is/was in pure hype mode. It's a reasonable thing to use in some specific cases, but it's getting wildly overused.

Khorne fucked around with this message at 17:39 on Oct 1, 2018

Munkeymon
Aug 14, 2003

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



New Yorp New Yorp posted:

I'm thinking more along the lines of something like the Azure portal. Everything you can do with the portal, you can do with REST APIs. I keep seeing people rebuilding their own Azure portal that calls the same REST APIs as the existing portal. I can't fathom why, other than "not invented here" and I was looking for a term to use to describe it when I'm telling people "that's dumb, don't do it".

It's interesting that this is what you were thinking of because I read you first post and thought "I just call that The Microsoft Way"

Nude
Nov 16, 2014

I have no idea what I'm doing.

New Yorp New Yorp posted:

I'm thinking more along the lines of something like the Azure portal. Everything you can do with the portal, you can do with REST APIs. I keep seeing people rebuilding their own Azure portal that calls the same REST APIs as the existing portal. I can't fathom why, other than "not invented here" and I was looking for a term to use to describe it when I'm telling people "that's dumb, don't do it".

I think "don't roll your own" comes close but it does lack a certain punch.

xtal
Jan 9, 2011

by Fluffdaddy

Plorkyeran posted:

C++ currently doesn't have a way to express "the two types passed to this function have to be comparable" (that's maybe finally coming in C++20 after over a decade of delays). As a result, the compiler doesn't know what point in the call stack is incorrect, and just prints the whole thing. As with any time you get an error stack starting in library code, you usually want to start with looking at the first one not in the library.


That's mostly just a result of compiler explorer having really long paths.

And the code block not wrapping lines. I wasn't disagreeing with you. It's definitely not a problem.

Steve French posted:

I think he is saying that they are useless layers on top of a database. Which is, uh, an interesting argument if I'm reading it right.

The database can do almost all app logic. Because it's not a perfect fit, we build mountains of layers of abstraction on top of it. The better solution would be to improve databases or constrain your use cases. PostgREST and PostgraphQL are evidence of this. All most DB apps need are proper constraints, auth and relationships. Then you get atomicity, fast-as-C and such for free.

xtal fucked around with this message at 19:28 on Oct 1, 2018

JawnV6
Jul 4, 2004

So hot ...

Dylan16807 posted:

I'm pretty sure they meant "EAX in thread 0 and EBX in thread 1".

So they're just talking about sequential consistency, not anything horrific.

No, I understood them to be using X and Y as memory locations. And the hardware that can divine the programmer intent from these sequences and meet that expectation continues to be horrific, your unnecessary second guessing aside.

necrotic
Aug 2, 2005
I owe my brother big time for this!

New Yorp New Yorp posted:

I'm thinking more along the lines of something like the Azure portal. Everything you can do with the portal, you can do with REST APIs. I keep seeing people rebuilding their own Azure portal that calls the same REST APIs as the existing portal. I can't fathom why, other than "not invented here" and I was looking for a term to use to describe it when I'm telling people "that's dumb, don't do it".

missed this earlier but the azure portal is dogshit, which might explain some people doing anything they can to not use it.

Just using the CLI would be better though, it at least is usable.

Dylan16807
May 12, 2010

JawnV6 posted:

No, I understood them to be using X and Y as memory locations. And the hardware that can divine the programmer intent from these sequences and meet that expectation continues to be horrific, your unnecessary second guessing aside.

Divine programmer intent? All it has to do is serialize memory accesses. It's not hard to do, it's hard to make fast.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
To be precise, it's hard to make fast if you have any intention of ever supporting multiple cores.

Cue a hundred web programmers jumping in to say that anything that stretches their childlike understanding of computers is premature optimization.

Absurd Alhazred
Mar 27, 2010

by Athanatos

rjmccall posted:

To be precise, it's hard to make fast if you have any intention of ever supporting multiple cores.

Cue a hundred web programmers jumping in to say that anything that stretches their childlike understanding of computers is premature optimization.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

Nude posted:

I think "don't roll your own" comes close but it does lack a certain punch.

We called it re-creating the universe at an old job. Then we'd have pie.

toiletbrush
May 17, 2010

pokeyman posted:

Swift generics are cool.
Are they, though? I know they're not bad...I honestly don't know and would like to find out.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Nude posted:

I think "don't roll your own" comes close but it does lack a certain punch.

rolling your own cigarettes/blunts/joints is actually a good skill to have. maybe you're looking for "don't reinvent the wheel?"

Bongo Bill
Jan 17, 2012

Most wheels are specialized for the vehicle they're attached to. Some wheel types have sophisticated mechanisms inside to help them roll better. Reinventing the wheel every now and then is a good thing.

Spatial
Nov 15, 2007

Why the hell would you write a timeout like this
C++ code:
volatile int32_t tmo = 50;
volatile int delay;

while (--tmo && hardware_thing) {
    if (tmo & 1) {
        delay = 50;
    }
    else {
        delay = 18000;
    }

    while (--delay > 1) {}
}

JawnV6
Jul 4, 2004

So hot ...
Is 'hardware_thing' actually touching hardware that will behave unexpectedly if flooded with requests? "every other time, do a 18,000 cycle delay"

Another guess would be reading updates it, so you want to do 2 quick reads but there's no point in asking more than once a millisecond.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

toiletbrush posted:

Are they, though? I know they're not bad...I honestly don't know and would like to find out.

I’m not a type wizard or anything but they can do a lot and have some capabilities not found in C# or Java.

Spatial
Nov 15, 2007

JawnV6 posted:

Is 'hardware_thing' actually touching hardware that will behave unexpectedly if flooded with requests? "every other time, do a 18,000 cycle delay"

Another guess would be reading updates it, so you want to do 2 quick reads but there's no point in asking more than once a millisecond.
It's just silly.

The register has a bit that tells you when it's done, and reading it has no side effects. The delays are also asspulls that don't correlate to anything. And the one error that can happen isn't fixed by timing out, you'd have to reset the peripheral. Once it fails it fails forever, and extra slowly!

Foxfire_
Nov 8, 2010

Does reading it go across a bus that is also being used for other things (DMA) so that spinning on it will block stuff?

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

Spatial posted:

Why the hell would you write a timeout like this
C++ code:
volatile int32_t tmo = 50;
volatile int delay;

while (--tmo && hardware_thing) {
    if (tmo & 1) {
        delay = 50;
    }
    else {
        delay = 18000;
    }

    while (--delay > 1) {}
}

The author clearly doesn’t know what "volatile" is for, so they probably misunderstood the problem, too.

Khorne
May 1, 2002

Zopotantor posted:

The author clearly doesn’t know what "volatile" is for, so they probably misunderstood the problem, too.
Please respect the project style guide where volatile means mutable.

Do you want to find out what inline means?

Khorne fucked around with this message at 15:47 on Oct 3, 2018

Soricidus
Oct 21, 2010
freedom-hating statist shill
volatile means "poo poo was breaking and i couldn't figure out why so i just threw in random things i'd vaguely heard of until it worked"

Rubellavator
Aug 16, 2007

Soricidus posted:

volatile means "poo poo was breaking and i couldn't figure out why so i just threw in random things i'd vaguely heard of until it worked"

Did this with some crap I was doing in java. I think I made a post about it in here even

JawnV6
Jul 4, 2004

So hot ...
What do y’all think while(x-->0); does when x isn’t volatile?

hint:

JawnV6 fucked around with this message at 03:09 on Oct 4, 2018

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Parse error at the en dash?

JawnV6
Jul 4, 2004

So hot ...

pokeyman posted:

Parse error at the en dash?

Ughhh I swear I tried

brap
Aug 23, 2004

Grimey Drawer
isn't the point of volatile so that if some hardware thing writes to the memory you can read it properly? and in certain balls-to-the-wall multithreading scenarios?

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

brap posted:

isn't the point of volatile so that if some hardware thing writes to the memory you can read it properly? and in certain balls-to-the-wall multithreading scenarios?

Sort of. It basically tells the compiler that the object declared "volatile" is not in normal RAM (typically these are memory mapped registers, or "IO memory"). Consecutive read accesses may return different values, and write accesses may have side effects beyond changing a stored value. The compiler must not remove any of the reads/writes specified by the program, or add new ones (e.g., to avoid spilling a value previously read).
DMA buffers (RAM that may be accessed by hardware other than the CPU) are different—they need special treatment beyond what a compiler can do, like making them uncacheable or changing memory mappings before/after a DMA operation. They generally don’t need to be declared "volatile" in addition to that.
That’s all ignoring multi-processing issues, so you may need to add memory barriers on top of all your "volatile" declarations and memory mapping whatnot. Writing device drivers is fun! If the hardware even works as it's supposed to. :shepicide:

Captain Cappy
Aug 7, 2008

No one knows what Volatile does, not even Dennis, Ken, or Bjarne.

baby puzzle
Jun 3, 2011

I'll Sequence your Storm.

Captain Cappy posted:

No one knows what Volatile does, not even Dennis, Ken, or Bjarne.

It means I can set a breakpoint there in an optimized build.

Foxfire_
Nov 8, 2010

Things volatile does:

- The variable must be given an address. The compiler can't just use a register
- Any load or store must actually happen. The compiler can't omit them even if no write happened since the last time it read it, it's writing the same value twice, or if it can determine that no other computation depends on the load/store.
- The compiler must issue loads/stores in the same order relative to every other volatile load/store. No swapping the order of them to make things faster

Things volatile doesn't do:

- Stop the processor from reordering loads/stores. A fancy ARM can and will do this unless you tell it when it's not allowed to
- Impose any ordering from the point of view of another core. Other cores can see the same memory accesses happen in different orders from the initiating core, and in different orders from each other.
- Do any sort of cache coherency operations. A volatile store will happily repeatedly rewrite the same data in cache and never actually go to memory.

It's a compiler-only thing. It limits how the compiler can rearrange and optimize, but has no impact whatsoever on the hardware rearranging and optimizing.

Carbon dioxide
Oct 9, 2012

Foxfire_ posted:

Things volatile does:

- The variable must be given an address. The compiler can't just use a register
- Any load or store must actually happen. The compiler can't omit them even if no write happened since the last time it read it, it's writing the same value twice, or if it can determine that no other computation depends on the load/store.
- The compiler must issue loads/stores in the same order relative to every other volatile load/store. No swapping the order of them to make things faster

Things volatile doesn't do:

- Stop the processor from reordering loads/stores. A fancy ARM can and will do this unless you tell it when it's not allowed to
- Impose any ordering from the point of view of another core. Other cores can see the same memory accesses happen in different orders from the initiating core, and in different orders from each other.
- Do any sort of cache coherency operations. A volatile store will happily repeatedly rewrite the same data in cache and never actually go to memory.

It's a compiler-only thing. It limits how the compiler can rearrange and optimize, but has no impact whatsoever on the hardware rearranging and optimizing.

This is for C-type languages.

In jvm languages, volatile has a rather different meaning.
It means that:
- volatile variables are not cached thread-locally, instead they are always stored in the jvm's main stack.
- volatile variables cause a thread synchronization on every access so that no two threads can touch them at the same time.

99% of the time the synchronized keyword is a safer alternative to volatile variables. But, because it has subtly different properties, there are rare times when someone might need volatile variables anyway. That said, anyone programming multithreading programs by hand in TYOOL 2018 is asking for disasters, and instead they should just use a good concurrency library of their choice.

QuarkJets
Sep 8, 2008

Carbon dioxide posted:

This is for C-type languages.

In jvm languages, volatile has a rather different meaning.
It means that:
- volatile variables are not cached thread-locally, instead they are always stored in the jvm's main stack.
- volatile variables cause a thread synchronization on every access so that no two threads can touch them at the same time.

99% of the time the synchronized keyword is a safer alternative to volatile variables. But, because it has subtly different properties, there are rare times when someone might need volatile variables anyway. That said, anyone programming multithreading programs by hand in TYOOL 2018 is asking for disasters, and instead they should just use a good concurrency library of their choice.

that seems like a poor choice of name for that kind of behavior

redleader
Aug 18, 2005

Engage according to operational parameters
I once used a volatile variable in C#, perhaps even correctly!

Then I came to my senses and just wrote the thing to run multiprocess-ly

Munkeymon
Aug 14, 2003

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



The best shared state is none at all

ChickenWing
Jul 22, 2010

:v:

Carbon dioxide posted:

That said, anyone programming multithreading programs by hand in TYOOL 2018 is asking for disasters, and instead they should just use a good concurrency library of their choice.

Time to add multithreading to the "don't roll your own" list

Sereri
Sep 30, 2008

awwwrigami

JavaScript code:
// Convert 2-digit to 4-digit year, padding it with the current century.
year = String(new Date().getFullYear() / 100 ^ 0) + year;
Turns out that if it's stupid and it works, it might still be stupid. Especially since year can only be 2018 and later and is a maximum of 5 years ahead.

Dr. Stab
Sep 12, 2010
👨🏻‍⚕️🩺🔪🙀😱🙀

Sereri posted:

JavaScript code:
// Convert 2-digit to 4-digit year, padding it with the current century.
year = String(new Date().getFullYear() / 100 ^ 0) + year;
Turns out that if it's stupid and it works, it might still be stupid. Especially since year can only be 2018 and later and is a maximum of 5 years ahead.

Sounds like you're not ready for Y2.1k

Adbot
ADBOT LOVES YOU

JawnV6
Jul 4, 2004

So hot ...

Zopotantor posted:

Sort of. It basically tells the compiler that the object declared "volatile" is not in normal RAM (typically these are memory mapped registers, or "IO memory"). Consecutive read accesses may return different values, and write accesses may have side effects beyond changing a stored value. The compiler must not remove any of the reads/writes specified by the program, or add new ones (e.g., to avoid spilling a value previously read).
DMA buffers (RAM that may be accessed by hardware other than the CPU) are different—they need special treatment beyond what a compiler can do, like making them uncacheable or changing memory mappings before/after a DMA operation. They generally don’t need to be declared "volatile" in addition to that.
That’s all ignoring multi-processing issues, so you may need to add memory barriers on top of all your "volatile" declarations and memory mapping whatnot. Writing device drivers is fun! If the hardware even works as it's supposed to. :shepicide:

You still haven't really explained why you think the timeout author doesn't understand 'volatile'? The declaration for hardware_thing isn't shown, it's presumably done properly and is reaching out to the MMIO every time. But if you don't have 'volatile' on delay/tmo, despite the fact that they reside in "normal" RAM, anything above -O0 is going to wipe out the entire loop.

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