← 回到首頁

每日新聞摘要

2025年12月28日

選擇語言 / Select Language

中文 English 简体中文
今日收集到 8 篇文章摘要

Kotlin Weekly #491

Kotlin Weekly #491
This final 2025 issue highlights Kotlin community news, a Kotlin Multiplatform contest, major articles and tutorials, and an AI-curated recap of the year's Kotlin breakthroughs.

重點摘要

Kotlin Multiplatform Contest — deadline January 12; prizes include a trip to KotlinConf 2026 in Munich
Newsletter collects articles on on-device AI limits, KMP adoption, Spring Boot 4 Kotlin support, Compose Multiplatform experiments, and more
Junie CLI EAP announced; sponsored and community resources include courses, libraries, and troubleshooting guides
Kotlin Weekly #491 (28 December 2025) wraps up the year with community news, resources, and a brief AI-curated review of notable Kotlin breakthroughs from 2025. Key announcements include the Kotlin Multiplatform Contest (deadline January 12) offering a trip to KotlinConf 2026 in Munich with tickets and hotels covered, the early access waiting list for the Junie CLI powered by Gemini 3 Flash, and practical guidance for mobile teams using Kotlin in 2025. The issue also links to technical articles covering limits of on-device tool calling with sub-1B models, semantic typing in Kotlin, ExoQuery’s SQL tooling, Ktor native backend tutorials, Circuit + SwiftUI for KMP iOS apps, and improved Kotlin support in Spring Boot 4. Additional items include a Compose Multiplatform experiment on Apple TV, an advanced Jetpack Compose course waitlist, a GitHub Actions troubleshooting sponsored post, an Android LLM crash course, and the ComposeWebView library. The newsletter closes with thanks to JetBrains.
Kotlin Weekly #491
本期为 2025 年最后一期,汇总 Kotlin 社区动态、Kotlin Multiplatform 比赛、重要文章与教程,以及 AI 整理的年度突破回顾。

重點摘要

Kotlin Multiplatform 比赛截止 1 月 12 日,优胜者可获 KotlinConf 2026 慕尼黑之旅(含门票与酒店)
精选文章涵盖:设备端工具调用限制、语义类型、ExoQuery 自动 SQL、Ktor native、Compose 与 SwiftUI 等
公布 Junie CLI EAP 等消息,并包含进阶 Compose 课程候补、GitHub Actions 故障排除赞助文与库推荐
Kotlin Weekly 第 491 期(2025/12/28)是今年的最后一期,汇集社区公告、教程与精选文章,并包含编辑团队请 AI 总结的年度 Kotlin 突破。公告重点有 Kotlin Multiplatform 比赛(1 月 12 日截止,奖品含到 KotlinConf 2026 慕尼黑的行程与住宿)、Junie CLI 的 EAP 候补列表,以及为移动开发团队提供的实用 Kotlin 建议。本文目录包括关于在设备端用 sub-1B 模型调用工具的限制、何时使用语义类型、ExoQuery 的编译时 SQL 与验证、Ktor native 后端教学、用 Circuit 与 SwiftUI 现代化 KMP iOS 架构、以及 Spring Boot 4 的 Kotlin 支持展望。另有 Compose Multiplatform 在 Apple TV 的实验、进阶 Compose 课程候补、Android 上运行 LLM 的速成课和 ComposeWebView 库,并感谢 JetBrains 的支持。
Kotlin Weekly #491
本期為 2025 年最後一期,總結 Kotlin 社群動態、Kotlin Multiplatform 比賽、重要文章與教學,以及 AI 彙整的年度突破摘要。

重點摘要

