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
Bloody
Mar 3, 2013

every thread is the bad programmer thread

Adbot
ADBOT LOVES YOU

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

MALE SHOEGAZE posted:

if you have to do it, you can try and make refinements work for you:

http://yehudakatz.com/2010/11/30/ruby-2-0-refinements-in-practice/

but just a fair warning, they're basically useless because any class worth monkey patching is probably being constructed through some factory module or something, and the factory wont be aware of any of your refinements (unless you like, monkey patch the factory) so it's basically worthless imo

in this case the class that's getting monkey patched doesn't even need to be aware of the poo poo that's being patched into it, so best thing is to keep it all in the module that would actually use it and leave the original class alone

MALE SHOEGAZE posted:

the team here at redhat seems to like ruby a lot. I'm excited to see whether that's because ruby is OK when used responsibly, or whether that's because they haven't gone very far down the rabbit hole yet.

here's hoping it's the former. i like ruby as long as nothing i'm using abuses the hairer language features too much (qv our last few posts)

that's probably true of any language, though. especially dynamic ones

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

MALE SHOEGAZE posted:

ruby seems great at first. the hash syntax seems really nice, the higher order functional methods are nice and work well, yield syntax is legitimately pretty great.

then you realize that there are actually two hash syntaxes and { 'foo' => 'butts' } and { foo: 'butts' } seeming more or less the same, since in both cases you're defining a key foo that points to butts, they are actually two totally different keys. and then 5 monhts later you're calling hash.with_indifferent_access! on everything and getting really comfortable with the idea of your code being generally nondeterministic,

lol if ur hash keys are strings instead of symbols

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

MALE SHOEGAZE posted:

sure i can do that if i'm implementing a new thing I am free to do that, or just use like something besides restclient (i mean lol at not using faraday anyhow), but that doesn't fix all of the things using restclient where I know the people who implemented them had no idea the money patches existed but were using the patches anyhow. it means i have to go and track all of those people down and be like 'hey did you know all calls to restclient sometimes have a timeout of 100s and sometimes have a timeout of 0s, depending on whether or not this code has been sourced??? what should i Do??

sorry for your interfaces and bad coworkers

MononcQc
May 29, 2007

the real question isn't if operators should be surrounded by whitespace but whether the full unicode category for spaces [Zs], including the OGHAM SPACE MARK (  ) such that a-b is an identifier but a - b is actual subtraction

sarehu
Apr 20, 2007

(call/cc call/cc)
a - b is an identifier, a − b is subtraction.

sarehu
Apr 20, 2007

(call/cc call/cc)
Also a – b is a closed range, a — b is a half-open range.

triple sulk
Sep 17, 2014



foo: :butts is a loving horrid syntax and putting it in was an even more horrid idea

Soricidus
Oct 21, 2010
freedom-hating statist shill
the only good languages are the ones that allow the poop emoji in identifiers

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

Soricidus posted:

the only honest languages are the ones that allow the poop emoji in identifiers

comedyblissoption
Mar 15, 2006

MALE SHOEGAZE posted:

the team here at redhat seems to like ruby a lot. I'm excited to see whether that's because ruby is OK when used responsibly, or whether that's because they haven't gone very far down the rabbit hole yet.

well it's dynamically typed, so

karms
Jan 22, 2006

by Nyc_Tattoo
Yam Slacker

Soricidus posted:

the only good languages are the ones that allow the poop emoji in identifiers

php wins again

VikingofRock
Aug 24, 2008




Back on the topic of unary minus, my biggest Haskell pet peeve is the difference between map (+1) [1,2,3] and map (-1) [1,2,3].

sarehu
Apr 20, 2007

(call/cc call/cc)
There's a simple workaround: map ((0-) . (+ 1) . (0-)) [1,2,3]

Arcsech
Aug 5, 2008

sarehu posted:

There's a simple workaround: map ((0-) . (+ 1) . (0-)) [1,2,3]

this is incredibly ugly and its not at all obvious what it does. map (+ (-1)) [1,2,3] is much better

VikingofRock
Aug 24, 2008




I think the best workaround is map (subtract 1) [1,2,3] (no symbolic operators; shoutout to NBSD!). Still pretty annoying IMO.

Bloody
Mar 3, 2013

