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
Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
If you have a flow analyzer, then breaks inside loops should be handled homogeneously -- you split the stuff after the break into a separate block, and then link it up to the conditional exit node of a branch, and use that info when you codegen your blocks.

ASTs and parse trees aren't that different in practice, the former just "less noise". In practice, in a hand-written recursive descent parser, you construct the AST as you go and don't even construct a "raw" parse tree.

Adbot
ADBOT LOVES YOU

Fluue
Jan 2, 2008
How should I deal with a task queue that calls to a non-idempotent API?

The task queue is responsible for provisioning and updating user accounts in a 3rd-party service. When given an email to create an account, the service will not respect whether an account with that same email already exists.

The task queue runs concurrently (SQS -> Lambda) each task is run independent of one another. If two calls are made to the 3rd-party service to try and create a new user account, the service will happily create two different accounts for the same email.

Should I look into batching up some of the tasks so that certain tasks perform more than one operation? Not sure how to proceed with this kind of behavior in a task queue.

Lamont
Mar 31, 2007
Who knows what evil lurks in the hearts of men?
I'm a hobbyist coder at a relatively basic level (I've completed Harvard's online CS50 course, if that means anything). Due to my part time job at a university I have access to the CS department intranet and thought I would try to learn some of the material from at least the first year of a CS degree, since I have no formal CS education (other than bits and pieces learned during an EE degree many years ago)

My question is, if I don't plan to ever get a job in this stuff, and just want to make things, do I really need to study set theory/formal logic? I find it incredibly dull and am struggling to see the relevance. I know CS academic types say "it will help you think more clearly" but surely there are ways I can do that while practicing actual programming.

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


Discrete math is highly relevant if you ever want to really understand databases. Even if you're not a programmer, that's something you might want to do. If you find it dull on its own, you might want to see if you can get a copy of Applied Mathematics for Database Professionals through your university's library.

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer

Lamont posted:

I'm a hobbyist coder at a relatively basic level (I've completed Harvard's online CS50 course, if that means anything). Due to my part time job at a university I have access to the CS department intranet and thought I would try to learn some of the material from at least the first year of a CS degree, since I have no formal CS education (other than bits and pieces learned during an EE degree many years ago)

My question is, if I don't plan to ever get a job in this stuff, and just want to make things, do I really need to study set theory/formal logic? I find it incredibly dull and am struggling to see the relevance. I know CS academic types say "it will help you think more clearly" but surely there are ways I can do that while practicing actual programming.

i am a professional software engineer and my highest level of math education is getting a c in calculus 1 my freshman year. Any other math I've needed I picked up in the course of learning to program and working on real projects. You absolutely do not need to study that stuff formally on its own. Just learn what you need as it comes up in real situations.

nielsm
Jun 1, 2009



Worth it to study discrete mathematics and theory of proof by induction, to get some understanding of asymptotic run time.

lifg
Dec 4, 2000
<this tag left blank>
Muldoon
If you're a hobbyist, and goal is just to have fun programming, then you absolutely do not need to study set theory.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

Lamont posted:

I'm a hobbyist coder at a relatively basic level (I've completed Harvard's online CS50 course, if that means anything). Due to my part time job at a university I have access to the CS department intranet and thought I would try to learn some of the material from at least the first year of a CS degree, since I have no formal CS education (other than bits and pieces learned during an EE degree many years ago)

My question is, if I don't plan to ever get a job in this stuff, and just want to make things, do I really need to study set theory/formal logic? I find it incredibly dull and am struggling to see the relevance. I know CS academic types say "it will help you think more clearly" but surely there are ways I can do that while practicing actual programming.

Oh good, my favorite rant. I have very strong opinions on Software Engineering vs Computer Science, and the fact that we demand the latter when most people want / need the former.

No, as long as you don't need the math or logic to understand how to make something, you can skip it. The most relevant thing you'll want to look at is logic because that will have implications on you making truth tables etc, but you can reason it out on paper if you need to.

Dominoes
Sep 20, 2007

I've taken a deep personal interest in math and science, and have also built a lot of software projects... The only direct overlap is if I'm doing math/science computation.

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

You need a solid basis in mathematics if you want to be a computer scientist. You need at least some understanding of set theory to understand the basics of the theory of computation.

You don't need to be a computer scientist at all to be a world class programmer.

taqueso
Mar 8, 2004


:911:
:wookie: :thermidor: :wookie:
:dehumanize:

:pirate::hf::tinfoil:

But some of that stuff is pretty fun to learn about anyway, if you are the right kind of nerdling.

Dominoes
Sep 20, 2007

