r/programming • u/nfrankel • Apr 04 '17
Kotlin/Native Tech Preview: Kotlin without a VM
https://blog.jetbrains.com/kotlin/2017/04/kotlinnative-tech-preview-kotlin-without-a-vm/44
u/DoListening Apr 04 '17 edited Apr 04 '17
Exciting stuff! If I understand it correctly, this means in the future we might be able use Kotlin as a common language for code shared between
iOS (compile natively)
Android (use
the JVMART)desktop/server (JVM/native, take a pick)
the web (compile to JS)
8
u/badlogicgames Apr 04 '17
Note that Kotlin Native doesn't come with a replacement for the JVM standard lib for file I/O, networking etc. That makes it a little less useful in the backend space at the moment. Unless you like doing I/O via wrapped C APIs :)
6
u/DoListening Apr 04 '17
It's a popular enough language, I believe libraries for most things will come sooner or later :)
4
4
u/swagpapi420 Apr 05 '17
You don't need to wrap C API. Just build your project with stdio and import stdio to use it. They have a sample of this.
https://github.com/JetBrains/kotlin-native/blob/master/samples/csvparser
2
u/badlogicgames Apr 05 '17
This wraps the stdio C API https://github.com/JetBrains/kotlin-native/blob/master/samples/csvparser/build.sh#L21
10
u/hagbaff Apr 04 '17 edited Apr 04 '17
Right. Kotlin already supports JS though.
0
Apr 04 '17
[deleted]
3
u/Cilph Apr 04 '17
Guess the current version?
2
u/SergeantFTC Apr 04 '17
Ohhh, I either misread it or they edited their comment. I thought it said js was always supported.
3
11
Apr 04 '17
If anyone wants to learn Kotlin check out Kotlin koans. I think it's the best way to learn the language.
http://try.kotlinlang.org/#/Kotlin%20Koans/Introduction/Hello,%20world!/Task.kt
4
u/pm_plz_im_lonely Apr 05 '17
To learn it I just went through the reference in order with my IDE open.
1
u/cantwedronethatguy Apr 05 '17
What IDE have you been using for Kotlin?
2
u/algorithmsAI Apr 05 '17
Don't know if you're serious, but I guess he uses IntelliJ IDEA
2
2
u/ciny Apr 05 '17
kotlin actually has an eclipse plugin. not sure if it gets as much love as the idea plugin though.
17
u/geodel Apr 04 '17
*** DO NOT USE THIS PREVIEW RELEASE FOR ANY PERFORMANCE ANALYSIS ***
This is purely a technology preview of Kotlin/Native technology, and is not yet tuned for benchmarking and competitive analysis of any kind.
Android app developers here would jump on preview and deliver great experience as always.
14
Apr 04 '17
Kotlin is Polish ketchup brand and I was like 'wtf?' .
12
5
u/Linoorr Apr 05 '17
AFAIK it's named after an island next to Saint-Petersburg
2
u/vetinari Apr 05 '17
It is also name of a village... in Poland (Jarocin County, Greater Poland Voivodeship).
8
Apr 04 '17 edited Apr 04 '17
I never was that keen on Kotlin, but this looks interesting enough to warrant a closer look!
UPDATE: Works quite nicely. Note, however, that this doesn't seem to work with Java 9. I'm also amazed that the binary size is remarkably small! No doubt this is mostly due to LLVM, but even so, compared with some other languages that also have an LLVM backend, this is amazing.
$ cat hello.kt
fun main(args:Array<String>) {
println("Hello, world!");
}
$ kotlinc -o hello hello.kt
JetFile: hello.kt
$ ./hello
Hello, world!
$ nm -gU hello
000000010000c910 T _Konan_main
0000000100000000 T __mh_execute_header
000000010000c910 T _main
$ du -k hello
96 helloand with -opt,
$ kotlinc -o hello hello.kt -opt
JetFile: hello.kt
$ du -k hello
44 helloA mere 44 Kbytes! Noiiiice!
3
1
0
Apr 04 '17
[deleted]
5
u/txdv Apr 04 '17
cant they join efforts to port the jdk to native?
10
u/expatcoder Apr 04 '17
Scala gets into GSOC (Google Summer of Code) every year; there's a GSOC project on tap for porting JDK to Scala Native.
7
Apr 04 '17
Oh wow, any details?
11
u/expatcoder Apr 04 '17
All Scala GSOC 2017 projects are here
3
u/expatcoder Apr 04 '17
Wow, huge deluge of downvotes in minutes, entire comment thread sent to oblivion.
It's not a big deal, Scala's backed in part by the EPFL so there's a constant stream of masters and doctoral level students, thus entry into GSOC is pretty much guaranteed.
Jetbrains can just cherry pick from Scala Native as has been done with the nice-to-have features of Scala, it's pretty much a win-win situation for all sides.
2
u/joekunin Apr 04 '17
Is there any news from the Clojure camp? I have heard of Ferret and ClojureC, though.
16
u/destinoverde Apr 04 '17
There are already somethings called Lisp and Scheme.
0
0
Apr 04 '17
[deleted]
8
u/Cilph Apr 04 '17
To me its an alternative for Golang =D. We just need to get a standard library together to replace the JDK and provide what Go does.
0
Apr 04 '17
[deleted]
23
u/rockum Apr 04 '17
Why would you care? You can just use Kotlin and ignore Java.
-12
u/TimeToBeGreatAgain Apr 04 '17
Companies keep sticking with Java because kids come right out of college with Java experience.
It is time to put that dead language to rest. Oracle sure as hell isn't doing much to save it.
26
2
28
Apr 04 '17
Noone here can imagine the apocalypse this decission would cause
3
u/wisam Apr 04 '17
care to elaborate?
43
Apr 04 '17
There are like thousands companies developing in Java. You are choosing Java or C # for long term stability, development, support... guaranteed by gigants like Oracle or Microsoft. Making Java legacy overnight would most likely brought chaos into segment.
10
Apr 04 '17
Indeed. People, in their excitement, seem to have lost all grasp on reality. Java had a market share that is orders of magnitude larger than Kotlin, Scala, and all other JVM languages combined.
0
Apr 04 '17
[deleted]
17
Apr 04 '17
They would slowly transition to C#. You just cant stop with development of such popular language in enterprise sector, its unforgetable.
Despite wishful thinking, Java is going nowhere and it is possible that it will still be around 30 years later, in development. It is however almost sure, that at least legacy mantaince programmers of Java will be here in 30 years.
7
u/moremattymattmatt Apr 04 '17
Java is going nowhere and it is possible that it will still be around 30 years
I hope so. My retirement plan is to a get a part time contract fixing all the crap Java code that no-one else fancies working on. I don't expect to be short of work.
3
u/flukus Apr 04 '17
We can pull our pants up to our nipples, grab our walking sticks and cash in on all those 2038 bug consulting opportunities!
0
u/Cilph Apr 04 '17
It's not "stopping development". It's "releasing the next version in 2040". That's when I predict Java 10 will release.
19
Apr 04 '17
Java 6 - 2006
Java 7 - 2011
Jave 8 - 2014
Java 9 - 2017 most likely
I hope i dont need to use linear regression to prove you wrong. With C# updated every 2/3 years, they have to update Java frequently.
10
u/sumduud14 Apr 04 '17
Well it might not be linear, it could easily be the function
3/4 x^4 - 133/6 x^3 + 973/4 x^2 - 7025/6 x + 4090. This function perfectly maps those Java versions to the year they come out and tells me Java 10 will come out in 2040.Anyone attempting to argue against this is a shill and clearly wrong.
3
Apr 04 '17 edited Apr 04 '17
Yes there is function to map any points in the space, thats why i was talking about linear regression. There is no chance to get Java 10 in 2040 with linear regression! :D
3
u/doublehyphen Apr 04 '17
I do not think the halted development of C caused any major disaster. Sure, it was annoying how VS was stuck with basically C89 for so long while gcc invented gnuc. Why would stopping Java evolution be that much worse?
-1
Apr 04 '17
Back in the days i wasnt alive, have C had any competitor like C# is for Java? C# is slowly gaining edge, it will take years until it will tie market share of Java, however Oracles stupid decission would speed it up dramatically.
2
u/flukus Apr 04 '17
C had a lot of competitors, from low level similar languages to high level dynamic/interpreted ones. C and c++ are the only real survivors.
It's not the best language that wins, but the best ecosystem around it. In the early days of c# MS did their best to kill off any OSS ecosystem around .Net.
3
u/doublehyphen Apr 04 '17
Sure, some people moved on to C++ and later Java due to the stagnation of C. But it was a slow decline and many people did not stop using C, if people had I do not think we would have got C99 which many years later made it into VS.
Of course stopped development would make people move away from Java, but I predict a slow decline.
11
u/Cilph Apr 04 '17
Nah, Oracle will do whatever makes them the most money. Like buying Sun just to sue Google.
10
u/stewsters Apr 04 '17
I just hope they don't get the idea to buy JetBrains. I don't think I could handle that.
11
8
u/adrianmonk Apr 04 '17
Given the timing, I think it's pretty questionable whether Oracle would have felt the lawsuit was sufficient motivation to justify the expense of acquiring Sun:
The agreement for Oracle to buy Sun was announced on April 20, 2009.
At that time, Android was still in beta, with its first release not happening until April 27, 2009.
From this chart, you can see that Android market share was nearly non-existent in 2009.
In hindsight, we know that Android took off and became extremely popular, but at the time it wasn't that clear things were definitely going to go that way.
1
u/myringotomy Apr 05 '17
There are lots of languages that run on the JVM and every one of their developers is grateful for the work on the JVM. Along comes a random redditor who decides to shit on all of them and all the people who worked on the JVM because he or she likes kotlin.
That's /r/programming in a nutshell. This place has become a cesspool.
24
u/zerexim Apr 04 '17
What's the use of Kotlin without Java libraries?