val list = listOf("Saab", "Volvo") val map = mapOf("firstName" to "John", "lastName" to "Doe") The above seems a really strange decision for a "new" language - why would you not just use the most common structure, being JSON?
Perhaps worth noting that none of that is langauge syntax, it's library syntax. mapOf takes vararg pairs: Pair , and then the 'to' operator is an infix function that makes a Pair . So you could trivially do your own listOf or mapOf that creates whatever data structure you want, whereas languages with special syntax for this tend to hardcode the result of it. That's a valid choice, sure, but just that there are tradeo…
From Java to Kotlin and Back Again
91–100 of 199 posts
Re: From Java to Kotlin and Back Again
#92I suspect type declaration order is a deeply personal preference. I hate C-style type-first declarations with a passion; type-last declarations have always felt more readable and natural to me.
Re: From Java to Kotlin and Back Again
#93Re: From Java to Kotlin and Back Again
#94To add to the authors list: time kotlinc Hi.kt user 4.5s !! (OK IN IDE on second run) trailing comma not allowed no python like package manager. import mail? no a = b = 1 // assignments are not expressions
Assignment being an expression is a dangerous misfeature in a language with mutable data. It is a good thing to get rid of them, and all reasonable compilers already throw a warning if a program relies on this behavior.
Re: From Java to Kotlin and Back Again
#95The biggest red flag IMHO with Kotlin is the teams disinterest in supporting the language server protocol. They are taking a very insular approach to the ecosystem just like Microsoft used to with .Net. The world has moved on a bit from that mindset, but they are completely happy with coupling the experience to their companies IDE...
Even if they did support it, you'd be getting a much worse experience with other tools than just using IntelliJ anyways. Given that they've gone through the trouble to write an entire programming language & the amount of value it provides, I really don't mind them trying to use it to push people towards their products a bit. Especially since both IntelliJ Community and the Kotlin plugin are open source.
I don't mind them doing this either. I just find the thinking outmoded, and I also don't mind just not using Kotlin. And to clarify, it's not just the decision to not support language server protocol at this time; it's their reaction to the mere suggestion of it. The language steering is too coupled to the biz IMHO. For what it's worth, I feel the same way about F# and the Visual F# Power Tools team and is the prior experience that raises the red flag.
Re: From Java to Kotlin and Back Again
#96Earlier quoted context omitted.
It's still pretty much invective (seriously, hateful?) and an invitation to a dumb programming language poop-flinging fest. As to the author of the thing, they just wrote about not liking Kotlin, you're the one who is taking this as some sort of personal affront. How do you know how long they spent learning it? You don't.
Maybe it is just me but when I critique things then I make sure that I am 100% right. This article, in its current form, can do a lot of harm for people who will read it and decide not to try Kotlin because author has had some problems with Kotlin. Problems that are really easy to get pass by if one reads the documentation and really learns the language with an open mind.
Re: From Java to Kotlin and Back Again
#97Earlier quoted context omitted.
Perhaps worth noting that none of that is langauge syntax, it's library syntax. mapOf takes vararg pairs: Pair , and then the 'to' operator is an infix function that makes a Pair . So you could trivially do your own listOf or mapOf that creates whatever data structure you want, whereas languages with special syntax for this tend to hardcode the result of it. That's a valid choice, sure, but just that there are tradeo…
how can a newly designed language not make lists and maps first class citizens?
Re: From Java to Kotlin and Back Again
#98Re: From Java to Kotlin and Back Again
#99Is it me, or does the article feel like it is written by someone who didn’t actually bother to learn Kotlin. Instead they learnt the bare minimum syntax and tried to write Java in Kotlin. The author complains a lot about how Kotlin is different from Java. Err.. it is a new language — it is supposed to be different — otherwise why bother? > I have my favorite set of JVM languages. Java in /main and Groovy in /test are…
Kotlin advocates try to have it both ways. If it's a full new language, to be evaluated as a full language, then why would you adopt it when it's missing important features compared to Scala? The narrative is that it's a set of small enhancements to Java that are easier to pick up than Scala, but the reality doesn't live up to that.
Re: From Java to Kotlin and Back Again
#100I work in Kotlin and Java and have opinions on both. Some feedback... I disagree about the name shadowing issue. In fact, I wish Kotlin didn't suck so hard and not allow me to ignore those warnings specifically. My primary use for name shadowing is so that I don't use the previous variable. This may be a bit strange, but in highly functional contexts with immutable variables, shadowing a name is reasonable especially…
Agree about the shadowing.
var x_2 = f(x_1) // never use x_1 again for anything
deserves its own syntax and compiler checks