# Null-Safety

Null-safety is a programming-language type-system feature and set of techniques for representing nullable values and detecting or handling null-reference errors, often at compile time.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## A Friendly Reminder: One Plus NULL Equals NULL | Blog | Fivetran

DevFeed: [A Friendly Reminder: One Plus NULL Equals NULL | Blog | Fivetran](<https://devfeed.tech/articles/a-friendly-reminder-one-plus-null-equals-null-blog-fivetran-140249.md>)

Original publisher: [Read original article](<https://wf.fivetran.com/blog/one-plus-null>)

Author: Charles Wang

Published: 2026-11-18T03:38:23Z

Content type: article

Language: en

Sources: [Fivetran Blog](<https://devfeed.tech/sources/fivetran-blog.md>)

Topics: [Null-Safety](<https://devfeed.tech/topics/null-safety.md>)

Tags: [fivetran](<https://devfeed.tech/tags/fivetran.md>), [function](<https://devfeed.tech/tags/function.md>), [null](<https://devfeed.tech/tags/null.md>), [sql](<https://devfeed.tech/tags/sql.md>)

### AI overview

In SQL, arithmetic with a NULL value produces NULL, so a missing tax or hazardous materials fee can make a row's calculated total cost NULL. The example uses COALESCE(column, 0) on each optional fee before adding it to price, treating missing fees as zero. The text says the same NULL behavior applies to subtraction, multiplication, and division.

### Source excerpt

Whenever you perform arithmetic across SQL columns, take care to handle NULL values appropriately.

## Clean Up Your Conditional Logic: Exploring Kotlin 2.5.0-Beta2's New Boolean & Nullable Utilities

DevFeed: [Clean Up Your Conditional Logic: Exploring Kotlin 2.5.0-Beta2's New Boolean & Nullable Utilities](<https://devfeed.tech/articles/clean-up-your-conditional-logic-exploring-kotlin-2-5-0-beta2-s-new-boolean-nullable-utilities-122284.md>)

Original publisher: [Read original article](<https://proandroiddev.com/clean-up-your-conditional-logic-exploring-kotlin-2-5-0-beta2s-new-boolean-nullable-utilities-7854207156ea?source=rss----c72404660798---4>)

Author: Nav Singh

Published: 2026-11-07T16:39:54Z

Content type: tutorial

Language: en

Sources: [ProAndroidDev](<https://devfeed.tech/sources/proandroiddev-medium.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [conditionals](<https://devfeed.tech/topics/conditionals.md>), [Boilerplate](<https://devfeed.tech/topics/boilerplate.md>), [if statement](<https://devfeed.tech/topics/if-statement.md>), [Null-Safety](<https://devfeed.tech/topics/null-safety.md>), [Gradle](<https://devfeed.tech/topics/gradle.md>), [scope function](<https://devfeed.tech/topics/scope-function.md>)

Tags: [also](<https://devfeed.tech/tags/also.md>), [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [androiddev](<https://devfeed.tech/tags/androiddev.md>), [annotation](<https://devfeed.tech/tags/annotation.md>), [api](<https://devfeed.tech/tags/api.md>), [apis](<https://devfeed.tech/tags/apis.md>), [apply](<https://devfeed.tech/tags/apply.md>), [boilerplate](<https://devfeed.tech/tags/boilerplate.md>), [boolean](<https://devfeed.tech/tags/boolean.md>), [chaining](<https://devfeed.tech/tags/chaining.md>), [clean-code](<https://devfeed.tech/tags/clean-code.md>), [condition](<https://devfeed.tech/tags/condition.md>), [data-class](<https://devfeed.tech/tags/data-class.md>), [experimental](<https://devfeed.tech/tags/experimental.md>), [functions](<https://devfeed.tech/tags/functions.md>), [gradle](<https://devfeed.tech/tags/gradle.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-2](<https://devfeed.tech/tags/kotlin-2.md>), [lambda](<https://devfeed.tech/tags/lambda.md>), [let](<https://devfeed.tech/tags/let.md>), [receiver](<https://devfeed.tech/tags/receiver.md>), [scope-functions](<https://devfeed.tech/tags/scope-functions.md>), [standard-library](<https://devfeed.tech/tags/standard-library.md>)

### AI overview

Kotlin 2.5.0-Beta2 introduces experimental standard-library helpers for conditional work: `onTrue` and `onFalse` run a supplied block when a Boolean matches, then return that Boolean unchanged; `ifOrNull` lazily computes and returns a value when its condition is true, or returns null when false. The excerpt shows using the Boolean helpers for authentication side effects and `ifOrNull` to produce a phone number only when contact information is available. Use requires opting in to `ExperimentalStdlibApi`, either at the function or file level or through Gradle language settings. The excerpt does not establish broader API availability or stability.

### Source excerpt

AI generated image Ditch redundant if-else boilerplate and awkward scope chaining with the newly introduced onTrue(), onFalse(), and ifOrNull() functions. Kotlin has always excelled at eliminating boilerplate. From concise data classes and standard scope functions (apply, also, let, takeIf) to smart casting, the language consistently seeks ways to make everyday idioms more expressive. Kotlin 2.5.0-Beta2 adds standard library functions that let us inspect a value before returning it, or return a nullable result based on that value. https://kotlinlang.org/docs/whatsnew-eap.html?utm_campaign=kotlin-releases&utm_content=2-5-0-beta2 Boolean.onTrue(action: () -> Unit): Boolean Boolean.onFalse(action: () -> Unit): Boolean ifOrNull(condition: Boolean, action: () -> T): T? Implementation Because these functions are introduced as experimental APIs in the standard library, we need to opt in to use them. File/Function Annotation OptIn(ExperimentalStdlibApi::class) Module-wide via Gradle config kotlin { sourceSets.all { languageSettings.optIn("kotlin.ExperimentalStdlibApi") } }onTrue() & onFalse() Both functions invoke a supplied block when the receiver matches the condition and return the original boolean unmodified. Example data class User(val id: String, val email: String) class AuthService() { // Before: fun authenticateLegacy(user: User, token: String): Boolean { val isValid = verifyToken(user.email, token) if (isValid) { "Auth.success" } else { "Auth.failure" } return isValid } // Now: @OptIn(ExperimentalStdlibApi::class) fun authenticate(user: User, token: String): Boolean = verifyToken(user.email, token) .onTrue { "Auth.success" } .onFalse { "Auth.failure" } }ifOrNull() When shaping API responses or DTOs, we may return one computed value if a flag is true and another if false. Traditionally, this looks like 👇 val phoneNumber = if (user.hasContactInfo) user.phoneNumber else nullThe New Way: ifOrNull() ifOrNull(condition) { //.. } lazily evaluates the lambda block only if

## AGDecode: Semantic Attribute Grammar Derivatives for Safety-Constrained Decoding of Large Language Models

DevFeed: [AGDecode: Semantic Attribute Grammar Derivatives for Safety-Constrained Decoding of Large Language Models](<https://devfeed.tech/articles/agdecode-semantic-attribute-grammar-derivatives-for-safety-constrained-decoding-of-large-language-models-103629.md>)

Original publisher: [Read original article](<https://arxiv.org/abs/2610.36105>)

Author: Rajan Maghera, Asher Tempest Arya, Aren A. Babikian, Marsha Chechik, Maryam Mehri Dehnavi

Published: 2026-10-28T04:00:00Z

Content type: article

Language: en

Sources: [arXiv: Software Engineering](<https://devfeed.tech/sources/arxiv-software-engineering.md>)

Topics: [Automated reasoning](<https://devfeed.tech/topics/automated-reasoning.md>), [LLM security](<https://devfeed.tech/topics/llm-security.md>), [Large Language Model](<https://devfeed.tech/topics/llm.md>), [Null-Safety](<https://devfeed.tech/topics/null-safety.md>), [typesafety](<https://devfeed.tech/topics/typesafety.md>)

Tags: [code](<https://devfeed.tech/tags/code.md>), [code-generation](<https://devfeed.tech/tags/code-generation.md>), [completion](<https://devfeed.tech/tags/completion.md>), [constraint](<https://devfeed.tech/tags/constraint.md>), [cs-pl](<https://devfeed.tech/tags/cs-pl.md>), [cs-se](<https://devfeed.tech/tags/cs-se.md>), [decoding](<https://devfeed.tech/tags/decoding.md>), [division-by-zero](<https://devfeed.tech/tags/division-by-zero.md>), [external](<https://devfeed.tech/tags/external.md>), [fixed](<https://devfeed.tech/tags/fixed.md>), [framework](<https://devfeed.tech/tags/framework.md>), [grammar](<https://devfeed.tech/tags/grammar.md>), [guarantees](<https://devfeed.tech/tags/guarantees.md>), [language-models](<https://devfeed.tech/tags/language-models.md>), [large-language-models](<https://devfeed.tech/tags/large-language-models.md>), [llms](<https://devfeed.tech/tags/llms.md>), [null](<https://devfeed.tech/tags/null.md>), [oracle](<https://devfeed.tech/tags/oracle.md>), [oracles](<https://devfeed.tech/tags/oracles.md>), [overhead](<https://devfeed.tech/tags/overhead.md>), [safety](<https://devfeed.tech/tags/safety.md>), [semantic](<https://devfeed.tech/tags/semantic.md>)

### AI overview

AGDecode constrains code generation by checking whether each token choice can still lead to a program satisfying specified semantic properties. It extends attribute grammars to partial syntax trees and compiles specifications into relational constraints checked by external verification oracles, such as SMT and CHC solvers. The authors prove soundness and completeness assuming an ideal oracle and mechanize the core metatheory in Rocq. Because real solvers can return uncertain results, the system may conservatively reject tokens or continue speculatively until later checks resolve them. In C-program generation, it enforces path-sensitive null-pointer safety, division-by-zero freedom, and initialized-variable usage, with reported modest computational overhead at regular program boundaries.

### Source excerpt

arXiv:2610.36105v1 Announce Type: new Abstract: Large language models (LLMs) are increasingly used for code generation, motivating techniques that guarantee the structural and semantic correctness of generated programs. Constrained decoding enforces correctness during generation by restricting token choices to those that admit at least one valid completion. While existing approaches can enforce syntactic constraints and selected semantic properties such as type safety, they either target specific properties or rely on operational pruning mechanisms that are difficult to generalize to data-dependent, inductive program properties. We present AGDecode, a programmable framework for semantic constrained decoding based on least-fixed-point semantics. AGDecode extends attribute grammars to partially constructed syntax trees, and reduces semantic constrained decoding to a realizability problem over such trees. The framework compiles semantic specifications into systems of relational constraints that are discharged by external verification oracles, such as SMT and CHC solvers, cleanly separating language semantics from constraint-solving machinery. We prove that our approach is sound and complete relative to an ideal verification oracle. In practice, solvers inevitably encounter uncertain queries; conservatively, our system can reject tokens for soundness or speculatively continue to generate until later queries resolve the entire generation. We mechanize the core metatheory in Rocq and evaluate the framework on semantic-constrained generation of C programs, enforcing path-sensitive safety properties including null-pointer safety, division-by-zero freedom, and initialized-variable usage. Our results demonstrate that solver-backed semantic constrained decoding can enforce rich semantic guarantees while incurring modest computational overhead at regular program boundaries.

## OpenTofu 1.13 Lets Module Authors Reduce Unknown Values at Plan Time

DevFeed: [OpenTofu 1.13 Lets Module Authors Reduce Unknown Values at Plan Time](<https://devfeed.tech/articles/opentofu-1-13-lets-module-authors-reduce-unknown-values-at-plan-time-100780.md>)

Original publisher: [Read original article](<https://www.infoq.com/news/2026/10/opentofu-1-13-unknown-values/>)

Author: Mark Silvester

Published: 2026-10-26T21:26:00Z

Content type: news

Language: en

Sources: [InfoQ](<https://devfeed.tech/sources/infoq.md>)

Topics: [opentofu](<https://devfeed.tech/topics/opentofu.md>), [data type](<https://devfeed.tech/topics/data-type.md>), [Null-Safety](<https://devfeed.tech/topics/null-safety.md>), [modules](<https://devfeed.tech/topics/modules.md>), [versioning](<https://devfeed.tech/topics/versioning.md>)

Tags: [architecture-design](<https://devfeed.tech/tags/architecture-design.md>), [cloud-native-computing-foundation](<https://devfeed.tech/tags/cloud-native-computing-foundation.md>), [development](<https://devfeed.tech/tags/development.md>), [devops](<https://devfeed.tech/tags/devops.md>), [error](<https://devfeed.tech/tags/error.md>), [functions](<https://devfeed.tech/tags/functions.md>), [infrastructure-as-code](<https://devfeed.tech/tags/infrastructure-as-code.md>), [module](<https://devfeed.tech/tags/module.md>), [news](<https://devfeed.tech/tags/news.md>), [opentofu](<https://devfeed.tech/tags/opentofu.md>), [opentofu-1-13-unknown-values](<https://devfeed.tech/tags/opentofu-1-13-unknown-values.md>), [plan](<https://devfeed.tech/tags/plan.md>), [terraform](<https://devfeed.tech/tags/terraform.md>), [values](<https://devfeed.tech/tags/values.md>)

### AI overview

OpenTofu 1.13 adds `convert` and `assumenotnull` so module authors can give the planner type and non-null guarantees for otherwise unknown values. This can resolve `count` or `for_each` instance decisions while resource attributes remain unknown until apply. Authors must ensure the values satisfy those guarantees; violations are reported during apply. Terraform shipped the equivalent `convert` function first, and OpenTofu chose to match its design. The release also introduces opt-in experimental lint rules and Symbol Libraries, which cannot directly access resources, data sources or provider functions. It removes WinRM support from `remote-exec` and `file`; changes to `base64gzip` may trigger resource updates despite equivalent decompressed output. The excerpt also reports Windows ARM64 packages, a macOS 13 minimum, and 1.13.2 security fixes.

### Source excerpt

OpenTofu 1.13 adds convert and assume... functions that let module authors give the planner type and value hints for unknown values, so more expressions resolve during tofu plan. If a value unknown during planning later violates a guarantee, OpenTofu reports an error during apply. By Mark Silvester

## SvelteKit 3 is here

DevFeed: [SvelteKit 3 is here](<https://devfeed.tech/articles/sveltekit-3-is-here-63450.md>)

Original publisher: [Read original article](<https://svelte.dev/blog/sveltekit-3-is-here>)

Author: The Svelte team

Published: 2026-10-01T00:00:00Z

Content type: release

Language: en

Sources: [Svelte](<https://devfeed.tech/sources/svelte-blog.md>)

Topics: [Svelte](<https://devfeed.tech/topics/svelte.md>), [Submodules](<https://devfeed.tech/topics/submodules.md>), [Null-Safety](<https://devfeed.tech/topics/null-safety.md>), [async](<https://devfeed.tech/topics/async.md>)

Tags: [environment-variables](<https://devfeed.tech/tags/environment-variables.md>), [error-handling](<https://devfeed.tech/tags/error-handling.md>), [migration](<https://devfeed.tech/tags/migration.md>), [release](<https://devfeed.tech/tags/release.md>), [service-workers](<https://devfeed.tech/tags/service-workers.md>), [svelte](<https://devfeed.tech/tags/svelte.md>), [sveltekit](<https://devfeed.tech/tags/sveltekit.md>), [type-safety](<https://devfeed.tech/tags/type-safety.md>)

### AI overview

SvelteKit 3 is available with a migration command, updated configuration and import conventions, improved type safety and error handling, and changes to environment variables and service workers. Remote functions remain experimental and require Async Svelte.

### Source excerpt

Version 3.0 of SvelteKit, the official application framework for Svelte, is now available. If you've used earlier versions of SvelteKit, everything will feel very familiar -- it's the same framework with a little more polish, a little more type safety, and a little less junk. We've made migration as seamless as we can with the sv migrate command... npx sv migrate sveltekit-3 --tasks all --confirm ...which will automatically migrate as much of your codebase as possible, and generate a TODO list for everything else. (If you're agentically inclined, your robot friends will make short work of it.) To create a new app, run sv create: npx sv create my-new-app As with any major version bump there are a handful of breaking changes to be aware of, which are covered in the migration guide (or, more briefly, in the recent release candidate announcement). Quick highlights: configuration now lives in vite.config.ts instead of svelte.config.js the $lib alias is now #lib, making use of standard subpath imports environment variables are more powerful and easier to use service workers are less boilerplatey error handling is improved across the board Are remote functions ready yet? Not quite. But it's our top priority! Remote functions are a set of utilities for secure, efficient, type-safe client-server communication. You've likely seen some version of this idea in other frameworks, but we think you're going to prefer this one. Using them requires Async Svelte, which for now requires an experimental flag. Bear with us. Join us in Ljubljana next month This is as good a place as any to remind everyone that the next in-person Svelte Summit is taking place on November 19-20 in the lovely town of Ljubljana, Slovenia. Among other things it will be a celebration of Svelte's 10th birthday, and we'd love to share some cake with you.

## Modularizing SOLR Query Creation for Multi-Market Scale

DevFeed: [Modularizing SOLR Query Creation for Multi-Market Scale](<https://devfeed.tech/articles/modularizing-solr-query-creation-for-multi-market-scale-22544.md>)

Original publisher: [Read original article](<https://medium.com/walmartglobaltech/modularizing-solr-query-creation-for-multi-market-scale-a1f34e28b631?source=rss----905ea2b3d4d1---4>)

Author: Naman Parikh

Published: 2026-03-03T12:18:55Z

Content type: article

Language: en

Sources: [Walmart Global Tech](<https://devfeed.tech/sources/walmart-global-tech.md>)

Topics: [Null-Safety](<https://devfeed.tech/topics/null-safety.md>), [Software Testing](<https://devfeed.tech/topics/software-testing.md>), [debugging](<https://devfeed.tech/topics/debugging.md>), [Test-driven development](<https://devfeed.tech/topics/tdd.md>)

Tags: [all](<https://devfeed.tech/tags/all.md>), [article](<https://devfeed.tech/tags/article.md>), [boost](<https://devfeed.tech/tags/boost.md>), [boosting](<https://devfeed.tech/tags/boosting.md>), [bug](<https://devfeed.tech/tags/bug.md>), [business](<https://devfeed.tech/tags/business.md>), [business-tools](<https://devfeed.tech/tags/business-tools.md>), [change](<https://devfeed.tech/tags/change.md>), [changes](<https://devfeed.tech/tags/changes.md>), [class](<https://devfeed.tech/tags/class.md>), [code](<https://devfeed.tech/tags/code.md>), [complexity](<https://devfeed.tech/tags/complexity.md>), [configuration](<https://devfeed.tech/tags/configuration.md>), [coupling](<https://devfeed.tech/tags/coupling.md>), [critical](<https://devfeed.tech/tags/critical.md>), [deep-dive](<https://devfeed.tech/tags/deep-dive.md>), [developer](<https://devfeed.tech/tags/developer.md>), [developers](<https://devfeed.tech/tags/developers.md>), [information-retrieval](<https://devfeed.tech/tags/information-retrieval.md>), [modular-monolith](<https://devfeed.tech/tags/modular-monolith.md>), [monolithic-architecture](<https://devfeed.tech/tags/monolithic-architecture.md>), [query](<https://devfeed.tech/tags/query.md>), [scale](<https://devfeed.tech/tags/scale.md>), [software-architecture](<https://devfeed.tech/tags/software-architecture.md>), [software-engineering](<https://devfeed.tech/tags/software-engineering.md>)

### AI overview

A 12,000-line SOLR query class combined filtering, boosting, pagination, and multiple query types, including primary search and item insertions through business tools or semantic sources. Market-specific changes required adding code to this shared implementation, risking effects on other markets and demanding broad regression testing. The excerpt also identifies limited configuration flexibility and loosely typed parameters as sources of ClassCastException and NullPointerException, which made testing and debugging difficult. It frames modularization as the response, but provides no design or implementation details in the supplied text.

### Source excerpt

Introduction When the SOLR query logic expanded into a 12,000-line monolithic implementation, each modification introduced significant risk, making every change feel akin to defusing a critical system. Adding a market-specific override required yet another if block, compounding complexity and slowing time-to-market. In this article, we will deep dive how we broke that SOLR query creation logic, enabling clean configuration per market, stronger typing, reducing technical debts and dramatically reduced runtime errors. Image generated with DALL-E via ChatGPTThe Problem: When SOLR Queries Creation Logic Become Technical Debt The SOLR query logic class was handling filtering logic, boosting logic, boost functions, pagination etc. All the parameters related to SOLR query was getting generated using single class. Overthe time, this core class handled various logics related to different type of queries: Primary search queries Item insertions via business tools Item insertions via semantic sources Thousands of lines tangled edge-case handling, scoring tweaks, and boosting logic. This unscalable approach: Blocked rapid iteration for new markets Tight Coupling: All query-handling logic lived in one massive class, making it difficult to cleanly separate concerns. Market-specific changes could unintentionally affect unrelated logic, requiring exhaustive regression testing. High Risk of Unintended Consequences: Changing business requirements (such as supporting different filtering or boosting strategies for a new market) entailed changing existing code that already served other markets. Developers had to be extremely cautious, as a bug or oversight could break unrelated functionality. No Configuration Flexibility: There was no clear system for externalizing market-specific configuration. Instead, all logic changes happened directly in code, preventing business users or product managers from making simple market changes without developer intervention. Increased Runtime exceptions

## Improving the usability of C libraries in Swift

DevFeed: [Improving the usability of C libraries in Swift](<https://devfeed.tech/articles/improving-the-usability-of-c-libraries-in-swift-2931.md>)

Original publisher: [Read original article](<https://swift.org/blog/improving-usability-of-c-libraries-in-swift/>)

Author: Doug Gregor

Published: 2026-01-22T12:00:00Z

Content type: tutorial

Language: en

Sources: [Swift.org](<https://devfeed.tech/sources/swift-org.md>)

Topics: [Swift](<https://devfeed.tech/topics/swift.md>), [Memory Safety](<https://devfeed.tech/topics/memory-safety.md>), [atomic reference counting](<https://devfeed.tech/topics/atomic-reference-counting.md>), [Null-Safety](<https://devfeed.tech/topics/null-safety.md>)

Tags: [api](<https://devfeed.tech/tags/api.md>), [c](<https://devfeed.tech/tags/c.md>), [functions](<https://devfeed.tech/tags/functions.md>), [gpu](<https://devfeed.tech/tags/gpu.md>), [graphics-processing-unit](<https://devfeed.tech/tags/graphics-processing-unit.md>), [headers](<https://devfeed.tech/tags/headers.md>), [interface](<https://devfeed.tech/tags/interface.md>), [interoperability](<https://devfeed.tech/tags/interoperability.md>), [libraries](<https://devfeed.tech/tags/libraries.md>), [pointers](<https://devfeed.tech/tags/pointers.md>), [safety](<https://devfeed.tech/tags/safety.md>), [swift](<https://devfeed.tech/tags/swift.md>), [usability](<https://devfeed.tech/tags/usability.md>), [webgpu](<https://devfeed.tech/tags/webgpu.md>)

### AI overview

Swift's API notes and Clang bridging annotations can make existing C libraries safer and more idiomatic to use without changing their implementations or headers. The WebGPU examples show how to import C enums as Swift enums, reference-counted opaque objects as automatically managed classes, and C functions as labeled methods, properties, or initializers. API notes also express ownership and pointer nullability; Swift wrappers can give typedefs distinct types, while OptionSet and Boolean-literal conformance add convenient Swift behavior. The article recommends building a small package to iterate on the imported interface. For regular generated headers like webgpu.h, a Swift script using regular expressions can automate many annotations, though the author calls this a hack and says libclang or the source API database would be better for arbitrary headers. Some covered fixes require Swift 6.2.3.

### Source excerpt

There are many interesting, useful, and fun C libraries in the software ecosystem. While one could go and rewrite these libraries in Swift, usually there is no need, because Swift provides direct interoperability with C. With a little setup, you can directly use existing C libraries from your Swift code. When you use a C library directly from Swift, it will look and feel similar to using it from C. That can be useful if you're following sample code or a tutorial written in C, but it can also feel out of place. For example, here's a small amount of code using a C API: var instanceDescriptor = WGPUInstanceDescriptor() let instance = wgpuCreateInstance(&instanceDescriptor) var surfaceDescriptor = WGPUSurfaceDescriptor() let surface = wgpuInstanceCreateSurface(instance, &surfaceDescriptor) if wgpuSurfacePresent(&surface) == WGPUStatus_Error { // report error } wgpuSurfaceRelease(surface) wgpuInstanceRelease(instance) The C library here that Swift is using comes from the webgpu-headers project, which vends a C header (webgpu.h) that is used by several implementations of WebGPU. WebGPU is a technology that enables web developers to use the system's GPU (Graphics Processing Unit) from the browser. For the purposes of this post, you don't really need to know anything about WebGPU: I'm using it as an example of a typical C library, and the techniques described in this blog post apply to lots of other well-designed C libraries. The Swift code above has a very "C" feel to it. It has global function calls with prefixed names like wgpuInstanceCreateSurface and global integer constants like WGPUStatus_Error. It pervasively uses unsafe pointers, some of which are managed with explicit reference counting, where the user provides calls to wpuXYZAddRef and wgpuXYZRelease functions. It works, but it doesn't feel like Swift, and inherits various safety problems of C. Fortunately, we can improve this situation, providing a safer and more ergonomic interface to WebGPU from Swift that fee

## TypeScript enums and falsy values

DevFeed: [TypeScript enums and falsy values](<https://devfeed.tech/articles/typescript-enums-and-falsy-values-52575.md>)

Original publisher: [Read original article](<http://www.jackfranklin.co.uk/blog/typescript-enums-0-values/>)

Published: 2024-11-17T00:00:00Z

Content type: article

Language: en

Sources: [Jack Franklin](<https://devfeed.tech/sources/jack-franklin.md>)

Topics: [TypeScript](<https://devfeed.tech/topics/typescript.md>), [enum](<https://devfeed.tech/topics/enum.md>), [union types](<https://devfeed.tech/topics/union-types.md>), [conditionals](<https://devfeed.tech/topics/conditionals.md>), [Null-Safety](<https://devfeed.tech/topics/null-safety.md>), [if statement](<https://devfeed.tech/topics/if-statement.md>)

Tags: [boolean](<https://devfeed.tech/tags/boolean.md>), [bug](<https://devfeed.tech/tags/bug.md>), [code](<https://devfeed.tech/tags/code.md>), [condition](<https://devfeed.tech/tags/condition.md>), [conditional](<https://devfeed.tech/tags/conditional.md>), [debugging](<https://devfeed.tech/tags/debugging.md>), [documentation](<https://devfeed.tech/tags/documentation.md>), [enum](<https://devfeed.tech/tags/enum.md>), [enums](<https://devfeed.tech/tags/enums.md>), [function](<https://devfeed.tech/tags/function.md>), [javascript](<https://devfeed.tech/tags/javascript.md>), [members](<https://devfeed.tech/tags/members.md>), [null](<https://devfeed.tech/tags/null.md>), [number](<https://devfeed.tech/tags/number.md>), [return](<https://devfeed.tech/tags/return.md>), [status](<https://devfeed.tech/tags/status.md>), [string](<https://devfeed.tech/tags/string.md>), [typescript](<https://devfeed.tech/tags/typescript.md>), [value](<https://devfeed.tech/tags/value.md>), [values](<https://devfeed.tech/tags/values.md>)

### AI overview

A numeric TypeScript enum starts at 0 by default, and JavaScript treats 0 as falsy. When a function returns an enum value or null, `if (status)` therefore mistakes the first enum member for "not logged in." The text recommends checking `status !== null`, or assigning enum members nonzero numeric values or nonempty strings so truthiness checks do not reject a valid status. It also notes that the issue can pass TypeScript compilation and mentions the TypeScript ESLint `strict-boolean-expressions` rule as a possible aid.

### Source excerpt

I recently lost an evening to debugging a subtle issue which highlights a potential pitfall in the interaction between TypeScript enums and "falsy" values in JavaScript. Let's look at a scenario that illustrates this problem: Spot the Bug Consider the following code where a function returns either an enum value or null depending on whether a user is logged in: const enum Status { Inactive, Active, Pending, } function getUserStatus(user?: User): Status | null { if (!user) { // No user is logged in. return null } return user.status() } function checkUserStatus(user?: User): void { const status = getUserStatus(userId) if (status) { console.log('User has a valid status:', status) } else { console.log('The user is not logged in.') } } What's the Issue? JavaScript has a concept of truthy and falsy values. In conditional statements, values that are considered falsy are treated as false. The list of falsy values in JavaScript include: false 0 "" (empty string) null undefined NaN This means that if(0) {} is always false in JavaScript. Now we can look at the default values assigned to enum members in TypeScript. As the TypeScript documentation states, when initializing enum values, the default values are numeric and start from 0. These two enums are equivalent: const enum Status { Inactive = 0, Active = 1, Pending = 2, } const enum Status { Inactive, Active, Pending, } This means that if an enum member is assigned the value 0, it will behave like false in any condition where truthiness is evaluated rather than explicitly checking for the null value. Solving with explicit checks To avoid this bug, explicitly check for null instead of relying on truthy checks: function checkUserStatus(user?: User): void { const status = getUserStatus(user) if (status !== null) { console.log('User has a valid status:', status) } else { console.log('The user is not logged in.') } } Solving with explicit enum values Alternatively, because each number in JavaScript that is not 0 is considered truth

## Why Learning Scala Gave Me Déjà Vu of Kotlin: A Developer's Journey

DevFeed: [Why Learning Scala Gave Me Déjà Vu of Kotlin: A Developer's Journey](<https://devfeed.tech/articles/why-learning-scala-gave-me-deja-vu-of-kotlin-a-developer-s-journey-22877.md>)

Original publisher: [Read original article](<https://medium.com/mindorks/why-learning-scala-gave-me-d%C3%A9j%C3%A0-vu-of-kotlin-a-developers-journey-3126b0e80272?source=rss----f1a763fc7443---4>)

Author: Kavya P S

Published: 2024-10-16T06:49:14Z

Content type: article

Language: en

Sources: [Mindorks](<https://devfeed.tech/sources/mindorks-medium.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Scala](<https://devfeed.tech/topics/scala.md>), [Learning](<https://devfeed.tech/topics/learning.md>), [Functional programming](<https://devfeed.tech/topics/functional-programming.md>), [Boilerplate](<https://devfeed.tech/topics/boilerplate.md>), [Null-Safety](<https://devfeed.tech/topics/null-safety.md>), [Tutorial](<https://devfeed.tech/topics/tutorial.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [backend](<https://devfeed.tech/tags/backend.md>), [backend-development](<https://devfeed.tech/tags/backend-development.md>), [beginners-guide](<https://devfeed.tech/tags/beginners-guide.md>), [boilerplate](<https://devfeed.tech/tags/boilerplate.md>), [chatgpt](<https://devfeed.tech/tags/chatgpt.md>), [extension](<https://devfeed.tech/tags/extension.md>), [functional](<https://devfeed.tech/tags/functional.md>), [functional-programming](<https://devfeed.tech/tags/functional-programming.md>), [functions](<https://devfeed.tech/tags/functions.md>), [immutable-data](<https://devfeed.tech/tags/immutable-data.md>), [inference](<https://devfeed.tech/tags/inference.md>), [journey](<https://devfeed.tech/tags/journey.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [learning](<https://devfeed.tech/tags/learning.md>), [null](<https://devfeed.tech/tags/null.md>), [null-safety](<https://devfeed.tech/tags/null-safety.md>), [option](<https://devfeed.tech/tags/option.md>), [programming](<https://devfeed.tech/tags/programming.md>), [scala](<https://devfeed.tech/tags/scala.md>)

### AI overview

After only 2-5 hours learning Scala through a RockTheJVM tutorial, the author found several concepts familiar from Kotlin. The excerpt compares singleton `object`s, function declarations (`def`/`fun`), inheritance syntax (`extends`/`:`, and Scala traits with `with` versus Kotlin interfaces separated by commas), companion objects, ranges, string interpolation, higher-order functions, lazy initialization, traits/interfaces, infix calls, and case/data classes. It emphasizes shared purposes alongside syntax differences--for example, Scala uses `s` interpolation while Kotlin uses `$`, and Scala's `lazy val` parallels Kotlin's `by lazy`. The author presents this as a learner's mental mapping or cheat sheet, not a comprehensive or authoritative language comparison.

### Source excerpt

Imagine you're 2 years deep into creating cool stuff with Kotlin for Android and you decide to venture into an unfamiliar territory -- Backend development with Scala. You are all prepared to start from zero. But as you go on, it feels strangely familiar, like meeting an old friend. Let me take you through my journey -- exploring Scala was a bit like déjà vu, reminding me of Kotlin in unexpected ways. Come along as I share this story of two coding worlds that seemed oddly similar to me! Disclaimer: Before I begin, I am only one day deep into Scala learning -- okay 2-5 hours deep thanks to this RockTheJVM tutorial! So, this article is not a consolidated list, but a spoiler before you learn the basics of Scala as a Kotlin developer (or vice versa). Before we begin, here's a "textbook" answer for similarities between Kotlin and Scala (thanks to ChatGPT) -- feel free to skip it! Kotlin and Scala, while having their unique features, share some similarities in their syntax. Here are a few key similarities between Kotlin and Scala:1. Conciseness: Both Kotlin and Scala are designed to reduce boilerplate code, allowing developers to write more with less. They provide concise syntax for common operations, making the code cleaner and easier to read. 2. Type Inference: Both languages support type inference, allowing developers to omit explicit type declarations in many cases. The compiler can often deduce the types based on the context, reducing verbosity in code. 3. Functional Programming Features: Both languages incorporate functional programming concepts. They support higher-order functions, immutable data structures, lambda expressions, and various functional programming paradigms. 4. Null Safety: Kotlin and Scala provide features to handle null references safely. Kotlin has a robust system with nullable and non-nullable types, while Scala includes options like `Option` or `Some` to deal with null values. 5. Extension Functions/Methods: Both languages support extension functions

## GraphQLNullable is not a trap!

DevFeed: [GraphQLNullable is not a trap!](<https://devfeed.tech/articles/graphqlnullable-is-not-a-trap-23353.md>)

Original publisher: [Read original article](<https://www.apollographql.com/blog/graphqlnullable-is-not-a-trap>)

Author: Calvin Cestari

Published: 2023-10-03T09:53:34Z

Content type: article

Language: en

Sources: [Apollo Blog](<https://devfeed.tech/sources/apollo-blog.md>)

Topics: [Null-Safety](<https://devfeed.tech/topics/null-safety.md>), [GraphQL](<https://devfeed.tech/topics/graphql.md>)

Tags: [apollo](<https://devfeed.tech/tags/apollo.md>), [code-generation](<https://devfeed.tech/tags/code-generation.md>), [graphql](<https://devfeed.tech/tags/graphql.md>), [mobile](<https://devfeed.tech/tags/mobile.md>), [optional](<https://devfeed.tech/tags/optional.md>), [swift](<https://devfeed.tech/tags/swift.md>), [types](<https://devfeed.tech/tags/types.md>)

### AI overview

GraphQL fields are nullable by default, while Swift values are non-null unless marked optional with `?`. Apollo iOS maps nullable GraphQL fields to Swift optionals, and may also generate optional fields for directives or fragment accessors whose values might not appear in a response. The excerpt distinguishes nullability from optionality as concepts that overlap but are not identical; it begins to explain why `GraphQLNullable` is needed but ends before completing that explanation.

### Source excerpt

Nullability is a fundamental concept in many programming languages giving us the ability to express the absence of a value or assigned object. This is particularly relevant in strongly typed languages where each constant or variable must be defined with one of the language data types or explicitly allowed to be null. GraphQL is strongly-typed and all fields are, by default, nullable with being a valid response for any field unless explicitly declared otherwise.

## Nullability in Kotlin

DevFeed: [Nullability in Kotlin](<https://devfeed.tech/articles/nullability-in-kotlin-39336.md>)

Original publisher: [Read original article](<https://kt.academy/article/kfde-nullability>)

Published: 2023-03-13T00:01:00Z

Content type: tutorial

Language: en

Sources: [Kt. Academy](<https://devfeed.tech/sources/kt-academy.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Null-Safety](<https://devfeed.tech/topics/null-safety.md>), [Exception](<https://devfeed.tech/topics/exception.md>), [Java](<https://devfeed.tech/topics/java.md>)

Tags: [elvis-operator](<https://devfeed.tech/tags/elvis-operator.md>), [exception](<https://devfeed.tech/tags/exception.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [null-safety](<https://devfeed.tech/tags/null-safety.md>), [safety](<https://devfeed.tech/tags/safety.md>), [type](<https://devfeed.tech/tags/type.md>), [workshop-learning-programming](<https://devfeed.tech/tags/workshop-learning-programming.md>)

### AI overview

This tutorial explains Kotlin null-safety and how nullable values are handled. It describes explicit values and nullable types, then introduces safe calls, not-null assertions, smart casts, and the Elvis operator.

### Source excerpt

How Kotlin null-safety works, and how can we deal with nullable values.

## Nullability in GraphQL and Apollo Kotlin

DevFeed: [Nullability in GraphQL and Apollo Kotlin](<https://devfeed.tech/articles/nullability-in-graphql-and-apollo-kotlin-23471.md>)

Original publisher: [Read original article](<https://www.apollographql.com/blog/nullability-in-graphql-and-apollo-kotlin>)

Author: Benoit Lubek

Published: 2023-02-27T08:10:00Z

Content type: article

Language: en

Sources: [Apollo Blog](<https://devfeed.tech/sources/apollo-blog.md>)

Topics: [Null-Safety](<https://devfeed.tech/topics/null-safety.md>), [GraphQL](<https://devfeed.tech/topics/graphql.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [typesafety](<https://devfeed.tech/topics/typesafety.md>)

Tags: [api](<https://devfeed.tech/tags/api.md>), [apollo](<https://devfeed.tech/tags/apollo.md>), [client](<https://devfeed.tech/tags/client.md>), [client-library](<https://devfeed.tech/tags/client-library.md>), [codegen](<https://devfeed.tech/tags/codegen.md>), [compile](<https://devfeed.tech/tags/compile.md>), [directives](<https://devfeed.tech/tags/directives.md>), [error-handling](<https://devfeed.tech/tags/error-handling.md>), [errors](<https://devfeed.tech/tags/errors.md>), [field](<https://devfeed.tech/tags/field.md>), [fields](<https://devfeed.tech/tags/fields.md>), [fragment](<https://devfeed.tech/tags/fragment.md>), [fragments](<https://devfeed.tech/tags/fragments.md>), [graphql](<https://devfeed.tech/tags/graphql.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [mobile](<https://devfeed.tech/tags/mobile.md>), [models](<https://devfeed.tech/tags/models.md>), [null](<https://devfeed.tech/tags/null.md>), [null-safety](<https://devfeed.tech/tags/null-safety.md>), [nulls](<https://devfeed.tech/tags/nulls.md>), [type-system](<https://devfeed.tech/tags/type-system.md>)

### AI overview

Apollo Kotlin generates Kotlin models from GraphQL operations and schema types: schema-nullable fields become nullable in the model. Fields controlled by `@include` or `@skip` are nullable even when their schema type is non-null, because they may be omitted from a response. Fragment fields can also be nullable when polymorphism means they may not be returned; the generator can infer a fragment is always applicable in some cases and generate its fields as non-null. The excerpt explains that GraphQL errors can produce partial responses: an unresolved nullable field becomes null, while an unresolved non-null field can make its parent null if possible. It also notes that GraphQL defaults fields to nullable, unlike Kotlin, where types are non-null by default.

### Source excerpt

The concept of is sometimes called a "billion dollar mistake". Mistake or not, is here to stay and there are ways to coexist peacefully! In fact, nullability is one of the key features of GraphQL, allowing API authors to clearly specify which fields of a type are nullable. As for Kotlin, the language supports nullability in its type system, significantly reducing the risk for errors - for example assigning a potentially value to a non-nullable field won't even compile!

## Interfaces 101 : Error Handling With Go Ep. 3

DevFeed: [Interfaces 101 : Error Handling With Go Ep. 3](<https://devfeed.tech/articles/interfaces-101-error-handling-with-go-ep-3-22213.md>)

Original publisher: [Read original article](<https://www.ardanlabs.com/blog/2023/02/interfaces-101-error-handling-with-go.html>)

Published: 2023-02-13T00:00:00Z

Content type: article

Language: en

Sources: [William Kennedy](<https://devfeed.tech/sources/william-kennedy.md>)

Topics: [Error Handling](<https://devfeed.tech/topics/error-handling.md>), [interface](<https://devfeed.tech/topics/interface.md>), [Null-Safety](<https://devfeed.tech/topics/null-safety.md>)

Tags: [3](<https://devfeed.tech/tags/3.md>), [error](<https://devfeed.tech/tags/error.md>), [error-handling](<https://devfeed.tech/tags/error-handling.md>), [error-interface](<https://devfeed.tech/tags/error-interface.md>), [exceptions](<https://devfeed.tech/tags/exceptions.md>), [go](<https://devfeed.tech/tags/go.md>), [go-error-handling](<https://devfeed.tech/tags/go-error-handling.md>), [golang](<https://devfeed.tech/tags/golang.md>), [interfaces](<https://devfeed.tech/tags/interfaces.md>)

### AI overview

The excerpt highlights a Go interface pitfall: a test can fail a nil check even when a function returns a custom error type without setting a value. It describes implementing Go's error interface with a method that returns an error, then testing the returned value. The video aims to explain how Go determines whether a value is nil and how to avoid false positives with custom interface implementations. The excerpt does not provide the missing method or function names or the specific fix.

### Source excerpt

Introduction In episode 2, Miki examined the impact interfaces have on the performance of a Go program. To perform this experiment, Miki invoked a type's method in two ways: with the concrete type and as an interface function to measure the difference in execution time. The conclusion of this experiment was that calling a method with the concrete type is faster than using an interface. During the experiment, Miki made use of the build flag -gcflag='-m' to display which variables were being allocated on the heap and where the compiler was automatically inlining function calls.

## Nulls and Null Safety

DevFeed: [Nulls and Null Safety](<https://devfeed.tech/articles/nulls-and-null-safety-25061.md>)

Original publisher: [Read original article](<https://typealias.com/start/kotlin-nulls/>)

Author: author@typealias.com (Dave Leeds)

Published: 2021-03-30T00:00:00Z

Content type: article

Language: en

Sources: [Dave Leeds on Kotlin - typealias.com](<https://devfeed.tech/sources/dave-leeds-on-kotlin-typealias-com.md>)

Topics: [Null-Safety](<https://devfeed.tech/topics/null-safety.md>)

Tags: [class](<https://devfeed.tech/tags/class.md>), [elvis-operator](<https://devfeed.tech/tags/elvis-operator.md>), [introduction](<https://devfeed.tech/tags/introduction.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [learn-to-program](<https://devfeed.tech/tags/learn-to-program.md>), [not-null-assertion-operator](<https://devfeed.tech/tags/not-null-assertion-operator.md>), [null](<https://devfeed.tech/tags/null.md>), [null-safety](<https://devfeed.tech/tags/null-safety.md>), [nulls](<https://devfeed.tech/tags/nulls.md>), [optional](<https://devfeed.tech/tags/optional.md>), [program](<https://devfeed.tech/tags/program.md>), [programming](<https://devfeed.tech/tags/programming.md>), [safe-call-operator](<https://devfeed.tech/tags/safe-call-operator.md>), [smart-cast](<https://devfeed.tech/tags/smart-cast.md>), [value](<https://devfeed.tech/tags/value.md>), [variable](<https://devfeed.tech/tags/variable.md>)

### AI overview

The excerpt introduces nulls as a way for a variable to hold no value, unlike the previously shown String, Int, and Boolean variables that were assigned values. It begins an example in which James collects coffee ratings and wants to track them in a Kotlin program; the excerpt ends before showing the class or explaining null safety.

### Source excerpt

So far in this book, every time that we created a variable, whether it was a String, an Int, or a Boolean, we assigned a value to it. There are times, though, when we need to create a variable that might not actually hold a value! This brings us to the exciting topic of nulls! Introduction to Nulls James has set up a coffee stand downtown, and he's ready to start sharing his fine brew!

## When LiveData and Kotlin don't play well together

DevFeed: [When LiveData and Kotlin don't play well together](<https://devfeed.tech/articles/when-livedata-and-kotlin-don-t-play-well-together-25889.md>)

Original publisher: [Read original article](<https://medium.com/google-developer-experts/when-livedata-and-kotlin-dont-play-hand-in-hand-30149aa794ec?source=rss-1331e67af4e1------2>)

Author: Danny Preussler

Published: 2020-12-15T13:38:10Z

Content type: article

Language: en

Sources: [Danny Preussler](<https://devfeed.tech/sources/stories-by-danny-preussler-on-medium.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Null-Safety](<https://devfeed.tech/topics/null-safety.md>), [RxJava](<https://devfeed.tech/topics/rxjava.md>), [Publish-subscribe pattern](<https://devfeed.tech/topics/pubsub.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [androiddev](<https://devfeed.tech/tags/androiddev.md>), [crash](<https://devfeed.tech/tags/crash.md>), [error](<https://devfeed.tech/tags/error.md>), [jetpack](<https://devfeed.tech/tags/jetpack.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [livedata](<https://devfeed.tech/tags/livedata.md>), [null](<https://devfeed.tech/tags/null.md>), [observable](<https://devfeed.tech/tags/observable.md>), [pattern](<https://devfeed.tech/tags/pattern.md>), [reactive](<https://devfeed.tech/tags/reactive.md>), [reactive-streams](<https://devfeed.tech/tags/reactive-streams.md>), [rxjava](<https://devfeed.tech/tags/rxjava.md>), [sticky](<https://devfeed.tech/tags/sticky.md>), [viewmodel](<https://devfeed.tech/tags/viewmodel.md>)

### AI overview

LiveData replays its latest value to new observers, which is useful for state but can repeat one-off errors after events such as device rotation. The excerpt presents SingleLiveEvent as one option for one-off events, then considers clearing an error from LiveData to retain sticky results without replaying the error. Setting the value to null can crash when Kotlin code treats the observed value as non-null: LiveData is implemented in Java, so Kotlin's compiler cannot prevent a null from reaching that observer. The excerpt also notes that Java generic type information and compile-time nullability annotations do not resolve this mismatch. It ends before giving a complete alternative implementation.

### Source excerpt

When LiveData and Kotlin don't play well togetherPlaying well together The idea of LiveData was an interesting one. Based on the idea of reactive streams, that was on the peak at that time with RxJava plus adding automatic lifecycle handling -- a problem on Android. LiveData had bad timing though. It arrived just before Kotlin made its impact in the Android community and sometimes both don't play that nice together. Let's explore why and what can happen! The good and the bad The idea of LiveData was pretty simple: a lifecycle-aware implementation of the Observable pattern. In addition, if you resubscribe, you will get the last emitted value again. It could be compared to a typed version of an EventBus with sticky messages. This is one of the core features of LiveData. But very soon after developers, including the authors, figured, you don't always want that behavior. Let's say you have an error value. Then you probably don't want to show that error value again after resubscribing, like after rotation of a device -- for instance. One way to solve this is SingleLiveEvent and it's a good choice for one-off events like errors. Both worlds But what if you want a bit of both? You want to have the last value "sticky" plus not showing potential errors multiple times! In that case, it would be good to remove our error value from LiveData after they have been consumed, right? Let's look at the implementation ofLiveData: The current value is saved on a field: private volatile Object mData; Initially, it is set to NOT_SET which. static final Object NOT_SET = new Object(); Unfortunately, is not public otherwise, we could use it to reset the value. What now? If you search for this problem, one of the most suggested solutions is simply setting it to null. Let's explore this: viewModel.results.observe(lifecycleOwner) { result -> when (result) { SomeResult.Error -> { handleError() viewModel.results.reset() } SomeResult.Result -> { handleResult(result) } } } where the ViewModel's imple

## The State of Ruby 3 Typing

DevFeed: [The State of Ruby 3 Typing](<https://devfeed.tech/articles/the-state-of-ruby-3-typing-15920.md>)

Original publisher: [Read original article](<https://developer.squareup.com/blog/the-state-of-ruby-3-typing>)

Author: Soutaro Matsumoto

Published: 2020-07-29T19:00:00Z

Content type: release

Language: en

Sources: [Square Corner](<https://devfeed.tech/sources/square-corner-blog-medium.md>)

Topics: [Ruby](<https://devfeed.tech/topics/ruby.md>), [typesafety](<https://devfeed.tech/topics/typesafety.md>), [Null-Safety](<https://devfeed.tech/topics/null-safety.md>)

Tags: [3](<https://devfeed.tech/tags/3.md>), [about](<https://devfeed.tech/tags/about.md>), [abstract](<https://devfeed.tech/tags/abstract.md>), [added](<https://devfeed.tech/tags/added.md>), [all](<https://devfeed.tech/tags/all.md>), [allowed](<https://devfeed.tech/tags/allowed.md>), [allows](<https://devfeed.tech/tags/allows.md>), [also](<https://devfeed.tech/tags/also.md>), [am](<https://devfeed.tech/tags/am.md>), [analysis](<https://devfeed.tech/tags/analysis.md>), [analyze](<https://devfeed.tech/tags/analyze.md>), [announce](<https://devfeed.tech/tags/announce.md>), [api](<https://devfeed.tech/tags/api.md>), [apps](<https://devfeed.tech/tags/apps.md>), [arguments](<https://devfeed.tech/tags/arguments.md>), [array](<https://devfeed.tech/tags/array.md>), [engineering](<https://devfeed.tech/tags/engineering.md>), [language](<https://devfeed.tech/tags/language.md>), [ruby](<https://devfeed.tech/tags/ruby.md>), [state](<https://devfeed.tech/tags/state.md>), [type](<https://devfeed.tech/tags/type.md>)

### AI overview

Ruby 3 introduces RBS, a separate `.rbs` signature language and command-line tooling for describing Ruby programs, alongside signatures for the standard library. Keeping signatures outside Ruby source lets teams add type information without changing their existing code; RBS aims to make definitions portable across type checkers. It supports generics, duck-typed interfaces, union types, and method overloads to describe common Ruby patterns. Tools using RBS can help find undefined methods or constants, detect possible `nil` values, and improve IDE completion and refactoring. Steep is an RBS-based static checker; Sorbet uses RBI and is not being displaced, with an RBI-to-RBS translator included and an RBS-to-RBI translator under development. The article frames RBS as a foundation for optional typing, with compromises made to support existing Ruby code while keeping the type system manageable.

### Source excerpt

Introducing RBS, Ruby's new type signature language

## Kotlin and Exceptions

DevFeed: [Kotlin and Exceptions](<https://devfeed.tech/articles/kotlin-and-exceptions-26024.md>)

Original publisher: [Read original article](<https://elizarov.medium.com/kotlin-and-exceptions-8062f589d07?source=rss-4762e889f8fc------2>)

Author: Roman Elizarov

Published: 2020-06-10T08:18:06Z

Content type: article

Language: en

Sources: [Roman Elizarov](<https://devfeed.tech/sources/stories-by-roman-elizarov-on-medium.md>)

Topics: [Exception](<https://devfeed.tech/topics/exception.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Exception handling](<https://devfeed.tech/topics/exception-handling.md>), [Error Handling](<https://devfeed.tech/topics/error-handling.md>), [Boilerplate](<https://devfeed.tech/topics/boilerplate.md>), [Null-Safety](<https://devfeed.tech/topics/null-safety.md>), [IO](<https://devfeed.tech/topics/io.md>), [Functional programming](<https://devfeed.tech/topics/functional-programming.md>), [async](<https://devfeed.tech/topics/async.md>)

Tags: [api](<https://devfeed.tech/tags/api.md>), [api-design](<https://devfeed.tech/tags/api-design.md>), [error-handling](<https://devfeed.tech/tags/error-handling.md>), [exception-handling](<https://devfeed.tech/tags/exception-handling.md>), [exceptions](<https://devfeed.tech/tags/exceptions.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [programming](<https://devfeed.tech/tags/programming.md>)

### AI overview

Kotlin treats exceptions as unchecked and primarily uses them for programming errors, such as violated preconditions or invariants; ordinary application code generally should not catch them, so bugs can reach top-level handlers. For expected, recoverable conditions, expose errors as values: use nullable results for a single success/failure case or a sealed class for distinct outcomes. The text illustrates this with `toIntOrNull()` for user input and a wrapper around Java's `DateFormat.parse`, which turns `ParseException` into a typed result. I/O is the main exception to that approach: Kotlin APIs commonly use exceptions so network and other external failures do not add handling ceremony to every operation. Handle these uniformly at an application boundary, for example by reporting or retrying. The same guidance applies to coroutines: structured concurrency is intended to propagate exceptions to centralized handling, while local failure cases should be represented as values.

### Source excerpt

Photo by John Mark Arnold on Unsplash What are Kotlin Exceptions and how should you use them? To figure it out let's look at their origins first. Exceptions came to Kotlin from Java. The story with exceptions in Java is complicated, though. I'll give a brief overview. The Origin Java has a unique concept of checked exceptions that were designed to solve the problem of verbose and error-prone error-handling (pun intended). In languages predating Java, like in venerable C, you have to write code like shown in this snippet when doing basic input/output: file = fopen("file.txt", "r"); if (file == NULL) { // handle error & return } // work with file, check for error after each file operation Every time you perform an operation that might fail due to some external circumstance, which happens especially often with files and network, you have to write code that checks the corresponding error condition and handles it. That's tedious, easy to forget, hard to debug. Java set on a noble goal to eliminate this problem. The solution was to use checked exceptions. Every file I/O operation is declared as throws IOException in Java and the compiler checks that you either handle it or declare that you rethrow it. The beauty of this is that you can write exception-handling code once for a whole bunch of I/O operations and you cannot forget writing it since the Java compiler is there to help you. file = FileInputStream("file.txt"); // throws IOException No error-handling boilerplate, no more missed error checks. It was such a bliss to program in Java... for a while. Problems Problems with checked exceptions accumulated over the years. Memory input/output APIs like ByteArrayInputStream were still declared to throw IOException that you had to handle even though it never happened, people abused checked exceptions in API design leading to long, contagious lists of thrown exceptions, developers routinely caught and ignored checked exceptions just to fit some exception-throwing API under an in

## An Optional's place in Kotlin

DevFeed: [An Optional's place in Kotlin](<https://devfeed.tech/articles/an-optional-s-place-in-kotlin-15498.md>)

Original publisher: [Read original article](<https://developer.squareup.com/blog/an-optionals-place-in-kotlin>)

Author: Jake Wharton

Published: 2017-05-14T16:18:21Z

Content type: article

Language: en

Sources: [Jake Wharton](<https://devfeed.tech/sources/jake-wharton.md>), [Square Corner](<https://devfeed.tech/sources/square-corner-blog-medium.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Null-Safety](<https://devfeed.tech/topics/null-safety.md>)

Tags: [abstraction](<https://devfeed.tech/tags/abstraction.md>), [adapters](<https://devfeed.tech/tags/adapters.md>), [annotations](<https://devfeed.tech/tags/annotations.md>), [converter](<https://devfeed.tech/tags/converter.md>), [engineering](<https://devfeed.tech/tags/engineering.md>), [exception](<https://devfeed.tech/tags/exception.md>), [gson](<https://devfeed.tech/tags/gson.md>), [java](<https://devfeed.tech/tags/java.md>), [java-8](<https://devfeed.tech/tags/java-8.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [moshi](<https://devfeed.tech/tags/moshi.md>), [null](<https://devfeed.tech/tags/null.md>), [observable](<https://devfeed.tech/tags/observable.md>), [okhttp](<https://devfeed.tech/tags/okhttp.md>), [optional](<https://devfeed.tech/tags/optional.md>), [retrofit](<https://devfeed.tech/tags/retrofit.md>), [rxjava](<https://devfeed.tech/tags/rxjava.md>), [serialization](<https://devfeed.tech/tags/serialization.md>), [stream](<https://devfeed.tech/tags/stream.md>), [streams](<https://devfeed.tech/tags/streams.md>), [type-system](<https://devfeed.tech/tags/type-system.md>)

### AI overview

Kotlin's nullable types do not solve every absence-of-value case: RxJava 2 streams disallow null, so a Retrofit response that deserializes to null causes an exception. Retrofit 2.3.0 adds delegating converters for Guava and Java 8 `Optional`; they pass byte conversion to another converter, then wrap its potentially null result. Add the chosen `Optional` converter alongside the serialization converter to return `Observable<Optional<Settings>>` for such responses. The article concludes that `Optional` can still be useful in Java and Kotlin despite explicit nullability support.

### Source excerpt

With nullability being a first-class citizen in Kotlin's type system, is there any need for an Optional type?

## Non-null is the Default

DevFeed: [Non-null is the Default](<https://devfeed.tech/articles/non-null-is-the-default-15782.md>)

Original publisher: [Read original article](<https://developer.squareup.com/blog/non-null-is-the-default>)

Author: Jesse Wilson

Published: 2017-05-13T17:27:56Z

Content type: article

Language: en

Sources: [Square Corner](<https://devfeed.tech/sources/square-corner-blog-medium.md>)

Topics: [Null-Safety](<https://devfeed.tech/topics/null-safety.md>), [Boilerplate](<https://devfeed.tech/topics/boilerplate.md>), [IntelliJ IDEA](<https://devfeed.tech/topics/intellij-idea.md>)

Tags: [annotations](<https://devfeed.tech/tags/annotations.md>), [engineering](<https://devfeed.tech/tags/engineering.md>), [java](<https://devfeed.tech/tags/java.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [null](<https://devfeed.tech/tags/null.md>), [okhttp](<https://devfeed.tech/tags/okhttp.md>), [type-system](<https://devfeed.tech/tags/type-system.md>)

### AI overview

The excerpt recommends making Java values non-null by default with JSR 305's `@ParametersAreNonnullByDefault`, set in each package's `package-info.java`, and marking exceptions with `@Nullable`. This lets tools flag nulls passed where they do not belong without requiring `@Nonnull` on every value. Kotlin is non-null by default, with `?` marking nullable types, but the excerpt says Kotlin does not yet honor Java's package-level default when calling Java APIs. It also announces OkHttp 3.8 as non-null by default and warns that three methods became stricter about incoming nulls; readers are directed to its change log. These points come from the supplied excerpt.

### Source excerpt

Using annotations to make Java's type system better

## Rolling out @Nullable

DevFeed: [Rolling out @Nullable](<https://devfeed.tech/articles/rolling-out-nullable-15829.md>)

Original publisher: [Read original article](<https://developer.squareup.com/blog/rolling-out-nullable>)

Author: Jesse Wilson

Published: 2017-05-12T16:26:05Z

Content type: release

Language: en

Sources: [Square Corner](<https://devfeed.tech/sources/square-corner-blog-medium.md>)

Topics: [Null-Safety](<https://devfeed.tech/topics/null-safety.md>)

Tags: [analysis](<https://devfeed.tech/tags/analysis.md>), [android](<https://devfeed.tech/tags/android.md>), [annotation](<https://devfeed.tech/tags/annotation.md>), [annotations](<https://devfeed.tech/tags/annotations.md>), [apis](<https://devfeed.tech/tags/apis.md>), [engineering](<https://devfeed.tech/tags/engineering.md>), [framework](<https://devfeed.tech/tags/framework.md>), [ides](<https://devfeed.tech/tags/ides.md>), [java](<https://devfeed.tech/tags/java.md>), [java-8](<https://devfeed.tech/tags/java-8.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [libraries](<https://devfeed.tech/tags/libraries.md>), [null](<https://devfeed.tech/tags/null.md>), [null-safety](<https://devfeed.tech/tags/null-safety.md>), [open-source](<https://devfeed.tech/tags/open-source.md>), [open-source-projects](<https://devfeed.tech/tags/open-source-projects.md>), [parameter](<https://devfeed.tech/tags/parameter.md>), [releases](<https://devfeed.tech/tags/releases.md>), [static](<https://devfeed.tech/tags/static.md>), [type-system](<https://devfeed.tech/tags/type-system.md>)

### AI overview

Square chose JSR 305's `javax.annotation.Nullable`, following Guava, to mark nullable Java parameters and return values in its open source libraries. This gives Java users more support from IDEs and static analysis tools, while Kotlin enforces null safety when calling the annotated APIs. Kotlin code that is not null-safe may need fixes during integration. The dependency is compile-time only, so build scripts and binary sizes do not change. Okio 1.13 is the first release in the rollout; releases of other Square libraries were planned over the following days.

### Source excerpt

We're helping the type system to help you to help your customers

## Xcode 8: New build settings and analyzer improvements

DevFeed: [Xcode 8: New build settings and analyzer improvements](<https://devfeed.tech/articles/xcode-8-new-build-settings-and-analyzer-improvements-21613.md>)

Original publisher: [Read original article](<http://miqu.me/blog/2016/07/31/xcode-8-new-build-settings-and-analyzer-improvements/>)

Author: Miguel Angel Quiñones

Published: 2016-07-31T20:50:16Z

Content type: article

Language: en

Sources: [Miguel Quinones](<https://devfeed.tech/sources/miguel-quinones.md>)

Topics: [Xcode](<https://devfeed.tech/topics/xcode.md>), [Null-Safety](<https://devfeed.tech/topics/null-safety.md>)

Tags: [build](<https://devfeed.tech/tags/build.md>), [clang](<https://devfeed.tech/tags/clang.md>), [compilation](<https://devfeed.tech/tags/compilation.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [conditional](<https://devfeed.tech/tags/conditional.md>), [deprecated](<https://devfeed.tech/tags/deprecated.md>), [embedded](<https://devfeed.tech/tags/embedded.md>), [false-positives](<https://devfeed.tech/tags/false-positives.md>), [improvements](<https://devfeed.tech/tags/improvements.md>), [legacy](<https://devfeed.tech/tags/legacy.md>), [legacy-code](<https://devfeed.tech/tags/legacy-code.md>), [objective-c](<https://devfeed.tech/tags/objective-c.md>), [settings](<https://devfeed.tech/tags/settings.md>), [swift](<https://devfeed.tech/tags/swift.md>), [warnings](<https://devfeed.tech/tags/warnings.md>), [xcode](<https://devfeed.tech/tags/xcode.md>)

### AI overview

Xcode 8 adds stricter nullability analysis and several Swift build settings. CLANG_ANALYZER_NONNULL can check all calls at the aggressive level; the excerpt recommends setting it to YES rather than YES_NONAGRESSIVE, while warning that stricter checks may expose misuse in legacy Objective-C code. CLANG_ANALYZER_OBJC_DEALLOC adds checks for cleanup of synthesized instance variables in -dealloc, though the author could not test it and notes possible false positives. SWIFT_ACTIVE_COMPILATION_CONDITIONS replaces -D-prefixed entries in OTHER_SWIFT_FLAGS with bare condition names. SWIFT_SUPPRESS_WARNINGS and SWIFT_TREAT_WARNINGS_AS_ERRORS map to compiler options and both default to NO. The excerpt also says ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES replaces deprecated EMBEDDED_CONTENT_CONTAINS_SWIFT, and notes optional xcconfig inclusion with #include?.

### Source excerpt

I always like to check the new build settings and analyzer improvements of every Xcode release. And this year's main release includes a couple of goodies. Let's check them out! Analyzer improvements From the current Xcode 8 beta 3 release notes: 'Misuse of null' or CLANG_ANALYZER_NONNULL The static analyzer check for nullability violations supports both aggressive and less aggressive levels of checking. The more aggressive level checks for nullability violations in all calls This is a very nice addition for anybody dealing with legacy Objective-C code and audited APIs. So remember to enable the more aggressive setting in your project as it won't be enabled after your upgrade. Most likely you'll find that some APIs were not used correctly, and you'll get more warnings. You should set it to YES instead of YES_NONAGRESSIVE for the most strict checking. Remember you can revert (hopefully temporarily) to YES_NONAGRESSIVE so you can make your code compile while you audit the analyzer warnings again. New setting: CLANG_ANALYZER_OBJC_DEALLOC The clang static analyzer now checks for improper cleanup of synthesized instance variables in -dealloc methods Possibly a minor one, but remember that the analyzer could give you new false positives in legacy code. I couldn't make it trigger in a test project, so I don't really know what it will warn you about. New build settings New setting: SWIFT_ACTIVE_COMPILATION_CONDITIONS "Active Compilation Conditions" is a new build setting for passing conditional compilation flags to the Swift compiler. Previously, we had to declare your conditional compilation flags under OTHER_SWIFT_FLAGS, remembering to prepend "-D" to the setting. For example, to conditionally compile with a MYFLAG value: 1 2 3 #if MYFLAG // do stuff #endif The value to add to the setting -DMYFLAG Now we only need to pass the value MYFLAG to the new setting. Time to move all those conditional compilation values! New settings: SWIFT_SUPPRESS_WARNINGS and SWIFT_TREAT_WARNING

## Rendering as NULL in XHP

DevFeed: [Rendering as NULL in XHP](<https://devfeed.tech/articles/rendering-as-null-in-xhp-22040.md>)

Original publisher: [Read original article](<https://codebeforethehorse.tumblr.com/post/80212486413>)

Author: Codebeforethehorse

Published: 2014-03-21T00:17:00Z

Content type: article

Language: en

Sources: [Stefan Parker](<https://devfeed.tech/sources/stefan-parker.md>)

Topics: [render](<https://devfeed.tech/topics/render.md>), [Null-Safety](<https://devfeed.tech/topics/null-safety.md>), [CSS Resets](<https://devfeed.tech/topics/css-reset.md>)

Tags: [abstraction](<https://devfeed.tech/tags/abstraction.md>), [children](<https://devfeed.tech/tags/children.md>), [class](<https://devfeed.tech/tags/class.md>), [component](<https://devfeed.tech/tags/component.md>), [css](<https://devfeed.tech/tags/css.md>), [display](<https://devfeed.tech/tags/display.md>), [element](<https://devfeed.tech/tags/element.md>), [errors](<https://devfeed.tech/tags/errors.md>), [facebook](<https://devfeed.tech/tags/facebook.md>), [links](<https://devfeed.tech/tags/links.md>), [null](<https://devfeed.tech/tags/null.md>), [rendering](<https://devfeed.tech/tags/rendering.md>), [xhp](<https://devfeed.tech/tags/xhp.md>)

### AI overview

The excerpt weighs XHP elements that render empty fragments against alternatives for conditionally absent content. In its edit-link example, hiding the permission check inside `render()` leaves the parent unable to manage a separator; moving the check to a factory method can expose an unsafe path if callers instantiate the link directly. It presents two ways to keep the check encapsulated: wrap separators in elements and hide misplaced ones with CSS (with limits for IE6/basic mobile support and extra DOM nodes), or use an `:x:primitive` that renders after its children and inserts separators only between rendered children. A `willRenderNULL()` method is another option when outside code needs to know whether content will render. The author says Facebook discourages empty rendering partly because engineers are traditionally urged not to extend `:x:primitive`, and because JavaScript may reference elements that do not render; the author favors keeping logic and security checks consolidated.

### Source excerpt

There are some at Facebook who have argued against returning null when rendering an XHP element. In fact, it's actually against Facebook's standards now. Personally, I prefer to structure my code to return null in XHP, but there definitely are pros and cons. I'll cover the situations in which you might want to return null and what the alternatives could be, and then you can decide for yourself. First, let me clarify that when I say returning null, I actually mean returning an empty <x:frag> element from your :x:element-extended class - basically meaning you don't want it to render into anything. So when would you return null from an XHP element? Well, often times it is when the element should only conditionally exist. Let's contrive a simple example. class :post:edit-link extends :x:element { attribute Post post @require; protected function render() { $post = $this->getAttribute('post'); if ($post->author != get_loggedin_user() && !user_is_admin()) { return <x:frag />; } return <a href={"/post/{$post->id}/edit"}>Edit</a>; } } class :blog:post extends :x:element { attribute Post post @required; protected function render() { $post = $this->getAttribute('post'); return <div class="post"> <div class="title">{$post->title}</div> {$post->content} <div class="links"> <post:permalink post={$post} /> &middot; <post:comment-link post={$post} /> &middot; <post:edit-link post={$post} /> </div> </div>; } } So in this scenario, we have <post:edit-link> which will conditionally return a link to edit the post if you are the author. However, if you are not the author you'll see a floating &middot; underneath each blog post. We cannot tell without rendering <post:edit-link> if it will return content or not, so there's no way to conditionally control the last &middot; from inside :blog:post::render(). This is the primary reason some people feel rendering null in XHP is bad practice. To remove the null rendering from <post:edit-link> we'll have to take that check and put it somewhere e