<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Onurbon</title>
    <description>The latest articles on Forem by Onurbon (@onurbon).</description>
    <link>https://forem.com/onurbon</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F261341%2F575f7e91-71d7-4c47-85aa-14d107e941ba.jpeg</url>
      <title>Forem: Onurbon</title>
      <link>https://forem.com/onurbon</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/onurbon"/>
    <language>en</language>
    <item>
      <title>Why can’t developers KISS?</title>
      <dc:creator>Onurbon</dc:creator>
      <pubDate>Wed, 30 Oct 2019 15:01:24 +0000</pubDate>
      <link>https://forem.com/prodo/why-can-t-developers-kiss-3cgn</link>
      <guid>https://forem.com/prodo/why-can-t-developers-kiss-3cgn</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--q-ZymDLp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/989/1%2AUOqw54Pt4Jx9gNPoBJpLWQ.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--q-ZymDLp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/989/1%2AUOqw54Pt4Jx9gNPoBJpLWQ.jpeg" alt=""&gt;&lt;/a&gt;Software development has become so complex that it’s almost funny.&lt;/p&gt;

&lt;p&gt;I’ve heard many developers praise the “&lt;a href="https://en.wikipedia.org/wiki/KISS_principle"&gt;Keep It Simple, Stupid&lt;/a&gt;” principle in public, but I’m yet to meet one describing the code they work with as “simple”.&lt;/p&gt;

&lt;p&gt;One of my favourite posts of all time, the insightful &lt;a href="https://www.onebigfluke.com/2016/04/whats-awful-building-software.html"&gt;What’s Awful about Building Software&lt;/a&gt;, has already covered nicely &lt;em&gt;what&lt;/em&gt; complex software feels like and &lt;em&gt;how&lt;/em&gt; it affects our lives. So I’m going to assume that you’ve either read it or experienced some of the pains yourself. But having now spent 10 years building software, including the last 3 years building developer-facing products (to try and simplify programming), I wanted to reflect on the reasons &lt;em&gt;why&lt;/em&gt; it is so hard in practice to change our code, our tooling, our culture and the status quo.&lt;/p&gt;

