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
carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

Soricidus posted:

not all of it, no

so by default it will allow some reflective access of certain parts of the standard library now. that's all. and it dumps pages of warning messages to stderr telling users that the program is broken.

they have still pressed on with modularisation, and some modules are no longer available by default that used to be, so learn to love those command line flags!

and they have still (at least within javafx) happily made sweeping changes to things everyone was using even though they were technically private. some of these changes have been to make those things public -- but since this involved changing their names or packages, there is basically literally no way to have a non-trivial javafx program that runs on java 8 and java 9 without maintaining two versions of the code

sounds like somebody's got a port to swing to do :unsmigghh:

Adbot
ADBOT LOVES YOU

brap
Aug 23, 2004

Grimey Drawer
Great job, Luigi Thirty.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

Soricidus posted:

not all of it, no

so by default it will allow some reflective access of certain parts of the standard library now. that's all. and it dumps pages of warning messages to stderr telling users that the program is broken.

they have still pressed on with modularisation, and some modules are no longer available by default that used to be, so learn to love those command line flags!

and they have still (at least within javafx) happily made sweeping changes to things everyone was using even though they were technically private. some of these changes have been to make those things public -- but since this involved changing their names or packages, there is basically literally no way to have a non-trivial javafx program that runs on java 8 and java 9 without maintaining two versions of the code

if the problem is you're doing reflective access to technically-private things that got moved around in java 9... can't you just fall back to looking up the java 8 way if your code doesn't find the java 9 version?

put that logic inside a convenience wrapper and that sounds (at least to me) like it makes everything work without maintaining two versions of the code

Soricidus
Oct 21, 2010
freedom-hating statist shill

Jabor posted:

if the problem is you're doing reflective access to technically-private things that got moved around in java 9... can't you just fall back to looking up the java 8 way if your code doesn't find the java 9 version?

the one I ran into is code that subclasses a built in skin, which is now in a different package. so I guess I could have two versions of that and try to load one and then load the other if it crashes

but working round that I then run into a third party library that doesn't work in java 9 because it used the other dumb javafx thing, which is that there were a whole load of public methods that the javafx devs didn't want other people to use so they put "impl" in their names instead of using any form of encapsulation. surprise! everyone used them anyway.

starting to think that rewriting the ui in swing might be less work

mystes
May 31, 2006

JavaFX seemed so nice, too. After this, nobody will use it though. (And probably everyone will just switch to Node.js, lol. Thanks Oracle.)

Luckily there's a lot of competition from Microsoft, which is doing a great job of providing a consistent and reliable development experience with the whole dotnet core thing.

Illusive Fuck Man
Jul 5, 2004
RIP John McCain feel better xoxo 💋 ðŸ™Â
Taco Defender

VikingofRock posted:

So I have some C++ code that I'd like some feedback on, if someone has time to look at it. It's a class which handles concurrent memoization of the results of a function for various inputs, so that the function is only called once for each set of arguments. Here's what I've got:

C++ code:
#include <map>
#include <mutex>
#include <tuple>

template <typename Value, typename F, typename ...Args>
class memo {
private:
    F calculate_;
    std::map<std::tuple<Args...>, Value> results_;
    std::mutex results_mutex_;
    // ^ lock before accessing results_
    std::map<std::tuple<Args...>, std::once_flag> calculation_flags_;
    std::mutex calc_flags_mutex_;
    // ^ lock before accessing calculation_flags_
public:
    /* Construct a memo, which stores a function `calculate` which takes
     * arguments of types `Args...` and which returns an object of type `Value`.
     * This memo will then store the results of `calculate` for each set of
     * arguments passed to `get()`, so that `calculate` is only called once
     * for each set of arguments.
     */
    explicit memo(F calculate): calculate_(calculate) {}