Kotlin Multiplatform 比賽截止 1 月 12 日,得獎者可獲 KotlinConf 2026 慕尼黑之旅(含票與飯店)
刊載多篇技術文章:裝置端工具呼叫限制、語義型別、ExoQuery SQL 工具、Ktor native、Compose 與 SwiftUI 等
宣布 Junie CLI EAP、進階 Compose 課程候補名單、以及贊助文章:GitHub Actions 故障排除
Kotlin Weekly 第 491 期(2025/12/28)為今年最後一刊,收錄多項社群公告與技術文章,並提到編輯團隊請 AI 整理出的年度 Kotlin 突破摘要。主要內容包括 Kotlin Multiplatform 比賽(1 月 12 日截止,獎品含 KotlinConf 2026 慕尼黑行程與住宿)、Junie CLI(EAP 候補)、以及對行動開發團隊有用的 Kotlin 建議。技術專題涵蓋在裝置上以小型模型呼叫工具的限制、何時使用語義型別、ExoQuery 的自動 SQL 重寫、Ktor native 教學系列、在 iOS 使用 Circuit 與 SwiftUI 的 KMP 架構現代化,以及 Spring Boot 4 的 Kotlin 強化。另有 Compose Multiplatform 在 Apple TV 的實驗、進階 Compose 課程候補、Android 上的 LLM Crash Course 與 ComposeWebView 等資源,並感謝 JetBrains 的支持。

Beyond Try-Catch: A New Era of Error Management in Kotlin

Beyond Try-Catch: A New Era of Error Management in Kotlin
Eliminate the "Pyramid of Doom" and write safer, cleaner Android code using Result.fold() and functional patterns.

重點摘要

Use Result.fold() to handle success and failure functionally
Avoid nested try-catch blocks that create the "Pyramid of Doom"
Adopt functional patterns to make Android error handling safer and cleaner
This piece advocates moving past pervasive try-catch nesting by embracing Kotlin's Result.fold() and functional patterns to manage errors. Instead of scattering try-catch blocks and producing deeply nested control flow (the "Pyramid of Doom"), treating outcomes as composable values clarifies success and failure paths, reduces boilerplate, and makes code more predictable. Functional handling centralizes error conversion and propagation, improves readability, and simplifies testing by separating error logic from business logic. For Android developers, applying Result.fold() and related patterns leads to safer, cleaner, and more maintainable code without relying solely on imperative exception handling.
超越 Try-Catch:Kotlin 错误管理的新纪元
使用 Result.fold() 与函数式模式消除“Pyramid of Doom”,让 Android 代码更安全、更简洁。

重點摘要

利用 Result.fold() 将成功与失败以函数式方式处理
避免产生嵌套 try-catch 的“Pyramid of Doom”
采用函数式模式提升代码可读性、可测试性与可维护性
本文建议通过 Kotlin 的 Result.fold() 和函数式设计,取代传统容易嵌套的 try-catch 写法。将结果视为可组合的值能够清晰区分成功与失败路径,减少样板代码并避免深层控制流(即“Pyramid of Doom”)。这种方法有助于集中处理错误的转换与传播、提高代码可读性与可测试性,从而使 Android 项目中的错误管理更安全、简洁且易于维护。文章并示范了在日常开发中如何应用这一模式以增强错误处理的一致性。
超越 Try-Catch:Kotlin 錯誤處理的新時代
使用 Result.fold() 與函式化(functional)模式消除「Pyramid of Doom」,讓 Android 程式碼更安全、更乾淨。

重點摘要

以 Result.fold() 將成功與失敗以函式方式處理
避免造成深層 try-catch 的「Pyramid of Doom」
採用函式化模式提升可讀性、可測試性與維護性
文章主張以 Kotlin 的 Result.fold() 結合函式化思維,取代傳統且容易互相嵌套的 try-catch 寫法。透過把結果視為可組合的值,可以清楚區分成功與失敗路徑,減少樣板程式碼並避免深層控制流程(即所謂的「Pyramid of Doom」)。這種做法有助於集中處理錯誤轉換與傳遞、提升程式可讀性、降低測試困難度,並使 Android 應用程式碼變得更安全、乾淨且易於維護。作者也示範如何在日常開發中應用此模式以提高錯誤處理的一致性。

Rethinking Android Widgets: Building with Jetpack Glance

Rethinking Android Widgets: Building with Jetpack Glance
Move beyond RemoteViews and build declarative, state-driven home screen widgets using the power of Jetpack Compose.

重點摘要

