<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ryan Lynch on Medium]]></title>
        <description><![CDATA[Stories by Ryan Lynch on Medium]]></description>
        <link>https://medium.com/@ryanlynch?source=rss-1d680a826062------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*w6rpKoaYF1DNQdoDId7mAQ.jpeg</url>
            <title>Stories by Ryan Lynch on Medium</title>
            <link>https://medium.com/@ryanlynch?source=rss-1d680a826062------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 17:00:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ryanlynch/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Minimum Loving Awareness]]></title>
            <link>https://medium.com/@ryanlynch/minimum-loving-awareness-fd7d7d001527?source=rss-1d680a826062------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd7d7d001527</guid>
            <category><![CDATA[business]]></category>
            <category><![CDATA[politics]]></category>
            <category><![CDATA[love]]></category>
            <category><![CDATA[ethics]]></category>
            <category><![CDATA[philosophy]]></category>
            <dc:creator><![CDATA[Ryan Lynch]]></dc:creator>
            <pubDate>Sat, 13 Jun 2020 12:28:02 GMT</pubDate>
            <atom:updated>2020-06-13T12:28:02.385Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6mTbUX0X9XUFDiyLFYRwfg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@paulgo?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Paul</a> on Unsplash</figcaption></figure><p>Before I begin here’s a definition of loving awareness by way of a meditation from the late Ram Dass:</p><blockquote>loving awareness is a name, for soul , which you really are<br>leads you to love everything you are aware of<br>the sky, the room, your body, other people<br> — Ram Dass</blockquote><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fopen.spotify.com%2Fembed%2Ftrack%2F59wrT695wnW81dAL059CJP&amp;display_name=Spotify&amp;url=https%3A%2F%2Fopen.spotify.com%2Ftrack%2F59wrT695wnW81dAL059CJP&amp;image=https%3A%2F%2Fi.scdn.co%2Fimage%2Fab67616d00001e02c70b489c695f42bd0323267f&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=spotify" width="300" height="380" frameborder="0" scrolling="no"><a href="https://medium.com/media/19ba6ad05f83964c93adb231fc16abc4/href">https://medium.com/media/19ba6ad05f83964c93adb231fc16abc4/href</a></iframe><p>This story is a synthesis of the idea from this post on <a href="http://design.co/2018/12/27/minimum-viable-lovable-product-mvlp/">Minimum Viable Lovable Product</a> and a reaction to this post on the idea of <a href="https://medium.com/invisible-strategy/minimum-viable-alignment-d65106cd66e8">Minimum Viable Alignment</a>. I’ll start with the question framed by the second post’s author <em>(full disclosure, we work together, and towards the same goals)</em>:</p><blockquote>What is the point of automation, if it does not free us to use our minds, be creative, to solve problems and to express our divergent visions for a better world?</blockquote><p>And I will pose my own:</p><p>Do we build tools without thought for the divergent worlds they might be used to create?</p><p>My answer is no, we shouldn’t. We should be directed by loving awareness, and we can achieve this by fostering <strong>Minimum Loving Awareness </strong>around our decisions as individuals and organizations.</p><p>We might view these divergent worlds as paths we might take together. Down some paths lies increased suffering, and down other paths lies a more equitable future. There is no neutral path of zero sum. We cannot act separate from consequence. While these consequences may seem abstract in societal terms, they can be explained more directly by physical principles:</p><blockquote>To every action there is always opposed an equal reaction: or the mutual actions of two bodies upon each other are always equal, and directed to contrary parts.<br> — <a href="https://en.wikipedia.org/wiki/Newton%27s_laws_of_motion">Isaac Newton</a></blockquote><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FxThuWottTebD22i21G%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FxThuWottTebD22i21G%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FxThuWottTebD22i21G%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="195" frameborder="0" scrolling="no"><a href="https://medium.com/media/38279576c30f46316e5684821447c766/href">https://medium.com/media/38279576c30f46316e5684821447c766/href</a></iframe><p>This is true for mass, and energy — it’s true for beings of mass and energy. This is true for the individual and it is true for a group of individuals. Whether we fly a corporate or other banner, we act in the world as beings of consequence, and beings of choice. And to quote some poets:</p><blockquote>If you choose not to decide<br>You still have made a choice<br> — <a href="https://g.co/kgs/KoVWN6">Geddy Lee / Alex Lifeson / Neil Peart</a></blockquote><p>Herein lies my issue with Minimum Viable Alignment alone: it gives no direction that reflects the consequence of the choices we make. To look at it again through the lens of physics, Heisenberg said this when discussing measurement of quantum phenomena:</p><blockquote>One can never know with perfect accuracy both of those two important factors which determine the movement of one of the smallest particles — its position and its velocity. It is impossible to determine accurately both the position and the direction and speed of a particle at the same instant.<br> —<a href="https://en.wikipedia.org/wiki/Uncertainty_principle"> Werner Heisenberg</a></blockquote><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fl0Iy1R9uttEN2KCXe%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fmotherboard-viceland-l0Iy1R9uttEN2KCXe&amp;image=https%3A%2F%2Fmedia1.giphy.com%2Fmedia%2Fl0Iy1R9uttEN2KCXe%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="236" frameborder="0" scrolling="no"><a href="https://medium.com/media/33b062481c326b7d65815f97da25950c/href">https://medium.com/media/33b062481c326b7d65815f97da25950c/href</a></iframe><p>What it means for us, is we will always be working in a messy world of imperfect information where we will affect all the things we try to understand. What a scary place to be! Unaware and yet unleashed to move through a fragile world.</p><p>Like a particle in an accelerator, direction is important if we hope to land on solutions that are both “good enough” and “do enough good”. So I would like to present a direction in which to aim for alignment as people and as groups. <strong>Minimum Loving Awareness.</strong> A recognition that the minimum alignment required to act as an organization is not based solely on what creates velocity, but rather velocity applied with loving awareness as our compass.</p><p>What this means is that we should actively ask ourselves the question: “Are we acting with love as our first priority?” If the answer is no, we should question the decision. If we find ourselves acting without asking the question, we should question ourselves. If we act with love in mind, we may make mistakes, but we will have better footing and process to correct them. And hopefully, we can work towards a better world where everyone can express their innate value and creativity.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd7d7d001527" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[You are not an Impostor]]></title>
            <link>https://medium.com/@ryanlynch/you-are-not-an-impostor-7a48a0dddb28?source=rss-1d680a826062------2</link>
            <guid isPermaLink="false">https://medium.com/p/7a48a0dddb28</guid>
            <category><![CDATA[inspiration]]></category>
            <category><![CDATA[problem-solving]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Ryan Lynch]]></dc:creator>
            <pubDate>Sun, 04 Sep 2016 14:52:25 GMT</pubDate>
            <atom:updated>2016-09-04T21:43:51.060Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GpY850CogpytUZFEbSnj9w.jpeg" /><figcaption>Awesome image by <a href="https://www.flickr.com/photos/clement127/">@clement127</a> on <a href="https://www.flickr.com/photos/clement127/19093561751">Flickr</a></figcaption></figure><p>Hi! I’m Ryan, and I’m here to tell you that you are a software engineer. If I could go back and say one thing to my junior noob developer self that would be it. I started out as a dev in the usual way, from zero. Zero can be a scary place to be when your livelihood depends on turning that zero into ones and zeros. I made it through that rough time though, and somehow found the confidence to continue in the field to this day. I’m still a noob time traveler, so in place of myself I’ll try and explain this truth to you in the hopes that it will ease your burden as you work through the challenges of starting out in software development. “You are not an Impostor” is an easy five words to say, but you’re likely a scientist at heart, and so you’ll want to see some proof behind the statement before you start to believe it. So here goes.</p><p>Now I am not the worlds greatest developer, but I’m more than happy to exist somewhere in the top 100%. That contentment is not something I’ve always had, and so I think it’s worthy of reflection. There are two important aspects that distinguish how I feel as a developer today from how I felt about the road ahead of me nearly eight years ago when I started this crazy journey. There’s also one important constant, one superpower that we all have right from the start. I’ll start with the constant, the common thread that binds us all together. I am a problem solver, and you reading this are a problem solver. You even see the meta problem of problem solving and are interested in my thoughts on the subject.</p><p>The crazy thing, and you may see this for yourself in time, is that the process I go through to solve problems in programming is the same today as it was in the beginning. I compare, I contrast, and I try and see the patterns in things. I look for what aspects I understand, and those that I don’t. I apply solutions, and observe outcomes. Basically I throw it all against the wall to see what sticks. You know how to do that too, and that combined with the fact that you strangely enjoy the challenge is the essential skill and personality trait that defines your value as a developer. That alone is why you are not an impostor.</p><p>So you belong in the software development community…whew! Pat yourself on the back. The truth is there are many more people who could be great software developers than there are great software developers. I believe that the world has a huge untapped problem solving potential, and there’s only way to tap into it. I may just put an ad up all over the internet: “Local noob discovers one weird trick to becoming a rockstar developer.” Are you ready for it? Problem solving is the constant, and here are the differences I see in myself today compared to where I was when I started.</p><p>The first difference is so obvious that you’d think it would go without saying. I have seen and solved many problems. Duh, right? I don’t think so. If I had a bit for every time a student asked me how I arrived at some solution, I bet I could at least encode the next sentence in ASCII. There’s no trick to it other than that. That may leave you disheartened if you look ahead and see only the difficulty involved gaining that knowledge. When I started out I saw the same mountain you see that I needed to climb, but looking back I see the path that I took to get where I am today.</p><p>So how do you find that path, and summon the gumption to follow it? That brings me to the second distinguishing feature I see reflected in my approach to solving problems today. This is the less obvious one, but it is the key to gaining that experience. I’m going to show you a diagram, one that is absolutely misleading but hopefully enlightening:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_lR_CdVMYIVe9_A2hQKsng.png" /></figure><p>This diagram is your problem solving space frozen in time, and you’re probably familiar with it. There is the part of the space you’ve seen before, the problems you can solve without any assistance. When we start out that space is so small as to be non-existent, and the miracle of it appearing out of nothingness is one you’ll repeat over and over again as you learn and grow. Then there are the problems where you know part of the solution, but you’ll need to supplement that understanding with outside help. Maybe it’s as simple as searching StackOverflow, maybe you’ll ask another developer for their thoughts. Then there are the problems that are simply too hard for you to solve. That last part is the scary bit, the mountain you see looming before you.</p><p>I said that this diagram is misleading however, and the reason why is that it only represents a single point in time. If you were to observe the shape of your knowledge as a continuum changing over time, you might see what I see: the part you cannot do exists only in the moment before you try to do it. Sure there are some problems that we simply cannot solve in a finite amount of time; and if you’re looking to add a PhD after your name you can have at them. In the day to day development world though there’s nothing I’ve encountered that couldn’t be solved. The solution may be absolutely impractical (and involve pulling a programming <a href="https://en.wikipedia.org/wiki/Kobayashi_Maru">Kobayashi Maru</a>) or difficult to discover, but it’s there. What might be holding you back from searching for it, and what held me back for a long time, is the fear that if you look for it you’ll run into a wall that you can’t climb.</p><p>That is the second difference I see in myself today; I don’t let fear stop me from completely looking for a solution. Maybe the solution requires me to peer all the way to the Google Chrome source code. Do I know C++? Not really, but that won’t stop me from looking. In fact, while I still get frustrated, the greatest skill I’ve developed is embracing problems that force me into the “I am completely lost here” zone. Having done it enough times, I can tell you that even if you don’t find the solution, you always bring back some awesome souvenirs.</p><p>So what can you do to accelerate this process, and reach that potential that is yours inherently? The answer is mind blowingly simple, and will only become more exciting as you make progress. Write code, and read code! I’ve said this before, but in writing code you explore your own unique problem solving process. You also need to read code, especially code you don’t understand. If you don’t stop at the API documentation, and delve all the way into the source, you will learn volumes about how other people solve problems. Repeat this process, and you’ll see the mountain shrink in the distance. So you’re not an impostor, and that mountain is really a permeable barrier that gets easier to cross each time you do it. So be brave, cross it, because you are a software engineer.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7a48a0dddb28" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ReduRx: More App, Less Code]]></title>
            <link>https://medium.com/@ryanlynch/redurx-more-app-less-code-7232c4b4e6bd?source=rss-1d680a826062------2</link>
            <guid isPermaLink="false">https://medium.com/p/7232c4b4e6bd</guid>
            <category><![CDATA[rxjs]]></category>
            <category><![CDATA[functional-programming]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[redux]]></category>
            <dc:creator><![CDATA[Ryan Lynch]]></dc:creator>
            <pubDate>Sun, 10 Jul 2016 12:19:33 GMT</pubDate>
            <atom:updated>2016-07-10T14:10:22.184Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*2ZpUFUtTwyEDCf453HuWRw.jpeg" /></figure><p>As of this writing <a href="https://github.com/shiftyp/redurx">ReduRx</a>, my take on the <a href="https://github.com/reactjs/redux">Redux</a> pattern implemented with observables, is at version 0.3.3; so I thought I’d do a simple write-up with some examples to give a general idea of what ReduRx is and why you might use it. In writing example applications for the library; I’ve found that it does more than I expected, and that you can do a whole lot without a lot of code. So here’s the rationale behind the library, along with some examples of the unique features exposed via ReduRx. If this is tl;dr checkout the <a href="https://github.com/shiftyp/redurx/tree/master/examples/todomvc">TodoMVC</a> and <a href="https://github.com/shiftyp/redurx/tree/master/examples/retweet">ReTweet</a> examples in the ReduRx repository, otherwise read on.</p><p>First, why build it at all. I’ve spent a lot of time writing Redux apps; so I’ve spent a lot of time writing action types, and action creators, and reducers with switch statements, using middleware; all that jazz. When I heard about <a href="https://github.com/Reactive-Extensions/RxJS">RxJS</a>, which implements the observable pattern in JavaScript, I wondered if there was a way to get the same pattern of Redux using observables. So to test out that theory I built ReduRx. It started out as an experiment, and ended up being a pretty powerful tool. ReduRx is like Redux, in that you get the same pattern, but minus the boilerplate and plus observables. So let’s start with the base of any application, state, and see how that’s possible</p><h4>State…the data frontier</h4><p>All applications have state. In fact all things in the world could be said to have state. If you woke up in the morning and I asked you “What’s your physical and emotional state”; you might say “I’m rested, hungry, and ready for the day!” Maybe without the enthusiasm… As the day goes on and events occur, like dinner, that state changes. If I asked you the same question in the evening, you might say “I’m tired, full, and ready for bed.”</p><p>Your application is the same way. The state of your application is the collection of values that the logic of your app acts upon, so you need some way to store state. State changes as events occur in your application, and so you need some way to change state. You also want to know when this state changes, so you’ll want some way to subscribe to state. ReduRx implements all these features using a compact syntax. First, let’s look at a simple and complete example; a counter application:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/daa5c6e627bb4a1e8db4b9f9bd428228/href">https://medium.com/media/daa5c6e627bb4a1e8db4b9f9bd428228/href</a></iframe><p>So here we have state, a counter, and we put that state in a container using the <em>createState</em> function. In doing so we convert the object into a tree of observables, where we can reduce and observe any value at any level. Each node in the tree is an accessor function, so from the root node we access the node for the counter. Then we subscribe to that node’s observable, and console log its value whenever it changes. Once we call <em>state.connect</em>; that subscription activates and we see the initial value for the counter logged to the console. Now that we have state we can subscribe to, we need some way to change that state in response to events. Enter ReduRx actions:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4e6878213a2bcd1a13dad7898e67b356/href">https://medium.com/media/4e6878213a2bcd1a13dad7898e67b356/href</a></iframe><p>Here we define two basic actions; <em>increment</em> and <em>decrement</em>. The nodes in the tree also implement a <em>reduce</em> function, which takes one or more observables, actions, or state nodes; and reduces state in response to those observables emitting values. In this case we take the previous state and increment or decrement the counter. When we call these action functions, we see the new state logged to the console.</p><h4>Real world features</h4><p>Instead of breaking down an entire application, for the sake of brevity I’ll highlight a few useful scenarios and how to approach them using ReduRx. For complete examples check out the examples directory in the <a href="https://github.com/shiftyp/redurx">ReduRx</a> repository. First situation…ajax and promises. Because ReduRx has observables built in, you can handle async and promises easily, no middleware required:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dd1ebe6f762601112dc6be7cc2988a86/href">https://medium.com/media/dd1ebe6f762601112dc6be7cc2988a86/href</a></iframe><p>The additional concept introduced here is the callback passed to <em>createAction</em>. This callback takes the base observable for the action as an argument, and returns a transformed observable to be used by the action. In this case, every time the <em>retrieveMessages</em> action is called, we make a request to our API for some data. When the promise resolves, the action observable will emit the resolved value, which will invoke the reducer passing that value.</p><p>Second situation, computing state from state. In the good ole’ <a href="http://todomvc.com/">TodoMVC</a> application, we have a base list of todos, and a filtered list of todos we’d like to display. If you look at the current <a href="https://github.com/reactjs/redux/blob/845079249648e768361c6d24cf551bb44fc5602a/examples/todomvc/components/MainSection.js">Redux TodoMVC</a> example, this filtered list is calculated within a component and stored there as state. If you can observe state directly, and transform state with a simple focused reducer, why not just do it at the state level instead?</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fb858b25a19030d5aeb5aae28ea6726d/href">https://medium.com/media/fb858b25a19030d5aeb5aae28ea6726d/href</a></iframe><p>Because we can reduce state using any observable (or any object with an <em>asObservable</em> method like the state nodes in this case), we’re not limited to using only actions, we can use state to compute state. Inception…</p><p>The final scenario I’ll share makes use of some RxJS observable features to simplify application logic. This example hits the GitHub Gist API (in reality you need an OAuth token, but I’ve left that out), and requests all new Gists that have been updated since the last refresh. If the action is triggered, it starts an interval of sixty seconds and requests on that interval. If the action is triggered in the meantime (by an impatient user) it will make a request and restart the interval over again. To protect our API Rate Limit from a really impatient user, we want to debounce the refresh action by half a second:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b103234bf258cac456fc9971ca5e7d66/href">https://medium.com/media/b103234bf258cac456fc9971ca5e7d66/href</a></iframe><p>Making use of <em>interval</em> observables, and the <em>debounce</em>, <em>flatMapLatest</em>, <em>timeInterval</em> observable methods, this logic is pretty straightforward to implement without reinventing the wheel.</p><p>So in conclusion, ReduRx gives you the essential pattern of Redux with the power of observables. This let’s you write more logic with less boilerplate, and gives you a rich pipeline to transform events into state. It’s still in an early stage, but I think it’s definitely worth taking for a spin. For more info and examples check out the <a href="https://github.com/shiftyp/redurx">repository</a>, and if you like it give it a try, and if you really like it think about contributing. Thanks, and happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7232c4b4e6bd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Functional JavaScript: The Elevator Pitch]]></title>
            <link>https://medium.com/@ryanlynch/functional-javascript-the-elevator-pitch-cb7cd7a7b3ae?source=rss-1d680a826062------2</link>
            <guid isPermaLink="false">https://medium.com/p/cb7cd7a7b3ae</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[functional-programming]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Ryan Lynch]]></dc:creator>
            <pubDate>Fri, 24 Jun 2016 03:46:21 GMT</pubDate>
            <atom:updated>2016-06-24T03:46:21.672Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/757/1*KaMcfAUznZobqLuQcVCfzw.png" /></figure><p>I’ll start with what is actually a great elevator pitch of the functional approach compared to a more familiar object oriented approach to programming. It doesn’t necessarily imply one is flat out better than the other, instead it lays out a choice of how you choose to handle the complexity inherent in programs.</p><h3>Michael Feathers on Twitter</h3><p>OO makes code understandable by encapsulating moving parts. FP makes code understandable by minimizing moving parts.</p><p>Of the two choices, compartmentalizing complexity vs. reducing it, I’ve decided that reducing it is an easier option for me. What that entails in practice is a big topic, and it can be intimidating to get your feet wet with it. At the same time I think it’s an easy sell once you see the basic rational behind why it’s done at all. There are a lot of resources out there on <em>how</em> to do functional programming, but it was’t until I saw the <em>why</em> of functional programming that I bothered to dig into any of them. I’ll focus on that reasoning in basic terms, and hopefully it will jive with your experience as it has with mine.</p><h4>What is Functional Programming?</h4><p>First, it does have to do with functions (perhaps that was obvious). Functions are a set of inputs, and some output, with some calculations that occur in between. You’re most likely already using functions in your JavaScript code; but beyond just using functions, functional programming is really about imposing some constraints on your code and the functions that you write.</p><p>Constraints is a word that might have some bad connotations, but when you’re programming you’re always working within certain constraints. There are physical constraints like the amount of memory you have available; there are environmental constraints like restrictions on cross origin requests in browsers; and there are language constraints like the upper limit of integer values (which is also connected to physical constraints, but you get the idea). Optimizing solutions given these constraints is what programming is all about.</p><p>Functional programming takes this idea a bit further and imposes some additional constraints. In some languages these are enforced strictly, in others like JavaScript it’s up to the programmer to work within certain guidelines. The practical list I like to use when I’m writing functional code in JavaScript is:</p><ol><li>Really think about how you can reduce the variables you modify.</li><li>If you have to modify variables, limit where you reference them.</li></ol><p>That’s a short list, and I’m sure some will disagree with that, but functional programming in JavaScript is really about how you’re managing the values, or state, that these variables represent within your application.</p><h4>State: The thing you already know about</h4><p>The term “state” in programming is a good one to familiarize yourself with. If I asked in the morning “What’s your physical / mental state right now?” you might say “I’m rested, hungry, and ready for the day!”. These are properties that define how you feel in that moment. If I asked again in the evening you might say “I’m tired, full, and ready for bed”. So as time passes and things happen, like eating dinner, the state that you’re operating on will be different.</p><p>Your applications are the same (although hopefully they don’t have emotional states), and these properties are the values that your application deals with. Let’s say you’re building a number guessing game. “What’s the state of your app?”…”The user has made zero guesses, and there’s no previous guess.” <em>the user enters a guess</em> “What’s the state of your app?”…”The user has made one guess, and the previous guess is 42.” <em>the user enters a guess</em> “What’s the state of your app?”</p><h4>Mutations and Side Effects: The things you may not think about</h4><p>As programmers we spend a lot of time thinking about state, and how our program reacts to it. The complexity of this task increases when state is mutable, meaning that it can be directly changed. If state is mutated, then it could be anything when you decide to use it. This can make your code unpredictable and difficult to reason about, which translates into bugs. That may seem very abstract, but lets look at an example. Let’s say I wanted to create a function that will take a single argument, and add it to some predetermined value. Your first thought might be to store the predetermined value, then create the function that adds an argument to that value.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/63ad825d17aa2aed7f355a84a39dc23f/href">https://medium.com/media/63ad825d17aa2aed7f355a84a39dc23f/href</a></iframe><p>This happens all the time in real code. For example the variable “x” might be a property on some object, and “addition” a method that references it. This does the job, but there’s an issue with this approach. In order to figure out what a given function will do, you have to keep track of the state, or values, outside of the function that it references. By referencing state, then changing that state, the same function will return different values at different times, even though we’re giving it the same input. In functional programming this is called an “impure” function, and it’s susceptible to what are known as “side effects”. All we did was change the value of x from 5 to 2, but a side effect of that was a change in how our addition function behaves. These side effects are not always so obvious, and if you create one without understanding all of its implications it can lead to unexpected problems down the road.</p><p>So how would you create a single function that references a predetermined value, have the ability to later determine a new value, while at the same time not mutating any variables? This may sound like a tough problem, and without introducing any new tools it may very well be. I gave two guidelines above that I keep in mind to write functional programs in JavaScript, but in order to stick to those you need a few new tools on your belt. For this particular situation I’ll introduce a functional concept called Currying (a reference to a person, not a food), which is expressed in JavaScript using closures.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9541cbbdfe4df6bd624701a0a5327321/href">https://medium.com/media/9541cbbdfe4df6bd624701a0a5327321/href</a></iframe><p>So you might cry foul and say “Well you cheated because they aren’t the same function.” It’s true that they aren’t the “same” function in terms of objects in memory. I only wrote the logic once however, so as far as our code is concerned they both represent a single function. So the program above has some state just like the previous example. There’s a value “x” that we’re predetermining and using at a later time. The difference is that when I want different state, the value 2 instead of the value 5, I create a new “x” by calling “createAddition” again instead of modifying the existing “x” to point to a different value. As a result “add5” will always add 5 to the passed number, and yet I can create new state within the scope of a call to “createAddition” and thereby add different numbers together.</p><p>If simply adding numbers seems somewhat contrived and not informative for real world situations, think of some other places you might use this technique. Say you have an event handler, and you’re determining a value before the associated event occurs. Then when the event occurs later on, you want to use that predetermined value for some purpose. That’s an extremely common task, and you could accomplish it by currying the event handler function with the value you want to store. If you were to create different handlers for different events, with different values, none of them would affect each other. This predictability and lack of side effects is exactly why you would code in the functional style.</p><h4>End of Line</h4><p>The elevator has reached the top floor, so my pitch is done. Obviously there’s much more to learn, but when I understood what a side effect was I said “Yeah, I’ve had that happen” and when I saw ways to limit them I said “Yeah, that sounds great!” So I encourage you to seek out all the other functional tools at your disposal to write more predictable code. Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cb7cd7a7b3ae" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Express & Redux: Different Tree, Same Bananas]]></title>
            <link>https://medium.com/@ryanlynch/express-redux-different-place-same-bananas-11f5e5a88a8a?source=rss-1d680a826062------2</link>
            <guid isPermaLink="false">https://medium.com/p/11f5e5a88a8a</guid>
            <category><![CDATA[functional-programming]]></category>
            <category><![CDATA[redux]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Ryan Lynch]]></dc:creator>
            <pubDate>Fri, 20 May 2016 03:30:23 GMT</pubDate>
            <atom:updated>2016-05-20T17:04:04.565Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rKA9o1OB8ncZ54pEFXBLOg.jpeg" /></figure><p>Through the magic of refactoring, I will turn a pair of Express route handlers into a Redux reducer function using only…bananas (<strong>disclaimer:</strong> this post has little to do with bananas, and everything to do with state and functional code). Observe. Take these two express handlers which interact with an imaginary database:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ea2da673de749cd088d4dc20ada8a6ed/href">https://medium.com/media/ea2da673de749cd088d4dc20ada8a6ed/href</a></iframe><p>What are the defining features of this code? Is it functional? Yes it is. Is it stateless? Yes, and sort of. There is shared state in the form of the database. But without some shared state that can be changed or recreated your app would be pretty boring. The code itself though is functional, and we trust the database to manage the shared state. So the code is functional and stateless, but it looks nothing like a reducer. What if instead of using the <strong>app.post</strong> and <strong>app.put</strong><em> </em>methods, we use <strong>app.use </strong>to handle both types of requests?</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/114db89302c4bdc50d27016e13b30b8e/href">https://medium.com/media/114db89302c4bdc50d27016e13b30b8e/href</a></iframe><p>Now it looks a bit more like a Redux reducer function. Requests in a REST API are processed much like actions in the Redux reducer: conditionally and in isolation. I say <em>the</em> Redux reducer instead of <em>a</em> Redux reducer, because much like an Express app it’s really one function composed of smaller functions with some conditional statements to determine which statements are executed in response to an action / request.</p><p>In the case of Express, the request has a URL and a method. The URL is being used to invoke a particular handler that deals with a particular part of the application state. The method is used finally to determine how we’d like to affect that state. With Redux all the reducers are invoked for every action, but there’s an action type which allows for conditionally running code. In both cases actions and requests are processed by their lonesome, with the shared state that they affect being stored in a single place.</p><p>What about that shared state though? How is a database like the Redux store? Well what if we modified things a bit. This is an imaginary database, so we can create our own api as we see fit. Let’s say that we’ve wrapped our handler such that we fetch the entire collection of bananas and pass it as the first argument. We then modify it and set it into the database using a synchronous method in the database api called <strong>setBananas</strong>. We’ll also make this method just handle data, and assume that we send the response in another function.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e965f37744c4193ee0db81f0ddd7b23b/href">https://medium.com/media/e965f37744c4193ee0db81f0ddd7b23b/href</a></iframe><p>This isn’t so different than the previous example, and even closer to a reducer function. Instead of calling <strong>db.insert</strong> and <strong>db.updateById</strong>, all of the banana state is being passed as an argument to our function, and we’re doing the insert and update ourselves directly. If we imagine that the database isn’t a separate server, but just another part of our application, then it doesn’t matter so much where we do the actual update. So we do the specifics of updating the data here, and generically set the new data into the database with <strong>setBananas</strong>.</p><p>This isn’t so different from how the reducer works in Redux. We get the current state as an argument, we create new state, and set it into the store by returning it. Not so different right? In the above example we’re modifying the array and objects directly, so let’s do one more change to create new arrays and objects, and then look at the Redux reducer which performs a similar job:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/de0f0884aa39d6bcabf1f191898d4d30/href">https://medium.com/media/de0f0884aa39d6bcabf1f191898d4d30/href</a></iframe><p>Pretty similar right? So why does this analogy work? It works because Express code for REST API’s and our Redux code is basically functional, and stateless. We process data which represents the artifact of some event, like a request to the server or some user or server event on the client. The side effects that result from that processing, the changes in the state of our application, all happen in one place: the database / store. Because we have trusted code managing side effects, we can focus on writing clean functional applications. Now, how do you like them bananas?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=11f5e5a88a8a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Selfish Side Of Teaching [Code]]]></title>
            <link>https://medium.com/@ryanlynch/the-selfish-side-of-teaching-code-9046f6e91d60?source=rss-1d680a826062------2</link>
            <guid isPermaLink="false">https://medium.com/p/9046f6e91d60</guid>
            <category><![CDATA[happiness]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[education]]></category>
            <dc:creator><![CDATA[Ryan Lynch]]></dc:creator>
            <pubDate>Mon, 09 May 2016 18:59:48 GMT</pubDate>
            <atom:updated>2016-05-09T22:42:25.870Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/588/1*GDC5EhBHyD6nDTWo2DiMmg.png" /></figure><p>In addition to software development and writing prose, I teach people to develop their own software at <a href="http://thinkful.com/">Thinkful</a>, an online coding bootcamp. This article is from my experience teaching coding, but I think teachers in general might relate. I love teaching, and I do it for selfish and unselfish reasons. I teach to help other people learn, but I also teach to learn myself and to better enjoy my work. There should be some personal reward that coexists with any altruistic reasons you have for doing something, otherwise it’s difficult to maintain the effort. So I thought I’d go over the selfish side of teaching from my perspective.</p><h4>Beginners Mind</h4><blockquote>“In the beginner’s mind there are many possibilities, but in the expert’s there are few.” — Suzuki Roshi</blockquote><p>First off, I learn from teaching because the way I understand problems is to see how the same problem looks from someone else’s perspective. Suzuki Roshi, a famous Buddhist teacher, once said “In the beginner’s mind there are many possibilities, but in the expert’s there are few.” So from experts I learn techniques to solve problems, and from beginners I learn possibilities to discover my own solutions to problems.</p><p>Those possibilities come from a place of newfound perspective that I get from teaching. The way I lead others to knowledge is by trying to relate mine in their own words. So I relate a concept, and I adjust my analogies and vocabulary based on how a student relates it back to me. By finding those words I discover a new facet of my own understanding as well. It’s easy to speak in jargon when you know it, but we think in metaphors and in arriving at new ones I find a new way of thinking.</p><h4>The Tree of Knowledge and Roots of Enlightenment</h4><blockquote>The true sign of intelligence is not knowledge but imagination. — Albert Einstein</blockquote><p>In teaching I also keep my ideas fresh, because knowledge isn’t just linear it’s cyclical as well. There’s the technique that I just used the other day, and there’s the basic concept I haven’t really thought about in years. While I’ve learned a curriculum of concepts, I have to walk around that tree of knowledge periodically to see how it’s growing and help it bear fruit.</p><p>This process helps me to enjoy my work more, and that’s the greatest reward for me. Coding for me is mostly about a personal expression of our unique understanding of a problem, and seeing how beginners express their understanding of problems is enlightening. There is so much excitement and imagination that comes with exploring the endless possibilities of software development, and I need to refresh that periodically.</p><h4>Logical Poems and Abstract Code Art</h4><blockquote>An intellectual says a simple thing in a hard way. An artist says a hard thing in a simple way. — Charles Bukowski</blockquote><p>When you program you’re often working on an impersonal optimization problem. You want to write the least amount of code with the fewest bugs and the simplest structure and so on. To that end we could all arrive at the same optimal solution to a given problem. We often don’t however, and instead we write what amounts to a poem expressing our unique view on the solution.</p><p>Because code is a poem written for computers, it’s easy to see it as strictly impersonal, but if you can identify the personal component I think it will bring joy into your work. So to my eyes code is art, in that it expresses our personal and incomplete view of a subject. I work as a professional developer because I love the optimization problem, and I teach because I love the way we express ourselves through suboptimal solutions</p><h4>Sharing Knowledge is a Way to Happiness</h4><p>So I’m a selfish teacher, but to really help others to be happy you have to start by finding happiness for yourself. Coding makes me very happy, both personally and professionally. So the unselfish reason I teach people to code is to help them find their own happiness, and in doing so I learn how to find it for myself.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9046f6e91d60" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ReactDux is a Verb]]></title>
            <link>https://medium.com/@ryanlynch/reactdux-is-a-verb-fad882628bd0?source=rss-1d680a826062------2</link>
            <guid isPermaLink="false">https://medium.com/p/fad882628bd0</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[redux]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Ryan Lynch]]></dc:creator>
            <pubDate>Sun, 08 May 2016 03:46:00 GMT</pubDate>
            <atom:updated>2016-05-08T03:57:07.063Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y6LN4seHxqFoolMmCjNWSA.jpeg" /></figure><h4>MVC Aint’ The Only Way To Be</h4><p>I’m a web developer, so the MVC (Model View Controller) architecture has been my bread and butter for a long time. For me it started with PureMVC, then into Backbone, with brief forays into anything and everything else. Lately I’ve been playing with this little known combination of libraries called React and Redux (henceforth to be known as ReactDux), and it’s made me think about what else exists outside of the world of MVC. Functional programming, like you see in ReactDux, is a bit hard to wrap your head around if you’re used to thinking of things almost exclusively in terms of objects and variables that change. It’s taken me a while, but I think through practice I’ve finally got enough of a handle on things that I can start to put some words together about it. I’ll start with three words, then give three more, and we’ll see how that goes.</p><p>In addition to developing with ReactDux, I also teach the combination to students I mentor at <a href="http://thinkful.com/">Thinkful</a>, an online coding bootcamp. Today I was working with a student on a ReactDux application, and they had tried to organize their code around three words. Three words I’ve uttered so many times in my career that I thought they encompassed the whole universe. <strong>Model</strong>,<strong> View</strong>, and <strong>Controller (MVC)</strong>. When I started with ReactDux I tried to think of things this way too. I mapped Reducers to Models, Action Creators to Controllers, and Components to Views. I got away with this for a bit, but now I think it’s best to start fresh with a new vocabulary instead of shoehorning similar looking things into ill fitting categories.</p><h4>Some New Verbage</h4><p>ReactDux to MVC is a confusing analogy to work under; because Model, View, and Controller are nouns that describe <em>persistent mutable objects </em>that you can create instances of and observe. When you’re writing functional code most of the things you’re dealing with don’t stick around for long, and instead changes flow from one function call to another. So trying to describe what you’re doing in terms of persistent constructs is not informative as to what you should create. It’s a bit confusing because in JavaScript functions are themselves objects, but their real existence is as a behavior that only has meaning when they are called. They’re not nouns, they’re verbs.</p><p>Developing with ReactDux is the process of defining these verbs and letting the frameworks handle the nouns (Store and DOM). So the best TLA (Three Letter Acronym) I could come up with for the combination of ReactDux is not a set of nouns like MVC, but the verbs <strong>Do</strong>, <strong>Change</strong>, and <strong>Show (DCS)</strong>. Unlike nouns which sit and exist across time, these verbs occur in a sequence through time, so in reality the acronym would be <strong>DCSDCSDCSDCS… </strong>on and on until the user closes the browser<strong>. </strong>But if we look at single cycle in this chain then DCS by itself is a good enough description.</p><h4>Easy As ∞ / 3</h4><ol><li><strong><em>const do = (data) =&gt; action</em></strong><br>In the beginning there was nothing: no state, no action, nothing pretty to look at. Then the page loads, the browser springs to life, and you <strong><em>do</em></strong> something. Then your program stops, and as far as your code is concerned there’s nothing again. Then another event occurs, and you <strong><em>do</em></strong> something. In the first case with Redux the action that occurs is <em>undefined</em>, so it could be said that you didn’t actually do anything. But for subsequent events you do the doing. Maybe the user submitted a form and you create something on the server. Maybe the server sends a message over a socket and you assemble some data from it. Maybe you just pass along some value from an event to the next step. This is the realm of <strong>action creation </strong>and the<strong> action creator </strong>function, and whatever you do there’s a consequence, an artifact, and you send that along to the next step as an action.</li><li><strong><em>const change = (state, action) =&gt; state</em><br></strong>Now something has happened, and we need to make some change to the data we were presenting to the user. This data is the <em>state</em> of your application. This is not to be confused with a model however, and change is not to be confused with mutation. State is a temporary thing that exists at a particular point in time, and it can’t be changed just like you can’t change the past. So given the previous state and some artifact of an event, we compute a new state for the application, and it is through creating new state that the illusion of change occurs. We call this behavior <strong>reduction </strong>and these functions<strong> reducers </strong>for the reason that state isn’t continuous and mutable, but instead a static aggregate of all the discrete actions that have occurred in our application up until this point in time. We take that aggregate, and pass it along to the next step as state.</li><li><strong><em>const show = (state) =&gt; dom</em></strong><br>This state however is useless. It’s a set of values stored in memory and has no purpose other than to be shown to the user in some format. So now it’s time to create the interface of the application, and we do this by <strong>rendering</strong> the state with <strong>render</strong> functions. We can call these components, as they are called in React, but only in that they can be composed into a single function that takes state and returns a representation of what the page should look like given this particular state.</li><li><strong><em>wait.then(do)</em></strong><br>There is no step 4…wait a bit and when something happens go back to step 1.</li></ol><h4>RIP MVC (for me anyway)</h4><p>When you look at a ReactDux application as a composition of verbs ad infinitum instead of a discrete set of nouns, then I think the how and why inherent in the process of building applications with it becomes a bit more clear. When you’re done you’ve created two big composed functions (render and reduce), and a myriad of smaller functions (action creators) that allow your app to respond to events and do things in a fine grained way. Events occur, data flows (sometimes with a pause as the server does its thing), and the page is made anew over and over again.</p><p>So forget MVC and other noun based TLA’s when it comes to ReactDux, and try to organize your application around a few verbs instead. Hopefully you’ve been able to see what I’ve been trying to <strong>do</strong> here, I’ve been able to <strong>change</strong> your understanding, and now you can <strong>show</strong> others ReactDux in a new way.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fad882628bd0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>