Live data from Hacker News

Kotlin 1.1 Released with JavaScript Support, Coroutines and more

blog.jetbrains.com

71–80 of 89 posts

Re: Kotlin 1.1 Released with JavaScript Support, Coroutines and more

#71

Earlier quoted context omitted.

I don't think of 'func' as a standard. Off the top of my head, you can see "defun", "fn", "def", "function", and on and on in various languages. I don't see much agreement across the board.

does anyone know of a place that compares syntax like this across languages? I've found myself often wondering if there is consensus for certain features or syntax.

http://rigaux.org/language-study/syntax-across-languages.htm...

Re: Kotlin 1.1 Released with JavaScript Support, Coroutines and more

#72
post #70

I wonder how Kotlin's JavaScript backend compars to Scala.js in Li Haoyi's list of fundamental reasons for betting on Scala.js: http://www.lihaoyi.com/post/FromfirstprinciplesWhyIbetonScal... I have a few concerns about Kotlin's JS backend: How much can the complete JS bundle be optimized by an advanced whole-program optimizer like the Google Closure Compiler? Kotlin for JS has no reflection, and I think JetBrains sh…

> How much can the complete JS bundle be optimized by an advanced whole-program optimizer like the Google Closure Compiler? JavaScript backend generates code understandable by static analyzers so it can be optimized. Anyway, we going to continue works in this area in near future. > Kotlin for JS has no reflection, and I think JetBrains should not look into that as they said they are. But is there powerful compile-tim…

> Why do you think that reflection is a bad idea?

OK, reflection isn't necessarily a bad idea. Clearly development tools need it, including future tools that run in the browser (e.g. an in-browser IDE). But I think that applications that are not development tools should not use reflection, because it interferes with static optimization, as the article that I linked in my original comment explains. So most libraries should probably not use reflection either. That means we need an alternative to reflection. For example, chapter 10 of _Kotlin in Action_ uses reflection to implement a serialization library. I think it would be better to use build-time code generation for that, even outside the JS use case (e.g. reflection interfers with optimization of Android app packages with ProGuard).

Edit: By the way, thanks for taking the time to respond.

Re: Kotlin 1.1 Released with JavaScript Support, Coroutines and more

#73
post #30

Earlier quoted context omitted.

I completely agree. Kotlin is close to the ideal language for me because it is just Java done right. If they want to go native and can do it without impairing any of the JVM usability, I guess go for it. But I don't see the point behind it. I don't develop native apps so maybe I just don't know enough, but it seems like Go and Rust have already satisfied the desire for modern natively compiled languages. I feel the s…

Personally I'm intrigued by Kotlin Native as a replacement for Python and Go tools without requiring the JVM. I find it's a fundamentally better language than both and so being able to write CLI tools and other smaller stuff in it would be nice while still being able to leverage Kotlin + JVM on the backend would also be nice.

Same - a common language for JVM, JS, Native is both unique and intriguing to me. These are three really big targets. It's not that it would be unique in being a higher level compiled language or a language making Java development more fun to me, but being a common languge for among the most popular targets besides .NET today.

Re: Kotlin 1.1 Released with JavaScript Support, Coroutines and more

#74
post #69
post #67

Earlier quoted context omitted.

Only if you make sure to call Marshal.ReleaseComObject on all your objects, which requires you to hang on to explicit references to all of them, which is not very convenient for many COM APIs, e.g. Application.Database.Classes.Item("MyClass").Refresh() where you would have to save all the intermediate objects in variables just so you can destroy them. Python works much better with COM, in my experience, because of it…

I use .NET since pre-alpha days and never used it, RCW and CCW take care of that. Unless you are talking about manually loading them. Also, are you aware that UWP and .NET Native are built on COM?

I have run into this problem in two cases:

1. When writing a COM add-in for a host application. When the application wants to shut down, the add-in must release all references to the objects of the host application, otherwise the process doesn't shut down. (At least with the application I'm currently writing an add-in for!)

2. When using out-of-process COM servers such as Excel from another application. This tends to leave lots of "excel.exe" processes running unless you explicitly release everything.

See for example: https://www.add-in-express.com/creating-addins-blog/2013/11/...

Here is Microsoft describing how they ran into this problem when mixing COM and .NET in Visual Studio, how they solved it using Marshal.ReleaseComObject, how that itself caused other problems later when they combined it with CCW, and ... I'm not sure what their ultimate correct solution was:

https://blogs.msdn.microsoft.com/vcblog/2006/09/19/mixing-de...

https://blogs.msdn.microsoft.com/visualstudio/2010/03/01/mar...

I am aware of UWP bringing COM back into fashion again, which is why I'm interested in potentially using Kotlin Native with it. :)

Re: Kotlin 1.1 Released with JavaScript Support, Coroutines and more

#75
post #73

Earlier quoted context omitted.

Personally I'm intrigued by Kotlin Native as a replacement for Python and Go tools without requiring the JVM. I find it's a fundamentally better language than both and so being able to write CLI tools and other smaller stuff in it would be nice while still being able to leverage Kotlin + JVM on the backend would also be nice.

Same - a common language for JVM, JS, Native is both unique and intriguing to me. These are three really big targets. It's not that it would be unique in being a higher level compiled language or a language making Java development more fun to me, but being a common languge for among the most popular targets besides .NET today.

Scala already does that with scala.js (production-ready) and scala-native (don't know if production-ready, probably not since it's only at 0.1 and they want to implement a better GC instead of relying on boehm like now).

Just wanted to point that out in case you didn't know that already.

Re: Kotlin 1.1 Released with JavaScript Support, Coroutines and more

#76
post #54
post #18

Earlier quoted context omitted.