&lt;p&gt;Below are 10 reasons that made it to my list, in no particular order:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;a href="https://dzone.com/articles/developer-ego"&gt;&lt;strong&gt;we have an ego problem&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt; &lt;/strong&gt; — developers can have strong opinions about the right way of doing things, and the right way is &lt;em&gt;their&lt;/em&gt; way, regardless of how complex others find it&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://medium.com/@rajeefmk/why-does-software-developers-suffer-from-imposter-syndrome-ccf961d0c29a"&gt;&lt;strong&gt;we suffer from impostor syndrome&lt;/strong&gt;&lt;/a&gt; — some blame themselves for not being smart enough when they should in fact blame the unnecessary complexity that crept into the code&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://www.grokcode.com/722/be-a-paranoid-pessimistic-programmer/"&gt;&lt;strong&gt;we can be pessimist control freaks&lt;/strong&gt;&lt;/a&gt; — instead of embracing high-level, declarative and automated frameworks, we often prefer the much more complex low-level alternative to remain in full control, just in case we might need this control down the line&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://dzone.com/articles/why-developers-fear-low-code"&gt;&lt;strong&gt;we’re particularly snobbish about low-code&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt; &lt;/strong&gt; — those “Enterprise low-code platform” are designed for the “suits” and not for smart people, right? Granted, the vendor lock-in of traditional low-code platforms can be a non-starter, but why isn’t anyone building an open-source platform?&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://twitter.com/iamdevloper/status/1184779211107717125"&gt;&lt;strong&gt;complex tools make us feel smart&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt; &lt;/strong&gt; — think about complex tools such as Kubernetes or Redux with their ~50k stars on GitHub; those are great for large-scale software projects, but &lt;a href="https://blog.bradfieldcs.com/you-are-not-google-84912cf44afb"&gt;you’re not Google&lt;/a&gt;, and some of us only use them out of vanity (to feel smart or boost our CVs)&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://www.sarahmei.com/blog/2014/07/15/programming-is-not-math/"&gt;&lt;strong&gt;we still confuse code with Maths&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt; &lt;/strong&gt; — yes, good abstractions can be extremely helpful (relational algebra gave us SQL), but there’s nothing simple about functions calling functions calling functions calling functions…&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.coderhood.com/12-reasons-avoid-individual-code-ownership/"&gt;&lt;strong&gt;we get very attached to our code&lt;/strong&gt;&lt;/a&gt; — we might have learned about all the problems that come with “code ownership”, but deep down, we’re still territorial and tend to push back when anyone suggests to refactor our own code just to make it simpler&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://medium.com/@gerstenzang/developer-tools-why-it-s-hard-to-build-a-big-business-423436993f1c"&gt;&lt;strong&gt;radical innovation is hard and risky&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt; &lt;/strong&gt; — how many technical entrepreneurs will dare building disruptive tools to “simplify software” when Microsoft is worth &lt;a href="https://www.theverge.com/2019/4/25/18515623/microsoft-worth-1-trillion-dollars-stock-price-value"&gt;$1T&lt;/a&gt; and controls a big chunk of the developer tools industry, including GitHub?&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://mortoray.com/2015/04/20/nobody-cares-about-your-code/"&gt;&lt;strong&gt;developers care, but no one else will &lt;/strong&gt;&lt;/a&gt;— it could really help if non-technical colleagues were contributing to the effort of keeping code simple, but that’s hard in practice. How could a PM or a designer tell the difference between simple code or complex code?&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.youtube.com/watch?v=fyzYEMVGvM4"&gt;&lt;strong&gt;it’s all because of Trump and Brexit&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt; &lt;/strong&gt; — just kidding here, but doesn’t everything boil down to politics at the end? It might help if society started to care a bit more about &lt;a href="https://link.springer.com/article/10.1007/s12599-010-0102-z"&gt;software transparency&lt;/a&gt;. Perhaps the complexity of software should even be &lt;a href="http://www.europarl.europa.eu/RegData/etudes/STUD/2019/624262/EPRS_STU(2019)624262_EN.pdf"&gt;regulated&lt;/a&gt; one day.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Despite all of the above, I personally remain very optimistic that things will eventually change for the better, simply because software &lt;em&gt;has&lt;/em&gt; to become simpler to write and maintain. The need for software and the &lt;a href="https://www.daxx.com/blog/development-trends/software-engineer-shortage-us-2019"&gt;shortage of developers&lt;/a&gt; have never been so acute, the &lt;a href="https://adtmag.com/articles/2019/08/12/gartner-lowcode.aspx"&gt;low-code space is booming&lt;/a&gt;, and VCs have a &lt;a href="https://www.businessinsider.com/microsoft-github-silicon-valley-investors-2018-8?r=US&amp;amp;IR=T"&gt;renewed appetite&lt;/a&gt; for dev tools, thus creating new opportunities.&lt;/p&gt;

&lt;p&gt;More importantly, and despite all the aforementioned hurdles, there are still many passionate developers out there shipping new open-source solutions to try and fix the complex mess we’re in. If you’d prefer to look at one of those new solutions (instead of just reading me rant about old problems), please consider giving &lt;a href="https://github.com/prodo-dev/prodo"&gt;Prodo&lt;/a&gt; a spin and &lt;a href="https://prodo-feedback-slackin.herokuapp.com"&gt;discussing&lt;/a&gt; it on Slack!&lt;/p&gt;




</description>
      <category>developertools</category>
      <category>softwaredevelopment</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Combining React, Firebase and TypeScript with zero boilerplate.</title>
      <dc:creator>Onurbon</dc:creator>
      <pubDate>Thu, 17 Oct 2019 22:57:40 +0000</pubDate>
      <link>https://forem.com/prodo/combining-react-firebase-and-typescript-with-zero-boilerplate-1c1n</link>
      <guid>https://forem.com/prodo/combining-react-firebase-and-typescript-with-zero-boilerplate-1c1n</guid>
      <description>&lt;p&gt;We’ve spent the last couple of years building a variety of apps with React, Redux, TypeScript and Firebase. We love each of those technologies, but combining everything together in a nice way proved very difficult, and we continue to hear other teams struggling with similar issues. This post summarises our take on the core problems and provides some hints on the solutions that we’re now building.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yyk1UAa---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2A_LfqUA20Ro1RLVm6BEjHmQ.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yyk1UAa---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2A_LfqUA20Ro1RLVm6BEjHmQ.jpeg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The problem: mixing apples with oranges
&lt;/h3&gt;

