Introducing Gemini 4 Argon – our new frontier model.
It’s built for complex workflows across coding, enterprise knowledge work, and cybersecurity defense – rolling out today to a set of trusted testers through our Fairwind Program.
Kotlin allows turning nearly any function into a fluent single-expression style. Some love it, some hate it. Let's see how it works, discuss the pros and cons, and decide whether we should do it or not.
Everything is based on four functions from Kotlin stdlib: let, also, takeIf, and apply. These functions can be called on any object and transform or modify it.
let is used to transform one value into another. It allows calling functions "on" parameters. It returns the result of its transformation. It is often used together with ?. to transform only non-null values.
You can also add function references to make their calls shorter.
also is used to execute an additional operation (side-effect) on a value. It returns the object it was called on.
takeIf and takeUnless are used to turn values we are not interested in into nulls. It is often used to eliminate invalid values, or files that does not exist.
let, also, are takeIf are for any object, what map, onEach, and filter are for collections.
apply is a function similar to also, but apply chages receiver (this) inside its body in the way it refers to the object apply is called on. It is perfect for mutable object configuration (setting properties).
They are often used for specific use cases, where they can offer a lot of value, by simplifying some expression.
They can also be used to achieve the single-expression style that mimics the style used in functional programming languages. Some developers like it, but let's look at that pragmatically.
Single-expression style is shorter, passes the minimal amount of data to the next step, it also lets us nicely deal with nullable values.
On the other hand imparative style is simpler, what is a benefit, especially for less experienced devs, easier to debug and modify.
I believe that the key motivator for singe-expression style is that "it looks cool". It is often skill signaling, but I do not find it pragmatic. It is better when our code is boring, then it is easier and more predictable.
I teach how to use scope functions, and how to read such complex expressions, because that is a useful skill, but I suggest to prefer simplicity over complexity.
You can learn more about it from my book, Functional Kotlin, or on my workshop Kotlin for Developers or Kotlin Pro. You can organize a workshop for your company, or join an open edition.
https://t.co/h6STtub5Dd
Schrödinger's code
1. fable wrote it, it must be great. in fact, i had Sol, opus 5, and Grok all review it.
2. if i look at it, its horrible
state changes based on observation
@ChatGPT@googledrive In desktop, the way we are switching from ChatGPT to Codex is awful.
I sometimes can't recognized which one is selected until I look at the top left corner. There is nothing really distinguishable until you find out a button disappeared
Compose HotSwan is going to Kotlin Multiplatform! 🚀
Have you ever seen Compose hot reloading on Android, iOS, and Desktop in real time at this speed? This could be the next-generation fast development loop in the AI area.
https://t.co/WwJ92PBvAU
Hands down one of the best Android channels on YouTube. Learned a ton from it like from the very start!
I built a much stronger Android vocabulary and understanding of the ecosystem, thanks to him!