# var

Published articles for var.

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

## Performance in Jetpack Compose

DevFeed: [Performance in Jetpack Compose](<https://devfeed.tech/articles/performance-in-jetpack-compose-25901.md>)

Original publisher: [Read original article](<https://skyyo.medium.com/performance-in-jetpack-compose-9a85ce02f8f9?source=rss-56174fa84bcc------2>)

Author: Denys Rudenko

Published: 2022-10-03T16:41:03Z

Content type: tutorial

Language: en

Sources: [Stories by Denis Rudenko on Medium](<https://devfeed.tech/sources/stories-by-denis-rudenko-on-medium.md>)

Topics: [Jetpack Compose](<https://devfeed.tech/topics/jetpack-compose.md>), [ui](<https://devfeed.tech/topics/ui.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [article](<https://devfeed.tech/tags/article.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [compose](<https://devfeed.tech/tags/compose.md>), [false-positive](<https://devfeed.tech/tags/false-positive.md>), [jetpack-compose](<https://devfeed.tech/tags/jetpack-compose.md>), [lambda](<https://devfeed.tech/tags/lambda.md>), [modifiers](<https://devfeed.tech/tags/modifiers.md>), [performance](<https://devfeed.tech/tags/performance.md>), [recomposition](<https://devfeed.tech/tags/recomposition.md>), [scopes](<https://devfeed.tech/tags/scopes.md>), [skip](<https://devfeed.tech/tags/skip.md>), [ui](<https://devfeed.tech/tags/ui.md>), [val](<https://devfeed.tech/tags/val.md>), [var](<https://devfeed.tech/tags/var.md>), [variables](<https://devfeed.tech/tags/variables.md>)

### AI overview

A practical guide to improving Jetpack Compose performance through stable parameters, skippable composables, optimized recompositions, remembered lambdas, and compiler and layout-inspector metrics.

### Source excerpt

Article tells about my research on how to write efficient Compose code. It consists of 6 sections and a TL;DR/Summary in the end. We will cover: Optimising recompositions When should you use @Immutable and @Stable annotations; Unstable classes, variables, lambdas; Non-restartable & skippable composables; Lambda modifiers; Passing lambdas providing required fields instead of fields in composables; Inlined composables; When you should use remember { }. We'll be using Compose Compiler Metrics and layout inspector tools to know: - If a class is stable or not; - If the composable function is skippable/restartable; - Amount of skipped recompositions. 1. Unstable objects on UI layer. To understand why we should care about stability, let us peek into a very important metric called skippability. It allows compose runtime to skip recomposition of a composable when all the parameters it uses are considered stable. What is considered stable by the compiler? - All primitive value types: Boolean, Int, Long, Float, Char, etc. - Strings - Lambdas (not always, we will get to it later) We want composable functions to use stable params to become skippable. 1) Don't use var when seeking stability. Fields declared as var are considered unstable: https://medium.com/media/724da23ba38eaa9d3312318e7e8038b9/hrefhttps://medium.com/media/f8dd8a39bce60e48b5ff8bdd4a02b9ef/href UserDetails composable will be recomposed even if the user never gets modified. Using val instead of var in User class will fix this issue. 2) Not all lambdas are considered stable. Let's look at the following examples: https://medium.com/media/fbbff417d165a501b21a3e5d2c6f087f/hrefhttps://medium.com/media/c6aaae01fda67c633edcdf7bb351e620/href Since the lambdas capture outside scopes, they won't be automatically inferred as stable and reused as expected. If the lambda requires access to external variables, the compiler will add those variables as fields, which are passed into the constructor of the lambda. We go a 2 ways of

## Random Animating Pie Button

DevFeed: [Random Animating Pie Button](<https://devfeed.tech/articles/random-animating-pie-button-32075.md>)

Original publisher: [Read original article](<https://www.maiatoday.net/p/random-animating-pie-button/>)

Published: 2021-06-16T21:36:11Z

Content type: tutorial

Language: en

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

Topics: [Compose](<https://devfeed.tech/topics/compose.md>), [Canvas](<https://devfeed.tech/topics/canvas.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [animate](<https://devfeed.tech/tags/animate.md>), [canvas](<https://devfeed.tech/tags/canvas.md>), [code](<https://devfeed.tech/tags/code.md>), [color](<https://devfeed.tech/tags/color.md>), [component](<https://devfeed.tech/tags/component.md>), [compose](<https://devfeed.tech/tags/compose.md>), [custom](<https://devfeed.tech/tags/custom.md>), [data-class](<https://devfeed.tech/tags/data-class.md>), [exploring](<https://devfeed.tech/tags/exploring.md>), [fun](<https://devfeed.tech/tags/fun.md>), [functions](<https://devfeed.tech/tags/functions.md>), [jetpack](<https://devfeed.tech/tags/jetpack.md>), [jetpack-compose](<https://devfeed.tech/tags/jetpack-compose.md>), [random](<https://devfeed.tech/tags/random.md>), [val](<https://devfeed.tech/tags/val.md>), [var](<https://devfeed.tech/tags/var.md>)

### AI overview

A Jetpack Compose sample demonstrates a custom pie-chart component that draws with Canvas and animates to a random percentage when a button is clicked.

### Source excerpt

I am exploring animations with small sampler functions using Jetpack Compose. This one is a custom component that draws a little pie chart. It will animate a random pie value on the click of the button. data class PieData( val foreground: Color = Color.White, val strokeWidth: Dp = 4.dp, val percentage: Float ) @Composable fun PieStatus( modifier: Modifier = Modifier, pieData: PieData ) { var animationPlayed by remember { mutableStateOf(false) } val currentPercentage = animateFloatAsState( targetValue = if (animationPlayed) pieData.percentage else 0f, animationSpec = tween(1000) ) LaunchedEffect(key1 = true) { animationPlayed = true } Canvas( modifier = modifier ) { val canvasWidth = size.width val canvasHeight = size.height drawCircle( color = pieData.foreground, center = Offset(x = canvasWidth / 2, y = canvasHeight / 2), radius = canvasWidth / 2 - pieData.strokeWidth.toPx(), style = Stroke(width = pieData.strokeWidth.toPx()) ) val arcPadding = pieData.strokeWidth.toPx() * 2 drawArc( color = pieData.foreground, startAngle = -90f, sweepAngle = currentPercentage.value * 360, useCenter = true, topLeft = Offset(arcPadding, arcPadding), size = Size(size.width - (arcPadding * 2f), size.height - (arcPadding * 2f)) ) } } code

## Avoid backing properties for LiveData and StateFlow

DevFeed: [Avoid backing properties for LiveData and StateFlow](<https://devfeed.tech/articles/avoid-backing-properties-for-livedata-and-stateflow-25886.md>)

Original publisher: [Read original article](<https://medium.com/google-developer-experts/avoid-backing-properties-for-livedata-and-stateflow-706006c9867e?source=rss-1331e67af4e1------2>)

Author: Danny Preussler

Published: 2021-01-12T14:03:52Z

Content type: tutorial

Language: en

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

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [coding](<https://devfeed.tech/topics/coding.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [abstract-class](<https://devfeed.tech/tags/abstract-class.md>), [android](<https://devfeed.tech/tags/android.md>), [class](<https://devfeed.tech/tags/class.md>), [clean-code](<https://devfeed.tech/tags/clean-code.md>), [implementation](<https://devfeed.tech/tags/implementation.md>), [interface](<https://devfeed.tech/tags/interface.md>), [interfaces](<https://devfeed.tech/tags/interfaces.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-flow](<https://devfeed.tech/tags/kotlin-flow.md>), [livedata](<https://devfeed.tech/tags/livedata.md>), [stateflow](<https://devfeed.tech/tags/stateflow.md>), [val](<https://devfeed.tech/tags/val.md>), [var](<https://devfeed.tech/tags/var.md>), [viewmodel](<https://devfeed.tech/tags/viewmodel.md>)

### AI overview

This Kotlin article argues that developers can avoid duplicated backing properties when exposing LiveData and StateFlow. It proposes separating the public API from the implementation with interfaces or an abstract class, including in ViewModels.

### Source excerpt

https://unsplash.com/photos/OopPIi_A428 If you have ever worked with LiveData you probably have written code similar to this: class MyViewModel: ViewModel() { val loading: LiveData<Boolean> get() = _loading private val _loading = MutableLiveData<Boolean>()} This seems nowadays the typical way developers would expose some immutable LiveData, while being able to have a mutable version inside the implementation we would write data into. Every time I saw, or even had to write, this kind of code something cringed inside me. As I quoted in one of my talks this feeling in our brain is for real: social missteps activate regions in the brain, [..] that have been previously associated with physical pain. As developers, we know something is wrong with this code, right? It also feels like we are writing manual getters and setters here. What's wrong? We could start with the prefix we use for the backing field, although we fought hard for a long time to get rid of prefixes, we accept it here! It is even made it into the official coding conventions. But even if we rename it, it still cringes: class MyViewModel: ViewModel() { val loading: LiveData<Boolean> get() = mutableLoading private val mutableLoading = MutableLiveData<Boolean>()} This duplication feels unneeded! Especially if you write something like a ViewModel that exposed many of these, you get lost in reading the code just by all these duplications. But it's just LiveData? You might think it's just a specialty of LiveData and the future of that construct might be a more limited one. And you would not have this issue with primitives. The language supports this out of the box with a private setter: var secret: String = "Secret" private set But there is a new kid in town: StateFlow needs the same thing! Look at this snippet from the official Jetbrains blog: class DownloadingModel { private val _state = MutableStateFlow<DownloadStatus>(DownloadStatus.NOT_REQUESTED) val state: StateFlow<DownloadStatus> get() = _state This probl

## Variables, Expressions, and Types

DevFeed: [Variables, Expressions, and Types](<https://devfeed.tech/articles/variables-expressions-and-types-25065.md>)

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

Author: author@typealias.com (Dave Leeds)

Published: 2020-03-05T00:00:00Z

Content type: tutorial

Language: en

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

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Programming](<https://devfeed.tech/topics/programming.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [developer](<https://devfeed.tech/tags/developer.md>), [expression](<https://devfeed.tech/tags/expression.md>), [fundamentals](<https://devfeed.tech/tags/fundamentals.md>), [introduction](<https://devfeed.tech/tags/introduction.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [language](<https://devfeed.tech/tags/language.md>), [learn-to-program](<https://devfeed.tech/tags/learn-to-program.md>), [programming](<https://devfeed.tech/tags/programming.md>), [statement](<https://devfeed.tech/tags/statement.md>), [types](<https://devfeed.tech/tags/types.md>), [val](<https://devfeed.tech/tags/val.md>), [var](<https://devfeed.tech/tags/var.md>), [variable](<https://devfeed.tech/tags/variable.md>)

### AI overview

An introductory Kotlin chapter explains variables, expressions, and types. It uses the example of a circle's radius to show how variables represent values and introduces variables as containers for numbers and other data in programming.

### Source excerpt

So you want to be a Kotlin developer? You've come to the right place! This book will take you through the fundamentals of Kotlin, gently introducing you to the most important concepts of the language in order to help you become a proficient Kotlin developer. Even if you're a seasoned professional, it's important to know the fundamentals in order to establish a solid foundation of understanding so that you can be as effective as possible.

## Kotlin Classes: Syntax, Properties, Constructors, Functions, and Inheritance

DevFeed: [Kotlin Classes: Syntax, Properties, Constructors, Functions, and Inheritance](<https://devfeed.tech/articles/classes-in-kotlin-more-power-with-less-effort-kad-03-27140.md>)

Original publisher: [Read original article](<https://antonioleiva.com/classes-kotlin>)

Published: 2016-12-07T00:00:00Z

Content type: tutorial

Language: en

Sources: [Antonio Leiva](<https://devfeed.tech/sources/antonio-leiva.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Java](<https://devfeed.tech/topics/java.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [classes](<https://devfeed.tech/tags/classes.md>), [code](<https://devfeed.tech/tags/code.md>), [constructor](<https://devfeed.tech/tags/constructor.md>), [java](<https://devfeed.tech/tags/java.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [properties](<https://devfeed.tech/tags/properties.md>), [property](<https://devfeed.tech/tags/property.md>), [val](<https://devfeed.tech/tags/val.md>), [var](<https://devfeed.tech/tags/var.md>)

### AI overview

A tutorial introducing Kotlin classes and comparing them with Java. It explains class declarations, properties instead of fields, constructors using val or var, functions, and Kotlin's default-closed inheritance behavior with the open modifier.

### Source excerpt

Everything Android, Kotlin and other random topics

## Variables in Kotlin, differences with Java. var vs val (KAD 02)

DevFeed: [Variables in Kotlin, differences with Java. var vs val (KAD 02)](<https://devfeed.tech/articles/variables-in-kotlin-differences-with-java-var-vs-val-kad-02-27232.md>)

Original publisher: [Read original article](<https://antonioleiva.com/variables-kotlin>)

Published: 2016-11-28T00:00:00Z

Content type: tutorial

Language: en

Sources: [Antonio Leiva](<https://devfeed.tech/sources/antonio-leiva.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Java](<https://devfeed.tech/topics/java.md>)

Tags: [java](<https://devfeed.tech/tags/java.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [val](<https://devfeed.tech/tags/val.md>), [var](<https://devfeed.tech/tags/var.md>)

### AI overview

A tutorial chapter explains how variables work in Kotlin and compares Kotlin's val and var declarations with Java. It covers mutable and immutable values, type inference, automatic casting, object types, and explicit numeric conversions.

### Source excerpt

Everything Android, Kotlin and other random topics

## Var and val in Java?

DevFeed: [Var and val in Java?](<https://devfeed.tech/articles/var-and-val-in-java-21990.md>)

Original publisher: [Read original article](<http://blog.joda.org/2016/03/var-and-val-in-java.html>)

Author: Stephen Colebourne (noreply@blogger.com)

Published: 2016-03-26T00:04:00Z

Content type: opinion

Language: en

Sources: [Stephen Colebourne](<https://devfeed.tech/sources/stephen-colebourne.md>)

Topics: [Java](<https://devfeed.tech/topics/java.md>), [Java Language](<https://devfeed.tech/topics/java-language.md>), [Developer experience](<https://devfeed.tech/topics/developer-experience.md>), [code productivity](<https://devfeed.tech/topics/code-productivity.md>)

Tags: [c-sharp](<https://devfeed.tech/tags/c-sharp.md>), [coding](<https://devfeed.tech/tags/coding.md>), [developer-experience](<https://devfeed.tech/tags/developer-experience.md>), [java](<https://devfeed.tech/tags/java.md>), [java-language](<https://devfeed.tech/tags/java-language.md>), [java9](<https://devfeed.tech/tags/java9.md>), [val](<https://devfeed.tech/tags/val.md>), [var](<https://devfeed.tech/tags/var.md>)

### AI overview

This opinion examines proposed local variable type inference for Java under JEP-286, including the possible use of var, val, or let. It argues that the feature could reduce Java's verbosity while making some code reviews harder, and considers Java's history when evaluating the keyword choice.

### Source excerpt

Should local variable type inference be added to Java? This is the question being pondered right now by the Java language team. Local Variable Type Inference JEP-286 proposes to add inference to local variables using a new psuedo-keyword (treated as a "reserved type name"). We seek to improve the developer experience by reducing the ceremony associated with writing Java code, while maintaining Java's commitment to static type safety, by allowing developers to elide the often-unnecessary manifest declaration of local variable types. A number of possible keywords have been suggested: var - for mutable local variables val - for final (immutable) local variables let - for final (immutable) local variables auto - well lets ignore that one shall we... Given the implementation strategy, it appears that the current final keyword will still be accepted in front of all of the options, and thus all of these would be final (immutable) variables: final var - changes the mutable local variable to be final final val - redundant additional modifier final let - redundant additional modifier Thus, the choice appears to be to add one of these combinations to Java: var and final var var and val - but final var and final val also valid var and let - but final var and final let also valid In broad terms, I am unexcited by this feature and unconvinced it actually makes Java better. While IDEs can mitigate the loss of type information when coding, I expect some code reviews to be significantly harder (as they are done outside IDEs). It should also be noted that the C# coding standards warn against excessive use of this feature: Do not use var when the type is not apparent from the right side of the assignment. Do not rely on the variable name to specify the type of the variable. It might not be correct. Having said the above, I suspect there is very little chance of stopping this feature. The rest of this blog post focuses on choosing the right option for Java Best option for Java When thi

## Operator Underloading In Scala

DevFeed: [Operator Underloading In Scala](<https://devfeed.tech/articles/operator-underloading-in-scala-32197.md>)

Original publisher: [Read original article](<https://bruceeckel.com/2014/12/30/operator-underloading-in-scala/>)

Author: Bruce Eckel

Published: 2014-12-30T00:00:00Z

Content type: tutorial

Language: en

Sources: [Bruce Eckel - Computing Thoughts](<https://devfeed.tech/sources/bruce-eckel-computing-thoughts.md>)

Topics: [Scala](<https://devfeed.tech/topics/scala.md>), [Programming](<https://devfeed.tech/topics/programming.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [code](<https://devfeed.tech/tags/code.md>), [immutability](<https://devfeed.tech/tags/immutability.md>), [let](<https://devfeed.tech/tags/let.md>), [map](<https://devfeed.tech/tags/map.md>), [programming](<https://devfeed.tech/tags/programming.md>), [scala](<https://devfeed.tech/tags/scala.md>), [var](<https://devfeed.tech/tags/var.md>), [vector](<https://devfeed.tech/tags/vector.md>)

### AI overview

The article examines Scala operator overloading and synthesized assignment operators such as += and -=. It explains how these operators interact with immutable Map values, var and val references, and Vector, arguing that the behavior can be useful but difficult to understand because it varies across classes and is not always documented clearly.

### Source excerpt

Here's a place where Scala does some clever stuff which ultimately might produce a more complicated programming model than one would like. I discovered it while sorting out some issues with the first exercise in the References & Mutability atom in Atomic Scala. I'll give you the examples directly out of the solution guide -- this includes the use of our tiny AtomicScala test framework, but if you don't want to include that you can just comment out the import and all the is statements and you'll still get the same results.

## Wstępne ładowanie programów przy starcie z ureadahead

DevFeed: [Wstępne ładowanie programów przy starcie z ureadahead](<https://devfeed.tech/articles/wstepne-adowanie-programow-przy-starcie-z-ureadahead-27516.md>)

Original publisher: [Read original article](<https://gagor.pro/2012/01/wstepne-ladowanie-programow-przy-starcie-z-ureadahead/>)

Author: Tom

Published: 2012-01-24T00:00:00Z

Content type: tutorial

Language: pl

Sources: [Tomasz Gągor](<https://devfeed.tech/sources/tomasz-gagor.md>)

Topics: [Ubuntu](<https://devfeed.tech/topics/ubuntu.md>), [Cache](<https://devfeed.tech/topics/cache.md>), [Caching](<https://devfeed.tech/topics/caching.md>)

Tags: [cache](<https://devfeed.tech/tags/cache.md>), [debian](<https://devfeed.tech/tags/debian.md>), [linux](<https://devfeed.tech/tags/linux.md>), [ubuntu](<https://devfeed.tech/tags/ubuntu.md>), [var](<https://devfeed.tech/tags/var.md>)

### AI overview

This tutorial explains how to make Ubuntu's ureadahead regenerate its list of programs to preload during system startup. It describes clearing ureadahead files, restarting the system, launching desired applications, and adjusting a configuration value if some programs are not cached.

### Source excerpt

Jakiś czas temu korzystałem z preload'a external link który sam uczył się jakie aplikacje odpalam i te programy ładował już podczas startu - przeważnie nieco spowalnia to start systemu ale gdy już się załaduje to programy, które uruchamiam jako pierwsze startują "z kopa". Od jakiegoś czasu popularniejszy jest instalowany domyślnie w Ubuntu ureadahead - pełni on podobną funkcję jak preload.

## MySQL - Proste metody optymalizacji

DevFeed: [MySQL - Proste metody optymalizacji](<https://devfeed.tech/articles/mysql-proste-metody-optymalizacji-27509.md>)

Original publisher: [Read original article](<https://gagor.pro/2011/12/mysql-proste-metody-optymalizacji/>)

Author: Tom

Published: 2011-12-29T00:00:00Z

Content type: tutorial

Language: pl

Sources: [Tomasz Gągor](<https://devfeed.tech/sources/tomasz-gagor.md>)

Topics: [MySQL](<https://devfeed.tech/topics/mysql.md>), [Cache](<https://devfeed.tech/topics/cache.md>)

Tags: [backup](<https://devfeed.tech/tags/backup.md>), [cache](<https://devfeed.tech/tags/cache.md>), [index](<https://devfeed.tech/tags/index.md>), [information-schema](<https://devfeed.tech/tags/information-schema.md>), [mariadb](<https://devfeed.tech/tags/mariadb.md>), [mysql](<https://devfeed.tech/tags/mysql.md>), [percona](<https://devfeed.tech/tags/percona.md>), [schema](<https://devfeed.tech/tags/schema.md>), [var](<https://devfeed.tech/tags/var.md>)

### AI overview

A Polish tutorial presents MySQL configuration adjustments for improving database performance, covering MyISAM key caching, InnoDB buffer pool and log file sizing, and the storage and compaction behavior of InnoDB data files.

### Source excerpt

Wcześniej czy później zawsze pojawia się potrzeba zoptymalizowania naszej bazy MySQL. Przedstawię kilka zmian w konfiguracji, które powinny zwiększyć wydajność w większości przypadków. MyISAM - key_buffer_size Najprostszą optymalizacją baz/tabel z mechanizmem MyISAM jest odpowiednie dobranie bufora na cache dla kluczy i indeksów (dane nigdy nie są cachowane). Poniższe zapytanie pozwala oszacować zalecany rozmiar cache'u: SELECT CONCAT(ROUND(KBS/POWER(1024, IF(PowerOf1024<0,0,IF(PowerOf1024>3,0,PowerOf1024)))+0.4999), SUBSTR(' KMG',IF(PowerOf1024<0,0, IF(PowerOf1024>3,0,PowerOf1024))+1,1)) recommended_key_buffer_size FROM (SELECT LEAST(POWER(2,32),KBS1) KBS FROM (SELECT SUM(index_length) KBS1 FROM information_schema.tables WHERE engine='MyISAM' AND table_schema NOT IN ('information_schema','mysql')) AA ) A, (SELECT 2 PowerOf1024) B; Wynik określa zalecany rozmiar bufora (parametr key_buffer_size w pliku /etc/mysql/my.cnf) dla bieżącego stanu bazy - warto ciut dodać na zapas. Na systemach 32 bitowych parametr key_buffer_size może przyjmować maksymalnie 4GB, na 64 bitowych maksymalnie 8GB.