>working on asp.net backend >homosexuals littering everything with linq >even places where it makes no sense >b.. b- b-but it's the future
I hate globohomosexual so fricking much
var items = new List<Vendor>();
foreach (var v in vendors)
if (v.CompanyName.Contains("Toy"))
items.Add(v);
items.Sort((a,b)=>string.CompareOrdinal(a,b));
simple and elegant, and more importantly nothing is hidden from user.
imperative programming is just cleaner and superior, admit it
>Nothing about this is more cleaner or superior
with just 5 lines of code you can replace the whole LINQ monstrosity https://github.com/Microsoft/referencesource/blob/master/System.Core/System/Linq/Enumerable.cs
If you want less bloat you can just run a raw SQL query, the approach in
var items = new List<Vendor>();
foreach (var v in vendors)
if (v.CompanyName.Contains("Toy"))
items.Add(v);
items.Sort((a,b)=>string.CompareOrdinal(a,b));
simple and elegant, and more importantly nothing is hidden from user.
imperative programming is just cleaner and superior, admit it
is very wasteful since it needs to retrieve all the items before filtering.
I've been using C# for over a decade (even familiarizing myself with Assembly structure and IL, P/Invoking etc) but I've never even touched LINQ. What is it and why do I need it?
It's for people that need to manipulate lists/entities on the fly without doing a bunch of for loops. You could if you want, but why would you when you could do it all in one line or one simple query.
Yeah, but it's explicit. The one roll of collect is to create a new object, and everything else is just transformations on iterators. Sorting is done in place.
Java tried to copy it with the Stream API and failed miserably with an inferior feature. Haskell and Rust have similar features but they aren't nearly as moron friendly as LINQ.
The idea of LINQ is, instead of using Yet Another Query Language (YAQL), LINQ will Interface to SQL, noSQL, XML/HTML parsing, and will also help you in the process of building your algos. It's one query language to rule them all.
People fighting about it being dead in the comments. Usually means it's dead. Seems EF replaced it.
2 years ago
Anonymous
you're probably confusing LINQ to Entities with LINQ to SQL. the latter only worked with MSSQL and had a ton of limitations, the former is used for most DB connections now. i honestly don't remember the last time i saw L2S code in use. everything is either EF or using a non-linq approach (Dapper or non-ORM).
>implement functional stuff as SQL statements >everyone hates it >but what if we spam venetian carpet knitting forum with the opposite of what people think
for me it's for loop
Feels good to be a C#ad
>working on asp.net backend
>homosexuals littering everything with linq
>even places where it makes no sense
>b.. b- b-but it's the future
I hate globohomosexual so fricking much
i write code with the least amount of dev effort, im not working harder to make your gayman website run 2% faster page loads
>the ordinary way with higher order functions is simpler and clearer
I don't know what you thought this proved OP
>How Do People Cope Not Having LINQ
I use Haskell, which is what C# is trying, and failing miserably, to emulate with LINQ.
they clearly wanted it to look like SQL which Entity Framework compiles it to using expression generators which poorly mimick Lisp
but it is a neat feature for a C-tard language
Haskell people making excuses for its ugly syntax be like, "Haskell can do it too!".
Look at how ugly that Haskell syntax is compared to C#'s LINQ.
>be like
go back
I'm not a haskelgay but couldn't you just a comprehension or map/filter?
getAge people = [ age p | p <- people, (name p) == "Edna" ]
i d get it. isn't that basically an archaic rxjs?
I do mostly C# and doesn't use LINQ much. If it was good it would be ported over to other languages. Since it isn't ported over it can't be good.
var items = new List<Vendor>();
foreach (var v in vendors)
if (v.CompanyName.Contains("Toy"))
items.Add(v);
items.Sort((a,b)=>string.CompareOrdinal(a,b));
simple and elegant, and more importantly nothing is hidden from user.
imperative programming is just cleaner and superior, admit it
>(a,b)=>string.CompareOrdinal(a,b)
extremely moronic
no it's too verbose
should be able to do something approaching list comprehensions
which linq is good enough
Nothing about this is more cleaner or superior. All I see is needless state that's way harder to test and refactor than function composition.
>Nothing about this is more cleaner or superior
with just 5 lines of code you can replace the whole LINQ monstrosity https://github.com/Microsoft/referencesource/blob/master/System.Core/System/Linq/Enumerable.cs
how is that isn't superior?
Imagine doing all of that when you can just do it all in one line.
var vendorQuery = vendors.Where(v => v.CompanyName.Contains("Toy")).OrderBy(v => v.CompanyName);
[/code[
that "one liner" is an abstraction that hides dozens of allocations and function calls and thousands of lines of code
with imperative program what you see is what you get.
If you want less bloat you can just run a raw SQL query, the approach in
is very wasteful since it needs to retrieve all the items before filtering.
I've been using C# for over a decade (even familiarizing myself with Assembly structure and IL, P/Invoking etc) but I've never even touched LINQ. What is it and why do I need it?
It's for people that need to manipulate lists/entities on the fly without doing a bunch of for loops. You could if you want, but why would you when you could do it all in one line or one simple query.
filters lists like es6 arrays but with a cleaner and easier syntax
linq is comfy but it makes inefficient queries for complex stuff, I saw one such example
Rust and C++ are deathly afraid of allocating operations in std iterators.
Ayep. Sorting won't even allocate
let mut vendor_query : Vec<Vendor> = vendors
.iter()
.filter(|v| v.company_name.contain("Toy"))
.collect();
vendor_query.sort_by(|a,b| a.company_name.cmp(b));
You allocated by calling collect.
yeah
you need to allocate for sorting either way
Yeah, but it's explicit. The one roll of collect is to create a new object, and everything else is just transformations on iterators. Sorting is done in place.
Itertools has sorted_by
LINQ is a nice feature, but it's not so nice that I can't tolerate using a standard method syntax in other languages.
Imagine your programming language not being able to query and iterate over a list for certain conditions and even create a new type, all in one line.
Loop chuds BTFO.
>convert slow operation to parallel linq
>it actually 4 times faster
probably the only time in world history that worked
>queries inside another langauge
did you people totally miss what QL is for
Why is C# so far behind Lisp? You have to hope and wait 5 years for them to add something everytime you need a macro.
Optics do the same thing but betterer
if its so good why doesn't every language has its own version? Seems like there are a major drawbacks.
Java tried to copy it with the Stream API and failed miserably with an inferior feature. Haskell and Rust have similar features but they aren't nearly as moron friendly as LINQ.
Why don't you write an sql like a normal person?
Because you want to query a variable in your program, not an external database.
The idea of LINQ is, instead of using Yet Another Query Language (YAQL), LINQ will Interface to SQL, noSQL, XML/HTML parsing, and will also help you in the process of building your algos. It's one query language to rule them all.
>LINQ will interface to
no.
Concise and highly readable unified syntax to query, filter and sort everything under the sun.
Isn't LINQ to SQL dead?
From where you come with that assumption exactly? I'd rather say it became ubiquitous.
https://stackoverflow.com/questions/8676/entity-framework-vs-linq-to-sql
People fighting about it being dead in the comments. Usually means it's dead. Seems EF replaced it.
you're probably confusing LINQ to Entities with LINQ to SQL. the latter only worked with MSSQL and had a ton of limitations, the former is used for most DB connections now. i honestly don't remember the last time i saw L2S code in use. everything is either EF or using a non-linq approach (Dapper or non-ORM).
That sounds about right.
Method syntax chad reporting in.
linq is just bread-and-butter functional programming concepts restated by POO enterprise programmers
>implement functional stuff as SQL statements
>everyone hates it
>but what if we spam venetian carpet knitting forum with the opposite of what people think