Perhaps the bigger issue here is fragmentation. Here you are, a young language with a lot of promise whose primary appeal is Java interop and whose target market is enterprise Java and already you're dividing your efforts to offer something which your target market will likely have zero interest in. Why not wait until you have real market share in the job market and only then worry about native? Kotlin is a very nich…

One of the niches where it's found a lot of popularity is Android development, which naturally leads developers to thinking about sharing code with the iOS version of their app. This is where Kotlin Native fits in, I think. Also (just dreaming here) if Kotlin Native were to use some kind of Swift-like reference counting rather than a traditional GC, it could be really nice for interfacing with COM on Windows, where y…

I agree with you about the potential of Kotlin Native. And I, too, would like reference counting, at least as an alternative to GC.

But I think that for really smooth interop with the host platform, it won't be good enough to have just one generic Kotlin Native, that compiles to native code with a cross-platform compiler infrastructure like LLVM. It would be much better to have multiple Kotlin native implementations that integrate well with various host platforms. For example:

* Kotlin for Apple platforms: Every Kotlin object is an ObjC object, and ObjC APIs can be used with minimal glue code in optimized builds. All Kotlin strings are NSStrings and vice versa. Same with collections (NSArray, NSDictionary, and their mutable counterparts); Kotlin's separation of read-only and mutable interfaces is a good match for this platform.

* Kotlin for Universal Windows Platform: UWP, being COM-based, doesn't have a root object type like the Apple platforms. Still, we'll want to be able to call UWP APIs and implement UWP interfaces with minimal runtime glue. And UWP has a reference-counted immutable string type (HSTRING), so all HSTRINGs should be Kotlin strings and vice versa. I don't recall how collections work on UWP.

* Kotlin for classic Win32 + COM: Similar to UWP, but the situation with strings is more complicated. BSTR isn't reference counted, so on this platform, Kotlin would probably need to have its own string implementation, with bridging to and from BSTR for COM interfaces.

Re: Kotlin 1.1 Released with JavaScript Support, Coroutines and more

#77
post #31

For fun, I've been working on a simple hobby web server in Kotlin that wraps Jetty: https://github.com/danneu/kog I think Kotlin is the statically-typed language I've been waiting for, especially with the team's interest in native and JS targets.

Do you have any opinions on Kotlin vs Clojure? are you liking Kotlin more?

I think static typing + solid IDE support is too useful to pass up, and that's what Kotlin has.

But Kotlin also has simplicity that, for example, Scala doesn't. I tried Clojure after spending a couple months with Scala and giving up, and then I used Clojure fulltime for 3+ years.

Eventually, I felt like I was hitting a ceiling with Clojure since it lacked good static analysis. I moved to Node because I felt like, if I'm going to use a dynamically-typed language, I might as well use the ubiquitous one. Also, Clojure was a hard sell to other developers I would meet.

What Clojure does have is an ecosystem of simplicity that I hope the Kotlin ecosystem will adopt.

For example, compare ztellman's http://aleph.io/ (Clojure) to Java's Netty or to the somewhat mind-numbing https://docs.oracle.com/javase/8/docs/api/java/util/concurre.... And compare Clojure's Ring to any Java web framework.

Even Spark, Java's simplest option afaict, doesn't have real middleware, just before/after "filters". That's why I went with the `(Request) -> Response` signature over the `(Request, Response) -> Unit` signature.

There's also ClojureScript's integration and tooling which are pretty impressive these days while Kotlin's JS support is still fledgling.

Though these are the impressions of someone who has only been using Kotlin for a few months without a Java background. And it's not like anyone should be using my lil framework in production, it's just a hobby.

Re: Kotlin 1.1 Released with JavaScript Support, Coroutines and more

#78
post #74
post #69

Earlier quoted context omitted.

I use .NET since pre-alpha days and never used it, RCW and CCW take care of that. Unless you are talking about manually loading them. Also, are you aware that UWP and .NET Native are built on COM?

I have run into this problem in two cases: 1. When writing a COM add-in for a host application. When the application wants to shut down, the add-in must release all references to the objects of the host application, otherwise the process doesn't shut down. (At least with the application I'm currently writing an add-in for!) 2. When using out-of-process COM servers such as Excel from another application. This tends to…

I've run into this kind of problem while implementing a Windows screen reader that needs to use COM-based accessibility APIs, both in-process and out-of-process. I naively chose, some 12 years ago, to use Lua, even for the in-process component. Lua, of course, uses tracing garbage collection, not reference counting.

Re: Kotlin 1.1 Released with JavaScript Support, Coroutines and more

#79
post #74
post #69

Earlier quoted context omitted.

I use .NET since pre-alpha days and never used it, RCW and CCW take care of that. Unless you are talking about manually loading them. Also, are you aware that UWP and .NET Native are built on COM?

I have run into this problem in two cases: 1. When writing a COM add-in for a host application. When the application wants to shut down, the add-in must release all references to the objects of the host application, otherwise the process doesn't shut down. (At least with the application I'm currently writing an add-in for!) 2. When using out-of-process COM servers such as Excel from another application. This tends to…

Thanks for the explanation and links.

I guess the reason for never bumping into it was that all use cases I encountered so far, the controls were in-process and died when the application terminated.

Re: Kotlin 1.1 Released with JavaScript Support, Coroutines and more

#80
post #3

What I like about Kotlin is it's what you might call a "pragmatic Scala", and could find a sweet spot between Java and Scala where its added expressiveness allows it to shine, but Scala's complexity and performance issues aren't in evidence to scare the development managers into staying with Java.

Scala's complexity and performance issues Is Kotlin really faster than Scala?

It hasn't been a big issue for me so far, but Kotlin often favours fast and compact where Scala favours generic and beautiful.

For example, in Scala, nullable references are just another monad object implemented in plain Scala, while in Kotlin they have a special syntax around Java's null pointer.

Post reply on HN