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.
 
  • Locked thread
piratepilates
Mar 28, 2004

So I will learn to live with it. Because I can live with it. I can live with it.



HappyHippo posted:

how easy is it to switch a javascript project over to typescript?

depends on how big it is and how much you want it

it's probably a lot easier now that typescript lets you include js files, so you can piecemeal convert everything. probably still a lot of stuff that will show warnings or errors at first. the good news is that generally typescript will transpile stuff anyway so if you can deal with errors being logged during transpilation at first while you straighten them out it may not be so bad. also make sure you don't have any lame rear end js dependencies that don't have a .d.ts file written for it or you'll have to start making one yourself.

Adbot
ADBOT LOVES YOU

Blinkz0rz
May 27, 2001

MY CONTEMPT FOR MY OWN EMPLOYEES IS ONLY MATCHED BY MY LOVE FOR TOM BRADY'S SWEATY MAGA BALLS

HappyHippo posted:

how easy is it to switch a javascript project over to typescript?

rename all js files to ts, include a tsconfig.json file, and you should be good to start

start adding types. anywhere you either need an external type you can find it on definitelytyped, declare it as any, or write a wrapper interface. then keep going.

brap
Aug 23, 2004

Grimey Drawer
transpiler is such a goofy loving word
it's ok to just call it a compiler. that's what the typescript team calls it.

piratepilates
Mar 28, 2004

So I will learn to live with it. Because I can live with it. I can live with it.



fleshweasel posted:

transpiler is such a goofy loving word
it's ok to just call it a compiler. that's what the typescript team calls it.

oh do they? yeah I don't really get why people have been using transpiler for a while instead of compiler, especially now that ~~WEBASSEMBLY~~ is hitting the shores

Illusive Fuck Man
Jul 5, 2004
RIP John McCain feel better xoxo 💋 🙏
Taco Defender
i'm trying to turn a conversation of "what should we name this thing in a public api?" to "why are we adding this to a public api? we're 2 quarters away from even possessing the necessary knowledge to define what it is." is this correct bikeshedding?

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

piratepilates posted:

oh do they? yeah I don't really get why people have been using transpiler for a while instead of compiler, especially now that ~~WEBASSEMBLY~~ is hitting the shores

a compiler is a program that takes code in one language as input and outputs code in a different language

kitten emergency
Jan 13, 2008

get meow this wack-ass crystal prison
my transpiler is leaking

Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

has anybody said buttpiler yet

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

Illusive gently caress Man posted:

i'm trying to turn a conversation of "what should we name this thing in a public api?" to "why are we adding this to a public api? we're 2 quarters away from even possessing the necessary knowledge to define what it is." is this correct bikeshedding?

are multiple words in your API path CamelCase, mixedCase, or_underscored? this is an important question that should be answered before you worry about what your API does or does not do or fail to do. same re json/xml and capitalization of the json/xml terms. that's a good 3-5 meetings you could have right there.

JewKiller 3000
Nov 28, 2006

by Lowtax

hackbunny posted:

I can't use sql, orms have spoiled me. validation hooks and change notifications are the things I miss the most when I'm using bare SQL, and schema migration is a pain

JewKiller 3000 posted:

i don't speak orm so maybe i'm wrong, but it sounds like you're talking about check constraints and triggers?

hackbunny posted:

kinda, except outside of the database, written in a sensible programming language and actually debuggable

umm ok well a "validation hook" sounds like it lets you ensure that an invalid value is never written to the database. why do you want this check to occur outside of the database?

a "change notification" sounds like something you want to happen when a modification to the database occurs. why don't you think the database is capable of triggering this for you? you know you can have the trigger call a function written in a normal programming language (not sql), right?

in conclusion:

JewKiller 3000 posted:

hmm, i need to query the database, so instead of using the sql language that was designed specifically for the purpose, i think i'll make 50 java classes and then eat my own poo poo

Illusive Fuck Man
Jul 5, 2004
RIP John McCain feel better xoxo 💋 🙏
Taco Defender

leper khan posted:

are multiple words in your API path CamelCase, mixedCase, or_underscored? this is an important question that should be answered before you worry about what your API does or does not do or fail to do. same re json/xml and capitalization of the json/xml terms. that's a good 3-5 meetings you could have right there.

everything is consistent case unfortunately.

