←back to thread

201 points olvy0 | 1 comments | | HN request time: 0s | source
Show context
high_na_euv ◴[] No.41878416[source]
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.

C# design team is/was unparalleled

replies(7): >>41878459 #>>41878543 #>>41878588 #>>41878686 #>>41879163 #>>41879194 #>>41879315 #
pjmlp ◴[] No.41878459[source]
LINQ is largely based on FP stuff, also how Smalltalk collections work.

It is relatively easy to find similar capabilities in most languages nowadays, unless one is stuck on Go, C and similar.

replies(7): >>41878547 #>>41878579 #>>41878702 #>>41878783 #>>41878792 #>>41878816 #>>41879057 #
blackoil ◴[] No.41878783[source]
One difference with LINQ is its ubiquity. It works with database, in memory data structures, on disk files. You can use your skills/code across all the system.
replies(1): >>41878827 #
John23832 ◴[] No.41878827[source]
It's just built on top of anything that is Iterable. If a language has first class iterator support, they could do something similar.
replies(2): >>41878964 #>>41879023 #
mythz ◴[] No.41879023[source]
Takes a lot more than that, LINQ providers work by accepting a LINQ Expression Syntax tree instead of an opaque function, which allows providers to inspect and traverse the Expression's AST and translate it into the data source it's implementing.

This Expression AST is constructed by the compiler, not something that can be tacked on by a library later.

replies(2): >>41879354 #>>41879511 #
megadal ◴[] No.41879354[source]
Yes, but I think the point is practically every high level language can already do this pretty trivially.

If it's scripted you can typically just get a string representation of the function.

If it's Java, JAR inspection/dynamics have been a thing for a long time. And in other languages, they usually directly support metaprogramming (like Rust) and plugging code into the compilation logic.

replies(3): >>41879513 #>>41879690 #>>41880343 #
mythz ◴[] No.41879513[source]
If it were trivial you'd see LINQ-like providers implemented in "practically every high level language".

Source code of the function means you have to implement the parser/lexer to convert it into a usable AST which is bad for both runtime performance and library size.

Very much doubt this is available in Java, which Java ORM lets you use native Java language expression syntax to query a database?

replies(2): >>41879899 #>>41887222 #
1. megadal ◴[] No.41887222{5}[source]
I mean they kind of are. You can find a library in almost every language that transpiles source code ASTs.

They're just not core features.

In Haxe, it's extremely common :) but Haxe is just one other high level language.