    /* Get the result for the memoized function given the arguments `args`. The
     * memoized function is called exactly once. Multiple concurrent calls to
     * `get` are thread safe, with all calls hanging until the stored calculation
     */
    Value get(Args... args) {
        auto key = std::make_tuple(args...);
        {
            std::lock_guard<std::mutex> calc_flags_lock(calc_flags_mutex_);
            // Add a once flag for `args` if it doesn't already exist
            // Note: map.emplace() will not overwrite a duplicate key
            calculation_flags_.emplace(
                std::piecewise_construct,
                std::forward_as_tuple(key),
                std::forward_as_tuple()
                // ^ gotta jump through hoops to avoid copying a once_flag
            );
        }
        std::call_once(
            calculation_flags_.at(key),
            [this, &key, &args...] () {
                Value result = calculate_(args...);
                std::lock_guard<std::mutex> results_lock_(results_mutex_);
                results_.emplace(key, result);
            }
        );
        std::lock_guard<std::mutex> results_lock_(results_mutex_);
        return results_.at(key);
    }
};
I suspect this sort of thing has already been implemented somewhere, but it was still a valuable exercise even if I did reinvent the wheel. I'd be curious to get some feedback on it. One thing I thought about was not having the argument types be part of the memo template parameter list, but I think that's asking for trouble with functions with default arguments. Also I'm only like 30% certain I got the concurrency right because concurrency is hard.

looks about right to me. phoneposting, but I think you can replace the verbose jumping through hoops bit with just
calculation_flags_[key];

that's just personal preference though

Workaday Wizard
Oct 23, 2009

by Pragmatica
what's a good hosting provider for personal poo poo?

Arcteryx Anarchist
Sep 15, 2007

Fun Shoe

Shinku ABOOKEN posted:

what's a good hosting provider for personal poo poo?

A qualified therapist

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

Shinku ABOOKEN posted:

what's a good hosting provider for personal poo poo?

i use digital ocean. it's like 10 bucks per month for a needs suiting vps.

never let me down and no bullshit

FamDav
Mar 29, 2008
use lightsail OP

crazypenguin
Mar 9, 2005
nothing witty here, move along
google cloud gives you an f1-micro for free forever, depending on what kind of hosting stuff you want

still have to pay for bandwidth, but that's probably pennies for personal stuff

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Luigi Thirty posted:

the sector nibblizer math was screwed up and offset $100 and nothing else was being miscalculated, causing the read’s checksum to fail

I fixed that and now it boots DOS and runs programs from disk just fine

now i need to hook up writing out to the disk image instead of pretending all disks are write protected

make it write to a diff file so your disks are automatically versioned :science:

Arcteryx Anarchist
Sep 15, 2007

Fun Shoe
if its just static content then nearlyfreespeech is pretty cheap and they have some other stuff too

https://www.nearlyfreespeech.net

hifi
Jul 25, 2012

github pages does something for free

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
there really needs to be a wikipedia that presents technical concepts in an accessible manner.

cinci zoo sniper
Mar 15, 2013




MALE SHOEGAZE posted:

there really needs to be a wikipedia that presents technical concepts in an accessible manner.

yeah whenever i open some it concept page my eyes glaze over and i hastily retrat to drawing consensus from bunch of russian forums posts because these idiots abstract the language away too

netcat
Apr 29, 2008

Luigi Thirty posted:

holy poo poo i got my apple 2 emulator to boot a DOS 3.3 master disk i am a goddamn wizard



"i kinda feel like god" --cereal killer, the hackers movie

that's really cool. I made a NES game for the SA summer game jam and of course the logical follow up to that is to write an emulator, but I kinda lost interest after doing the CPU

aardvaard
Mar 4, 2013

you belong in the bog of eternal stench

Shinku ABOOKEN posted:

what's a good hosting provider for personal poo poo?

scaleway is decent

Arcteryx Anarchist
Sep 15, 2007

Fun Shoe

MALE SHOEGAZE posted:

there really needs to be a wikipedia that presents technical concepts in an accessible manner.

What you don't want a jumbled explanation with whatever mathematical notation they might have learned interspersed throughout?

Arcteryx Anarchist
Sep 15, 2007

Fun Shoe
Ala I don't really understand this so im just going to blind you with math

Fergus Mac Roich
Nov 5, 2008

Soiled Meat
I'll get the monad article going on simple english wikipedia

VikingofRock
Aug 24, 2008




Fergus Mac Roich posted:

I'll get the monad article going on simple english wikipedia

Shouldn't be too difficult, "burrito" is definitely among my most commonly used English words.

Sapozhnik
Jan 2, 2005

