News for hackers. Stuff that matters.
Re:Kotlin 1.1: What’s coming in the standard library by bsaul on Wednesday January 25, 2017 @03:28AM (#13479729)
I'm really not proficient with the jvm ( my only experience with it has been slow start time and huge memory consumption).

Could you give some example oF unique features of the toolsuite around the jvm ?

Re:Kotlin 1.1: What’s coming in the standard library by mike_hearn on Wednesday January 25, 2017 @04:13AM (#13479934)
JVM can run "Hello World" in about 50msec these days. The java guys do care about startup time, you can see if you read their mailing lists that they are constantly trying to defend their startup time as new features come in that add initialisation work. It's a priority.

Still, the reason many Java apps may feel like they start slowly is that they tend to do a lot. The app I'm currently working on starts in about 5 seconds, which isn't terrible by the standards of the space but isn't great either. But the reason is that that 5 seconds involves initialising an entire message queue broker, an entire relational database and an entire web server. These aren't tiny 'embedded' versions either: they're Artemis, H2 and Jetty, which are both also used standalone and have cutting edge featuresets. If we weren't using the JVM then we'd presumably be using some container based solution and starting postgres, some other MQ broker and apache or something. Bringing up such a container from scratch could easily take 5 seconds or more I think.

The JVM will by default use all the memory on your machine. This is an unintuitive default, to put it mildly. The reason is that the JVM can make your software run faster by using more memory. Doubling RAM is easy. Doubling your CPU cores whilst keeping them actually used is hard, doubling the speed of an individual CPU core at this point appears to be nearly impossible. So it makes sense in a technical way. But it does make it hard to judge memory bloat.

Again, speaking about the app I currently work on, I got a support request the other week from someone who wanted to run the app on a Raspberry Pi and was complaining it took much memory. Quick testing showed we actually only needed about 50-75mb of heap and simply telling the JVM to limit the Java heap to that size slaughtered memory usage and resolved the problem. Not hard to check that and configure things for small devices, but it's a knob you can't/don't need to twist when using manual memory management, or GCs designed for mobile/laptop devices where minimising memory usage took priority over raw runtime performance.

Re:Kotlin 1.1: What’s coming in the standard library by vbezhenar on Wednesday January 25, 2017 @05:42AM (#13480310)
Honestly 5 seconds is an eternity when it comes to modern processors. I'm not convinced that it's a norm and I'm still wondering, what really happens, where that time goes?

"initialising an entire message queue broker, an entire relational database and an entire web server" is just abstract words. Initialization of an entire web server is creating a socket and binding it to 80 port, that's what should be done, but what else happens? Initializing a relational database is something like opening a file. May be read journal, rollback unfinished transaction, but those things could be done after initialization.

I use Java and I'm always trying to improve startup time. Last time I used undertow for tiny project, with jdbc to access remote database. Project started in mere milliseconds and it was much easier to iterate. But every time I enable something monstrous like servlets, hibernate, spring or, save god, java ee, it's always 30+ seconds start time. And I always wondered, why that's happens? I can serve millions of customers in those 30 seconds, I can read gigabytes of data from my HDD and parse millions of XMLs.

Re:Kotlin 1.1: What’s coming in the standard library by pron on Wednesday January 25, 2017 @06:00AM (#13480383)
It's not so much the startup time (which is ~60ms), but warmup time. Assuming you're using a JITting JVM, it's compiling. There's now work on AOT compilation in HotSpot (and some JVMs already have it), but it really doesn't matter for big, long-running server apps, which are currently HotSpot's forté.
Re:Kotlin 1.1: What’s coming in the standard library by mike_hearn on Wednesday January 25, 2017 @07:57AM (#13481007)
I haven't done startup profiling in detail but I'd expect most of the time to go on waiting for IO. CPUs are fast but opening a database, checking disk for queued messages etc is slow. Startup involves querying the database in our app, so the DB can't do that work after initialisation. There's also network traffic and RPCs happening in that 5 seconds too.

Without a doubt also some algorithmic waste in various libraries that aren't optimised for startup time. Startup time is rarely a metric that products compete on outside the consumer space, so improving it is not normally a priority.

And then yeah, finally the lack of AOT compilation. When Java 9 rolls around I plan to try and see how much difference it makes.

Re:Kotlin 1.1: What’s coming in the standard library by grandinj on Wednesday January 25, 2017 @05:23AM (#13480232)
Always good to hear H2 has cutting edge featuresets :-) (I'm one of the devs)
Re:Kotlin 1.1: What’s coming in the standard library by mike_hearn on Wednesday January 25, 2017 @11:21AM (#13482694)
H2 is really nice. We did hit a bug the other day though. When write delay is set to zero compaction never occurs.
Re:Kotlin 1.1: What’s coming in the standard library by MrBuddyCasino on Wednesday January 25, 2017 @09:02AM (#13481393)
I'd like to take the opportunity and say thanks! Its a fine piece of software.
Re:Kotlin 1.1: What’s coming in the standard library by pron on Wednesday January 25, 2017 @04:24AM (#13479981)
Sure. The ability to inspect what the system is doing and interact with it while it's running full-speed is unparalleled, and only pulling further ahead than anything else out there. Just take a look at monitoring tools like VisualVM, or Java Flight Recorder, which is part of the Oracle JDK and free for development use. You can inject and take out code at runtime, and the same monitoring and management API, JMX, is standard and used by everything from the JVM, the JDK libraries, various frameworks, and all the way up to the application code. With the proper tools, you can record everything your app is doing with very little overhead.

In addition, the GCs and the compiler are pretty much the best in the business, and the next-gen compiler, Graal, is probably the biggest breakthrough in compiler technology of the past decade. Apart from jaw-dropping optimizations, it lets you control machine code generation.

Last but not least, critical parts of the standard library (though not all of it) -- such as the concurrency packages, which contains schedulers and concurrent data structures -- are of quality that is hard to match.