Have fun bros. Sometimes considered a seminal work in CS

Thermopyle
Jul 1, 2003

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

I need to expand my knowledge of win32 programming from minuscule to minuscule + 1 to do some stuff from a python application that I don't understand how to do yet.

From my understanding there's not a lot new in the world of win32 programming so I'm thinking that a book from 2000 isn't going to significantly handicap me. Is that right?

(I ask because I have a copy of Python Programming on Win32 and it's from the year 2000)

To avoid the XY problem, I'm wanting to get images of other apps live-ish using DWM into my python program.

The Fool
Oct 16, 2003


I've never tried it myself, but maybe PythonNet and use a .Net method.

Graphics.CopyFromScreen may do the trick.

nielsm
Jun 1, 2009



The concepts for Win32 haven't changed massively since then, no, but Python has. It's more likely the Python parts of that book are out of date. In particular Python 2.0 was only released in October 2000, so the book may very well cover Python 1.x more than Python 2, and not at all 3.

Also, DWM doesn't have an (official) API for extracting images of other applications, as far as I know.

Thermopyle
Jul 1, 2003

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

nielsm posted:

The concepts for Win32 haven't changed massively since then, no, but Python has. It's more likely the Python parts of that book are out of date. In particular Python 2.0 was only released in October 2000, so the book may very well cover Python 1.x more than Python 2, and not at all 3.

Also, DWM doesn't have an (official) API for extracting images of other applications, as far as I know.

The outdated python part doesn't bother me, I won't have any problem converting those concepts to new stuff (fingers crossed).

As far as extracting images of other applications, I had assumed this page meant that I could get the image data...but now from your comment I'm thinking it just means that windows will draw the thumbnail in my application (which doesn't actually have a window anyway) without giving me access to the image data.


The Fool posted:

I've never tried it myself, but maybe PythonNet and use a .Net method.

Graphics.CopyFromScreen may do the trick.

Oh nice. I'll look into this. I think the problem with CopyFromScreen will be that it requires the window to be visible and not minimized unlike the DWM stuff.

My goal was to get other window contents with as low of a performance overhead as possible but I haven't actually tried anything yet...I just remember when Vista came out the "live" nature of thumbnails and Task View and whatever was a big feature.

nielsm
Jun 1, 2009



I think the thumbnail rendering happens inside the DWM and is controlled by it, so if the destination window isn't visible the thumbnail won't get drawn.

Alternative methods include sending the WM_PRINT message to the victim window and ask it to paint itself into your device context.
Or read though screen capture software like OBS how they do it.

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


The Win32 API is also very well documented online, so if you have a rough idea of what you're looking for, it shouldn't be too bad to get the latest info.

Thermopyle
Jul 1, 2003

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

nielsm posted:

I think the thumbnail rendering happens inside the DWM and is controlled by it, so if the destination window isn't visible the thumbnail won't get drawn.

I wonder if I could create a window off-screen...like at DESKTOP_WIDTH+100 or whatever, have DWM send it's thumbnails into it, and then capture that so I can get the contents of windows that are not actually visible.

Of course, I can't really try any of this until I figure out the basics of how to use win32.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
Other OSes get around this limitation by making minimize not actually minimize the window, and just stack it "under" the desktop window. It's also common to, yeah, just have a hack to shove the window offscreen somewhere at -9000,-9000 or something. This is how most Windows TTYs work, since they always open a console window.

mystes
May 31, 2006

Suspicious Dish posted:

This is how most Windows TTYs work, since they always open a console window.
Does ConPTY still do this internally?

Bonfire Lit
Jul 9, 2008

If you're one of the sinners who caused this please unfriend me now.

Thermopyle posted:

To avoid the XY problem, I'm wanting to get images of other apps live-ish using DWM into my python program.

Do you actually need to read/manipulate pixels, or are you just interested in displaying the window content to the user (like the taskbar does)? If it's the former, I don't think you can do it (with DWM) - DWM just renders the thumbnails in the correct location during composition. If it's the latter, you can use DwmRegisterThumbnail.

Thermopyle
Jul 1, 2003

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

Unfortunately I need the actual pixels.

I'm going to try having DWM render to an off-screen window and then capturing the contents of that window.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
Not sure why you want DWM to do it, you should just be able to BitBlt from the HWND to your own DC using GDI.

Thermopyle
Jul 1, 2003

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

Suspicious Dish posted:

Not sure why you want DWM to do it, you should just be able to BitBlt from the HWND to your own DC using GDI.

Well, like I originally said this is all a bit out of my comfort zone.

