13. React Native
Main thread
Общая незрелость экосистемы
Архитектура в разы сложнее
Хороший, качественный код
Отсутствие возможности работы с Accessibility
JSCore — iOS / Android — ВИРТУАЛЬНАЯ МАШИНА
LLVM-несовместимый?
“Свой компонент” — даже TextView
Royalty?
GroundBreaking Changes
Future-Proof?
Security?
Возможность писать без участия Native разработчиков
Не может в сторонние библиотеки
Ограничения использования API
Быстродействие
Актуализация кодовой базы
– React Native Immaturity - непредсказуемые
задержки из-за сырости
– Maintaining a Fork of React Native - пришлось делать
форк RN и дорого его поддерживать
– JavaScript Tooling - сложно масштабировать
написанное на JS
– Refactoring - тяжело рефакторить RN код
– JavaScriptCore inconsistencies - нет JSCore на
Android
– React Native Open Source Libraries - кривые либы
– Parallel Infrastructure and Feature Work - пришлось с
нуля наводить мосты между компонентами на RN
14. React Native
– React Native Immaturity - непредсказуемые задержки из-за сырости
– Maintaining a Fork of React Native - пришлось делать форк RN и дорого его поддерживать
– JavaScript Tooling - сложно масштабировать написанное на JS
– Refactoring - тяжело рефакторить RN код
– JavaScriptCore inconsistencies - нет JSCore на Android
– React Native Open Source Libraries - недостаточная поддержка
– Parallel Infrastructure and Feature Work - пришлось с нуля наводить мосты между
компонентами на RN
– Crash Monitoring - не все креши приходили в систему и тяжело дебажились
– Native Bridge - не стабильна интеграция с нейтивом
– Initialization Time - долго запускается аппа
– Initial Render Time - рендер дольше из-за чего мигает UI
– App Size - бинарник тяжелее
– 64-bit - 64бита на андроиде пока невозомжно
– Gestures - приходится отключать сложные жесты
– Long Lists - лагают длинные списки
– Upgrading React Native - тяжелый апдейт с версии на версию
– Accessibility - слабо поддерживаются режимы для инвалидов
– Troublesome Crashes - невозпроизводимые креши
– SavedInstanceState Across Processes on Android - невозможность сохранить стейт при
выключении из фона
22. Swift Kotlin
var myVariable = 42
myVariable = 50
let myConstant = 42
var myVariable = 42
myVariable = 50
val myConstant = 42
let explicitDouble: Double = 70 val explicitDouble: Double = 70.0
let names = ["Anna", "Alex", "Brian", "Jack"]
let count = names.count
for i in 0..<count {
print("Person (i + 1) is called
(names[i])")
}
val names = arrayOf("Anna", "Alex", "Brian",
"Jack")
val count = names.count()
for (i in 0..count - 1) {
println("Person ${i + 1} is called $
{names[i]}")
}
for index in 1...5 {
print("(index) times 5 is (index * 5)")
}
for (index in 1..5) {
println("$index times 5 is ${index * 5}")
}
var shoppingList = ["catfish", "water",
"tulips", "blue paint"]
shoppingList[1] = "bottle of water"
var shoppingList = arrayOf("catfish",
"water", "tulips", "blue paint")
shoppingList[1] = "bottle of water"
let numbers = [20, 19, 7, 12]
numbers.map { 3 * $0 }
val numbers = listOf(20, 19, 7, 12)
numbers.map { 3 * it }
34. 77%
protocol RoomProfile {
var profileID: String { get }
var title: String { get }
var abbreviation: String { get }
var colorIndex: Int { get }
var type: Type { get }
}
enum Type {
case unknown
case user(_ id: String)
case group
}
interface RoomProfile {
val profileID: String
val title: String
val abbreviation: String
val colorIndex: Int
val type: Type
}
sealed class Type {
object Unknown: Type()
class User(val id: String): Type()
object Group: Type()
}
35. Syntax sugar
// Syntax sugar from Swift
fun List<String>.joined(separator: String): String {
val string = StringBuilder()
for (s in this) {
if (string.isNotEmpty()) {
string.append(separator)
}
string.append(s)
}
return string.toString()
}
fun String.replacingOccurrences(of: String, with: String) = replace(of, with)
36. didSet, willSet?
// Room List
private var sortedRoomList:
Set<RoomMessage> = Set() {
didSet {
// Do something
}
}
❓
37. didSet, willSet!
// Room List
private var sortedRoomList:
List<RoomModel> by
observing(emptyList(), didSet = {
// Do something
}
// Room List
private var sortedRoomList:
Set<RoomMessage> = Set() {
didSet {
// Do something
}
}
38. didSet, willSet:
// Syntax sugar from Swift
fun <T> observing(
initialValue: T,
willSet: () -> Unit = { },
didSet: () -> Unit = { }
) = object : ObservableProperty<T>(initialValue) {
override fun beforeChange(
property: KProperty<*>,
oldValue: T,
newValue: T): Boolean = true.apply { willSet() }
override fun afterChange(
property: KProperty<*>,
oldValue: T,
newValue: T) = didSet()
}
40. .filter / .map
public inline fun
<T, C : MutableCollection<in T>>
Iterable<T>.filterTo(
destination: C, predicate: (T) ->
Boolean
): C {
for (element in this)
if (predicate(element))
destination.add(element)
return destination
}
@_transparent
public func _filter(
_ isIncluded: (Element) throws -> Bool
) rethrows -> [Element] {
var result = ContiguousArray<Element>()
var iterator = self.makeIterator()
while let element = iterator.next() {
if try isIncluded(element) {
result.append(element)
}
}
return Array(result)
}
41. .filter / .map
fun <E> filterTo(): ArrayList<E> {
for (element in this)
if (predicate(element))
destination.add(element)
return destination
}
func filter() -> [Element] {
var result = Array<Element>()
var iterator = self.makeIterator()
while let element = iterator.next() {
if try isIncluded(element) {
result.append(element)
}
}
return Array(result)
}