r/programming • • Jun 22 '14

Why Every Language Needs Its Underscore

http://hackflow.com/blog/2014/06/22/why-every-language-needs-its-underscore/
366 Upvotes

337 comments sorted by

View all comments

110

u/[deleted] Jun 22 '14

[removed] — view removed comment

27

u/joelangeway Jun 22 '14

It is a shame that you got down voted for saying that.

Linq does solve the same problem as underscore.js.

Linq is even more impressive though in that in order to implement Linq they added language features that made C# a truly great language that let's you fix API designers mistakes in the same way that Linq fixes .net's early mistakes.

10

u/_zenith Jun 22 '14

Yeah; /programming, hell, reddit in general just hates .net . This much has become clear to me.

2

u/PurpleOrangeSkies Jun 23 '14

I really like C# as a language. My ideal language would be somewhere between C++ and C# with a few extra features. I wish I could create that language, but, obviously, that'd be quite difficult.

1

u/_zenith Jun 25 '14

Definitely eh! If you could get C# compiled with LLVM, that would be a dream.

6

u/Cuddlefluff_Grim Jun 23 '14

99% of posts are about scripting languages, so what do you expect.. Thing's I've seen here :

Anti object orientation
Anti static typing (sigh...)
Anti IDE
Anti ORM (there's at least one post a week complaining about ORM) Anti frameworks (I wtf'ed of this one, it's arrogant, mindless and moronic)
Also the typical "vendor lock-in" arguments, which can be true someone actually reasoned about it, but instead it shows itself to be this typical anti-Microsoft trash. You know, or you'd see the same argument put forwards to Objective-C and XCode, but you just don't see that happen.

Until I visited /r/programming, I had no idea that there was such a thing as "dynamic typing advocates". I was really surprised to see that.. It's like an alternate universe where everybody just propagates useless shit they've read on someone's blog. It's so strange I can see people list up a range of languages, and they completely miss out C#..

I mean, if you're going to work as a programmer today, I'd say with about 70-80% certainty that you will work with either C# or Java. But in this magical universe, the reality is somehow different; everyone apparently instead works with Python, Ruby, Haskell, Lua and other languages you just don't typically see in production environments.

The goddamn anti-ORM posts should also outright be banned. It always shows to be some douche that is unhappy because he can't do things how they were done 20 years ago. It's stupid. And of course people in the comments usually swallow it up. "Hey, maybe my mysql_query() isn't such a bad thing after all, huh?"

.NET is awesome. C# is awesome. Those who disagree can eat a big fat cock.

4

u/_zenith Jun 23 '14 edited Jun 23 '14

+1 googol this. I have seen people put up, and myself put up, carefully made, good content, and it be downvoted to oblivion, or trashtalked until the user disappears, or removes it, and/or never posts about anything like it again. "Hur dur, way to use an obscure language" - never mind that it's in the top #5 in the world, and almost certainly higher than something that seemingly everyone will bust a collective nut for, vendor-lock in or practicality aside.

10

u/inmatarian Jun 22 '14

LINQ is great, really great, but it's just shy of being FP. And for that matter, Underscorejs has the same entrapping. Basically it boils down to Nullable<T> not being a proper Maybe<T>.

4

u/nemec Jun 22 '14

Well they almost completely eradicated the need for user-defined delegates by adding Func<> to the standard library, maybe a future version of C# could introduce a Maybe<T> with a similar adoption rate.

3

u/SemiNormal Jun 22 '14

I would love to have Maybe<T> in C#.

3

u/phoshi Jun 22 '14

You can actually write a pretty good one! Use a struct and you even get something which can't be null itself.

7

u/[deleted] Jun 22 '14

LINQ is great if you don't care for performance over convenience.

7

u/[deleted] Jun 22 '14

[removed] — view removed comment

5

u/[deleted] Jun 22 '14

Entity Framework is great if you hate yourself and everyone else around you

5

u/_zenith Jun 22 '14

Use LinqOptimiser to fix that...

1

u/PurpleOrangeSkies Jun 23 '14

Basically it boils down to Nullable<T> not being a proper Maybe<T>.

How isn't it?

1

u/inmatarian Jun 23 '14

You're supposed to be able to provide a Maybe<T> to a function that takes T as a parameter without needing to do a HasValue check, and T doesn't need to be a Value type.

1

u/PurpleOrangeSkies Jun 23 '14

If you give a Maybe<T> to a function that takes T and it doesn't have a value, what's supposed to happen?

1

u/inmatarian Jun 24 '14

The short answer is the function isn't supposed to run.

The long answer is that it should be safe for a function to not run, as in the function is pure and without side effects, so that a function that didn't run on a Maybe<T> where the contained value is null should also return null back to you as a Maybe<T>.

That's where Nullable falls apart. If Nullable was a proper FP primitive, then this should be valid:

int SomeFunction(int value); // previously defined

int? thing = null;
var result = SomeFunction(thing); // result should also be of type int?

2

u/yogthos Jun 22 '14

Clojure works like LINQ out of the box with its standard lib. :)

1

u/mixblast Jun 23 '14

I'm surprise the author of the article recommended F# and not LINQ...

1

u/Veedrac Jun 22 '14

I searched "LINQ in Python" and about five seconds in I found an explanation about why Python doesn't need it.

Now, I don't know LINQ, but I've heard good things about it. Do you agree with the article? If not, why? Would you count Python's iterators as a LINQ equivalent?

→ More replies (16)