diesieben07
12/21/2019, 10:05 PMtype Foo = "foo" | "bar"
cannot be expressed in Kotlin).
Another thing that I have noticed is that the kotlinx libraries (ktor, kotlinx.serialization, io) and the stdlib seem to think that they should be polyfilling things themselves if they are missing in the underlying platform. This leads to things like <http://kotlinx.io|kotlinx.io>
requiring an outdated npm library (text-encoding
) using dynamic calls to require (what if the underlying module system is not commonjs?) if the global TextEncoder
API is not found. Instead it should be the user's responsibility (based on their browser support demands) to load an appropriate polyfill if required.
There are great tools (babel and their preset-env) that make it so you can transpile modern Javascript code to run on older browsers and polyfill missing APIs (using core-js). Kotlin should imho use this amazing toolchain, instead of re-inventing the wheel.
</rant>Quy D X Nguyen
12/21/2019, 11:18 PMbjonnh
12/21/2019, 11:59 PMfkrauthan
12/22/2019, 12:56 AMbjonnh
12/22/2019, 2:02 AMQuy D X Nguyen
12/22/2019, 5:41 AMdiesieben07
12/22/2019, 12:40 PMKotlin is simply too far removed from JS semantics to be overly efficent.This just isn't true. • JS has classes (which Kotlin does not leverage - why not?). • The number type problem is solved (double works anyways, float can be emulated using Math.fround, int and lower can be done already using things like
Math.imul
. and now we even have bigint for longs)
• Ecmascript modules allow exporting and importing single functions, classes and variables, this allows a very clear 1:1 mapping from .kt to .js files:
val foo = "bar"
private val baz = "private value"
fun foo() {
}
turns into
export const foo = "bar";
const baz = "private value"; // no export here
export function foo() {
}
These (simple?) changes would already make life a lot easier. Combine that with a kotlin-loader
for webpack and suddenly you have kotlin has a first-class citizen in the modern web-development world instead of a "foreign tumor", which infects everything (you have to use gradle now? Tell that to a web developer!)diesieben07
12/22/2019, 12:54 PMdiesieben07
12/22/2019, 12:56 PMdynamic
everywhere).Quy D X Nguyen
12/22/2019, 2:14 PMdiesieben07
12/22/2019, 2:24 PMfun foo(a: String)
fun foo(a: Int)
turns into
function foo$mangled1(a)
function foo$mangled(a)
function foo(...args) {
if (args.length === 1) {
const a = args[0];
if (typeof a === 'string') return foo$mangled1(a) ... etc
} else {
throw new TypeError()
}
}
That is how overloading is done in JS. It's ugly, but that's why we have a compiler.diesieben07
12/22/2019, 2:25 PMthe vision JB has for JS right now is heading into a closed or limited ecosystem.I really hope not. This would imho be the "death" for Kotlin/JS. It also goes against Kotlin's explicit goals: Work in tandem with the underlying platform, whichever it might be.
Quy D X Nguyen
12/22/2019, 3:00 PMdiesieben07
12/22/2019, 3:13 PMepabst
12/24/2019, 1:59 PMdiesieben07
12/24/2019, 2:04 PMdiesieben07
12/24/2019, 2:19 PMdiesieben07
12/24/2019, 2:21 PMdiesieben07
12/24/2019, 2:33 PMcreate-react-kotlin-app
and it is not used by the Kotlin gradle plugin when creating a browser-js target...diesieben07
12/24/2019, 2:34 PM.kt
files.epabst
12/29/2019, 5:19 AMdiesieben07
12/29/2019, 1:21 PM