Top Banner
Polyglot Micro-Services with a Dash of Wittgenstein Charles Pletcher @brophocles 4 July 2015 at PolyConf
25
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Polyglot Micro-Services with a Dash of Wittgenstein - PolyConf 2015

Polyglot Micro-Services with a Dash of Wittgenstein

Charles Pletcher @brophocles

4 July 2015 at PolyConf

Page 2: Polyglot Micro-Services with a Dash of Wittgenstein - PolyConf 2015

Ludwig Wittgenstein1889 - 1951

Austrian-British Philosopher

Page 3: Polyglot Micro-Services with a Dash of Wittgenstein - PolyConf 2015

A is building with building stones: there are blocks, pillars, slabs, and beams. B has to pass him the stones and to do so in the order in which A needs them. For this purpose they make use of a language consisting of the words “block,” “pillar,” “slab,” “beam.” A calls them out; B brings the stone which he has learnt to bring at such-and-such a call. — Conceive of this as a complete primitive language.

(Wittgenstein, PI, §2)

Page 4: Polyglot Micro-Services with a Dash of Wittgenstein - PolyConf 2015

A B ?“block”

“pillar”

“slab”

<block>

<pillar>

<slab>

“beam”<beam>

Page 5: Polyglot Micro-Services with a Dash of Wittgenstein - PolyConf 2015

1. How does data’s meaning change from one context to another?

2. How do we figure out what data means in a given context?

3. What can we do about it?

Page 6: Polyglot Micro-Services with a Dash of Wittgenstein - PolyConf 2015

1. Data’s meaning changes from context to context. 2. We can describe data in a given context 3. There are tools and techniques at our disposal to

mitigate confusion.

Page 7: Polyglot Micro-Services with a Dash of Wittgenstein - PolyConf 2015

• Chuck Pletcher

