Size: a a a

2020 January 24

AZ

Alex Zhukovsky in rust_offtopic
и это бест практис
источник

E

Evgeniy in rust_offtopic
ок, согласен
источник

AZ

Alex Zhukovsky in rust_offtopic
Although I can’t give it the full treatment it deserves right now, I’d still like to touch on the idea briefly so that interested readers may be able to find other resources on the subject should they wish to do so. The key idea is that many dynamically typed languages idiomatically reuse simple data structures like hashmaps to represent what in statically-typed languages are often represented by bespoke datatypes (usually defined as classes or structs).

These two styles facilitate very different flavors of programming. A JavaScript or Clojure program may represent a record as a hashmap from string or symbol keys to values, written using object or hash literals and manipulated using ordinary functions from the standard library that manipulate keys and values in a generic way. This makes it straightforward to take two records and union their fields or to take an arbitrary (or even dynamic) subselection of fields from an existing record.

In contrast, most static type systems do not allow such free-form manipulation of records because records are not maps at all but unique types distinct from all other types. These types are uniquely identified by their (fully-qualified) name, hence the term nominal typing. If you wish to take a subselection of a struct’s fields, you must define an entirely new struct; doing this often creates an explosion of awkward boilerplate.
источник

SP

Stanislav Popov in rust_offtopic
в тс все неплохо с этим
источник

SP

Stanislav Popov in rust_offtopic
есть keyof есть &
источник

VS

Victor Sapiens in rust_offtopic
Evgeniy
😂 жжешь. На самом деле для типичного веба неплох после php, nodejs и прочего
Там где PHP, JS норм там уже все что угодно норм. Даже Go
источник

SP

Stanislav Popov in rust_offtopic
тс имхо стильно лучше го
источник

AZ

Alex Zhukovsky in rust_offtopic
Stanislav Popov
есть keyof есть &
да, это приятно
источник

AZ

Alex Zhukovsky in rust_offtopic
но то что валидация типчиков прикручена где-то слева через io-ts это неудобно
источник

MK

Mikhail Kilin in rust_offtopic
но самое неприятное в проекте на ТС - это коллеги, любители джаваскрипта
источник

MK

Mikhail Kilin in rust_offtopic
которые делают все, чтобы отключить тс
источник

DS

Doge Shibu in rust_offtopic
Alex Zhukovsky
Although I can’t give it the full treatment it deserves right now, I’d still like to touch on the idea briefly so that interested readers may be able to find other resources on the subject should they wish to do so. The key idea is that many dynamically typed languages idiomatically reuse simple data structures like hashmaps to represent what in statically-typed languages are often represented by bespoke datatypes (usually defined as classes or structs).

These two styles facilitate very different flavors of programming. A JavaScript or Clojure program may represent a record as a hashmap from string or symbol keys to values, written using object or hash literals and manipulated using ordinary functions from the standard library that manipulate keys and values in a generic way. This makes it straightforward to take two records and union their fields or to take an arbitrary (or even dynamic) subselection of fields from an existing record.

In contrast, most static type systems do not allow such free-form manipulation of records because records are not maps at all but unique types distinct from all other types. These types are uniquely identified by their (fully-qualified) name, hence the term nominal typing. If you wish to take a subselection of a struct’s fields, you must define an entirely new struct; doing this often creates an explosion of awkward boilerplate.
На шейплессе в две строчки делается и статически типизированно.
источник

AZ

Alex Zhukovsky in rust_offtopic
Doge Shibu
На шейплессе в две строчки делается и статически типизированно.
я рад, но обычно под "статически типизированными япами" имеют ввиду джавы
источник

SP

Stanislav Popov in rust_offtopic
Alex Zhukovsky
я рад, но обычно под "статически типизированными япами" имеют ввиду джавы
я на такое говорю что жава не статика но похоже это слишком смело )
источник

MK

Mikhail Kilin in rust_offtopic
Alex Zhukovsky
но то что валидация типчиков прикручена где-то слева через io-ts это неудобно
https://github.com/ts-type-makeup/superstruct-ts-transformer
вот такая штука еще есть (но еще не юзал)
источник

MK

Mikhail Kilin in rust_offtopic
но пока в проде мало где используется
источник

SP

Stanislav Popov in rust_offtopic
ts-type-visitor
источник

SP

Stanislav Popov in rust_offtopic
если по статике генерить типы иотс то был бы топ
источник

SP

Stanislav Popov in rust_offtopic
деприкейшон
источник

MK

Mikhail Kilin in rust_offtopic
м?
источник