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
Cybernetic Vermin
Apr 18, 2005

cinci zoo sniper posted:

what’s wrong with some stuff just producing generators, rather than fully formed iterables?

core functionality should either produce concrete things or have a very pervasive concept of laziness

Adbot
ADBOT LOVES YOU

Toady
Jan 12, 2009

zed's just a troll who says over-the-top things and then claims they were jokes people didn't get

cinci zoo sniper
Mar 15, 2013




Cybernetic Vermin posted:

core functionality should either produce concrete things or have a very pervasive concept of laziness

while i would appreciate the second half of what you said in simple english, i don't see how an "out-of-memory" iterable (or a non-recursive call capable coroutine in moonspeak, i believe - or whatever c# iterators are) is not a rather concrete thing

cinci zoo sniper
Mar 15, 2013




ryde posted:

Anything write-up of that? Asking... for a friend.

sadly i think it was some c-goons itt sharing the hottest takes

prisoner of waffles
May 8, 2007

Ah! well a-day! what evil looks
Had I from old and young!
Instead of the cross, the fishmech
About my neck was hung.
dunno if this is a canonical place to pick up the conversation but, https://www.google.com/search?q=site%3Aforums.somethingawful.com+%22learn+c+the+hard+way%22 suggests

https://forums.somethingawful.com/showthread.php?threadid=3481275&userid=180172&perpage=40&pagenumber=30

e: huh, for some reason it found one poaster's poasts? weeeird
e^2: it's not obvious how to go from a poast on a "just this person's post" page back to that poast in a chronological listing of poasts
e^3: here we go https://forums.somethingawful.com/showthread.php?threadid=3481275&pagenumber=1369&perpage=40#post478672891

prisoner of waffles fucked around with this message at 18:37 on Oct 24, 2018

Soricidus
Oct 21, 2010
freedom-hating statist shill

Cybernetic Vermin posted:

inserting iterators in random places (in the output of 'map' i find especially egregious)

you’re expected to use a list comprehension if you want a list, or a set comprehension if you want a set.

I agree it wasn’t necessary to change map but it’s not necessary to use it either

FamDav
Mar 29, 2008

MononcQc posted:

I recall a team looking at docker early on and it had such comically bad security that it couldn’t reasonably be used for anything that was multitenant. This apparently did not stop some people from building their own platforms with it. By the time docker was safer to use it was already late, and I think Heroku had compromised on offering ‘dockerized builds’ where you could use docker but only if you had used a specific set of base images or something. Not too sure if I remember this right.

we’re just getting better at putting a better VM boundary around your collection of containers and a minimal OS. docker is still awful

quote:

At some point competition became google itself who could sink years of dev time on k8s and you have to turn around to use that rather than competing by writing your own, but you hardly see that coming when you’re right in it. You also have to recall the uncertainty around the time the docker community forked once or twice and asking how long you are signing up to maintain this

k8s is just absolutely unnecessary for herokus bread and butter. they should’ve had fargate as a service much earlier.

quote:

As for functions, I think this was the kind of project that had hit the right mix of very cross-team project where no one could herd the cats, and tech debt in the stack that would prevent enough flexibility to quickly make this work without major modifications to the whole platform.

I wasn’t really on any of the involved teams for any of this, for what it’s worth.

functions is hard logistically because the time constraints require you have warm pools of VMs/bare metal instances provisioned to support your peak aggregate concurrency. unless you as a company already have a pool abstraction in place that allows you to drive cross-product efficiency, you’re throwing $$$ out the window on faas as a platform driver.

TheFluff
Dec 13, 2006

FRIENDS, LISTEN TO ME
I AM A SEAGULL
OF WEALTH AND TASTE
i don't think i've ever used map() in python, list comprehensions always seemed more natural

in js on the other hand with lodash-fp and its auto-currying i've written a bunch of pretty terrible stuff along the lines of

code:
let frobnicate = _.flow(
  _.filter(somePredicate),
  _.uniqBy(_.get('id')),
  _.map(_.pick(['id', 'foo', 'bar'])),
);
but that's a functional style that really doesn't feel natural in python even if you can do it that way if you insist

JawnV6
Jul 4, 2004

So hot ...

prisoner of waffles posted:

e^2: it's not obvious how to go from a poast on a "just this person's post" page back to that poast in a chronological listing of poasts

the question mark gets you there, the upside down one takes you back

Tavistock
Oct 30, 2010



I do like 60% clojure 40% python and I still think map is almost never the right way to do it in python

cinci zoo sniper
Mar 15, 2013




joining the seldom-map crowd for python, i do genuinely not remember when was the last time i used map and the gist of my work is "harry potter and financial data collections"

