News for hackers. Stuff that matters.
Re:How generics were added to .NET by btschaegg on Tuesday March 06, 2018 @02:08AM (#16527374)
Regarding LINQ: I really like certain parts of it, dislike others (mainly inline Select-statements and the EntityFramework built on top of it), but I'd be hard-pressed to call it the greatest invention of any time. PEP 255 laid the ground work for similar language features in 2001, and I doubt that the python guys "invented" all of that out of thin air (cf. Reference #4 in the PEP).

What you can argue is that LINQ made this stuff available to more developers (with useful syntax and in a statically typed language, which also must have taken a lot of work), but filter/map/reduce have been around for quite a while.

That obviously doesn't make it less useful or the underlying tech less impressive though.

Re:How generics were added to .NET by tehlike on Tuesday March 06, 2018 @02:40AM (#16527484)
The magic behind LINQ is that it's a query layer on top of a backing data store. When it first came out, you'd see data providers written against twitter, file system and everything like that. Then entity framework & nhibernate linq provider came out. It was great, hid a lot of details from user, brought static type checking to otherwise very hard to "verify" sql. You'd now think in terms of objects, and not tables.

Linq compiler compiled the whole query into a AST, which you could then convert to a backing query your data store could understand.

To date, I still think Linq was great. I was indifferent to the "sqlized linq", but i liked the lambda quite a lot. It was a nice abstraction and a pretty good language to write queries on.

Disclaimer: I worked on NHibernate Linq integration ~10 years ago.

Re:How generics were added to .NET by brusch64 on Tuesday March 06, 2018 @02:59AM (#16527559)
What is your opinion on the state of NHibernate ?

I've started using it in 2009. I am still using it in my projects, but I am still not sure if NHibernate is functional complete or if the project is nearly dead.

It works fine for me (if it is not worth the effort I am using Dapper.net), but it doesn't seem that there is much active development going on.

Re:How generics were added to .NET by eldavido on Tuesday March 06, 2018 @11:24AM (#16529800)
On the way out (daily user here).

I started a project about 4yrs ago, it was EF vs NH. Went with NH because EF was still pretty immature.

The momentum is pretty clearly toward EF IMO. NH is missing a lot, including proper migration tooling and deep async support. But I don't think that's the real issue. The more foundational problem in my view, is that NH deeply assumes blocking/synchronous database access. I have no idea how NH lazy loading will ever work with async. I imagine you'll have a bunch of FK refs all marked Task<T> that will have to be awaited? In any case, my bet is that EF will get there a lot more quickly than NH.

Re:How generics were added to .NET by tehlike on Tuesday March 06, 2018 @03:06AM (#16527581)
To my surprise, it seems fairly active: https://github.com/nhibernate/nhibernate-core

I stopped working on nhibernate around 2010-2011, when i started masters. I did only keep in touch with one friend - i am not very sociable person. So I guess short answer is, i am not sure to be honest.

Back in 2008ish, I was thinking it was going to die because Entity framework provided a great support for linq, and it had a great hype. A bunch of enterprises moved away from NHibernate (we also had a lot of legacy from XML configuration - a bunch of internal data structures were referencing xml), so it was clunky. Fabio, Oren (Ayende) did a bunch of improvements, I worked a bunch of shortening initialization times and so on. I think Ayende did a very good job with Linq initially, but there were plenty of edge cases that i remember having to fix :) It was my first opensource project as a core member (second and last was castle project) - so it has a very special place for me :)

Re:How generics were added to .NET by brusch64 on Tuesday March 06, 2018 @03:59AM (#16527729)
Okay - it really seems to be quite active right now. Thank you for your insight.

I've used the Linq queries in one of my projects, but I like the QueryOver statements more (a little bit too much black magic in the Linq queries).

But I believe that it was a great effort - so let me thank you for that !

Re:How generics were added to .NET by mattmanser on Tuesday March 06, 2018 @05:14AM (#16527966)
In my expereince you shouldn't even touch the black magic stuff unless you're a small org or it's a throwaway app.

Linq with the EF is great for simple queries and updates, anything else and you're in for serious performance problems as soon as the app scales. Better to drop to normal SQL for complicated data loading.

Even MS can't write decent LINQ queries, their ASP.Net identity provider is now the most 'expensive' bit of our app now because they used expensive LINQ queries instead of using raw SQL queries. Admittedly our use-case is abnormal as the specific problem we have is that because of the way users are added their password gets reset almost immediately, as they're invited by an organiser. It also means new users are constantly being added. When the password reset is saved it completely unnecessarily "verifies" the update by making sure the username and email are unique, which means two UPPER()s and CONTAINS()s on string fields. Unlike the old provider there's no usernamelowered field already in the db to avoid this.

We can fix it by over-riding these queries, but it's annoying that the ASP.Net team took a core framework piece that was very performant with fast performing SQL and made it substandard. At least I can look at the code now ;).

Re:How generics were added to .NET by WorldMaker on Tuesday March 06, 2018 @10:51AM (#16529530)
I've never thought of LINQ as black magic and have scaled some astoundingly complex LINQ queries in a past life. I've even done some things in LINQ optimization that you couldn't do in just "normal" SQL (clever joins of databases on different servers without linked servers; complex client-side caching and statistics work).

I think LINQ gets a lot of flak it doesn't necessarily deserve in complex queries due to people stopping at the black box and assuming black magic. It's a very functional programming paradigm embedded in an otherwise procedural world, and so the skills to debug complex LINQ should be unsurprisingly just a bit different than debugging most else in C#. I don't blame people for stopping at the black box. I just think more people should know that you can do more than stop at the black box.

(Also, it amuses me that your example from ASP.NET identity's changes have nothing to with that it should be using raw SQL queries versus LINQ, and everything to do with denormalization versus the query execution engine. It shouldn't be a huge surprise that Microsoft might trust SQL Server to be able to UPPER() and CONTAINS() fast enough, and the queries rare enough that it isn't necessary to denormalize that information.)

Re:How generics were added to .NET by tehlike on Tuesday March 06, 2018 @01:01PM (#16530605)
Check ravendb and see how linq can be a first class citizen in a database.
Re:How generics were added to .NET by mrits on Tuesday March 06, 2018 @09:07AM (#16528908)
Most of the points you brought up existed even in .NET before LINQ with DataTables/DataSets
Re:How generics were added to .NET by _r_o_y_ on Tuesday March 06, 2018 @09:38AM (#16529082)
For me DataTables where magic objects with no type safety at compile time.
Re:How generics were added to .NET by WorldMaker on Tuesday March 06, 2018 @10:57AM (#16529576)
After LINQ, I entirely refused to work on DataTables code without refactoring it to something more sane, even if just ugly DBReader junk and its version of casting hell. I was briefly sad that .NET Standard 2.0 had to bring in DataTables and preserve that ugliness for the rest of foreseeable time.
Re:How generics were added to .NET by tehlike on Tuesday March 06, 2018 @03:49PM (#16531988)
Type-safety is a blessing.
Re:How generics were added to .NET by tehlike on Tuesday March 06, 2018 @03:49PM (#16531985)
datatables are pretty much how regular SQL behaves, there are no magic behind them, right?

I would have prefered using DataReader, most often.

Re:How generics were added to .NET by wenc on Tuesday March 06, 2018 @10:32AM (#16529406)
Filter/map/reduce are ubiquitous ideas from the functional world, which in turn are ideas drawn from mathematics. Math has pre-existed many of our programming constructs, so in that sense, nothing was really invented as such.

To me, what LINQ offers is a very nice orthogonal DSL that allows programmers to express these thoughts. The underlying constructs are universal, but one could argue that LINQ itself was invented. LINQ was apparently guided by category thinking [0], which makes it fairly elegant, but in terms of expressiveness it is probably similar to SQL. It's all set theory underneath anyway. Unlike SQL however, LINQ does force the SELECT statement to the very end of the query expression, which makes IDE auto-complete work better due to avaiable context. :)

I first had the realization that most data manipulation operations on list-like or table-like objects were actually just glorified set operations (and there was a certain universality to them regardless of query language syntax) when I read this quote [1]: "The turning point was a conversation with Erik Meijer. He told me how categorical thinking guided him in designing LINQ, and explained how category theory brings out a simple relationship between various kinds of databases. The diagram below comes from a paper he wrote on this. It turns out that so-called No-SQL databases are in a categorical sense co-SQL databases."

[0] https://queue.acm.org/detail.cfm?id=2024658

[1] https://www.johndcook.com/blog/applied-category-theory/

Re:How generics were added to .NET by golergka on Tuesday March 06, 2018 @02:43AM (#16527497)
I always saw Linq as the iPhone of functional programming: it didn't really invent anything, but put existing things into such an appealing package for mass-market that it really finally made all those things popular and usable by people (developers) at large.
Re:How generics were added to .NET by eldavido on Tuesday March 06, 2018 @11:27AM (#16529827)
This is a broader theme in how technology develops.

When I look at technologies like bitcoin, it's just proof of work/puzzles (a well-understood defense to sybil attacks) + basic crypto primitives like signatures + some of the p2p stuff from bittorrent, etc.

There's real genius in combining the pieces, though. I also spent a few years in serious CS academia so not clear how widely these things (especially puzzles) were known beyond universities.

Re:How generics were added to .NET by btschaegg on Tuesday March 06, 2018 @03:06AM (#16527579)
Yes, I think you sum it up pretty nicely.
Re:How generics were added to .NET by Guillaume86 on Tuesday March 06, 2018 @04:34AM (#16527850)
It seems you're just thinking of the IEnumerable API and not LINQ at large, which includes the Expression and IQueryable API and enable things like LINQ-to-SQL.
Re:How generics were added to .NET by btschaegg on Tuesday March 06, 2018 @07:05AM (#16528305)
...which I'm also not a big fan of after having seen their implications in older products (i.e. ones that had to be maintained for a while). In most cases, they made the problem worse.

Plus, while they are enabled by other techniques, those weren't invented in LINQ, either.

Re:How generics were added to .NET by coldtea on Tuesday March 06, 2018 @06:04AM (#16528111)
>PEP 255 laid the ground work for similar language features in 2001, and I doubt that the python guys "invented" all of that out of thin air (cf. Reference #4 in the PEP).

LINQ is not about generators...

Re:How generics were added to .NET by btschaegg on Tuesday March 06, 2018 @07:00AM (#16528292)
The IEnumerable parts are mainly enabled by coroutines, which for this case more or less equate to generators. The other parts are pretty much what I've already seen so much problems with that I wouldn't touch them with a 10 foot pole (see the "black magic" comment by others, that sums it up nicely for me).

But those are also more or less just about building ASTs and transforming them, something Lisp has done for decades.