Move beyond RemoteViews
Build declarative, state-driven home screen widgets
Leverage Jetpack Compose through Jetpack Glance
This piece advocates moving past the legacy RemoteViews approach and adopting Jetpack Glance to create home screen widgets in a declarative, state-driven way, leveraging Jetpack Compose. It highlights a shift toward Compose-style UI construction for widgets, emphasizing that widgets can be built using familiar, modern patterns that react to state rather than relying on the older imperative RemoteViews model. The article points developers to Jetpack Glance as the pathway to integrate Compose principles into widget development, enabling clearer, more maintainable code for home screen components while aligning widget creation with contemporary Android UI practices.
重新思考 Android 小部件:使用 Jetpack Glance 构建
超越 RemoteViews,利用 Jetpack Compose 的力量构建声明式、以状态驱动的主屏小部件。

重點摘要

摆脱传统 RemoteViews
采用声明式、以状态驱动的设计
通过 Jetpack Glance 利用 Jetpack Compose 能力
文章主张放弃传统的 RemoteViews 方法,转而使用 Jetpack Glance 配合 Jetpack Compose,构建声明式、以状态驱动的主屏小部件。该方法强调用 Compose 风格的 UI 构建替代命令式的 RemoteViews,使小部件代码更直观、更易维护,也更能响应应用状态变更。作者将 Jetpack Glance 视为将 Compose 原则引入小部件开发的途径,从而让主屏组件开发与现代 Android UI 实践保持一致。
重新思考 Android 小工具:以 Jetpack Glance 建構
超越 RemoteViews,利用 Jetpack Compose 的力量建構宣告式、以狀態驅動的主畫面小工具。

重點摘要

超越傳統 RemoteViews
採用宣告式、以狀態驅動的設計
透過 Jetpack Glance 使用 Jetpack Compose 能力
文章主張擺脫舊有的 RemoteViews 作法,改以 Jetpack Glance 並結合 Jetpack Compose 的思維,建構宣告式且以狀態驅動的主畫面小工具。此做法強調以 Compose 式的 UI 建構模式替代命令式的 RemoteViews,讓小工具的程式碼更直觀、易維護,並能更自然地回應應用程式狀態。作者指出 Jetpack Glance 是將 Compose 原則導入小工具開發的途徑,使主畫面元件的開發能與現代 Android UI 實務接軌。

ViewModel in MVVM

ViewModel in MVVM
One common problem in Android apps is that UI state is lost with the lifecycle — ViewModel helps preserve that state across configuration changes.

重點摘要

UI state can be lost during lifecycle events
ViewModel holds state separate from the View
ViewModel enables lifecycle-aware, testable UI logic
Android apps frequently face the issue of UI state being lost as activities or fragments go through lifecycle changes. In MVVM, the ViewModel is designed to hold and manage UI-related data so it survives configuration changes (such as rotations) and decouples state management from the View. The View observes state exposed by the ViewModel (for example via LiveData) and updates UI accordingly, while the ViewModel avoids direct references to the View to keep concerns separated and improve testability. Using ViewModel reduces bugs caused by lifecycle-driven state loss and helps maintain a clear structure where the View handles rendering and the ViewModel handles state and business logic.
MVVM 中的 ViewModel
Android 应用常见的问题之一是 UI 状态会随生命周期丢失;ViewModel 可以在配置更改之间保留这些状态。

重點摘要

UI 状态可能在生命周期事件中丢失
ViewModel 负责管理并保存 UI 状态
分离关注点以提升可测性与稳定性
在 Android 应用中,界面(UI)状态常在 Activity 或 Fragment 的生命周期变更时丢失。采用 MVVM 架构时,ViewModel 用于保存与管理 UI 相关的数据,使其在配置更改(例如屏幕旋转)时依然存在,从而避免状态丢失。View 通过观察 ViewModel 暴露的状态(如 LiveData)来更新 UI,而 ViewModel 不直接引用 View,以实现关注点分离并提升可测试性和可维护性。将状态逻辑放在 ViewModel 中有助于减少由生命周期引起的问题,使界面渲染与状态管理职责明确。
MVVM 中的 ViewModel
Android 應用常見問題之一是 UI 狀態會隨生命週期消失;ViewModel 可在組態變更間保留這些狀態。