the talent deficit
Dec 20, 2003

self-deprecation is a very british trait, and problems can arise when the british attempt to do so with a foreign culture





FamDav posted:

functions is hard logistically because the time constraints require you have warm pools of VMs/bare metal instances provisioned to support your peak aggregate concurrency. unless you as a company already have a pool abstraction in place that allows you to drive cross-product efficiency, you’re throwing $$$ out the window on faas as a platform driver.

the capacity logistics is supposed to be heroku's core competency tho. it's basically the same problem as shared hosted services, just at a finer granularity

MononcQc
May 29, 2007

most problems with functions iirc had more to do with the fact that the entire platform was built over lightweight containers each having their own small webserver.

You could have written functions for it, but that implied changes at every level: pricing, APIs, CLI, routing, runtime, build chain (heroku builds customer apps), logging, monitoring, etc. That's what I meant by a project that is difficult to drive. It requires the involvement of the whole company to create a new platform on the side while maintaining the old one. In fact they were already building another platform (for bigger customers, which ended up being private spaces) at that time, so it would have been a third one.

Malcolm XML
Aug 8, 2009

I always knew it would end like this.
https://www.cs.virginia.edu/~cs415/reading/bacon-garbage.pdf

redleader
Aug 18, 2005

Engage according to operational parameters

cinci zoo sniper posted:

joining the seldom-map crowd for python, i do genuinely not remember when was the last time i used map and the gist of my work is "harry potter and financial data collections"