Nap Ghost
in a fit of frustration, i have decided to propose a "lang-shitlang continuum", which i shall illustrate with the following examples:

langs: java, python, dare i say go. langs have established conventions and anybody can join a project written in a lang and contribute by adhering to them.
shitlangs: c++, javascript. a shitlang is a dialect construction kit. every fucker has to invent their own dialect before they can get any work done.

that's not to say go is a good lang, but at least it's not a shitlang. it at least has that going for it. not all langs are good but all shitlangs are poo poo.

akadajet
Sep 14, 2003

Shinku ABOOKEN posted:

what's a good hosting provider for personal poo poo?

aws s3

Mao Zedong Thot
Oct 16, 2008


Sapozhnik posted:

in a fit of frustration, i have decided to propose a "lang-shitlang continuum", which i shall illustrate with the following examples:

langs: java, python, dare i say go. langs have established conventions and anybody can join a project written in a lang and contribute by adhering to them.
shitlangs: c++, javascript. a shitlang is a dialect construction kit. every fucker has to invent their own dialect before they can get any work done.

that's not to say go is a good lang, but at least it's not a shitlang. it at least has that going for it. not all langs are good but all shitlangs are poo poo.

python is a *solid* shitlang, and go is actually good. c++ probably belongs in the middle, not that I would want to ever, ever write any of it.

Mao Zedong Thot
Oct 16, 2008


python is almost as fucky as javascript, but the syntatic white space thing i think makes people forget how loving looseygoosey it plays with everything else

NihilCredo
Jun 6, 2011

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

VikingofRock posted:

Shouldn't be too difficult, "burrito" is definitely among my most commonly used English words.

this is a valid excuse to repost:

http://emorehouse.web.wesleyan.edu/silliness/burrito_monads.pdf posted:

The advent of fast-casual Mexican-style dining establishments, such as Chipotle and Qdoba, has greatly improved the productivity of research mathematicians and theoretical computer scientists in recent years. Still, many experience confusion upon encountering burritos for the first time.

Numerous burrito tutorials (of varying quality) are to be found on the Internet. Some describe a burrito as the image of a crêpe under the action of the new-world functor. But such characterizations merely serve to reindex the confusion contravariantly. Others insist that the only way to really understand burritos is to eat many different kinds of burrito, until the common underlying concept becomes apparent.

It has been recently remarked by Yorgey [9] that a burrito can be regarded as an instance of a universally-understood concept, namely, that of monad. It is this characterization that we intend to explicate here. To wit, a burrito is just a strong monad in the symmetric monoidal category of food, what’s the problem?

VikingofRock
Aug 24, 2008




shitlangs are freedom

cinci zoo sniper
Mar 15, 2013




im getting really tired of monad meme

MononcQc
May 29, 2007

lancemantis posted:

if its just static content then nearlyfreespeech is pretty cheap and they have some other stuff too

https://www.nearlyfreespeech.net

Been using them for most of my websites on the side. If you barely get visits it's very cheap. As your usage (see: visits and bandwidth usage) grows, it gets a bit more expensive, but so far I've stuck with them anyway.

Arcsech
Aug 5, 2008

VOTE YES ON 69 posted:

python is a *solid* shitlang, and go is actually bad.

ftfy

hobbesmaster
Jan 28, 2008

go feels like they got bored halfway through making the language or something

at least it did

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

VikingofRock posted:

So I have some C++ code that I'd like some feedback on, if someone has time to look at it. It's a class which handles concurrent memoization of the results of a function for various inputs, so that the function is only called once for each set of arguments. Here's what I've got:

your concurrency is correct but really you might as well use a single lock and map. look up the map entry optimistically and if you don't find one call the function and do an insertion. if you actually care about parallelism between keys just store a std::optional and drop the lock temporarily, you'll need to add a condition variable though and there's some risk of priority inversion. but you're literally acquiring up to three locks here per lookup, two in the steady state

aardvaard
Mar 4, 2013

you belong in the bog of eternal stench

cinci zoo sniper posted:

im getting really tired of monad meme

it's been years since i first heard of a monad, and i've read many people try to explain it, and i still do not understand what a monad is

CRIP EATIN BREAD
Jun 24, 2002

