Live data from Hacker News

Kotlin is like TypeScript

gi-no.github.io

21–30 of 49 posts

Re: Kotlin is like TypeScript

#23

    name: string;
    constructor(name: string) {
        this.name = name
    }
You don't have to do this in TypeScript either, you can just do

    constructor(public name: string) { }
Also, the "Empty collections" section doesn't do the same thing, the collections you created in Kotlin are immutable.

And the TypeScript ones have the value `undefined` (unfortunate that strictNullChecks doesn't catch things like that https://github.com/Microsoft/TypeScript/issues/8476).

And for some nitpicking, please be consistent with your semicolons, either use them or don't use them, but don't mix it randomly like that.

Re: Kotlin is like TypeScript

#24
post #3

TypeScript has structural typing, that is a HUGE difference.

Ya, I'm not away of any other popular OO language that goes this route. The implications of structural sub-typing are huge, though I guess many programmers wouldn't be able to call it out.

Scala has it. With Shapeless, you can go all crazy with it.

Re: Kotlin is like TypeScript

#25

Earlier quoted context omitted.

Kotlin, Swift, and TypeScript have modern features like type inherence, null-safe, closure, and are supported by big company.

> type inherence, null-safe, closure Modern? Are you serious?

I laughed so hard :D

Re: Kotlin is like TypeScript

#28
post #17

Earlier quoted context omitted.

> modern features like type inherence, null-safe, closure This is one of the more annoying problems with our industry. People rediscover solutions from 60s and 70s and sell them as if they were new and revolutionary...

Still waiting for web developers to rediscover 90's RAD tooling.

I don't think we're ever going to go back to that. Those UIs were pretty static, i.e. you only created the "initial state" in the UI designer, and then modified it during the application run-time (sometimes even creating new widgets in code), or attached some kind of data-binding models to it.

With the popularity of things like React, you now have a powerful way to express how the UI looks in every state, not just the initial one.

Re: Kotlin is like TypeScript

#30
post #3

TypeScript has structural typing, that is a HUGE difference.

Yes, that would be its biggest differentiator.

Scala has it too indeed, but it's not the default mode and feels awkward, also has known limitations.

The nice thing with typescript is that structural typing makes sense for 90% of the use cases, and for the remaining 10%, you can very easily simulate nominal typing by adding a field like so:

interface Robot { __Robot: true }

Post reply on HN