MCE2015: Kotlin Session and JetBrains Booth

February 5th and 6th, MCE2015 takes control of the iconic Kinoteka cinema at the Palace of Culture and Science in Warsaw, Poland. Initially a conference for developers by developers, this year’s event expands to embrace all mobile creators – developers, designers and tech leaders.

At MCE2015 and JetBrains booth will be Anastasia Kazakova, Maxim Medvedev and Svetlana Isakova, who has a talk at the conference. Come by and learn about the latest advancements in our tools for mobile development including: Kotlin for Android and AppCode with Swift support. You may also be interested in having a look at our recent interview with Maxim discussing Swift support in AppCode.

Be sure to catch our Kotlin session on the second day of the conference.

Svetlana IsakovaKotlin, the Swift of Android

Presented by Svetlana Isakova
February 6th, 15:00, Auditorium 3

Apple has introduced “a better language” for iOS developers. But what options do we have for Android? Surely, Kotlin should be under consideration! Android Studio is now based on IntelliJ IDEA, the “native” environment for Kotlin.

Kotlin can help you reduce the amount of code you write for Android applications and at the same time make it readable and more maintainable. In this session we’re going to see how certain constructs and DSL’s can be used to make Android more enjoyable.

Posted in General | Tagged , , , | 2 Comments

JavaScript Interop

When working with JavaScript, i.e. creating a Kotlin application that compiles down to JavaScript, we often need to interoperate with existing libraries in JavaScript. While Kotlin already provides support for this, we’ve added a few more options in M10 to make interoperability even easier.

Dynamic support

In M10 we’ve added the dynamic keyword[1] which allows us to declare types as dynamic, permitting certain interoperability which previously could be more cumbersome. For instance, when working with jQuery, up to M10, our only option was to use the strongly typed libraries that Kotlin provides. As for M10 we can now use the dynamic keyword too

The code above calls getJSON function on jQuery to return a list of commits from GitHub. The function takes a lambda with a single parameter, which is the actual commits. Each entry in this list is in turn a commit entry with its own fields such as html_url or commit.message.

In the code jQuery, commits and commit are all dynamic, which means that anything we call on these will be resolved at runtime, i.e. by the JavaScript interpreter. This allows for two things:

  • Not have to use a strongly-typed library to work with jQuery
  • Be able to consume model that hasn’t previously been defined

The second ability is quite useful since it means that we don’t have to create intermediate strongly-typed classes to consume HTTP endpoints.

Of course, we could even use language constructs such as for loops to do the same thing, not only using the forEach extensions function.

In order for this code to work however, we still need to declare jQuery as dynamic, and mark it with the corresponding native equivalent for Kotlin to call

The noImpl is required since non-nullable variables in Kotlin need initializing, which in this case would be throwing an exception, however this never occurs since it is effectively being compiled down to JavaScript and called on the client-side. The native annotation which already existed pre-M10 is telling Kotlin what the identifier is equivalent to in JavaScript.

Operators

When declaring dynamic types, certain operators act natively in JavaScript, such as for instance index accessors:

would be compiled to:

in JavaScript.

Inlining JavaScript code

Another feature we added in M10 is the ability to inline some native JavaScript code in Kotlin code. We can do this using the js function:

The second line inserts console.log(‘Calling JavaScript’) in the output resulting from compilation, interlining JavaScript with Kotlin code.

Language Injections

M10 also added Language Injection support in IntelliJ IDEA for Kotlin. And while this applies to any string and any language, not just JavaScript, it definitely proves useful when using js, allowing this:

js-string

to look like this:

js-injected

when injecting JavaScript language:

inject-js

Summary

In addition to dynamic and js, we also introduced support for nativeGetter,nativeSetter and nativeInvoke annotations for JavaScript, which we already covered in the M10 release post.

These new features are all provided for better interoperability with JavaScript, but they do not trump any plans to continue to provide strongly-typed support for existing libraries and frameworks in JavaScript.

[1]
“dynamic” is a soft keyword:

  • if it occurs in a non-type context, it’s an identifier
  • in a type context, when followed by a dot (except for a dot that separates a receiver type from a function/property name) or an angle bracket <, it’s an identifier
  • on the left-hand-side of :: in a callable reference: dynamic::foo implies that dynamic there is a normal identifier
Posted in General | Leave a comment

M10 is out

Right before the festivities start, we’ve managed to release the next milestone of Kotlin, adding dynamic types and more. Let’s see what M10 brings us. Continue reading

Posted in General | Tagged | 25 Comments

M9 is here!

M9 has arrived and it’s bringing many new features and important changes. We’ve already highlighted these and covered others in detail. Let’s dig deeper into some of the other improvements.
Continue reading

Posted in General | Tagged | 12 Comments

Making Platform Interop even smoother

Being 100% interoperable with the JVM, and subsequently with JavaScript, has always been among Kotlin’s top priorities. With the amount of existing code, and a rich JVM ecosystem, having the ability of interoperating and leveraging these is crucial. Continue reading

Posted in Uncategorized | 30 Comments

M9 is coming

We’ve been working hard on the next upcoming release for Kotlin, M9, and it contains quite a good number of new features and some important changes. Continue reading

Posted in General | 15 Comments

Full-Day Kotlin Workshop October 6th in Malmö, Sweden

Edument_1Edument, a JetBrains Training and Consulting Partner, will be providing a full day of Kotlin hacking on Monday, October 6, 2014, in the lovely city of Malmö.

The hands-on workshop will begin by walking through the basic syntax, and work its way towards unit testing and language features such as object orientation and functional programming. In the afternoon we will consider use-cases such as writing a domain-specific language and seeing how the syntax and semantics of Kotlin help with some common problems that you may encounter in languages such as Java and C#.

Snacks and drinks will be provided during the day.

Space for this Kotlin Workshop is limited; learn more and register now

Posted in General, Uncategorized | Tagged , , , | Leave a comment

A New Open Source Web Site

We have a new web site and a new domain!

Main Page

It’s Open Source

It would make no sense to be developing a language that is Open Source and not having an Open Source web site and documentation. We worked by gradually porting all the old site from the previous platform to Jekyll. The new site is all written in Markdown (actually Kramdown, a flavour of Markdown) and hosted on GitHub. In fact, we’ve made it really easy to contribute. On nearly every page there is an Edit Page icon: Continue reading

Posted in General | Tagged | 9 Comments

M8 is out!

It’s been a really busy couple of months since the last release and we’ve been working hard on making substantial improvements, particularly in terms of speed. We have a lot of goodies for this release. Let’s get started Continue reading

Posted in General | Tagged | 24 Comments

Kotlin gets support for S-expressions

Kotlin is always happy to learn from other programming languages, and this is why we decided to support S-expressions, the empowering concept of LISP.

The main motivation behind this is the compatibility with Clojure, the LISP for the JVM. Clojure is well-known for its solid libraries, particularly the ones used for concurrency and read-only data structures.

To facilitate interoperability with LISP (and Clojure libraries in particular), Kotlin now allows expressions like this one:

This is only to give you the taste. Now, let’s explain the constructs one-by-one. Continue reading

Posted in Uncategorized | 21 Comments