map owns and i use it all the time (it's named Select in c#)

cinci zoo sniper
Mar 15, 2013




redleader posted:

map owns and i use it all the time (it's named Select in c#)

im not saying it’s bad, it’s just not necessary in my work to use map specifically

echinopsis
Apr 13, 2004

by Fluffdaddy
is map when ya wanna expand a range from this to that without wanting to think

echinopsis
Apr 13, 2004

by Fluffdaddy
i used that poo poo in ue4 blueprints all the time


ue4 blueprints are the best language

brand engager
Mar 23, 2011

brand engager posted:

realistically whats gonna happen is I spend all tomorrow trying to get myself to focus on it while my brain will want to do anything but that. And then I'll end up writing the whole thing at 3am the morning of

[still working on it at 4:30 am voice] it do be like that

AggressivelyStupid
Jan 9, 2012

echinopsis posted:

is map when ya wanna expand a range from this to that without wanting to think

maps, in this instance, take an array and a function, then iterate through that array applying the function to each item, and returning the results in an array

Sweeper
Nov 29, 2007
The Joe Buck of Posting
Dinosaur Gum

AggressivelyStupid posted:

maps, in this instance, take an array and a function, then iterate through that array applying the function to each item, and returning the results in an array

it returns an iterator in py3, but I’m not sure why you’d ever use it over a comprehension

AggressivelyStupid
Jan 9, 2012

whoops, yeah I've never used it in python over list comprehension because list comprehension is so nice

luchadornado
Oct 7, 2004

A boombox is not a toy!

map is lazy and list comprehensions (in python) are not, so theres one good reason

also because "not pythonic" is dumb - i use map/filter/fold/etc. all the time in other languages and its irritating that python had to be a snowflake

Sweeper
Nov 29, 2007
The Joe Buck of Posting
Dinosaur Gum

Helicity posted:

map is lazy and list comprehensions (in python) are not, so theres one good reason

also because "not pythonic" is dumb - i use map/filter/fold/etc. all the time in other languages and its irritating that python had to be a snowflake

it used to not be lazy, which is what the poster was complaining about iirc and the whole point of this dumb conversation. so now python3 has the ability to be not lazy (list comprehension) and lazy (map, filter, etc)

luchadornado
Oct 7, 2004

A boombox is not a toy!

Sweeper posted:

it used to not be lazy, which is what the poster was complaining about iirc and the whole point of this dumb conversation

gently caress, van rossumed again

Phobeste
Apr 9, 2006

never, like, count out Touchdown Tom, man
you can use a tuple comprehension, those are lazy. next you're going to ask "why are tuple comprehensions lazy" or say "that's insanely loving stupid that tuple and list comprehensions (really all other comprehensions) behave that differently" and for that i have no answer

mystes
May 31, 2006

Phobeste posted:

you can use a tuple comprehension, those are lazy. next you're going to ask "why are tuple comprehensions lazy" or say "that's insanely loving stupid that tuple and list comprehensions (really all other comprehensions) behave that differently" and for that i have no answer
Do you mean "generator expression"?

Phobeste
Apr 9, 2006

never, like, count out Touchdown Tom, man

mystes posted:

Do you mean "generator expression"?

probably i guess. that's not what it looks like though

Pie Colony
Dec 8, 2006
I AM SUCH A FUCKUP THAT I CAN'T EVEN POST IN AN E/N THREAD I STARTED
it doesn't look like a tuple though. there are no commas and you don't even need the parentheses if it's the single argument to a function.

generator expressions and list comprehensions are superior to map and filter, both in readability and performance (at least in cpython), but they came out later which is why you have both

mystes
May 31, 2006

I also thought the term "comprehension" was deprecated in python but maybe not.

mystes fucked around with this message at 14:06 on Oct 25, 2018

cinci zoo sniper
Mar 15, 2013




Phobeste posted:

probably i guess. that's not what it looks like though

yes it’s generator exprsssion, there are no tuple comprehensions

cinci zoo sniper
Mar 15, 2013




mystes posted:

I also thought the term "comprehension" was deprecated in python but maybe not.

:wow:

cinci zoo sniper
Mar 15, 2013




cinci zoo sniper posted:

yes it’s generator exprsssion, there are no tuple comprehensions

unless you count tuple() generator expressions or unpacking tuple comprehension (which is tuple(list(generator expression)) syntax sugar)

Coffee Jones
Jul 4, 2004

16 bit? Back when we was kids we only got a single bit on Christmas, as a treat
And we had to share it!

TheFluff posted:

i don't think i've ever used map() in python, list comprehensions always seemed more natural

in js on the other hand with lodash-fp and its auto-currying i've written a bunch of pretty terrible stuff along the lines of

code:
let frobnicate = _.flow(
  _.filter(somePredicate),
  _.uniqBy(_.get('id')),
  _.map(_.pick(['id', 'foo', 'bar'])),
);
but that's a functional style that really doesn't feel natural in python even if you can do it that way if you insist

this week I’m working on a codebase that’s about 200k of this stuff written in a similar FP library and the writing/debugging of this is Pain. No compiler, because JavaScript, and anything that goes wrong I.e. where a function expects a function instead of an array ... it’s a runtime error with a stacktrace that comes out of the library itself.

luchadornado
Oct 7, 2004

A boombox is not a toy!

add typescript to get some compile time guarantees. its opt in so you only need to add types for the low hanging fruit

Xarn
Jun 26, 2015
I was already beaten to it, but Python does provide lazy comprehensions (expresions?) via (x for x in foo).

Also being able to omit the outer parens in something like sum(f(x) for x in foo) is p. nice.

cinci zoo sniper
Mar 15, 2013




Xarn posted:

I was already beaten to it, but Python does provide lazy comprehensions (expresions?) via (x for x in foo).

Also being able to omit the outer parens in something like sum(f(x) for x in foo) is p. nice.

yeah (x for x in too) is formally called a generator expression

Captain Foo
May 11, 2004

we vibin'
we slidin'
we breathin'
we dyin'

cinci zoo sniper posted:

yeah (x for x in too) is formally called a generator expression

(poo poo for post in thread)

TheFluff
Dec 13, 2006

FRIENDS, LISTEN TO ME
I AM A SEAGULL
OF WEALTH AND TASTE

Coffee Jones posted:

this week I’m working on a codebase that’s about 200k of this stuff written in a similar FP library and the writing/debugging of this is Pain. No compiler, because JavaScript, and anything that goes wrong I.e. where a function expects a function instead of an array ... it’s a runtime error with a stacktrace that comes out of the library itself.

pain? i'll show you pain.

code:
let aTerribleIdea = _.curry((foo, bar, callback) => {
  // do something async with foo and bar
  return callback(null, result);
});
at first glance this is p cool because now you can pass around partially applied async functions almost as if they were promises, and it works pretty neatly with the tooling in the async lib (which is legitimately extremely cool & good). i once worked on a project where pretty much all flow control was done with this pattern. it was actually quite legible and nowhere near the usual callback hell at all because of this pattern and the async lib (and especially the incredibly nifty async.auto).

in truth, though, this is actually hell on earth. if you happen to call a function like this with too few arguments somewhere, all of your business logic just stops for no apparent reason, with the excution seemingly disappearing into the soulless void. you get no stack trace, no errors, not even "undefined is not a function" - the application just seems to stop, and you have no idea where it stopped or why. this happens because a curried function called with too few arguments returns a new (partially applied) function that takes the remaining arguments, but the actual curried function doesn't get called until all arguments have been provided. nobody ever checks the return value of a js async function because of course they don't, it doesn't return anything useful - you get the return value via the callback, duh. but the callback never gets called, and you have no idea why.

Adbot
ADBOT LOVES YOU

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

Captain Foo posted:

(poo poo for post in thread)

a bijection on thread

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