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
Plastic Snake
Mar 2, 2005
For Halloween or scaring people.

was gonna post this myself. another loving homerun from aphyr, i wish i was 10% as smart as him

also lmao at the comments on the ticket he filed with them https://jira.mongodb.org/browse/SERVER-17975

"working as expected, wontfix"

Adbot
ADBOT LOVES YOU

Sapozhnik
Jan 2, 2005

Nap Ghost
read jira project name as SEVER there

triple sulk
Sep 17, 2014



http://railsbird.tumblr.com/post/117076597115/existential-crisis-at-railsconf

lol rails dev(s) slowly realizing now that rails has been dying for a while

Notorious b.s.d.
Jan 25, 2003

by Reene

Plastic Snake posted:

was gonna post this myself. another loving homerun from aphyr, i wish i was 10% as smart as him

it's not that aphyr is smart. i mean, he is, but i don't think that's the key to the "call me maybe" work

it's that aphyr works hard. really, really hard. he's built a huge toolbox of stuff specifically to work on these problems, himself, via relentless grind. if you look at the github committers, 50,000 lines of code changes came from aphyr alone.

i'd really like to have even half the dedication that guy carries into his work

fritz
Jul 26, 2003

triple sulk posted:

http://railsbird.tumblr.com/post/117076597115/existential-crisis-at-railsconf

lol rails dev(s) slowly realizing now that rails has been dying for a while

waiter this omakase is stale

crazysim
May 23, 2004
I AM SOOOOO GAY

Notorious b.s.d. posted:

it's not that aphyr is smart. i mean, he is, but i don't think that's the key to the "call me maybe" work

it's that aphyr works hard. really, really hard. he's built a huge toolbox of stuff specifically to work on these problems, himself, via relentless grind. if you look at the github committers, 50,000 lines of code changes came from aphyr alone.

i'd really like to have even half the dedication that guy carries into his work

don't just count the lines of code. think of his posts too! and it's not filled with noise. that's quite a few "lines" in itself.

Workaday Wizard
Oct 23, 2009

by Pragmatica
his github picture sure is something

Plastic Snake
Mar 2, 2005
For Halloween or scaring people.

Notorious b.s.d. posted:

it's not that aphyr is smart. i mean, he is, but i don't think that's the key to the "call me maybe" work

it's that aphyr works hard. really, really hard. he's built a huge toolbox of stuff specifically to work on these problems, himself, via relentless grind. if you look at the github committers, 50,000 lines of code changes came from aphyr alone.

i'd really like to have even half the dedication that guy carries into his work

Yeah that's a great point. I also wish I had 10% of the drive he does. If I didn't already work 8hrs a day on code maybe I'd be more motivated to do it outside of work too.

Plastic Snake
Mar 2, 2005
For Halloween or scaring people.

crazysim posted:

don't just count the lines of code. think of his posts too! and it's not filled with noise. that's quite a few "lines" in itself.

Yeah he's got a real knack for technical writing. And endless patience judging by the comments on that jira ticket

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
endless patience is pretty much a prerequisite for good technical writing on complex topics

sarehu
Apr 20, 2007

(call/cc call/cc)
Singapore Prime Minister Lee Hsien Loong says the phrase, "learn you a Haskell for great good"

(a bit after 9:51:)

https://www.youtube.com/watch?v=49YeHvJ6yZg

sarehu fucked around with this message at 22:00 on Apr 22, 2015

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip
it's a shame BONUS stopped poasting

VikingofRock
Aug 24, 2008




Here's a cool article about the Option monad in Rust. It's nice seeing monads (and the clean code that they create) getting some play in imperative languages.

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

im a monad

Carthag Tuek
Oct 15, 2005

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



get the monad, scholar scholar chill tall

cowboy beepboop
Feb 24, 2001

VikingofRock posted:

Here's a cool article about the Option monad in Rust. It's nice seeing monads (and the clean code that they create) getting some play in imperative languages.

looking forward to writing some slow python and php stuff in rust once it hits 1 or maybe 1.1

Vanadium
Jan 8, 2005

VikingofRock posted:

Here's a cool article about the Option monad in Rust. It's nice seeing monads (and the clean code that they create) getting some play in imperative languages.

Please stop trying to make Rust look bad by associating it with that weirdo Haskell stuff :argh:

gonadic io
Feb 16, 2011

>>=
no monads here guv, just putting a value inside a container and then accessing it with callbacks. completely different and not scary.

Dicky B
Mar 23, 2004

a blog post about monad

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?

VikingofRock posted:

Here's a cool article about the Option monad in Rust. It's nice seeing monads (and the clean code that they create) getting some play in imperative languages.

as someone who knows nothing about rust, is the lambda here necessary?
code:
.and_then(|shortest| find_user_by_name(shortest))
could you just do
code:
.and_then(find_user_by_name)
?

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

HappyHippo posted:

as someone who knows nothing about rust, is the lambda here necessary?
code:
.and_then(|shortest| find_user_by_name(shortest))
could you just do
code:
.and_then(find_user_by_name)
?

i just tried it out and yes, your way works too

gonadic io
Feb 16, 2011

>>=

fart simpson posted:

i just tried it out and yes, your way works too

partial application can be hard to read if you're not used to it, they probably just wanted to keep it simpler

Max Facetime
Apr 18, 2009

