
Kotlin/Native Tech Preview: Kotlin without a VM - essh
https://blog.jetbrains.com/kotlin/2017/04/kotlinnative-tech-preview-kotlin-without-a-vm/
======
virtualwhys
> This Technology Preview features automatic reference counting with a cycle
> collector on top, but what the final memory management solution(s) will look
> like is unknown at this point.

Same issue with Scala Native[1]. Both projects are a long way from being
production ready wrt to targeting ios, android and desktop.

Probably at least a couple of years before either project delivers the one-
language-to-rule-them-all.

[1] [https://github.com/scala-native/scala-native](https://github.com/scala-
native/scala-native)

~~~
geodel
May they all do great. But I am sceptical that Scala/Kotlin and many others
started in last decade stand chance against Java/Rust/Swift/Go. IMO these 4
are backed by powerful corporations and have large community momentum. They
are going to keep >90% of all software work along with C/C++.

~~~
vetinari
Some of these corporations are experts in shooting in the foot.

I wanted to read 'The Swift Programming Language (Swift 3.1 Edition)'. It is
just an epub, just distributed via Apple iBooks, right?

When trying to open in on an Android tablet, I found out that it is DRM-ed.
Why on earth would you put DRM on a publication you want to circulate as
widely as possible? Why would anyone have to read reference docs for multi
platform language on a single platform?

That certainly dampened my enthusiasm for Swift.

~~~
pjmlp
No, it is distributed on the open source site since it exists.

[https://swift.org/documentation/](https://swift.org/documentation/)

I never had any issue reading it on Aldiko, even the Apple versions.

~~~
vetinari
I have it from iBooks, because in the past, it wasn't on the site yet. Since
then, I just update it via iBooks. The previous editions didn't have DRM
either.

------
meddlepal
This is great! I've adopted Kotlin as my go-to JVM language but being able to
write code that outputs native binaries for things like CLI tools would be
huge and may serve as a strong competitor to Go as a pragmatic, but well
designed language.

~~~
proyb2
In addition I feel SCADE.io uses Swift has more production quality than Go. I
tested Unsafepointer C in Swift is significantly faster in version 3.1. It is
in some case is faster than Go, Ruby, GCC and Java just for fun in benchmark.

Kotlin to LLVM is amazing idea and risky if it will break in Android. Only
time will tell.

~~~
camgunz
A little OT but something called SCADE already exists: [http://www.esterel-
technologies.com/products/scade-suite/](http://www.esterel-
technologies.com/products/scade-suite/) .

------
mwcampbell
I think using ARC for memory management is smart. However, the cycle collector
isn't going to work when you start doing interop with native objects. So I
think Kotlin is going to need a "Weak" annotation in the standard library,
which will be a no-op on the JVM and JS.

~~~
pjmlp
Or it needs to pin it.

------
randomThoughts9
Is there a spec?

They talk about modules and I am curious about their syntax (if any). If we
are to support a new multi-platform ecosystem, we should make sure it is built
on a stable foundation.

For example, I really like scala, but I can't convince myself to try scala-js
due to the unsoundness of the platform. Some scala libraries work, some
libraries compile but won't work as expected and some libraries need porting.
And you don't really know which is which.

[https://www.scala-js.org/doc/semantics.html](https://www.scala-
js.org/doc/semantics.html)

------
mwcampbell
For really smooth interop between Kotlin and a host platform, I don't think
there can be just one Kotlin Native. Perhaps it would be better to target just
one platform initially. Here's what my ideal Kotlin for iOS would look like:

The compiler wouldn't compile to native code using LLVM, but would produce
Objective-C source code, to be compiled with Apple's clang compiler. That way,
no matter what crazy requirements Apple throws at us tomorrow (similar to
64-bit and bitcode), we don't have to wait on JetBrains.

Kotlin's Any type should be synonymous with NSObject.

Kotlin's String type should be synonymous with NSString.

Kotlin shouldn't define its own concrete collection classes on this platform,
but should use NSArray, NSDictionary, NSSet, and their mutable counterparts.

The standard library should be the intersection of the Kotlin JVM and JS
standard libraries. Nothing more, at least at first.

Any reflection facilities should be in a separate, optional library. I want to
be able to ship an app without the slightest hint of run-time dynamism, to
keep Apple happy.

Memory management should be ARC. Period. This means we'll need a Weak
annotation.

Edit:

The ability to export Kotlin classes to ObjC, with control over the names of
classes and methods, and support for ObjC properties.

Basically, I want J2ObjC for Kotlin, but with no concrete collection classes
of its own, and generally much less of a runtime library.

------
jorgemf
Using kotlin in web pages, client side and server side could be a big win. You
could be able to use exactly the same language in all you stack. Although
programming for the frontend will be different than programming for the
backend, the fact that any of them can review the code of the others is great.
You could also move resources in peak times to help a little.

~~~
superzadeh
> use exactly the same language in all you stack

isn't this what people are doing with JavaScript?

~~~
mathw
It is, but the problem with that is that they're doing it in JavaScript.

Kotlin could offer better performance and certainly offers strong type safety
throughout the stack, which I at least certainly believe gives a better
programming experience.

~~~
hasenj
Have you tried TypeScript?

~~~
deno
Typescript is nice but its type system is not the strongest selling point.

For example this compiles without warnings:

    
    
       const foo: Promise<string|null> = Promise.resolve(null);
       const bar: Promise<string> = foo;
    
       bar.then((value) => value.toString()); // runtime null error

~~~
coldtea
That's because null is an acceptable value for a string object.

Which is the same thing as in Java and plenty of other languages.

~~~
ptx
Not in Kotlin, though. You have to make it explicitly nullable if you want it
to be null.

~~~
hasenj
You can enable strict null checking.

------
iammiles
As someone who learned Kotlin for work and then started using it in personal
projects, I'm really excited for its future. I'm surprised more Java shops
aren't espousing or even trying it.

------
jnordwick
Is Kotlin used outside of the web dev community?

(Real question)

~~~
herval
The most popular use is allegedly Android development, so... yes?

------
proyb2
If ARC is a concern, I wasn't sure how they will work on Android whereas
SCADE.io use Swift to compile native app to Android and iOS is more production
ready with Swift built on LLVM and Clang.

------
adrianlmm
Jetbrains is trying to chew to much, from Kotlin for the JVM, Kotling for
javascript and Kotling native, soon or later, it will implode and it won't be
nice.

~~~
coldtea
> _it will implode and it won 't be nice._

Hyperbolic much? At worst, it will fail to gain much traction.

~~~
adrianlmm
We disagree, "it won't be nice" is not a hyperbolic statement.

~~~
coldtea
The whole phrase "it will implode and it won't be nice" implies some kind of
big mess or even the company collapsing or whatever...

Whereas it's just one of the things the company does, not even a profitable
one, and at worst it will just fail to catch.

Sure, that "wont be nice either". But hardly the kind of "not nice" to be
really concerned with...

~~~
always_good
You're feeding a known troll. Look at their post history.

~~~
adrianlmm
I didn't know that not falling for the Jetbrains marketing machine was
catalogued as being a troll. I beg to differ.

~~~
coldtea
The "Jetbrains marketing machine"? I could spend my whole life, visiting tons
of programming forums and websites, and hardly see a Jetbrains ad ever.

~~~
adrianlmm
You are wrongly assuming that their marketing team only use ads.