重點摘要

UI 狀態可能隨生命週期事件遺失
ViewModel 負責管理並保留 UI 狀態
透過分離關注提高可測試性與穩定性
在 Android 應用中,畫面(UI)狀態常會在 Activity 或 Fragment 的生命週期變化時消失。採用 MVVM 架構時,ViewModel 被用來保存與管理 UI 相關的資料,使其能在組態變更(例如螢幕旋轉)時存活,避免狀態遺失。View 觀察並呈現 ViewModel 所提供的狀態(如 LiveData),而 ViewModel 則不直接持有 View 的參考,藉此達到關注點分離、提高可測試性與維護性。透過將狀態邏輯置於 ViewModel,可以減少因生命週期而產生的錯誤,並讓介面呈現與狀態管理各司其職。

Jetpack Compose Best Practices and Performance Optimization in 2025

Jetpack Compose Best Practices and Performance Optimization in 2025
A deep dive into advanced techniques, recomposition control, and the December 2025 updates.

重點摘要

Explores advanced Jetpack Compose techniques
Focuses on recomposition control to improve performance
Summarizes December 2025 updates and their implications
This article provides a focused examination of Jetpack Compose best practices and performance optimization as of December 2025. It surveys advanced techniques for building Compose UIs, emphasizes approaches for controlling recomposition to avoid unnecessary work, and reviews the most recent framework updates released in December 2025 that affect performance strategies. The piece outlines practical considerations for developers aiming to write efficient, maintainable Compose code, highlights patterns for reducing wasted recompositions, and discusses how the latest changes to the library influence optimization trade-offs. Intended as a deep-dive resource, the article aims to help readers align their code and tooling choices with the newest Compose recommendations and performance guidance available at the end of 2025.
2025 年 Jetpack Compose 最佳实践与性能优化
深入探讨高级技术、重组(recomposition)控制以及 2025 年 12 月的最新更新。

重點摘要

介绍 Compose 的高级实践
关注重组控制以提升性能
概述 2025 年 12 月更新及其影响
本文围绕 2025 年 12 月的 Jetpack Compose,深入介绍最佳实践与性能优化要点。文章讨论了构建高效 Compose 界面的进阶方法、如何控制重组以减少不必要的工作以及最新发布的 12 月更新对性能策略的影响。目标是为开发者提供可操作的建议与权衡考虑,帮助编写更高效、易维护的 Compose 代码,并说明新版库变更如何影响优化方向和测量工具的使用。
2025 年 Jetpack Compose 最佳實務與效能優化
深入探討進階技術、重組(recomposition)控制,以及 2025 年 12 月的最新更新。

重點摘要

介紹 Compose 的進階使用技巧
強調重組控制以提升效能
整理 2025 年 12 月更新及其影響
本文針對 2025 年 12 月時的 Jetpack Compose,提供最佳實務與效能優化的深入說明。內容涵蓋進階 UI 技術、如何透過設計與程式模式減少不必要的重組,以及最新的 12 月更新對性能策略的影響。文章旨在為開發者整理可實作的考量與取捨,協助採用更有效率且可維護的 Compose 寫法,並說明新版函式庫變更如何改變優化方向與調整工具與測量方法的必要性。

Jetpack Compose Best Practices: Building a Real-World Search Feature

Jetpack Compose Best Practices: Building a Real-World Search Feature
When I first started working with Jetpack Compose, I made every mistake in the book — including creating composables with side effects.

重點摘要

Author recounts early Compose mistakes and lessons learned
Focus on avoiding side effects in composables and managing state
Practical guidance for implementing a real-world search feature
In this article Abhinay reflects on his early mistakes when adopting Jetpack Compose and uses those lessons to present best practices for building a real-world search feature. He highlights common pitfalls—such as introducing side effects inside composables and mishandling state—and emphasizes patterns that keep UI logic modular and predictable. The piece aims to translate experience into actionable guidance: how to structure composables, manage state and effects responsibly, and design a search flow that behaves reliably under recomposition. Intended for developers moving from traditional Android UI to Compose, the article balances candid personal anecdotes with pragmatic recommendations to help readers avoid typical errors and build more maintainable, testable Compose code for search interfaces.
Jetpack Compose 最佳实践:构建真实场景的搜索功能
刚开始使用 Jetpack Compose 时,我犯了各种错误,比如在 composable 中引入副作用。

