Better HN
topnewbestaskshowjobs
Log inSign up

ghostc0der

44 karma · joined Aug 23, 2016 (10y ago) · 4 submissions

Submissions

comment 8y ago · link · parent

Poverty is a systematic problem. Poor families do not have the time or money to give their children opportunities to succeed. Everyone should have a voice in politics. Not just the the people who are born into wealth.

comment 9y ago · link · parent

Jetbrains has been using Kotlin in house since at least 2011. At my company we started using Kotlin when it turned 1.0 in Feb 2016. It's been a huge success with programmer productivity and happiness. Currently have 18000+ lines of Kotlin in production. Whenever given the chance we refactor large Java classes that are 1500ish lines to 300ish lines of Kotlin.

Compared with switching from Obj-C to Swift, the transition was relatively seamless. No bridging header for interop with Java. Also Android Studio/IntelliJ has very mature language support for Kotlin that should keep most IDE driven developers happy.

comment 9y ago · link · parent

State machines aren't even Turing complete. Even if they where, that doesn't mean we should be using them to program Von Neumann machines. Building levels of abstraction just helps you get more work done. Otherwise you might as well go back working in a tarpit (https://en.wikipedia.org/wiki/Turing_tarpit).

comment 9y ago · link · parent

"Actually, I wouldn’t care about for if there was an alternative. But there isn’t one."

Learn the collections library. https://kotlinlang.org/docs/reference/collections.html All loops can be written in terms of them. Also because of inlining they have have the same runtime costs as hand written for loops.

"Smart cast to ‘Int’ is impossible, because ‘value’ is a mutable property that could have been changed by this time"

Smart casts only work on immutable values because of concurrency. If the variable hast to be mutable use ?.let { ... } instead of smart casts.

What's wrong with two exclamation points? If you're using it you are probably doing something wrong anyway.

When getting a type from Java that hasn't been annotated as @NonNull or @Nullable it is regarded a platform type. This means it's programmers responsibility to check if it can be null. Same as in Java or any other language that doesn't have nullable types.

Assignment is not an expression. We've written 20K of production Kotlin code without this ever being a useful convention. Assignment being an expresssion is layover from the C family of languages. If you really want C's syntax and semantics, go write C.

The ?: operator is great when chaining a bunch of operations all of which could return a null which we want to convert to a default. Here is an example: claimData?.claimTimeMinutes?.toLong() ?: 5L

Generics in Kotlin have the same issues as Java because of type erasure. It does offer a few improvements with the use of reified type variables.

Lastly, if you want to have descriptive structures use data classes.

This guy just wants to program in C. If it's not C it's crap according to the article.