&lt;p&gt;Building full-stack applications with JavaScript in 2019 often requires integrating at least 3 or 4 pieces:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a framework to manage your visual components, e.g. React;&lt;/li&gt;
&lt;li&gt;a framework to manage your application’s state, e.g. Redux;&lt;/li&gt;
&lt;li&gt;a backend solution for your data and authentication, e.g. Firebase; and&lt;/li&gt;
&lt;li&gt;if you like catching bugs at compile time, a type-system like TypeScript&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A few solutions have been proposed to manage most of the above combination, such as the react-redux-firebase library on GitHub. But after 700+ commits from 80+ contributors (and even the much welcomed introduction of React Hooks), this library has not yet managed to provide a truly simple and intuitive developer experience, and we don’t think it can.&lt;/p&gt;

&lt;p&gt;The core of the problem, in our opinion, is that a React/Redux/Firebase stack will always end up mixing very different patterns and computational paradigms for manipulating data:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🍏 React is processing data with &lt;strong&gt;synchronous functions&lt;/strong&gt; , which are typically &lt;strong&gt;evaluated multiple times&lt;/strong&gt; as the data is loaded and modified,&lt;/li&gt;
&lt;li&gt;🍊Redux doesn’t let you just call functions, but instead forces you to &lt;strong&gt;dispatch actions&lt;/strong&gt; which modify data using reducers that are typically &lt;strong&gt;evaluated a single time.&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;🍏 Because redux itself doesn’t have built-in support for asynchronous effects, you’ll probably introduce the concept of &lt;strong&gt;thunks&lt;/strong&gt; (with redux-thunks) or &lt;strong&gt;sagas&lt;/strong&gt; (with redux-sagas)&lt;/li&gt;
&lt;li&gt;🍊Or you might have replaced redux by an alternative, thus introducing yet more concepts such as &lt;strong&gt;observables&lt;/strong&gt; (e.g. MobX) or &lt;strong&gt;streams&lt;/strong&gt; (e.g. Rx)&lt;/li&gt;
&lt;li&gt;🍏 The interaction with Firebase relies on &lt;strong&gt;asynchronous functions&lt;/strong&gt; , and the real-time data from Firestore is updated multiple times using &lt;strong&gt;subscriptions&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;🍊React Hooks may then be used to try and simplify a lot of the above, but they rely on yet another paradigm. Hooks are intuitively a form of &lt;strong&gt;dependency injection&lt;/strong&gt; , and they typically handle the asynchronous nature of side effects using &lt;strong&gt;callback functions&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is a huge technical mess, and is a very typical example of “framework fatigue”, something that is only getting worse in the JavaScript world. It is not an intuitive way to build applications, and forces beginners to deal with a steep learning curve. And it’s also a real-world problem for experts; writing code takes longer because of the boilerplate, reviewing code takes longer because of the general awkwardness and inconsistency, and writing tests is very cumbersome — meaning that you probably won’t write that many. And on top of all that, getting useful feedback from TypeScript is hopeless because most of the data coming from Firestore won’t be typed.&lt;/p&gt;

&lt;h3&gt;
  
  
  The solution: rethinking state management
&lt;/h3&gt;

&lt;p&gt;We believe the problem of inconsistent patterns and paradigms can only be tackled by changing the layer that ties every thing together: the state management layer. A lot of simplicity can be achieved by reinventing state management with the right priorities in mind. In particular, we think that a good solution should:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Provide (most of) the same benefits as Redux, without the boilerplate and unnecessary abstractions (we’ll typically rely on proxies and/or transpilation to achieve this).&lt;/li&gt;
&lt;li&gt;Drastically simplify the computational model to keep it in line with React (based on synchronous functions, evaluated multiple times).&lt;/li&gt;
&lt;li&gt;Allow users to integrate backend technologies like Firebase by adding a “plugin” (in contrast to Redux’s middleware system, which is very low-level).&lt;/li&gt;
&lt;li&gt;Enable maximal TypeScript inference by design (meaning that you define your schema once, and then TypeScript infers all your types, without requiring manual annotations).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Replacing Redux is quite an ambitious task — we’re talking about a library with 50k+ stars on GitHub, and more than 3M weekly downloads on npm. And we’re also not the first developers interested in replacing Redux (we found about ~100 related libraries on GitHub). But we haven’t found any attempt that followed the same priorities.&lt;/p&gt;

&lt;p&gt;You might also have encountered dozens of “Redux is dead” blog posts on Medium in the last few months, often making the argument that GraphQL and/or React Hooks can help you get rid of Redux. But we found no real evidence of this outside of toy examples of apps. Hooks only provide a more convenient syntax to deal with React state or React context, but they’ve not drastically changed state management. Neither Hooks nor GraphQL have truly replaced Redux — they only let you reduce the amount of Redux needed in your application. That’s why we believe that state management remains a problem worth digging into.&lt;/p&gt;

