Refactoring to Immutability - Kevlin Henney

preview_player
Показать описание
It has been said that immutability changes everything. But what does that mean in practice? What does it mean for existing code that looks more like the mutant apocalypse than an elegant application of mathematical thinking?

Immutability can be an ideal that is hard to reach. Refactoring, on the other hand, is all about the art of the possible. In this talk we'll be clarifying motivation and exploring some approaches to help reducing state mutability in code.

NDC Conferences
Рекомендации по теме
Комментарии
Автор

"I had a problem in my code. I used regular expressions to solve it, and now I have problem*" is such a brilliant formulation of the classic quote. You have somewhere between zero and infinity problems after using regular expressions.

UCHHFiXnPsuMhyIKDOlsZA
Автор

loved that array example, because it makes you realize that even an array is just that illusion, since you can happily have multiple pointers to the same piece of physical memory right before you screw everythiSegmentation Fault
Received signal 11 (SIGSEGV), core dumped.

nonchip
Автор

Confucius say: "Man with clock always knows what time it is. Man with two clocks is never quite certain which time it is."

juaningles
Автор

Kevlin Henney really is a true master of explaining software patterns in a pragmatic and easy to understand language coupled to architecture and other great examples from history and art. Also he is a nice guy if you have the privilege to talk to him in person :)
He is one of my top ten house goods in my world of software development.

jimifriis
Автор

"Asking a question should not change the answer." - Obviously Bertrand Meyer had never studied Quantum Mechanics.

stuartcoyle
Автор

The Persistent Stack example was enlightening!

covoeus
Автор

36:10 off the top of my head:
- Python: you can do some real horrible shit in the operator overloads because it's dynamically typed
- Swift: Compound assignment operators are overloaded separately from the actual operators. To support this, operators can have inout parameters (ref in C#), and they are implicitly passed as such when used (so you can not only change object state, but reassign the whole variable to whatever you damn well please)

sodiboo
Автор

"mother was a psychotherapist and it has had no effect on me whatsoever" /sarcasm
As a software engineer with a psychotherapist mother this hits me in the solar plexus.

KoenZyxYssel
Автор

This weekend I applied some of these ideas to my favorite personal toy-program, Conway's Game of Life. I like it!

aMulliganStew
Автор

IMO, Rust solves the problem of mutable vs immutable perfectly: you can still use an imperative style, but you have to be explicit about when you are sharing mutable state.

SolomonUcko
Автор

"this is just like putting needles in your eyes but without the fun"

antoniocolagrande
Автор

"Your code should be reasonable" . While this idea certainly sounds like a lack of ambission, it shouldn't. At the end of the day, the spirit behind the latest best practices stems from this idea of "reasonability". And any innovation that goes against it eventually evolves so as to become "reasonable", or it gets replaced by one that does.

DevToolsMadeSimple
Автор

I think these types of talks would help people understand why immutability can be a good thing by explaining why languages choose to make strings immutable. I've found asking why strings are an immutable reference type in interviews (C#) quite interesting, everyone I've asked this question to is stumped and this highlights to me that most developers don't understand or really think about why being able to change state can lead to issues especially when multiple developers are working on something or when a bug is fixed/additional functionality is worked on at a later date.

dwhxyz
Автор

I too wish more languages would take on units of measure as part of the type system. I didn't know F# had that.

trejkaz
Автор

29:12 It's not just "a few characters typing"; I've seen these things get threaded through function after function after function, 5 levels deep, through the whole program.

Erhannis
Автор

I think the immutability fans miss a crucial aspect of how the idea gets implemented. Immutable doesn't mean that state never changes, but that there is an essential data "flow" from immutable inputs to well defined outputs, which could change from what it was because one of the inputs changed (not universally immutable, only locally immutable).

The flipping of data from mutable output to immutable input is where we can get a lot of the performance boosts, but only if we're doing immutable everywhere.

timh.
Автор

Red is not the universal color of danger. In Italy, it's routinely used for "Order Placed Successfully!"

HollywoodCameraWork
Автор

I enjoy watching Kevlin's talks and I actually agree with a lot of what he has to say. Something undefinable rubs me the wrong way about him though.

timseguine
Автор

I'm in to any insights or beneficial behaviours I can immediately deploy and its amusing to listen to Kevlin's polemics.
I'm a big fan of software anthropo-archaeology so seeing that slim Lisp 1.5 manual did bring a tear to the eye (the one with needles in it)
Anyway while I would rather drink my own vomit than perform test driven development, banning the IF statement has become a moral imperative.

cameronduffy
Автор

What time is it?

What time is it?

Whoops

ImperatorZed
visit shbcf.ru