However, I was under the impression that wouldn't work for windows that were not visible because they were covered by other windows?

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
The DWM compositor affects windows so that they have their own backing store (an option since Windows 2000, and basically always on since Vista), and you can blit those window contents at any time.

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.

Suspicious Dish posted:

The DWM compositor affects windows so that they have their own backing store (an option since Windows 2000, and basically always on since Vista), and you can blit those window contents at any time.

Yeah, that's why desktop live thumbnails (play a video, minimize it, and hover your mouse over it in the start menu) and aero peek work even if a window is minimized.

Thermopyle
Jul 1, 2003

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

Bruegels Fuckbooks posted:

Yeah, that's why desktop live thumbnails (play a video, minimize it, and hover your mouse over it in the start menu) and aero peek work even if a window is minimized.

This doesn't actually work. I was surprised about this, but while researching this I came across someone pointing out that it doesnt. It caches a snapshot of the last time it was not minimized and shows you the cached version.

If the window is occluded or off-screen in some way, it does show you live contents.

Love Stole the Day
Nov 4, 2012
Please give me free quality professional advice so I can be a baby about it and insult you
Trying to figure out how to organize and deploy a Monorepo:tm:. Am attempting to do the back-end with Node+Express.

I'm able to get a basic thing working on localhost with the NPM package called micro-proxy, which allows me to route to different URL addresses (i.e. localhost ports) based on the URI path.

What I'm confused about, though, is how I'm supposed to put all of these microservices under the same roof such that not only can users hit the correct service but also so that the services can communicate with one another as well.

Does anyone know of any useful reads to accomplish this? I feel like all of the solutions I can come up with on my own will fall apart once I actually try to deploy everything.

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.

Thermopyle posted:

This doesn't actually work. I was surprised about this, but while researching this I came across someone pointing out that it doesnt. It caches a snapshot of the last time it was not minimized and shows you the cached version.

If the window is occluded or off-screen in some way, it does show you live contents.

I had to wrestle with aero breaking poo poo in minimized windows in windows vista years ago and this may have been something turned off as an "optimization" in a later version of windows.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

Thermopyle posted:

This doesn't actually work. I was surprised about this, but while researching this I came across someone pointing out that it doesnt. It caches a snapshot of the last time it was not minimized and shows you the cached version.

If the window is occluded or off-screen in some way, it does show you live contents.

If by "occluded" you mean "behind another window", I don't think that's right. This is literally the method that OBS uses in its Window Capture source, and it can display those windows just fine. Windows that are minimized don't seem to correctly update, and in my one test app, windows that are partially offscreen indeed don't have the offscreen parts update.

Part of this might be the WM_PAINT exposure rect clipping that Windows can do by default. Not sure if there's an easy way to fake onscreen-ness.

Hughmoris
Apr 21, 2007
Let's go to the abyss!
Just a reminder that this year's Advent of Code just kicked off: https://adventofcode.com/2019/day/1

For those not familiar, it's a yearly puzzle solving event. I think I'm going to try F# for this year's puzzles.

Jewel
May 2, 2009

Hughmoris posted:

Just a reminder that this year's Advent of Code just kicked off: https://adventofcode.com/2019/day/1

For those not familiar, it's a yearly puzzle solving event. I think I'm going to try F# for this year's puzzles.

Oh jeez, I forgot this was so soon. My plan this year was to learn F# or Rust, I'm not mentally prepared yet :negative:

Thermopyle
Jul 1, 2003

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

Suspicious Dish posted:

If by "occluded" you mean "behind another window", I don't think that's right. This is literally the method that OBS uses in its Window Capture source, and it can display those windows just fine. Windows that are minimized don't seem to correctly update, and in my one test app, windows that are partially offscreen indeed don't have the offscreen parts update.

Part of this might be the WM_PAINT exposure rect clipping that Windows can do by default. Not sure if there's an easy way to fake onscreen-ness.

Wait, one of us confused the other. I probably confused you as my post is oddly worded.

I'm saying DWM can capture windows behind other windows, and I think you're saying the same thing here.

Joda
Apr 24, 2010

When I'm off, I just like to really let go and have fun, y'know?

Fun Shoe
At work I'm trying to come up with a way to solve the horrible performance and massive amounts of deadlocks our system causes, and I have a fairly good idea of how to do it. Essentially the problem is that we don't have any layers, so our API code does logic, external notifications and database interactions directly and without any layers of abstraction. This also means that we compose logic by having the API call itself, leading to all sorts of side-effects when it does this inside of transactions for instance. E.g.we'll be inserting two objects at once from two different requests, inserting the object requires the insertion/update of another type of object, and this insertion is done via another API request inside of a transaction, that will then try to read a table that the other thread locked. Essentially, the secondary object's insertion request is not designed to be run inside of a transaction.