christ this is so stupid

code:
fn get_user_with_shortest_name(names: Vec<&str>) -> Option<User> {
   get_shortest(names)
    .and_then(|shortest| find_user_by_name(shortest))
    .and_then(|user| json_to_user(user))
}
just make ?. the default dereferencing operator for nullable values and make foo(object) and object.foo() mean the same thing

now you can simply write the thing you ACTUALLY want to write:

code:
fn get_user_with_shortest_name(names: Vec<&str>) -> User {
   names.get_shortest().find_user_by_name().json_to_user()
}
and none of the Option crtap

Sapozhnik
Jan 2, 2005

Nap Ghost
i guess instead of having a NULL that's built into the language they created an Option<> type that isn't. About as good an idea as a non-built-in String type imo (i.e. not a good idea).

Still this looks just like java.util.Optional<>, except "and_then" is called flatMap().

Sapozhnik
Jan 2, 2005

Nap Ghost
Suspicious Dish mentioned that Red Hat has an employee whose surname is Null, and his name makes their HR systems gently caress up in entertaining ways

this amuses me greatly

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Mr Dog posted:

Still this looks just like java.util.Optional<>, except "and_then" is called flatMap().

is that bad?

Max Facetime
Apr 18, 2009

java.util.Optional is so stupid too

worst new addition of java 8

my homie dhall
Dec 9, 2010

honey, oh please, it's just a machine

Mr Dog posted:

i guess instead of having a NULL that's built into the language they created an Option<> type that isn't. About as good an idea as a non-built-in String type imo (i.e. not a good idea).

Optional typing is much better than NULL, hth

Sapozhnik
Jan 2, 2005

Nap Ghost
Optional typing is great but it should be built-in, just like strings should be built in, because both of those things are used constantly

java.util.Optional<> is a band-aid for a language that already has null references in it, Rust shouldn't need an identical copy of it if they're starting from scratch.

I use java.util.Optional in new code everywhere. It's clunky but it's a drat sight better than constant "hmm is this parameter nullable or not"

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

what would be different in Rust if it were built in? can you not rely on its presence? is it just the dereference sugar that you miss?

Sapozhnik
Jan 2, 2005

Nap Ghost
something like c# 4 (or is it 5?)'s conditional-dereference operator ?? or whatever would make the optional value gonad a lot less verbose.

if you're focusing on a page of code then you shouldn't have a bunch of extra chaff in the way of the meat of the operation.

leftist heap
Feb 28, 2013

Fun Shoe
hell, go one step further and bake some sort of generalization of the option type into the language. and then like, some special syntax for doing stuff i dunno i'm just an ideas guy.

CPColin
Sep 9, 2003

Big ol' smile.
The worst part of java.util.Optional is that Eclipse still can't apply @NonNull and @Nullable to it. Java 9 had better bring those annotations into the language specification.

giogadi
Oct 27, 2009

rrrrrrrrrrrt posted:

hell, go one step further and bake some sort of generalization of the option type into the language. and then like, some special syntax for doing stuff i dunno i'm just an ideas guy.

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

Max Facetime posted:

christ this is so stupid

code:
fn get_user_with_shortest_name(names: Vec<&str>) -> Option<User> {
   get_shortest(names)
    .and_then(|shortest| find_user_by_name(shortest))
    .and_then(|user| json_to_user(user))
}
just make ?. the default dereferencing operator for nullable values and make foo(object) and object.foo() mean the same thing

now you can simply write the thing you ACTUALLY want to write:

code:
fn get_user_with_shortest_name(names: Vec<&str>) -> User {
   names.get_shortest().find_user_by_name().json_to_user()
}
and none of the Option crtap

but what if get_shortest() returned null? then you need to build explicit null handling into every function? they could have written the option example like this
code:
fn get_user_with_shortest_name(names: Vec<&str>) -> Option<User> {
   get_shortest(names).and_then(find_user_by_name).and_then(json_to_user)
}

Arcsech
Aug 5, 2008

Mr Dog posted:

something like c# 4 (or is it 5?)'s conditional-dereference operator ?? or whatever would make the optional value gonad a lot less verbose.

if you're focusing on a page of code then you shouldn't have a bunch of extra chaff in the way of the meat of the operation.

we could always make and_then into an operator like... Hmm, how about >>=

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

Arcsech posted:

we could always make and_then into an operator like... Hmm, how about >>=

i like this idea, i wonder if there;s any languages out there that do it

Sapozhnik
Jan 2, 2005

Nap Ghost

Arcsech posted:

we could always make and_then into an operator like... Hmm, how about >>=

making it infix seems pretty cool

not sure about replacing a nice idiomatic "and_then" with gobbledygook symbols though

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

fart simpson posted:

but what if get_shortest() returned null? then you need to build explicit null handling into every function? they could have written the option example like this
code:
fn get_user_with_shortest_name(names: Vec<&str>) -> Option<User> {
   get_shortest(names).and_then(find_user_by_name).and_then(json_to_user)
}

it also only works if you have existing functions with the right signature and behaviour, and don't require any fields to be extracted or anything to be computed specific to this application.

still, I see the appeal of optional-friendly syntax. wonder why they didn't go there; too much "put it in the library"?

Adbot
ADBOT LOVES YOU

Bloody
Mar 3, 2013

this all looks bad and worse than doing it in c#

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