All Projects → wojta → hello-kotlin-multiplatform

wojta / hello-kotlin-multiplatform

Licence: other
Multiplatform Kotlin Hello World (Android/Java/JavaScript)

Programming Languages

kotlin
9241 projects
shell
77523 projects
java
68154 projects - #9 most used programming language
HTML
75241 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to hello-kotlin-multiplatform

KotlinMultiplatformAndoridParcelize
Use the Parcelize Annotation of the Kotlin Android Extensions in Kotin Multiplatform projects
Stars: ✭ 16 (-75%)
Mutual labels:  kotlin-js, kotlin-multiplatform
SevenFacette
7Facette is an open-source multiplatform test automation library supporting JVM and JS.
Stars: ✭ 28 (-56.25%)
Mutual labels:  jvm, kotlin-multiplatform
tmdb-api
This Kotlin Multiplatform library is for accessing the TMDB API to get movie and TV show content. Using for Android, iOS, and JS projects.
Stars: ✭ 31 (-51.56%)
Mutual labels:  kotlin-js, kotlin-multiplatform
thelema-engine
Thelema - 3D graphics engine, written in Kotlin. Based on sources of libGDX.
Stars: ✭ 51 (-20.31%)
Mutual labels:  kotlin-js, kotlin-multiplatform
kotlin-multiplatform-example
A Kotlin multiplatform example app that targets Android, ReactJS, iOS, JavaFx, and Spring Boot
Stars: ✭ 115 (+79.69%)
Mutual labels:  kotlin-js, kotlin-multiplatform
Lastik
Kotlin Multiplatform + Jetpack Compose pet project, based on www.last.fm/api (in development)
Stars: ✭ 37 (-42.19%)
Mutual labels:  jvm, kotlin-multiplatform
2p-kt
A Kotlin Multi-Platform ecosystem for symbolic AI
Stars: ✭ 52 (-18.75%)
Mutual labels:  jvm, kotlin-multiplatform
Sheasy
This an Android App that helps you share/manage your files on your Android Device through a WebInterface in the Browser - Built with Ktor and Kotlin-React
Stars: ✭ 34 (-46.87%)
Mutual labels:  kotlin-js, kotlin-multiplatform
Friceengine
🎮 JVM game engine based on Swing/JavaFX.
Stars: ✭ 330 (+415.63%)
Mutual labels:  jvm, platform-independent
crypto
A collection of Kotlin Multiplatform Mobile cryptographic hashing functions.
Stars: ✭ 45 (-29.69%)
Mutual labels:  jvm, kotlin-multiplatform
kfsm
Finite State Machine in Kotlin
Stars: ✭ 76 (+18.75%)
Mutual labels:  kotlin-js, kotlin-multiplatform
KmLogging
Kotlin multiplatform logging. High performance, composable and simple to use.
Stars: ✭ 21 (-67.19%)
Mutual labels:  jvm, kotlin-multiplatform
metrics-agent
JVM agent based metrics with Prometheus and Dropwizard support (Java, Scala, Clojure, Kotlin, etc)
Stars: ✭ 25 (-60.94%)
Mutual labels:  jvm
hsbeat
Beat for Java HotSpot VM
Stars: ✭ 24 (-62.5%)
Mutual labels:  jvm
codeforces watcher
Mobile client application for Codeforces competitive programming platform.
Stars: ✭ 81 (+26.56%)
Mutual labels:  kotlin-multiplatform
dev-feed
Flutter-based mobile app displaying a list of daily curated content from top engineering blogs and articles. Backed by a GraphQL-based API written in Kotlin..
Stars: ✭ 20 (-68.75%)
Mutual labels:  jvm
fluid-react
Highly experimental Kotlin wrapper for React
Stars: ✭ 12 (-81.25%)
Mutual labels:  kotlin-js
scalecube-config
ScaleCube Config is a configuration access management library for JVM based distributed applications
Stars: ✭ 15 (-76.56%)
Mutual labels:  jvm
Penicillin
Modern powerful Twitter API wrapper for Kotlin Multiplatform. #PureKotlin
Stars: ✭ 91 (+42.19%)
Mutual labels:  kotlin-multiplatform
JavaYouth
主要是Java技术栈的文章,涉及到了源码、原理,面试等知识。如AQS,JVM,rpc,计网,os等等,后续可能会写mysql,redis,zk这些
Stars: ✭ 616 (+862.5%)
Mutual labels:  jvm

CircleCI

Multiplatform Kotlin Hello World

This project demonstrates sharing runtime independent code between different Kotlin's runtimes (Java/Android/JavaScript). It uses Gradle build engine.

It uses new support for multiplatform modules with plugin kotlin-multiplatform.

Applications are built using features available from Kotlin 1.2 regarding multiplatform modules - see this blog posts:

Older implementation that didn't use kotlin-multiplatform plugin and various hacks was moved to old-multiplatform branch. Oldest implementation that used various hacks was moved to old-multiplatform branch.

What is Kotlin?

Kotlin otlin is a programming language developed by Jetbrains. It's fully compatibile with Java runtimes and also there is support for JavaScript transpilation. Experimental version of Kotlin/Native has goal to also build fully native apps for iOS, Linux, Windows and possibly other platforms.

What is it doing?

  • writes Hello Kotlin!
  • calculates first 1000 prime numbers (this part is shared between runtimes) and prints them

Structure

It's the Gradle multiple modules project.

  • hello_android_app - Android application module, it's compiled to DEX bytecode, it produces APK file upon build
  • hello_js_browser_app - application transpiled for frontend JavaScript, packed in WebPack, it's only statically served by Node.js
  • hello_js_node_app - console application transpiled to Node.js JavaScript
  • hello_jvm_app - console application compiled to Java bytecode for JVM, produces JAR that can be executed by eg. Oracle JVM
  • hello_lib - multiplatform library project, with shared and platform specific code
    • commonMain - shared Kotlin source code, platform independent code
    • commonTest - shared tests, platform independent tests
    • jsMain - JavaScript runtimes platform dependent code
    • jsTest - JavaScript runtimes specific tests
    • jvmMain - Java runtime platform dependent code
    • jvmTest - Java runtime specific tests
    • androidMain - Android runtime platform dependent code
    • androidTest - Android runtime specific tests

Modules dependency

Platform implementation specifics

  • prime number calculation is platform independent, single code shared for all platforms
  • text output on screen is platform dependent
    • Android - it's done by adding with TextView to layout
    • Frontend JavaScript - it adds element in DOM of HTML page
    • Node.js JavaScript - uses console.log()
    • JVM - uses System.out.println()

Note: Ordinary console output can be done by println() function from Kotlin Standard Library.

Implementation in modules

Building and running the demo

It was checked only under Linux Mint, probably there won't be any problems with most Unix-like environments.

Android application

You can use Android Studio to run the application. To build from command line, you can use

# ./gradlew hello_android_app:build

and APK file is located in your build/outputs/apk directory.

Hello Android

JVM console application

# ./gradlew hello_jvm_app:build

You can than run the JAR file using java -jar hello_jvm_app.jar command from build/libs directory.

Hello JVM

Frontend JavaScript application

# ./gradlew hello_js_browser_app:build

Webpack allows to host site directly from Gradle by

# ./gradlew hello_js_browser_app:run 

It will run locally on http://localhost:8088/.

Hello JavaScript Browser

Node.js console application

# ./gradlew hello_js_node_app:build

You can execute it in hello_js_node_app directory by:

# node ./app.js

Hello JavaScript Node.js

to see all build options

# ./gradlew tasks --all

License

Do whathever you want with this.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].