My proposed solution is to add a Model layer that has a mutation and an accessor part which will be injected into a new logic layer that only worries about the actual business logic. The mutation part will have two modes of operation 1) direct; all operations are committed to the persistence layer directly 2) deferred; a catalogue is maintained of changes for the thread and will be committed on request. The accessor part will then, if mutations are deferred, try to read from the mutation catalogue first, and only read from the database/cache/mocked data/whatever if it doesn't find anything.

Now my question is; is there a name for this sort of deferred mutation? I feel like I cannot possibly be the first person trying to solve this problem. Am I trying to reinvent the wheel here? Also, I feel like there must be a less verbose, more elegant solution, but I just haven't thought of it.

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!
It seems strange to me that an entire table could be locked by one thread such that it can't even be read by others. Are you sure that's what happens?

Joda
Apr 24, 2010

When I'm off, I just like to really let go and have fun, y'know?

Fun Shoe

Kilson posted:

It seems strange to me that an entire table could be locked by one thread such that it can't even be read by others. Are you sure that's what happens?

Not the entire table, that was poorly put. I meant it's locking reads that require reading the whole table for whatever reason (e.g. full reads, lacking indices etc.) It's one thread that has committed something to the database, trying to do a query that might read something another thread has committed to the database and vice versa, but unintentionally they're both in transactions from their parent requests, so they lock each other, since neither can finish. It's not locking the entire table, but the way the query works it shouldn't be in a transaction at all, since it might (for instance,) do a full table scan.

I'm essentially trying to move the transaction of ALL requests to the very end (regardless of intermediate logic and dependency on other functions,) so it will only include actual mutation, and not be dependent on queries.

Joda fucked around with this message at 21:52 on Dec 1, 2019

rarbatrol
Apr 17, 2011

Hurt//maim//kill.

Joda posted:

...

Now my question is; is there a name for this sort of deferred mutation? I feel like I cannot possibly be the first person trying to solve this problem. Am I trying to reinvent the wheel here? Also, I feel like there must be a less verbose, more elegant solution, but I just haven't thought of it.

That kind of sounds like a write-through cache to me. Your reads are making use of in-memory knowledge of a pending operation. I'm not sure that actually deferring the mutations gets you anything though... I guess it could make the overall time window for the transaction smaller, which should make deadlocking less common. I'd also have some questions about multiple client/server use cases if some of these things aren't happening exactly when requested, but that might not be a concern for your usages.

At my job, we implemented deadlock retry logic with an exponential back-off for any request that isn't part of a larger transaction, and that's helped cut down on a lot of the dumber failures. Retrying an entire transaction's worth of requests requires more of a case-by-case evaluation, since the entire operation may have been based on a premise that's no longer valid.

Joda
Apr 24, 2010

When I'm off, I just like to really let go and have fun, y'know?

Fun Shoe
Yeah, write-through cache seems to be the word

rarbatrol posted:

I'm not sure that actually deferring the mutations gets you anything though...

It gets rid of the interweaving of queries and mutations, so reads after mutations inside of a transactions can't cause deadlocks any longer, as mutation will always be the very last operation. And it allows me to enforce a very specific order in which to do mutations. So if we know all requests will do their mutations to tables in this very specific order, it should technically be impossible for the threads to deadlock each other, because they won't be able to lock resources that will be needed for mutations on another thread. There's still the possibility that one thread will do a read that another thread will soon invalidate, but we don't have any real handling for that either, so I'm sticking to one problem at a time.

That's the theory at least. Maybe nothing will work like I think it will.

Joda fucked around with this message at 23:35 on Dec 1, 2019

Adbot
ADBOT LOVES YOU

Mr Shiny Pants
Nov 12, 2012

Joda posted:

Yeah, write-through cache seems to be the word


It gets rid of the interweaving of queries and mutations, so reads after mutations inside of a transactions can't cause deadlocks any longer, as mutation will always be the very last operation. And it allows me to enforce a very specific order in which to do mutations. So if we know all requests will do their mutations to tables in this very specific order, it should technically be impossible for the threads to deadlock each other, because they won't be able to lock resources that will be needed for mutations on another thread. There's still the possibility that one thread will do a read that another thread will soon invalidate, but we don't have any real handling for that either, so I'm sticking to one problem at a time.

That's the theory at least. Maybe nothing will work like I think it will.

Sounds like you need a queue.

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