TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Net 9.0 LINQ Performance Improvements

203 点作者 olvy07 个月前

15 条评论

olvy07 个月前
For me, the most useful part of LINQ is neither the IQueryable syntax tree based extension mechanism, nor the language integrated part (which I dislike), but simply the IEnumerable extensions. Originally known somewhat confusingly as linq to objects. Those allow me to write c# in functional style, keeping the code concise.<p>The post I submitted refers mostly to optimizations to those extension methods.<p>This clicked for me after having learned Haskell. It also shares some of Haskell&#x27;s features&#x2F;pitfalls, such as laziness.<p>There are pitfalls, sure, and honestly I wouldn&#x27;t advise a team having no one somewhat experienced with basic functional idioms (including laziness) to use it. It can lead to obtuse and slow code if used indiscriminately. I try to lead by example myself.
评论 #41882332 未加载
评论 #41879713 未加载
评论 #41883519 未加载
评论 #41883044 未加载
评论 #41882614 未加载
评论 #41879608 未加载
zija7 个月前
I don&#x27;t understand why the dotnet team doesn&#x27;t invest more resources and time into tools: doctests and documentation generation, better and faster unit tests that I can write next to the actual code, easy access to the source code, no need to decompile a Dll to see it after pressing F12, a central place for packages and documentation like in pkg.go.dev or docs.rs . Most packages in nuget have no documentation at all, or only in readme format on GitHub, or a short Wiki on this page. Other environments like Rust, Golang, Java, Python are light years ahead when it comes to these aspects.
评论 #41882271 未加载
评论 #41885066 未加载
评论 #41883613 未加载
评论 #41882721 未加载
评论 #41883692 未加载
louthy7 个月前
&quot;LINQ Performance improvements&quot; really should read: &quot;our own List&lt;T&gt; implementation performance improvements&quot;. Microsoft seem to spend their time improving what they need, rather than spending time on general improvements. LINQ (the syntax, not the method extensions) needs investment. Primarily around lambda allocation and potentially on compile-time reduction of lambdas.<p>It&#x27;s time to have value-type local lambdas, or a strategy that doesn&#x27;t make lambda allocation the overhead that it is. And also there really should be wildcard support (`_`) for LINQ variables by now. Which was been completely ignored when they were brought in for lambdas. It should also be possible to use a lifted-type (like IEnumerable&lt;T&gt;, Option&lt;T&gt;, etc.) as the final item in a LINQ expression, rather than `select ...`. The select adds overhead that isn&#x27;t needed for certain use-cases and limits things like tail-recursive LINQ expressions.<p>Libraries like mine that go all-in on LINQ [1], but aren&#x27;t using `IEnumerable` or `IQueryable`, or any of the LINQ extensions, continually get ignored because MS are focusing purely on improving the performance of their own projects.<p>A good example is the improved lambda inference. It was only brought forward because ASP.NET Core needed it for its minimal API. It seems like many of the features of the language&#x2F;framework are driven by their own needs rather than those of the community. The absolute worst thing is the ever expanding set of &#x27;magic methods&#x27; (like the LINQ extensions Select, SelectMany, and Where, but also GetAwaiter, and the rest). MS are adding capabilities for themselves (the compiler mostly) rather than do what is really needed and add proper higher-kinded traits to resolve the magic. So everything is weakly typed and only vaguely discoverable by the compiler :&#x2F;<p>LINQ is one of those key differentiators between languages, yet it&#x27;s been wallowing, pretty much untouched since C# 3. I think it&#x27;s a crying shame that it has basically been ignored since then and, even now, they think LINQ is only useful for iterating lists. And primarily only their own list implementations.<p>&#x2F;rant<p>Don&#x27;t get me wrong, I appreciate all performance improvements, I&#x27;m sure it will help plenty of users. But the focus always seems to be narrowly targeted, which limits the potential.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;louthy&#x2F;language-ext&#x2F;">https:&#x2F;&#x2F;github.com&#x2F;louthy&#x2F;language-ext&#x2F;</a>
评论 #41883339 未加载
评论 #41884775 未加载
DeathArrow7 个月前
The more C# borrows from F#, the happier I am. I am awaiting for discriminated unions to finally reach C# so I can do domain modelling like a boss. :)
评论 #41885677 未加载
评论 #41880258 未加载
评论 #41879289 未加载
评论 #41903512 未加载
nightski7 个月前
Whenever I work in other languages&#x2F;ecosystems LINQ is the one thing that I really miss. It&#x27;s just such a nice capability to have available in the standard library. Beautifully designed given the constraints it had to work within.
neonsunset7 个月前
Relevant section in the annual book-sized post on all performance improvements in .NET 9:<p><a href="https:&#x2F;&#x2F;devblogs.microsoft.com&#x2F;dotnet&#x2F;performance-improvements-in-net-9&#x2F;#linq" rel="nofollow">https:&#x2F;&#x2F;devblogs.microsoft.com&#x2F;dotnet&#x2F;performance-improvemen...</a><p>(for some reason HN would not allow to resubmit it, and the post was left by wayside not reaching frontpage)
hakanderyal7 个月前
Beware, once you get used to using LINQ and usually work in a domain that it shines, you won&#x27;t want to go back to using anything else.
评论 #41880247 未加载
评论 #41887550 未加载
blackoil7 个月前
Anyone knows of a comprehensive book&#x2F;tutorial to learn end to end web development in dotnet. Most I have found are elementary, outdated or poor quality.
评论 #41879009 未加载
评论 #41879030 未加载
评论 #41879860 未加载
评论 #41878995 未加载
评论 #41879834 未加载
Culonavirus7 个月前
There has to be a better way to do things than this annotation noodle soup. My eyes are bleeding every time I look at modern Net code.
评论 #41880606 未加载
评论 #41880904 未加载
ibejoeb7 个月前
&gt; Some more optimizations can happen when the chain ends up with methods like Count(), First(), Last(), ElementAt() or Sum(). For instance, OrderBy(criteria).First() can be optimized to execute as Min(criteria).<p>As useful as that might be, we should really be writing better code. This is interesting for dynamically generated chains, I suppose. But if these operations are done on bespoke code, this is kind of perverse positive reinforcement. The library itself is recognizing a sub-optimal pattern and correcting for it. I hope there&#x27;s feedback, at least, that suggests improvements to the underlying code.
mannycalavera427 个月前
I have fond memories of using LINQPad<p>That&#x27;s why I guess today I work in Clojure :)
评论 #41881913 未加载
评论 #41880197 未加载
high_na_euv7 个月前
LINQ is so fucking useful and well designed feature of .NET ecosystem that it is unreal when you gotta use lang which doesnt have such a thing.<p>C# design team is&#x2F;was unparalleled
评论 #41878588 未加载
评论 #41878459 未加载
评论 #41879163 未加载
评论 #41878543 未加载
评论 #41879194 未加载
评论 #41878686 未加载
评论 #41879315 未加载
dingdingdang7 个月前
OK, so since I&#x27;ve never actually bothered to look at what LINQ actually is.. there may be others in the same boat: &quot;LINQ allows you to query any enumerable collections such as List&lt;T&gt;, Array, or Dictionary&lt;TKey,TValue&gt;.&quot;. Got to admit I still find the LINQ to DB passtru rather opaque even after reading up on it: <a href="https:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;30716776&#x2F;passing-a-query-directly-through-linq-to-the-db&#x2F;30716910#30716910" rel="nofollow">https:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;30716776&#x2F;passing-a-query...</a><p>Basically allowing for a uniform way to query data which is reminiscent of a more modern version of SQL (in my optics anyway). Does anything library wise come close to this within the Golang ecosystem?
评论 #41878718 未加载
评论 #41878734 未加载
评论 #41878990 未加载
评论 #41879319 未加载
EVa5I7bHFq9mnYK7 个月前
It&#x27;s a shame, actually, that .NET performance improvements of up to x1000 could still be found after two decades and hundreds of millions spent on development.
评论 #41879654 未加载
评论 #41879332 未加载
stonethrowaway7 个月前
C# is Pragmatic [0].<p>[0] <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=41761346">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=41761346</a>