重點摘要

作者回顾早期使用 Compose 的错误与收获
强调避免在 composable 中产生副作用并正确管理状态
针对实现真实搜索功能提供实用建议
作者 Abhinay 以自身经验为出发点,总结在使用 Jetpack Compose 时常见的问题与应对方法,并将这些经验应用到构建真实场景的搜索功能上。文章指出应避免在 composable 中引入副作用、妥善处理状态以及采用可预测的设计模式,进而保持 UI 逻辑的模块化与可维护性。针对如何组织 composable、管理副作用与设计在重组(recomposition)下稳定运行的搜索流程,文章给出务实建议,适合希望将传统 Android 界面迁移到 Compose 的开发者,帮助他们减少常见失误并构建更易测试与维护的搜索界面。
Jetpack Compose 最佳實務:構建真實世界的搜尋功能
剛開始使用 Jetpack Compose 時,我犯了書上所有的錯誤,例如在 composable 中引入副作用。

重點摘要

作者以自身經驗回顧常見錯誤與教訓
強調避免在 composable 裡產生副作用並正確管理狀態
提供實作真實搜尋功能的實務建議
本文作者 Abhinay 回顧他在採用 Jetpack Compose 初期的種種錯誤,並以此整理出針對構建真實世界搜尋功能的最佳實務。文章指出常見陷阱,例如在 composable 中引入副作用或錯誤處理狀態,並提出可維護且可預期的設計模式,說明如何組織 composable、負責任地管理狀態與副作用,以及設計在重新組合(recomposition)下仍能穩定運作的搜尋流程。文章適合從傳統 Android UI 過渡到 Compose 的開發者,透過經驗分享與具體建議,幫助讀者避免常見錯誤並建立更容易測試與維護的搜尋介面程式碼。

How to Reset InputStream and Read File Again

How to Reset InputStream and Read File Again
We can mark a position in the stream so that we can return to it later.

重點摘要

InputStream defines mark(), reset(), and markSupported(), but defaults do not support marking.
ByteArrayInputStream supports reset and ignores read-ahead limits; BufferedInputStream supports mark/reset but requires a sufficient read-ahead limit and buffer.
RandomAccessFile offers an alternative via getFilePointer() and seek() for true random access.
This tutorial explains how to mark and reset positions when reading streams in Java. It reviews InputStream's key methods—mark(), reset(), and markSupported()—and notes that the default InputStream implementation does not support marking. The article shows ByteArrayInputStream supports resetting (and the read-ahead limit is irrelevant because all data is in memory) and demonstrates BufferedInputStream wrapping a FileInputStream to enable marking, while emphasizing the need for a meaningful read-ahead limit and sufficient buffer to avoid invalidating the mark (which causes reset() to throw an IOException). As an alternative to stream-based backtracking, RandomAccessFile is presented, using getFilePointer() and seek() to emulate mark/reset behavior via random file access. Example test snippets illustrate each approach and the code is available on GitHub.
如何重置 InputStream 并再次读取文件
我们可以在流中标记一个位置,然后返回到该位置继续读取。

重點摘要

InputStream 定义了 mark()、reset() 与 markSupported(),但默认实现不支持标记。
ByteArrayInputStream 支持重置且不受 read-ahead 限制影响;BufferedInputStream 支持 mark/reset,但需合适的 read-ahead limit 与缓冲区。
RandomAccessFile 可通过 getFilePointer() 与 seek() 实现随机访问,作为替代方案。
本文介绍了在 Java 中如何在读取流时回退位置。首先讲解 InputStream 的 mark()、reset() 与 markSupported(),并说明默认实现不支持标记。示例展示 ByteArrayInputStream 支持重置且创建时数据已在内存中,因此 read-ahead 限制无意义;BufferedInputStream 可用于文件读取并支持标记,但必须提供足够的 read-ahead limit 和内部缓冲,否则当读取超出限制或缓冲区时,调用 reset() 会抛出 IOException。文章还介绍了 RandomAccessFile,使用 getFilePointer() 与 seek() 可自由选择文件位置以模拟 mark/reset 的行为。示例代码可在 GitHub 找到。
如何重置 InputStream 並再次讀取檔案
我們可以在串流中標記一個位置,之後回到該位置繼續讀取。