actually, the best workaround is to use a real language

Zaxxon
Feb 14, 2004

Wir Tanzen Mekanik

Bloody posted:

actually, the best workaround is to use a real language

actually the best workaround is realizing computers are for nerds.

Bloody
Mar 3, 2013

ah true

VikingofRock
Aug 24, 2008




Bloody posted:

actually, the best workaround is to use a real language

Out of curiosity, what would the equivalent idiomatic C# be?

Bloody
Mar 3, 2013

I have no idea, because that indecipherable pile of rear end appears useless

comedyblissoption
Mar 15, 2006

VikingofRock posted:

Out of curiosity, what would the equivalent idiomatic C# be?
code:
new List {1, 2, 3}
    .Select(x => x - 1);

VikingofRock
Aug 24, 2008




comedyblissoption posted:

code:
new List {1, 2, 3}
    .Select(x => x - 1);

Ah interesting, thanks. I've never really used C# and I was wondering how much functional stuff has creeped into it in recent years. What you posted seems fairly functional-esque to me.

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
imo functional stuff owns the hardest when injected into a non functional context

MeruFM
Jul 27, 2010
lodash?

comedyblissoption
Mar 15, 2006

VikingofRock posted:

Ah interesting, thanks. I've never really used C# and I was wondering how much functional stuff has creeped into it in recent years. What you posted seems fairly functional-esque to me.
IEnumerable is also lazily evaluated.

code:
//select returns an IEnumerable<int> which features lazy evaluation
//some basic type inference allows you to not explicitly specify the type here in a local scope
var someEnumerable = new List {1, 2, 3}
    .Select(x => x - 1);

//do some stuff. someList hasn't evaluated yet. someList doesn't evaluate until you need to iterate over it to produce some value(s)
...

var firstValue = someEnumerable.First(x => x > 0); //enumerate only until the first matching is found and then stop enumerating

Notorious b.s.d.
Jan 25, 2003

by Reene
the "correct" way to monkey patch poo poo in ruby is to use ruby 2.1 "refinements." it's like a monkey patch, scoped to files that include the refinement

the evaluation order and behavior are predictable, and it can't gently caress up code that isn't yours

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

Notorious b.s.d. posted:

the "correct" way to monkey patch poo poo in ruby is to use ruby 2.1 "refinements." it's like a monkey patch, scoped to files that include the refinement

the evaluation order and behavior are predictable, and it can't gently caress up code that isn't yours

yeah but they're useless for any class that you dont instantiate directly, eg. most classes.

Notorious b.s.d.
Jan 25, 2003

by Reene

MALE SHOEGAZE posted:

yeah but they're useless for any class that you dont instantiate directly, eg. most classes.

you shouldn't be altering classes you don't/can't instantiate

make a wrapper instead i guess

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

Notorious b.s.d. posted:

you shouldn't be altering classes you don't/can't instantiate
i agree with you but that doesn't stop people from doing it, and if they're going to do it, i'd like them to be doing it through refinements rather than breaking poo poo for everyone in the codebase

Shaggar
Apr 26, 2006

Bloody posted:

actually, the best workaround is to use a real language

Soricidus
Oct 21, 2010
freedom-hating statist shill

Notorious b.s.d. posted:

the "correct" way to monkey patch poo poo in ruby

this is like talking about the "correct" way to cook feces, or the "correct" way to commit bestiality

the problem isn't so much how you're doing the thing, it's that you're trying to do it at all

b0lt
Apr 29, 2005

Soricidus posted:

the "correct" way to commit bestiality

mrhands.mpg

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

b0lt posted:

mrhands.mpg

Notorious b.s.d.
Jan 25, 2003

by Reene

b0lt posted:

mrhands.mpg

there's a right way and a wrong way to accomplish any task

Sauer
Sep 13, 2005

Socialize Everything!
java lol

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

is that "suppress and approve" or "suppress and decline"

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

Wheany posted:

is that "suppress and approve" or "suppress and decline"

decline

i assume you were asking a legit question and not being sarcastic because oracle

Adbot
ADBOT LOVES YOU

Workaday Wizard
Oct 23, 2009

by Pragmatica
trying to write some R in a hurry without previous exposure is torture

is their a reason R is so weird?

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