Earlier quoted context omitted.
The point of the class instance (the "singleton") is not performance, it's that it exists independently of any instance of the type, so it can be used for factories and such. This however, is not my main concern, and as you remarked, it does not fit very well in OO, which is why it isn't in my proposal. On to the interesting part. You want multiple adapters, rather than multiple interfaces, precisely because you want…
Thanks for the explanations. Yes, there seems to be an impedence mismatch when trying to import the concept of Haskell type classes to OOP languages. WRT a combined adapter class, it'd look like this in Kotlin: class FooBarAdapter(val x: Baz, private val y = Foo(x), private val z = Bar(x)) : Foo by y, Bar by z A bit bloaty, but still a single line of code. (I know you already know this, I'm writing it here for Kotlin…
Kotlin 1.0 Released: Pragmatic Language for JVM and Android
101–110 of 112 posts
Re: Kotlin 1.0 Released: Pragmatic Language for JVM and Android
#102Been using it for a while, glad 1.0 is out! This is an amazing replacement for Java on Android and hope it gets more public recognition now that it's officially out.
I designed my reactive mvvm micro-library ( https://github.com/zserge/anvil ) for Android with kotlin in mind, and so far it saved me lots time. Kotlin+Android is a great choice.
Re: Kotlin 1.0 Released: Pragmatic Language for JVM and Android
#103Earlier quoted context omitted.
You're really comparing a small subset of what "LINQ-like functional programming" is to the (small) pieces that Kotlin can do. LINQ is not (just) an interface over some collections. It is a comprehension syntax (that kotlin doesn't have) that works on any types that have Select/SelectMany/Where. This gives you a lot more power than what Kotlin gives you, as you can 'extend' other things that don't inherit from an IEn…
It's not a small subset, it's the most popular subset that .NET developers use LINQ for everyday as identified by C#'s 101 LINQ Examples and compares them against the equivalent code in Kotlin. The C# examples does use the LINQ SQL-like DSL whereas other languages get by with a more readable and less indirection version using functional API's available on collections. It's up to the developer which they prefer howeve…
As far as I know, LINQ to SQL uses Expression Trees under the hood, I'd argue that even if you're not using them directly, LINQ to SQL is a pretty useful application of LINQ.
Effectively, Expression Trees are what enables custom macros for LINQ. Even if not everyone writes macros, the number of users of those macros is much more widespread.
Re: Kotlin 1.0 Released: Pragmatic Language for JVM and Android
#104Kotlin sort of feels like Groovy "done properly" (with no disrespect to the authors of Groovy). Groovy kind of evolved in an opportunistic, unplanned manner and ended up with millions of features, cool whiz bang aspects that look awesome that don't always turn out well when you use them on a large scale. Kotlin seems to capture the same ideas (highly pragmatic, maintain perfect bidirectional compatibility with Java),…
I understand the author of Groovy said he'd never have started the language if he'd known about Scala.
http://macstrac.blogspot.co.uk/2009/04/scala-as-long-term-re...
Re: Kotlin 1.0 Released: Pragmatic Language for JVM and Android
#105Earlier quoted context omitted.
I understand the author of Groovy said he'd never have started the language if he'd known about Scala.
"I can honestly say if someone had shown me the Programming in Scala book by Martin Odersky, Lex Spoon & Bill Venners back in 2003 I'd probably have never created Groovy." http://macstrac.blogspot.co.uk/2009/04/scala-as-long-term-re...
Re: Kotlin 1.0 Released: Pragmatic Language for JVM and Android
#106Earlier quoted context omitted.
It's not exactly helping your case that it isn't at all clear what that sample is actually doing and what kind of practical task it might be used for. I've been doing C# for years, use and enjoy Linq, and I can't remember the last time I touched the comprehension syntax. IIRC, it does make a few relatively obscure things easier than they would be with method and lambda syntax, while there are a few different obscure…
The sample is not clear?! How would you write the same asynchronous code in C# without the LINQ syntax? Can you give an example? All the code does is get a from async taska, b from async task b, feed the result of b into task c to get c, and if c contains blah return c+a asynchronously.
If they are enumerable, then what exactly does c + a do? It is creating a new enuerable of every a added to every c, like a SQL cross join?
If it is a single object, then what exactly does the where clause do? What does it return if c does not contain blah, and what becomes of a in that case? Does it get returned, added to null, disappear into the ether, or does it figure out that it doesn't need it, and never actually evaluate taska? What happens if taska modified some other state somewhere? For that matter, if it's figuring that out, that would control the order that the tasks are evaluated in. What is that, exactly? Is taska run at the same time as taskb, or does it wait to see if there is actually a c to add to it's result? Or maybe it gets evaluated before or after taskb, or at the same time.
That stuff matters. I'd rather make it clear at a glance what's going on than write something super short and clever that nobody can figure out the details of.
Re: Kotlin 1.0 Released: Pragmatic Language for JVM and Android
#107Earlier quoted context omitted.
The sample is not clear?! How would you write the same asynchronous code in C# without the LINQ syntax? Can you give an example? All the code does is get a from async taska, b from async task b, feed the result of b into task c to get c, and if c contains blah return c+a asynchronously.
If you understand it, then exactly what are the return types of these tasks and the types of a, b, and c? Are they single objects or IEnumerables? If they are enumerable, then what exactly does c + a do? It is creating a new enuerable of every a added to every c, like a SQL cross join? If it is a single object, then what exactly does the where clause do? What does it return if c does not contain blah, and what become…
Re: Kotlin 1.0 Released: Pragmatic Language for JVM and Android
#108Earlier quoted context omitted.
While it's an excellent example, I wonder if people don't see "endoMonoid" and run away screaming. I really wonder if people would have different reactions if this was presented as "Addable" instead.
Yeah, I wonder about calling it "addable" or "mergeable". But neither of those really captures the full generality of it - would you expect composing functions to count as "adding" or "merging"?
That's reverse API psychology for you :D
Re: Kotlin 1.0 Released: Pragmatic Language for JVM and Android
#109Earlier quoted context omitted.
Didn't downvote, just FYI: Haskell's Applicative is a superclass of Monad now.
Which means you are now forced to write the boilerplate pure = return ( ) = liftM2 ($) In Scala, you get it for free for any monad.
Re: Kotlin 1.0 Released: Pragmatic Language for JVM and Android
#110I've been using Kotlin for work (I'm a PhD student, so work is to be understood in a peculiar fashion) and I'm really liking it. It's a much needed upgrade to Java whose fundamental advantage is what I'd call "crispness": you can write terse code that is actually understandable. In particular, the notion of inlining closures allows for efficient functional programming and great DSLs. In comparison to Scala, Kotlin is…