&lt;h3&gt;
  
  
  Show me some code!
&lt;/h3&gt;

&lt;p&gt;DISCLAIMER: We’re still experimenting with different options and invite you to check &lt;a href="https://github.com/prodo-dev/prodo"&gt;our repo&lt;/a&gt; to see what our framework looks like today. But we would also love your feedback (on &lt;a href="https://prodo-feedback-slackin.herokuapp.com/"&gt;Slack&lt;/a&gt; or in the comments below this article) on the syntax and architecture that we’re envisioning for the long term, which is outlined below.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Define your data models&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Prodo will give you a function dataModel parameterised by a type definition and a list of plugins. You’ll then be able to export variables such as state (the redux-state of your app), auth (the authentication data, automatically pulled from Firebase) and db (automatically synced with Firestore) which can be used directly in your action definitions. You’ll also be able to export a hook called useData to use (and watch changes in) the data in your React components.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Note in the above that we’re not exporting any type definition, because we won’t need any in the other files. That’s because we’ll be able to infer everything from the types of db, state, auth and useData.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Define your actions&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Prodo actions will be defined as plain old JavaScript functions and those function will be able to use mutation operations to modify data in your state and your database, as if they consisted of in-memory JSON objects. But this is obviously an abstraction.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Under the hood, we’ll use &lt;a href="https://immerjs.github.io/immer/docs/introduction"&gt;immer.js&lt;/a&gt; to implement copy-on-write semantics and keep track of data changes in a non-destructive way (thus making time travel debugging possible). We’ll also rely on dynamic binding to map state and db to the current execution context of each action. Intuitively, this means that an expression such as state.roomId will in fact evaluate to window.currentProdoContext.state.foo. This global variable currentProdoContext will then need to be to swapped when different actions start and terminate, by we’ll be able to do this in a reliable way as long as long as actions remain synchronous.&lt;/p&gt;

&lt;p&gt;Note however that keeping actions syncrhonous doesn’t prevent us from using asynchronous &lt;em&gt;effects&lt;/em&gt;, although this will also require special care. In particular, if the newId function in the above snippet was fetching some remote data, it would first need to throw an error saying “I’m not ready yet!”, and the action will need to be restarted from the top when the data does come in.&lt;/p&gt;

&lt;p&gt;Those are only some of the technical details that will need to be addressed, but this was hopefully enough to give you an idea of how we want to bring the computational model closer to React’s model, using only synchronous functions, and allowing to re-evaluate these functions multiple times until all the data is ready and the computed patched can be applied.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Using your data and actions from React&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;After defining our data models and our actions, we will then use them directly in React with the (typed) hooks that we have exported:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Here is what a Message component would look like:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Here is what a RoomSelector component (with a controlled input) would look like:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Here is what a PostMessage component would look like:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Finally, here is what our chat application will look like at the end, using a query function from Prodo’s plugin to pull and watch collections from Firestore:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;A fair amount of non-trivial heuristics will be needed to ensure that the above components are re-rendered (efficiently) when the data is updated, but the experiments we’ve conducted so far suggest that we should be able to match Redux’s and MobX’s performances. You may also note that the above example — unlike most frameworks — are not requiring you to wrap every single component inside a “connect” functions. This is again something we’ve been able to achieve in our experiments (by dynamically redefining React’s createElement function to auto-connect all the relevant components), but the performance implications there will also require proper testing. And these are only some examples of the exciting challenges which we’re tackling now to achieve a truly simple, boilerplate-free experience for our users.&lt;/p&gt;

&lt;h3&gt;
  
  
  What now?
&lt;/h3&gt;

&lt;p&gt;If you’ve liked what you’ve read so far, or just want to see where this is going, please consider starring our &lt;a href="https://github.com/prodo-dev/prodo"&gt;repository on GitHub&lt;/a&gt;, to let us know that you care. You can also stay up-to-date with upcoming features, and more importantly, join the discussion by joining our &lt;a href="https://prodo-feedback-slackin.herokuapp.com/"&gt;Slack Community&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you want to jump right in, you can try Prodo today — our docs are online at &lt;a href="https://docs.prodo.dev/"&gt;https://docs.prodo.dev&lt;/a&gt; and you can quickly build your own example by following the tutorial &lt;a href="https://docs.prodo.dev/tutorials/github-prs/"&gt;here&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>redux</category>
      <category>typescript</category>
      <category>firebase</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
