Hi everyone. Why in “kotlin in action 2nd ed” auth...
# getting-started
g
Hi everyone. Why in “kotlin in action 2nd ed” authors frequently mention “define variable”? I thought you can only define something that has a body, i.e. a type; and that body becomes the definition of it. For some things, like functions, declaration always coinsides with the definition, so in such cases, one can simply say declaration instead of declaration and definition. I think for variable it makes more sense to say “declare a variable”. Looking, for example, at go language reference, they also say “declare a variable”.
s
Hi, one of the authors here! We use "define" and "declare" rather interchangeably (the same with "member functions" and "methods", as I'm sure you'll notice later on). C-adjacent languages make a clearer distinction between the terms because AFAIR it's a matter of compiler/linker responsibilities. Saying "declare a variable" is obviously just as correct. Hopefully this won't stand in the way of your learning journey!
g
Hi @Sebastian Aigner thanks for the insights. No problem, it's just a bit irritating, especially when learning or using multiple language simultaneously. A bit unrelated, but I also find the concept of lambda (although long established) unnecessary. Function or function literal would suffice, as it's the same thing (as lambda). Why burden the mental model with more when you can do with less.
s
Lambdas are one of the core concepts in Kotlin, and we actually build on top of them, with functionality like lambdas with receivers, that become especially relevant when doing DSL-style abstractions. And while I can understand that some other phrasing might be potentially more intuitive, as you've mentioned yourself, it's a very established term in a lot of other programming languages as well, so we're hoping that people will find their way and keeping the established names will allow people to find answers quickly when googling, for example 🙂
h
sorry for hijacking the thread - but since you're around, @Sebastian Aigner... 😅 Do you happen to have any news about the release date of the 2nd edition? I am going to present Kotlin to a number of Java teams in our company and I'd like to hand out a couple of your books during those sessions. I've checked some of the more recent books but I still think yours would be perfect. Would be cool to hand out the 2nd edition though rather than a 6 years old edition.
s
@horse_badorties we're still in the middle of preparing the coroutines-related content, so the plan is to have them go into print early 2024. (you can of course preorder the print)
👀 4
h
ok, thanks! Preordering is not really an option since I need them as hand-outs - this year 🙂 I'll take the 1st edition then, it's fine. Still 95% up-to-date anyway and plenty enough to get Java devs up and running with Kotlin.
s
That makes sense! Maybe for future sessions, then!
👍🏼 1
h
I had a thread in #books about this - may I quote you there, for others to see it? https://kotlinlang.slack.com/archives/C8B5U78DP/p1691690063452649
s
of course!
👍🏼 1
s
Hi @horse_badorties If you preorder/buy the second edition, you get the first edition free (as ebook).
h
yeah, thanks! You can't really hand out ebooks though 😅
j
I also find the concept of lambda (although long established) unnecessary. Function or function literal would suffice, as it's the same thing (as lambda).
@Gasan are you referring to the name "lambda" or to the syntax style? In Kotlin there are 2 types of function literals: anonymous functions (
fun(x: Int): Int { println(x) }
) and lambda expressions (
{ x -> println(x) }
), so we need names for both, hence why I'm asking. Do you mean you would prefer the Kotlin language to only have anonymous functions?
s
@horse_badorties but you can hand out tablets 😃