重點摘要

InputStream 提供 mark()、reset() 與 markSupported(),但預設實作不支援標記。
ByteArrayInputStream 支援重設且不受 read-ahead 限制影響;BufferedInputStream 支援 mark/reset,但需足夠的 read-ahead limit 與緩衝區。
RandomAccessFile 可用 getFilePointer() 與 seek() 提供隨機存取,作為替代方案。
本文說明在 Java 中如何對輸入串流設定標記並回溯位置。介紹 InputStream 的 mark()、reset() 與 markSupported(),並指出預設實作不支援標記。示範 ByteArrayInputStream 可重設且不受 read-ahead 限制影響;BufferedInputStream 可標記但需傳入足夠的 read-ahead limit 與內部緩衝區,否則超過後 reset() 會拋出 IOException。範例展示在超出讀取限制或緩衝區大小時標記會失效。最後介紹 RandomAccessFile,透過 getFilePointer() 與 seek() 可直接對檔案做隨機存取,模擬 mark/reset 行為。文中附有測試程式碼與 GitHub 範例。

Modernizing an Android App After Years: A Complete Technical Overhaul

Modernizing an Android App After Years: A Complete Technical Overhaul
Bringing Stereogram Fun Back to Life

重點摘要

A comprehensive technical overhaul to modernize an Android app
Focus on reviving a stereogram app and restoring its fun
Reflections on challenges, decisions, and outcomes
This article documents a comprehensive effort to modernize an Android app after years of neglect, described as a complete technical overhaul aimed at "bringing stereogram fun back to life." The author recounts the motivations for revisiting an older codebase, the broad scope of work necessary to update and stabilize the project, and the practical trade-offs encountered during the process. Rather than a step-by-step tutorial, the piece focuses on the narrative of diagnosing issues, making design and tooling decisions, and applying lessons learned to restore functionality and user experience. It emphasizes the value of careful planning, prioritizing improvements, and iterating to achieve a maintainable, rejuvenated app while sharing insights useful to developers facing similar legacy modernization tasks.
多年之后的现代化:对 Android 应用的完整技术改造
让立体画(stereogram)的乐趣重现

重點摘要

对多年未更新的 Android 应用进行全面技术改造
目标是恢复 stereogram 应用的可玩性和体验
记录改造中的挑战、决策与实际教训
本文记录了作者对一款多年未维护的 Android 应用所做的完整技术改造,目的在于“让 stereogram 的乐趣重现”。文章说明了回归旧代码库的动机、为更新与稳定化所需的广泛工作,以及在改造过程中遇到的关键挑战与取舍。作品以叙述与经验总结为主,涵盖问题诊断、设计与工具选择,以及通过迭代恢复功能和用户体验的过程。全文强调了周密规划、优先级排序与逐步改进的重要性,并对面临类似遗留系统现代化的开发者提供了可借鉴的见解。
多年後的現代化:對 Android 應用程式的完整技術改造
重啟視差立體畫(stereogram)的樂趣

重點摘要

對多年未維護的 Android 應用進行全面技術改造
以復甦 stereogram 應用的可玩性為目標
分享過程中的挑戰、決策與經驗教訓
本文記述作者對一款停滯多年的 Android 應用所進行的完整技術改造,核心目標是「重啟 stereogram 的樂趣」。文章說明為何需要回頭檢視舊有程式碼、進行全面更新與穩定化,以及在改造過程中所面臨的各種取捨與挑戰。內容以回顧與經驗分享為主,涵蓋診斷問題、做出設計與工具選擇,以及如何透過反覆改進來恢復功能與使用體驗。文章強調周詳規劃與分優先級改進的重要性,並提供對處理遺留系統現代化有幫助的實務見解。

Generated by Kotlin News Summarizer with AI Summaries