Hey stop worrying bout my acting bitch, and worry about your WACK ass music. In the mean time... Eat a hot bowl of Dicks! Ice T



Soiled Meat

CommunistPancake posted:

it's been years since i first heard of a monad, and i've read many people try to explain it, and i still do not understand what a monad is

A monad is just a monoid in the category of endofunctors.

VikingofRock
Aug 24, 2008




Illusive gently caress Man posted:

looks about right to me. phoneposting, but I think you can replace the verbose jumping through hoops bit with just
calculation_flags_[key];

that's just personal preference though

rjmccall posted:

your concurrency is correct but really you might as well use a single lock and map. look up the map entry optimistically and if you don't find one call the function and do an insertion. if you actually care about parallelism between keys just store a std::optional and drop the lock temporarily, you'll need to add a condition variable though and there's some risk of priority inversion. but you're literally acquiring up to three locks here per lookup, two in the steady state

Thank you both very much for the feedback. Yeah, I thought my design was a little lock heavy, but my thinking was that each lock is only going to be held for the length of a lookup so it's not too bad. I think rjmccall your design with the std::optional is better though (although I am stuck on C++14 so I'll be using boost::optional). I'll give that a shot tomorrow.

VikingofRock
Aug 24, 2008




CommunistPancake posted:

it's been years since i first heard of a monad, and i've read many people try to explain it, and i still do not understand what a monad is

Think about types that depend on other types. Like a List<T> or a Nullable<T> or a Tuple<int, T>. Let's call that first type M, so we have an M<T>.

Okay, now picture we have a way of turning a T into an M<T>. So if we have a T called t, we can turn our T into a List<T> by just making a List containing only t. So our t becomes [t]. Similarly, we can turn a T into a Nullable<T> by just saying "this T is nullable, but isn't actually null at the moment", and we can turn a T into a Tuple<int, T> by just making it (0, T).

Okay, so now imagine you have a way of taking an M<T>, and a function which takes a T and returns an M<V>, and you can combine that M<T> and that function to get an M<V>. So for a List<T>, if we have a function f which takes a T and gives us a List<V>, we can make a new List<V> by applying that function to every element in the first list and concatenating the resulting Lists. For a Nullable<T>, we take our function (which takes a T and gives a Nullable<V>), and apply it to the T from the original Nullable<T> to get a Nullable<V>. If the original Nullable<T> was null, we keep it null, except now it's a null V instead of a null T. For a Tuple<int, T>, we could do something like take our function (which takes a T and gives a Tuple<int, V>), and apply it to the T from the original tuple to get a Tuple<int, V>. We could then (say) add the ints from the original Tuple and the new Tuple to get a Tuple<int, V>, or we could just keep the old int or the new int and ignore the other one.

Okay, so if you can do those things to your type, and those two things behave pretty intuitively together, you have a monad. In this case, Lists, Nullables, and Tuple<int, ...>s are monads.

The real question is why are monads interesting, and the answer to that is that they can be used to model various things like non-determinism, state, and stuff like that. But that's for another post.

redleader
Aug 18, 2005

Engage according to operational parameters
do people actually make their own monads? because it seems like most/all of the useful ones (lists, maybe, async, state, whatever idk) have been written already, and any new useful ones would be far beyond the abilities (or imagination) of anyone reading a 'what is a burrito' tutorial

Asymmetrikon
Oct 30, 2009

I believe you're a big dork!

redleader posted:

do people actually make their own monads? because it seems like most/all of the useful ones (lists, maybe, async, state, whatever idk) have been written already, and any new useful ones would be far beyond the abilities (or imagination) of anyone reading a 'what is a burrito' tutorial

you don't "make a monad" by starting with the concept of monads and then aiming at a specific goal, you write code that solves a problem and realize after the fact that it has monadic characteristics. lots of code people write probably is "monadic" in some sense but they don't realize it because they didn't need to try to generalize it.

Adbot
ADBOT LOVES YOU

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
Conceptually, understanding what makes something monadic and how you'd create one is really useful for understanding.

But in practice yeah, most things you typically come across that make useful monads are fairly common, and someone else has already done the implementation work for you. Either that or, even though it's monadic, you don't actually need it to be a monad for your specific use case.

  • Locked thread