now im arguing toilet (which is the thing we can't fully define yet) should be an optional property of turd rather than a parent on the resource url. not all turd users need a toilet, and it dilutes the meaning of toilet. it just makes sense!!!!!

imagine youre checking out turd API v1, and the first thing you're required to do is create a toilet. you've never heard of toilets, and after reading the docs, it turns out you don't care. doesn't that sound like a bad design?

toilets exist because some customers wont use our turd API unless their turds are in toilets, but a lot of customers wont care, or don't want to pay for toilets. IMO, turds should be allowed to exist outside a toilet when users don't need toilets.


but enough about my posting

karms
Jan 22, 2006

by Nyc_Tattoo
Yam Slacker
A better way imho is to let everyone write a spec indiviually and compare contrast them. This ways you can suss out any inherent beliefs that would otherwise be a loving nightmare to do face to face. however if you dont know wtf youre building then you might as well piss in the wind forever

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

piratepilates posted:

oh do they? yeah I don't really get why people have been using transpiler for a while instead of compiler, especially now that ~~WEBASSEMBLY~~ is hitting the shores

anything involving js isn't "real" programming, but compilers are real programming, therefore js people aren't allowed to use the word compiler

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?
thanks for the replies guys. one other thing, how is the debugging in the browser? my understanding is that the js code looks mostly the same (just with the annotations removed) so its not that difficult?

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

Plorkyeran posted:

anything involving js isn't "real" programming, but compilers are real programming, therefore js people aren't allowed to use the word compiler

what if they wrote a C compiler in js? i'm sure someone has been dumb enough to do it

piratepilates
Mar 28, 2004

So I will learn to live with it. Because I can live with it. I can live with it.



HappyHippo posted:

thanks for the replies guys. one other thing, how is the debugging in the browser? my understanding is that the js code looks mostly the same (just with the annotations removed) so its not that difficult?

Typescript debugging is fine since it's so similar to JavaScript. Even if you turn off source maps it's pretty easy to see what code in the compiled version is which in the original TS version.

EXCEPT for some stuff like generators and async/await which gets turned in to an odd looking state machine block, but that's also pretty easy to read one you realise what they're doing. You can go to the babeljs site and play around with their online transpiling playground (TS has one too actually) and see how similar the final js code is and how things are getting compiled to ES5 compliant JavaScript.

Baxate
Feb 1, 2011

HappyHippo posted:

how easy is it to switch a javascript project over to typescript?

well technically plain JavaScript is valid typescript afaik

Baxate
Feb 1, 2011

so uh what's the proper way to do a feature branch in git that depends on master and another unmerged branch?

I created a new branch from master then merged the other branch then started working. when I submitted the branch as a pull request the reviewer told me to use stashing and I'm thinking like how the heck do I use git stash for this???

piratepilates
Mar 28, 2004

So I will learn to live with it. Because I can live with it. I can live with it.



Ludwig van Halen posted:

so uh what's the proper way to do a feature branch in git that depends on master and another unmerged branch?

I created a new branch from master then merged the other branch then started working. when I submitted the branch as a pull request the reviewer told me to use stashing and I'm thinking like how the heck do I use git stash for this???

I know one person who might have an idea how stashing would work with your feature branch, should probably ask him

Baxate
Feb 1, 2011

piratepilates posted:

I know one person who might have an idea how stashing would work with your feature branch, should probably ask him

:jerkbag:

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

leper khan posted:

what if they wrote a C compiler in js? i'm sure someone has been dumb enough to do it

it would be a "toy compiler"

Shaggar
Apr 26, 2006

Illusive gently caress Man posted:

everything is consistent case unfortunately.

now im arguing toilet (which is the thing we can't fully define yet) should be an optional property of turd rather than a parent on the resource url. not all turd users need a toilet, and it dilutes the meaning of toilet. it just makes sense!!!!!

imagine youre checking out turd API v1, and the first thing you're required to do is create a toilet. you've never heard of toilets, and after reading the docs, it turns out you don't care. doesn't that sound like a bad design?

toilets exist because some customers wont use our turd API unless their turds are in toilets, but a lot of customers wont care, or don't want to pay for toilets. IMO, turds should be allowed to exist outside a toilet when users don't need toilets.


but enough about my posting

As long as turds will never require a toilet then having a property on turd with a reference to the containing toilet is correct. However if turds have a hidden default toilet then that counts as being required. Don't hide that kind of implementation detail.

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

LeftistMuslimObama posted:

ok, so with wpf, the basic way to dynamically populate lists, trees, etc is just to bind them to a collection, then have that collection throw off the right events when they change? that feels too god damned easy. like, can i seriously filter my list of items by a particular metadata by just clearing the collection my listview is bound to and then repopulating the collection using a query against my sqlite database on that metadata? this can't be real, it feels too sane. i have to be missing something.

that's generally how data binding systems work

WPF here just follows in the footsteps of Apple's Cocoa Bindings and its predecessor, the NeXT EOInterface framework

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

LeftistMuslimObama posted:

my poor tortured mind can't accept that there's not some kind of minefield hiding behind this simple premise

there are minefields for sure

for example, people sometimes try to just use objects that have been bound to on threads other than the main/UI thread; different bindings systems deal with this differently, but in virtually none actually "just work" (and it's not even entirely clear what that would necessarily mean)

piratepilates
Mar 28, 2004

So I will learn to live with it. Because I can live with it. I can live with it.



eschaton posted:

there are minefields for sure

for example, people sometimes try to just use objects that have been bound to on threads other than the main/UI thread;

javascript solves this in the best way :v:


(actually i'm only half kidding)

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer

eschaton posted:

that's generally how data binding systems work

WPF here just follows in the footsteps of Apple's Cocoa Bindings and its predecessor, the NeXT EOInterface framework

what this experience is teaching me is that i need to get out as soon as i dont owe for the tuition anymore and my insurance has paid for all the procedures i need. good thing im writing something to put on my github :)

FamDav
Mar 29, 2008

LeftistMuslimObama posted:

what this experience is teaching me is that i need to get out as soon as i dont owe for the tuition anymore and my insurance has paid for all the procedures i need. good thing im writing something to put on my github :)

so you were fine with mumps?

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

eschaton posted:

there are minefields for sure

for example, people sometimes try to just use objects that have been bound to on threads other than the main/UI thread; different bindings systems deal with this differently, but in virtually none actually "just work" (and it's not even entirely clear what that would necessarily mean)

yeah, core data objects on ios for example. if you hit a fault (some part of the object wasn't retrieved from the database and must be queried), you'll be blocked while the query runs on the managed object context's thread. I try not to use locks anywhere (the lock is evil! the lock shoots sleeps, and makes new deadlocks to poison the App with a plague of crashes, as it once was), but iirc I managed to hit a deadlock anyway. I had to write a proxy around NSFetchedResultsController (the class that's used to bind data queries to UI tables/lists), which converted all managed objects into POOCOs to move data to the main thread

I find that the worst part by far when you write multi-threaded code is not synchronization (although lock-free synchronization can be a bitch and a half), but startup/teardown. you end up putting queues everywhere and generating lots of spurious events to stave off the risk of data loss, desynchronization, or endless waits. I really should try erlang or distributed programming in general

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
speaking of teardown, holy poo poo how the hell did I manage to conceive of and write this:
C++ code:
-(void)finishCloseStore:(NS_RELEASES_ARGUMENT NSManagedObjectContext *)closingManagedObjectContext
               isSecure:(BOOL)isSecure
             onComplete:(void (^)(void))onComplete
{
    LogDebug(TAG_SECURESTORE,
            @"Broadcasting %@ notification {%@: %p, %@: %@}",
            SecureStoreWillCloseNotification,
            SecureStoreNotificationManagedObjectContextKey,
            (char *)(__bridge void *)closingManagedObjectContext, /* NOTE: printed as a pointer, DON'T call -description
                                                                     because it executes synchronously in the context's queue,
                                                                     causing all sorts of synchronization issues (like
                                                                     deadlocks). Also don't remove the cast to char *, because
                                                                     char * can't be mistakenly printed with %@, as object
                                                                     pointers, id or void * can */
            SecureStoreNotificationIsSecureKey,
            @(isSecure));

    [notificationCenter postNotificationName:SecureStoreWillCloseNotification
                                      object:self
                                    userInfo:@{SecureStoreNotificationManagedObjectContextKey: closingManagedObjectContext,
                                               SecureStoreNotificationIsSecureKey: @(isSecure)}];
    
    LogDebug(TAG_SECURESTORE, @"%@ notification broadcast", SecureStoreWillCloseNotification);

    LogInfo(TAG_SECURESTORE, @"Waiting for operations on the managed object context to complete");

    [closingManagedObjectContext performBlockAndWait:^{
        LogInfo(TAG_SECURESTORE, @"All operations on the managed object context completed");
    }];

    LogInfo(TAG_SECURESTORE, @"Releasing the last reference to the managed object context");
    closingManagedObjectContext = nil;

    [self usingAnyState:^{
        assert(state == SecureStoreClosing);

        if (state == SecureStoreClosing) {
            state = SecureStoreInitial;
            [self internalUpdateState];
            LogInfo(TAG_SECURESTORE, @"State reinitialized to %@: notifying the state change", SecureStoreStateDescription(state));
            [stateLock broadcast];
        }
        else {
            [self internalHandleBadState];
        }

        LogDebug(TAG_SECURESTORE, @"Scheduling broadcast of notification %@ on main thread", SecureStoreDidCloseNotification);

        dispatch_async(dispatch_get_main_queue(), ^{
            LogDebug(TAG_SECURESTORE, @"Broadcasting %@ notification", SecureStoreDidCloseNotification);
            [notificationCenter postNotificationName:SecureStoreDidCloseNotification object:self];
            LogDebug(TAG_SECURESTORE, @"%@ notification broadcast", SecureStoreDidCloseNotification);
        });

        LogInfo(TAG_SECURESTORE, @"Finished closing managed object context");

        if (onComplete) {
            onComplete();
        }
    }];
}
note this comment in particular:
C++ code:
/* NOTE: printed as a pointer, DON'T call -description
because it executes synchronously in the context's queue,
causing all sorts of synchronization issues (like
deadlocks). Also don't remove the cast to char *, because
char * can't be mistakenly printed with %@, as object
pointers, id or void * can */
note the two separate pitfalls addressed by it:
  • if you have a managed object context with its own dedicated thread (abstracted by the framework as a queue), almost all of its methods will execute synchronously in that thread, including surprising ones like -[NSObject description], which is used to print the object to a string when using the %@ format specifier
  • Objective C absolutely loves implicitly converting between id, void * and int, so I have to cast to something that can't be printed with %@ by mistake

also note this apparent no-op which is actually very important:
C++ code:
    [closingManagedObjectContext performBlockAndWait:^{
        LogInfo(TAG_SECURESTORE, @"All operations on the managed object context completed");
    }];
before this method is called, the managed object context (represents an instance of an open database) has been made inaccessible to clients of this class, so they can't start new queries on it. what if there are any outstanding queries? the code above executes an empty block synchronously on the context's queue, which (if clients of the class are well-behaved and don't submit new work from within the context's queue but only through "official channels") is guaranteed to execute once all outstanding queries are finished. yes, this blocks the main thread, but it's supposed to (it's for when the user enters the special panic password instead of the regular password, and all the app's data has to be erased). blocks submitted by users can't simply be dropped, it could cause corruption of their state if a query was submitted and then never executed (for example, since queries are expensive, some code sets a flag that a query is in progress, so that it's only performed once. if the query doesn't run, the flag is never reset)

also of note the use of a condition variable to broadcast changes in state (I don't remember what this is for, honestly). so to sum up in the same function we have examples of lockless and lock-free synchronization, a state machine, a promise/future, and a careful dance to preserve integrity that I would document if I had the formal knowledge (and the time) to do it, and if this wasn't a one man project. it was a lot of work to write, but it's been extremely dependable, and it's well designed enough that I can use it as if it was a stable third party API

hackbunny fucked around with this message at 10:35 on Mar 18, 2016

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope
turds, toilets, butts, boners.

i love programming chat on yospos

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer

FamDav posted:

so you were fine with mumps?

ya. at least mumps is weird and esoteric, which can be fun. being shackled to 20-year-old versions of vb or to a c# client that refuses to use any of the tools that actually make c# good sucks rear end.

gonadic io
Feb 16, 2011

>>=
terrible programmer status: wasted about 3 days on this loving problem

code:
	[StructLayout(LayoutKind.Sequential)]
	private struct BadOptionVec3
	{
		public bool isSome;
		public float x;
		public float y;
		public float z;
	}
works just fine

code:
	[StructLayout(LayoutKind.Sequential)]
	private struct Vec3
	{
		public float x, y, z;
	}

	[StructLayout(LayoutKind.Sequential)]
	private struct BadOptionVec3
	{
		public bool isSome;
		public Vec3 vec;
	}
if a ffi function returns the nested struct, then calliing that function crashes unity with a Null Pointer Exception from deep inside and never even calls the native function

i mean sure i have a work around but christ that was annoying

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

hackbunny posted:

yeah, core data objects on ios for example. if you hit a fault (some part of the object wasn't retrieved from the database and must be queried), you'll be blocked while the query runs on the managed object context's thread. I try not to use locks anywhere (the lock is evil! the lock shoots sleeps, and makes new deadlocks to poison the App with a plague of crashes, as it once was), but iirc I managed to hit a deadlock anyway. I had to write a proxy around NSFetchedResultsController (the class that's used to bind data queries to UI tables/lists), which converted all managed objects into POOCOs to move data to the main thread

since I actually helped create Core Data, I have to suggest that a proxy around NSFetchedResultsController is probably the wrong way to go about this

use a parent-child NSManagedObjectContext hierarchy, with the parent context configured for private queue concurrency and the child configured for main queue concurrency and use that for the FRC

then when you need to fetch, do an object-IDs-only fetch against the parent context, and when it's done make the FRC do its fetch

the first fetch will populate the coordinator's row cache, and only realizing the objects in the main queue context will actually happen for the FRC's fetch

Core Data is designed to work very well in multithreaded code, as long as you don't fight the framework's opinionated concurrency design (which everyone does at first because it's not designed like they might otherwise be used to)

Blinkz0rz
May 27, 2001

MY CONTEMPT FOR MY OWN EMPLOYEES IS ONLY MATCHED BY MY LOVE FOR TOM BRADY'S SWEATY MAGA BALLS

hackbunny posted:

speaking of teardown, holy poo poo how the hell did I manage to conceive of and write this:
C++ code:
-(void)finishCloseStore:(NS_RELEASES_ARGUMENT NSManagedObjectContext *)closingManagedObjectContext
               isSecure:(BOOL)isSecure
             onComplete:(void (^)(void))onComplete
{
    LogDebug(TAG_SECURESTORE,
            @"Broadcasting %@ notification {%@: %p, %@: %@}",
            SecureStoreWillCloseNotification,
            SecureStoreNotificationManagedObjectContextKey,
            (char *)(__bridge void *)closingManagedObjectContext, /* NOTE: printed as a pointer, DON'T call -description
                                                                     because it executes synchronously in the context's queue,
                                                                     causing all sorts of synchronization issues (like
                                                                     deadlocks). Also don't remove the cast to char *, because
                                                                     char * can't be mistakenly printed with %@, as object
                                                                     pointers, id or void * can */
            SecureStoreNotificationIsSecureKey,
            @(isSecure));

    [notificationCenter postNotificationName:SecureStoreWillCloseNotification
                                      object:self
                                    userInfo:@{SecureStoreNotificationManagedObjectContextKey: closingManagedObjectContext,
                                               SecureStoreNotificationIsSecureKey: @(isSecure)}];
    
    LogDebug(TAG_SECURESTORE, @"%@ notification broadcast", SecureStoreWillCloseNotification);

    LogInfo(TAG_SECURESTORE, @"Waiting for operations on the managed object context to complete");

    [closingManagedObjectContext performBlockAndWait:^{
        LogInfo(TAG_SECURESTORE, @"All operations on the managed object context completed");
    }];

    LogInfo(TAG_SECURESTORE, @"Releasing the last reference to the managed object context");
    closingManagedObjectContext = nil;

    [self usingAnyState:^{
        assert(state == SecureStoreClosing);

        if (state == SecureStoreClosing) {
            state = SecureStoreInitial;
            [self internalUpdateState];
            LogInfo(TAG_SECURESTORE, @"State reinitialized to %@: notifying the state change", SecureStoreStateDescription(state));
            [stateLock broadcast];
        }
        else {
            [self internalHandleBadState];
        }

        LogDebug(TAG_SECURESTORE, @"Scheduling broadcast of notification %@ on main thread", SecureStoreDidCloseNotification);

        dispatch_async(dispatch_get_main_queue(), ^{
            LogDebug(TAG_SECURESTORE, @"Broadcasting %@ notification", SecureStoreDidCloseNotification);
            [notificationCenter postNotificationName:SecureStoreDidCloseNotification object:self];
            LogDebug(TAG_SECURESTORE, @"%@ notification broadcast", SecureStoreDidCloseNotification);
        });

        LogInfo(TAG_SECURESTORE, @"Finished closing managed object context");

        if (onComplete) {
            onComplete();
        }
    }];
}
note this comment in particular:
C++ code:
/* NOTE: printed as a pointer, DON'T call -description
because it executes synchronously in the context's queue,
causing all sorts of synchronization issues (like
deadlocks). Also don't remove the cast to char *, because
char * can't be mistakenly printed with %@, as object
pointers, id or void * can */
note the two separate pitfalls addressed by it:
  • if you have a managed object context with its own dedicated thread (abstracted by the framework as a queue), almost all of its methods will execute synchronously in that thread, including surprising ones like -[NSObject description], which is used to print the object to a string when using the %@ format specifier
  • Objective C absolutely loves implicitly converting between id, void * and int, so I have to cast to something that can't be printed with %@ by mistake

also note this apparent no-op which is actually very important:
C++ code:
    [closingManagedObjectContext performBlockAndWait:^{
        LogInfo(TAG_SECURESTORE, @"All operations on the managed object context completed");
    }];
before this method is called, the managed object context (represents an instance of an open database) has been made inaccessible to clients of this class, so they can't start new queries on it. what if there are any outstanding queries? the code above executes an empty block synchronously on the context's queue, which (if clients of the class are well-behaved and don't submit new work from within the context's queue but only through "official channels") is guaranteed to execute once all outstanding queries are finished. yes, this blocks the main thread, but it's supposed to (it's for when the user enters the special panic password instead of the regular password, and all the app's data has to be erased). blocks submitted by users can't simply be dropped, it could cause corruption of their state if a query was submitted and then never executed (for example, since queries are expensive, some code sets a flag that a query is in progress, so that it's only performed once. if the query doesn't run, the flag is never reset)

also of note the use of a condition variable to broadcast changes in state (I don't remember what this is for, honestly). so to sum up in the same function we have examples of lockless and lock-free synchronization, a state machine, a promise/future, and a careful dance to preserve integrity that I would document if I had the formal knowledge (and the time) to do it, and if this wasn't a one man project. it was a lot of work to write, but it's been extremely dependable, and it's well designed enough that I can use it as if it was a stable third party API

i've never used the language but i hate how objective-c looks

Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

quote:

performBlockAndWait:^{

yeah i'd be :^{ too

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

Blinkz0rz posted:

i've never used the language but i hate how objective-c looks

everyone hates it at first, but you get used to it pretty quickly

at least now that there's array literals and subscript syntax. i never did get used to NSArray *array = [NSArray arrayWithObjects:foo, bar, baz, nil]; [array objectAtIndex:2];

dictionaries were even worse because you specified the values before the keys

kitten emergency
Jan 13, 2008

get meow this wack-ass crystal prison
ive been loving around in scala for a week and it seems ok. what's going to bite me in the rear end?

gonadic io
Feb 16, 2011

>>=

uncurable mlady posted:

ive been loving around in scala for a week and it seems ok. what's going to bite me in the rear end?

implicits

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

eschaton posted:

since I actually helped create Core Data, I have to suggest that a proxy around NSFetchedResultsController is probably the wrong way to go about this

it's too late and I'm not going back to change it at this point

eschaton posted:

use a parent-child NSManagedObjectContext hierarchy, with the parent context configured for private queue concurrency and the child configured for main queue concurrency and use that for the FRC

ok I didn't know about parent-child contexts. yeah this would have saved me a lot of trouble lol. like I said, it's too late to change it, it works and it works great so the proxy is staying. it has several desirable properties too, like completely uncoupling data from the database, so I can reliably close it (closing the database is something that core data isn't too hot about, as far as I can remember)

I really have to learn to read documentation rather than hammer at the code until it behaves, but it bores me so much, especially when my scenario isn't addressed directly and I have to extrapolate and experiment. it's especially disheartening when it's something with so many moving parts

Adbot
ADBOT LOVES YOU

Soricidus
Oct 21, 2010
freedom-hating statist shill

Plorkyeran posted:

everyone hates it at first, but you get used to it pretty quickly

at least now that there's array literals and subscript syntax. i never did get used to NSArray *array = [NSArray arrayWithObjects:foo, bar, baz, nil]; [array objectAtIndex:2];

dictionaries were even worse because you specified the values before the keys

I don't think I'd be very comfortable entrusting my data to an :nsa:rray

  • Locked thread