Victor Savkin

Victor Savkin

06-10-2022

14:00

1/8 My code style is getting simpler with every passing year. Things I used to be into: • Functional Programming (category theory etc) • FRP (first and higher order) • Domain specific languages • Proper OOP (Smalltalk etc) ... Today I barely use anything from the list.

2/8 Most of what I write today is basically "procedural + immutability". Every module has a few public functions. Each public function receives and returns immutable data.

3/8 Within each module it's OK to mutate. Local mutability helps write concise, easy to understand, fast code. I used to write nested reduces and feel good about myself--no more.

4/8 Of course local mutability isn't sufficient, so I have a few places at the top where global mutation happens. Classes are OK as long as they are used as modules, not instantiated in random places.

5/8 I'm also much more selective at using abstraction. I realized how costly it is: abstraction often creates indirection, which makes code harder to understand. So if you abstract, it's better be worth it.

6/8 DSLs, in almost all cases, are unnecessary abstractions. Imo 9 times out of 10 they hide bad design.

7/8 As many engineers I used to like being clever. "My whole solution is a 3 line data transformation pipeline using 10 types of unnamed tuples."

8/8 FP, FRP, DSL, ... there is something to learn from each of them. But somehow I arrived at the code style that looks like something from 30 years ago :) It's boring.


Follow us on Twitter

to be informed of the latest developments and updates!


You can easily use to @tivitikothread bot for create more readable thread!
Donate 💲

You can keep this app free of charge by supporting 😊

for server charges...