• Software Engineering at Assembly (https://assembly.com)

• Not a philosopher

Page 8: Polyglot Micro-Services with a Dash of Wittgenstein - PolyConf 2015

When they (grown-ups) named some object and at the same time turned towards it, I perceived this, and I grasped that the thing was signified by the sound they uttered, since they meant to point it out. This, however, I gathered from their gestures, the natural language of all peoples, the language that by means of facial expression and the play of eyes, of the movements of the limbs and the tone of voice, indicates the affections of the soul when it desires, or clings to, or rejects, or recoils from, something. In this way, little by little, I learnt to understand what things the words, which I heard uttered in their respective places in various sentences, signified. And once I got my tongue around these signs, I used them to express my wishes.

(Augustine, Confessions I. 8)

Page 9: Polyglot Micro-Services with a Dash of Wittgenstein - PolyConf 2015

2.1 We make to ourselves pictures of facts. 2.11  The picture presents the facts in logical space, the existence and non-existence of atomic facts. 2.12  The picture is a model of reality. 2.13  To the objects correspond in the picture the elements of the

picture. 2.131 The elements of the picture stand, in the picture, for the objects. 2.14 The picture consists in the fact that its elements are combined with one another in a definite way. 2.141 The picture is a fact.

(Wittgenstein, Tractatus Logico-Philosophocus)

Page 10: Polyglot Micro-Services with a Dash of Wittgenstein - PolyConf 2015
Page 11: Polyglot Micro-Services with a Dash of Wittgenstein - PolyConf 2015

Someone suddenly sees something which he does not recognize (it may be a familiar object, but in an unusual position or lighting); the lack of recognition perhaps lasts only a few seconds.

(Wittgenstein, PI, Part II, §141)

Page 12: Polyglot Micro-Services with a Dash of Wittgenstein - PolyConf 2015
Page 13: Polyglot Micro-Services with a Dash of Wittgenstein - PolyConf 2015

Is it correct to say that he has a different visual experience from someone who recognized the object straightaway? Couldn’t someone describe an unfamiliar shape that appeared before him just as accurately as I, to whom it is familiar? And isn’t that the answer?

(Wittgenstein, PI, Part II, §§141-142)

Page 14: Polyglot Micro-Services with a Dash of Wittgenstein - PolyConf 2015

Duckrabbit Typing

Page 15: Polyglot Micro-Services with a Dash of Wittgenstein - PolyConf 2015

A B ?“block”

“pillar”

“slab”

<block>

<pillar>

<slab>

“beam”<beam>

Page 16: Polyglot Micro-Services with a Dash of Wittgenstein - PolyConf 2015
Page 17: Polyglot Micro-Services with a Dash of Wittgenstein - PolyConf 2015

import React from 'react'

export default function connectToStores(...stores) { return function(Component) { return class StoreConnection extends React.Component { static willTransitionTo(transition, params, query) { Component.willTransitionTo && Component.willTransitionTo(transition, params, query) }

constructor(props) { super(props) this.state = Component.getPropsFromStores(props) this.handleStoresChanged = this.handleStoresChanged.bind(this) }

render() { return <Component {...this.props} {...this.state} ref="component" />; }

componentDidMount() { stores.forEach(store => store.addChangeListener(this.handleStoresChanged) ); }

componentWillUnmount() { stores.forEach(store => store.removeChangeListener(this.handleStoresChanged) ); }

handleStoresChanged() { this.setState(Component.getPropsFromStores(this.props)) }

// for testing static get Component() { return Component } } } } https://medium.com/@dan_abramov/mixins-are-dead-long-live-higher-order-components-94a0d2f9e750

Render the target Component along with any props and state

Attach listeners to each of the Component’s stores (declared

in the call to this decorator)

Think of this as ReactRouter sugar — it’s not super

important for our purposes, but I’ll explain it if you want

Page 18: Polyglot Micro-Services with a Dash of Wittgenstein - PolyConf 2015

import AvailableUsernameInputActions from 'actions/AvailableUsernameInputActions' import AvailableUsernameInputStore from 'stores/AvailableUsernameInputStore' import classnames from 'classnames' import connectToStores from 'lib/connectToStores.jsx' import React from 'react'

@connectToStores(AvailableUsernameInputStore) export default class AvailableUsernameInput extends React.Component { static getPropsFromStores(props) { return { valid: AvailableUsernameInputStore.isValid(props.id) } }

static defaultProps = { id: 'available-input' }

componentDidMount() { AvailableUsernameInputActions.validate(this.props.id, this.props.value) }

constructor(props) { super(props)

this.handleChange = this._handleChange.bind(this) }

render() { const classes = classnames(this.props.className, { 'is-error': this.props.valid === false }) return ( <div className="clearfix"> <input {...this.props} className={classes} onChange={this.handleChange} /> {this.renderMessage()} </div> ) }

renderMessage() { const { valid, value } = this.props

// `valid` can be `null`, in which case we do nothing if (valid === false) { return ( <small className="red left mt1"> {value} is taken. Try again! </small> ) }

return null }

_handleChange(e) { AvailableUsernameInputActions.validate(this.props.id, e.target.value)

this.props.onChange && this.props.onChange(e) } }

Pass any changes off to action creators.

`valid` is ultimately the prop that we care about

Page 19: Polyglot Micro-Services with a Dash of Wittgenstein - PolyConf 2015

@AuthenticatedMixin() @connectToStores(HighlightsStore) export default class HighlightPicker extends React.Component { static getPropsFromStores(props) { return { highlights: HighlightsStore.all(), page: HighlightsStore.page, moreAvailable: HighlightsStore.moreAvailable } }

static defaultProps = { changelogId: RouterContainer.changelogSlug() }

constructor(props) { super(props)

this.onScrollBottom = this._onScrollBottom.bind(this) }

render() { const changelogId = this.props.changelogId

return ( <div className="bg-white"> {this.renderPaginator()}

{…} {this.renderHighlights()} </div> ) }

renderHighlights() { const filter = RouterContainer.get().getCurrentParams().filter return List(this.props.highlights).filter(highlight => { if (filter !== 'mine') { return true }

return List(highlight.mentioned_users).some((user) => { return user.username === SessionStore.user.username }) }).sortBy(highlight => -highlight.occurred_at).map((highlight) => { return <div className="border-bottom" key={highlight.id}> <Highlight highlight={highlight} /> </div> }) }

renderPaginator() { if (this.props.moreAvailable) { return <ScrollPaginator page={this.props.page} onScrollBottom={this.onScrollBottom} /> } }

_onScrollBottom() { HighlightActions.fetchAll(this.props.changelogId, this.props.page + 1) } }

Just render whatever Highlights we have, with a simple short-circuit in case we’re rendering

the user’s own highlights

Page 20: Polyglot Micro-Services with a Dash of Wittgenstein - PolyConf 2015

A B ?“block”

“pillar”

“slab”

<block>

<pillar>

<slab>

“beam”<beam>

Page 21: Polyglot Micro-Services with a Dash of Wittgenstein - PolyConf 2015

[T]he language-games stand there as objects of comparison which, through similarities and dissimilarities, are meant to throw light on features of our language. For we can avoid unfairness or vacuity in our assertions only by presenting the model as what it is, as an object of comparison — as a sort of yardstick; not as a preconception to which reality must correspond. (The dogmatism into which we fall so easily when doing philosophy.)

(Wittgenstein, PI, §§130-131)

Page 22: Polyglot Micro-Services with a Dash of Wittgenstein - PolyConf 2015

[T]he language-games stand there as objects of comparison which, through similarities and dissimilarities, are meant to throw light on features of our language. For we can avoid unfairness or vacuity in our assertions only by presenting the model as what it is, as an object of comparison — as a sort of yardstick; not as a preconception to which reality must correspond. (The dogmatism into which we fall so easily when doing philosophy computer science.)

(Wittgenstein, PI, §§130-131)

Page 23: Polyglot Micro-Services with a Dash of Wittgenstein - PolyConf 2015

A B ?“block”

“pillar”

“slab”

<block>

<pillar>

<slab>

“beam”<beam>

Page 24: Polyglot Micro-Services with a Dash of Wittgenstein - PolyConf 2015

Can there be a clash between the picture [our data] and application? Well, they can clash in so far as the picture makes us expect a different use; because people in general apply this picture like this. I want to say: we have here a normal case and abnormal cases.

(Wittgenstein, PI, §141)

Page 25: Polyglot Micro-Services with a Dash of Wittgenstein - PolyConf 2015

Thanks•

• Wittgenstein, Ludwig. Philosophical Investigations. Translated by G. E. M. Anscombe, P. M. S. Hacker, and Joachim Schulte. Fourth Edition. Blackwell Publishers, Malden, MA: 2009. (Originally published 1953)

• Wittgenstein, Ludwig. Tractatus Logico-Philosophicus. Translated by C. K. Ogden. Kegan Paul, Trench, Trubner and Co., Ltd., London: 1922.