<?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 Paulo Esteves on Medium]]></title>
        <description><![CDATA[Stories by Paulo Esteves on Medium]]></description>
        <link>https://medium.com/@pauloesteves8?source=rss-d2375d1d713------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*26SoPXm9GvfuVlE52qEmew.jpeg</url>
            <title>Stories by Paulo Esteves on Medium</title>
            <link>https://medium.com/@pauloesteves8?source=rss-d2375d1d713------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 06:18:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pauloesteves8/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[AI and the Ever-Increasing Distortion of Reality]]></title>
            <link>https://pauloesteves8.medium.com/ai-and-the-ever-increasing-distortion-of-reality-2c59f01cde58?source=rss-d2375d1d713------2</link>
            <guid isPermaLink="false">https://medium.com/p/2c59f01cde58</guid>
            <category><![CDATA[polarization]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[social-media]]></category>
            <category><![CDATA[time-well-spent]]></category>
            <dc:creator><![CDATA[Paulo Esteves]]></dc:creator>
            <pubDate>Wed, 23 Sep 2020 14:37:57 GMT</pubDate>
            <atom:updated>2020-09-23T14:47:41.909Z</atom:updated>
            <content:encoded><![CDATA[<h4>The methods we use to discern what is true will become the most effective way to deceive us</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NZu_sgHMSum-teLczv4GqQ.jpeg" /></figure><h3>The Outrage Machine</h3><p>More and more people are aware of the tragic consequences of the ad-based business model many tech companies adhere to. Here’s the recursive algorithm that’s been changing the world:</p><p>1 — To earn more ad revenue, users must spend more time on these platforms (e.g., social media, YouTube, etc.), which happens if they provide content that most effectively captures their attention. AI algorithms calculate, <strong>for each person individually</strong>, what most effectively captures their attention, which happens to be, quite often, fake, misleading, or outrageous content — the algorithm doesn’t really know whether the content is deceptive, out of context, or outrageous, only that it increases engagement.</p><p>2 — Different people watching different outrageous content will become outraged for different reasons.</p><p>3 — Let the whole thing run its course for a while. The result is a society divided into countless factions of people, each with a completely distorted view of the world, whether by overestimating or underestimating real problems or by merely believing fake conspiracy theories. Each group, frightened, furious, and shocked at how other groups seem to ignore what is obviously “true” (informed by content that never actually shows up in any other group’s feed), gets ready to furiously defend what is “right.”</p><p>4 — But that’s mostly fine. Because as violent and tragic consequences materialize in real life over, and over, and over again, everyone will get super outrageous and share <em>that </em>on social media and YouTube, thankfully increasing what matters most: ad revenue — back to step #1.</p><p>One of the most insidious aspects of this whole thing is that, even if there were no actually fake content being shared, users would still be misled by the frequency with which they are exposed to outrageous content, overestimating the radicalization of their adversaries. This overestimation, in turn, results in actual radicalization as a response to the exaggerated perception of others’ radicalization, creating a tragic feedback loop that kind of works like a self-fulfilling prophecy. Once radicalization numbers get higher, everyone involved will have their biases confirmed. No one will spend more than two minutes wondering about the impact that recommendation engines might have had in all of this.</p><p>These companies don’t intend to cause social havoc. In fact, they certainly would prefer to make money while bringing all sorts of benefits (which they do), without any drawbacks. That’s certainly what most executives <a href="https://www.theguardian.com/technology/2014/nov/03/larry-page-google-dont-be-evil-sergey-brin">thought they were doing</a> when they started this. But this isn’t about intentions; it’s about consequences resulting from certain incentives. And the incentives have to change, whether through government regulation, boycott, or some new, more ethical monetization source.</p><h3>An Even More Outrageous Future</h3><p>The scary thing here is that what I wrote above is where we are <em>right now. </em>But unless incentives change, this can get much worse.</p><p>Here are two examples: deep fakes indistinguishable from reality and individually targeted automatically generated text. The former will be used intentionally as a source of disinformation, whereas the latter, whether or not used to spread lies, will inevitably lead to polarization.</p><h4>Deep Fakes</h4><p>Deep fakes aren’t perfect, you can usually tell that there’s something off, but <a href="https://www.wbur.org/hereandnow/2019/10/02/deepfake-technology">soon that won’t be the case anymore</a>. Hopefully, the same technologies that allowed for the development of deep fakes <a href="https://news.berkeley.edu/2019/06/18/researchers-use-facial-quirks-to-unmask-deepfakes/">will become better at detecting them</a>, but that likely won’t entirely prevent fake videos’ proliferation, as the <a href="https://www.vice.com/en_us/article/ywyxex/deepfake-of-mark-zuckerberg-facebook-fake-video-policy">indiscriminate removal of any videos with deep-fake technology</a> might not be desirable. The technology can be used for satire or art, but the line between <a href="https://www.creativebloq.com/features/deepfake-examples">humor and deception can become tenuous</a>. And even if misleading fake videos get correctly identified and reported, just the fact that <em>any </em>video can be bogus will be enough to demoralize and give the sense that one can’t trust anything anymore. That’s the most significant risk in the end. Despite being known for not having qualms related to censorship, China is trying to solve this problem by making it illegal to share deep fakes, unless <a href="https://www.reuters.com/article/us-china-technology/china-seeks-to-root-out-fake-news-and-deepfakes-with-new-online-content-rules-idUSKBN1Y30VU">users label them as such</a>. This could help respect the principle of freedom of expression while preventing the proliferation of dissimulative practices. Whichever solutions appear, both governments and tech companies must admit that this is a severe problem that needs addressing. Since most people can’t spend hours investigating the timestamps and origins of videos — <a href="https://www.wired.com/story/the-blockchain-solution-to-our-deepfake-problems/">though blockchain technology might help with this</a> - there will come a time when people will debate which video came first, the deep fake or the original, depending on which version makes the other side look good or bad. At the very minimum, <a href="https://www.forbes.com/sites/jessedamiani/2019/09/03/a-voice-deepfake-was-used-to-scam-a-ceo-out-of-243000/#7a50655a2241">scams using deep fakes will become much more common</a>.</p><h4>Automatically Generated Text</h4><p>In the podcast <a href="https://www.humanetech.com/podcast">Your Undivided Attention</a>, <a href="https://www.humanetech.com/who-we-are">Tristan Harris and Aza Raskin</a> discuss the hypothetical AI usage of generating text at the individual level. An incredibly narrow form of <a href="https://blog.mozilla.org/internetcitizen/2018/10/04/microtargeting-dipayan-ghosh/">microtargeting</a>, this would allow a company like Facebook to use the history of all messages that a given user has sent and received to generate an ad targeted in a way to be as familiar as possible to the user. Imagine if everyone received a separate, perfectly suited message, whether it’s a text message or some sponsored post that felt like a conversation you would have with your best friend or sound like the public intellectuals you follow online and trust the most. <strong>The ability to use tone and choice of words as a tool to gauge credibility would become useless and could instead be used to tailor a message that would most likely move you.</strong> Without the public exposure that a billboard or a news channel has, tracking these sorts of campaigns would be nearly impossible, and having these messages tailored individually would raise the levels of deceit and polarization to new heights. With the recent release of the <a href="https://www.technologyreview.com/2020/07/20/1005454/openai-machine-learning-language-generator-gpt-3-nlp/">GPT-3 system</a>, generated text indistinguishable from a human is already here. There’s an issue here that shouldn’t be overlooked: even if the content isn’t explicitly misleading, the bubble effect of being exposed to the content that most likely will engage you, will distort your perception of reality, for instance, by leading you to overestimate the frequency of certain events, due to the <a href="https://www.behavioraleconomics.com/resources/mini-encyclopedia-of-be/availability-heuristic/">availability heuristic</a>.</p><h3>What Can We Do</h3><p>The widespread consequences of these companies’ recklessness are very real. From the alarming increase in <a href="https://journals.sagepub.com/doi/10.1177/2167702617723376">depression rates, self-harm, and suicide in teenagers</a> to <a href="https://www.bbc.com/news/world-asia-india-44435127">multiple murders in India resulting from fake rumors</a>, <a href="https://www.reuters.com/article/us-myanmar-rohingya-un/myanmar-generals-had-genocidal-intent-against-rohingya-must-face-justice-u-n-idUSKCN1LC0KN">from the killing of specific ethnic groups</a> to the <a href="https://www.omidyargroup.com/wp-content/uploads/2017/10/Social-Media-and-Democracy-October-5-2017.pdf">decline of democratic principles worldwide</a>. All fueled by drastically distorted perceptions of what’s true and what matters.</p><p>Tech companies transcend borders. They affect the world horizontally, making it difficult to regulate their behavior in an effective way. <a href="https://eur-lex.europa.eu/legal-content/EN/TXT/?uri=CELEX%3A32016R0679">Some countries are developing laws</a> to tackle these problems, but only a few. And those laws are far from being enough. Moreover, the accelerating speed with which technology evolves makes it incredibly hard for lawmakers to know what to look for unless their background is rich in knowledge and experience of this industry, <a href="https://www.nytimes.com/2018/04/12/business/congress-facebook-regulation.html">which is quite rare</a>. Because of all this, the rate of public discussion related to this problem has to increase drastically.</p><p>There are two things we should do right away:</p><p>1 — Get informed. As I was writing this text, the <a href="https://www.humanetech.com/">Center for Humane Tech</a> released a documentary called <a href="https://www.netflix.com/pt-en/title/81254224">The Social Dilemma</a> that is the best introduction to this problem I know. It leaves out many important details that are discussed in their podcast <a href="https://www.humanetech.com/podcast">Your Undivided Attention</a>. I also recommend their <a href="https://www.humanetech.com/">website</a>, which includes calls to action, suggestions to improve our relationship to tech, and forums where this is being discussed in more depth.</p><p>2 — Inform and help others understand the problem so we can all incentivize lawmakers and tech companies to do something about this. One good example of this is the <a href="https://www.stophateforprofit.org/">Stop Hate For Profit</a> campaign.</p><p>The software these companies develop should work as tools that serve <em>us,</em> not the other way around. Many of these companies started with a <a href="https://observer.com/2009/07/the-evolution-of-facebooks-mission-statement/">commitment to improve communication, build connections, and strengthen relationships</a>. Let’s make sure they stand by their commitments.</p><p><strong>If you found this article useful, feel free to </strong>👏<strong> or leave a comment.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2c59f01cde58" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[6 movie sequels that ripped off their originals]]></title>
            <link>https://pauloesteves8.medium.com/star-wars-episode-vii-and-5-other-sequels-that-ripped-off-their-originals-4be199cfef77?source=rss-d2375d1d713------2</link>
            <guid isPermaLink="false">https://medium.com/p/4be199cfef77</guid>
            <category><![CDATA[movies]]></category>
            <category><![CDATA[star-wars]]></category>
            <category><![CDATA[hollywood]]></category>
            <category><![CDATA[comedy]]></category>
            <category><![CDATA[image]]></category>
            <dc:creator><![CDATA[Paulo Esteves]]></dc:creator>
            <pubDate>Thu, 15 Mar 2018 00:04:09 GMT</pubDate>
            <atom:updated>2020-11-30T20:01:16.843Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1pI5ng2YOsliqY5tm3csqQ.jpeg" /></figure><p>Hollywood loves sequels. And why shouldn’t they? In the past few years, almost all of the <a href="https://en.wikipedia.org/wiki/2010s_in_film#Highest-grossing_films">highest grossing movies worldwide were a sequel</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/881/1*7MTDANs6EH16dg4UHzqMlA.png" /><figcaption>In case clicking the Wikipedia link is too exhausting.</figcaption></figure><p>A sequel is in itself already a safe move, but sometimes they really, really, really want to make sure everything goes as well as the first time. The easiest way to do that is to do the same movie all over again and pretend it’s another at the expense of having stories that end up being comically far-fetched.</p><p>That’s precisely what happened in the sequels to the great movies featured in this article. If you don’t already hate them, hopefully you will now.</p><p><strong>1. The Hangover Part I and II</strong></p><p>The Hangover was such a surprising success that sequels were to be expected. However, anyone would assume they would take a route similar to Judd Apatow’s Knocked Up “sequel”. Now even though <a href="http://www.imdb.com/title/tt1758830/">This is Forty</a> didn’t really work out all that well, the idea of taking characters from one story and develop them in a totally different one was definitely interesting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u1gexV5QQJL3PC76zKfrjw.jpeg" /><figcaption>But then again, why not save time and reuse the same storyboards?</figcaption></figure><p>I’m not even saying that the movie shouldn’t be about a hangover. I’m just saying that it shouldn’t have been about the same Hangover, except in Bangkok instead of Las Vegas</p><p>… and with a monkey instead of a baby</p><p>…and with Stu having a tattoo on his face, instead of a missing tooth</p><p>… and with having them steal a monk, instead of a tiger</p><p>… and with Stu getting involved with a transsexual prostitute, instead of a stripper and</p><p>… you get the idea.</p><p>Both movies start with a scene in which people are relaxing in a paradisaic scenery waiting for a wedding that will take place in a few hours. Doug’s fiancée/wife answers a phone and Phil tells her that they “fucked up”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JvM_Q1JctnOuoGxC4isoTw.jpeg" /></figure><p>Cut to a montage accompanied by a song by Danzig (that sounds almost exactly the same in both movies) and we go back a couple of days when everyone was happy.</p><p>In The Hangover, Doug’s getting married and Stu is treated like shit by his girlfriend.</p><p>In The Hangover Part II, <em>Stu</em>’s getting married and he’s treated like shit by his future father in law.</p><p>The guys decide to celebrate the upcoming wedding and have toast at night.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_kOTK4X0ZZ4QmzWzoJgwNQ.jpeg" /><figcaption>“To an enriching night of moderate enthusiasm, gentlemen”</figcaption></figure><p>The next morning, they’re lying on the floor of a wrecked hotel room with no memory of the previous night.</p><p>A member of the group is missing: Doug (the groom) in The Hangover (H1) and Teddy (the bride’s brother) in The Hangover Part 2 (H2).</p><p>Stu has something different on his face.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*abZGPFuW9rkm81JA6b5K-A.jpeg" /></figure><p>After a while, they realize they happen to have a baby around in H1 and a monkey in H2, having no idea how either ended up with them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-AwnYxZIWuJdr0Un7OAhyQ.jpeg" /></figure><p>At one point, they realize they kidnapped a tiger from Mike Tyson’s mansion in H1 and a monk from a Buddhist monastery in H2. They return them and learn more about the previous night.</p><p>Then, in H1, Alan pretends that the baby is masturbating. In H2 Alan pretends that the monkey is doing a blowjob to the monk.</p><p>“That’s wrong. You shouldn’t be doing that.” everyone says while laughing during a sweet moment of camaraderie.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5sqCUYnrLZpiYCUPVDsj7g.jpeg" /></figure><p>Stu plays a funny song describing their situation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y0xoxXaRSLo8Z1UBFYg2kA.jpeg" /></figure><p>Then…</p><ul><li>Alan admits having drugged everyone, thus explaining the fact that they didn’t remember anything.</li><li>They have to make sure that a sum of money ends up in the hands of a criminal who allegedly is holding Doug/Teddy hostage.</li><li>After succeeding, turns out the guy they gave the money to didn’t have their friend, after all.</li><li>Phil calls Doug’s fiancée/wife (the scene described in the beginning) and Stu has a <a href="https://www.urbandictionary.com/define.php?term=a%20House%20moment">Dr. House moment</a> when he realizes Doug/Teddy has been at the hotel this whole time. Doug’s on the roof and Teddy is stuck in an elevator. Doug has a sunburn all over him, and Teddy is missing a finger.</li><li>They rush back to the wedding, where Stu confronts the person who was bullying him. His girlfriend in H1 and his future father in law in H2.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FAhDVG_WJkddquFJZyMMjw.jpeg" /><figcaption>”Sure, I married a hooker and had a transsexual prostitute ejaculate inside my ass, so what? I don’t understand your lack of confidence in me, I really don’t.”</figcaption></figure><p>All is well and the guys relax together after the wedding.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JD83sDB7_U0Ysv2iu_vlsg.jpeg" /></figure><p>One of the characters finds the camera they used that night. They all agree to delete the photos after watching them and promptly do some silly faces before cutting to the credits/photos sequence.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4gh1bwpc1JFq4DVhyAZlig.jpeg" /></figure><p>The photos include all sorts of shocking stuff including a lot of nudity, oral sex, people doing drugs, Carrot Top, and worst of all, Carrot Top doing drugs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A8xpp0chex8-m_ONkjRUgQ.jpeg" /><figcaption>LOL, those guys are wack!</figcaption></figure><p>They did, however, try diverging the formula slightly with The Hangover Part 3 and that ended up being the least successful, both <a href="http://www.rottentomatoes.com/m/the_hangover_part_iii/">critically</a> and commercially. But… good effort guys.</p><p><strong>2. Home Alone 1 and 2</strong></p><p>Home Alone is one of the most recognizable movies ever. Most of you watched it on Christmas unless Die Hard was on. With a budget of only 17 million, the movie became the highest grossing live-action comedy of all-time, making a total of <a href="http://www.boxofficemojo.com/movies/?id=homealone.htm">over 533 million dollars</a>.</p><p>Since no one expected such success, the producers figured they should redo the same thing and hope it works. The repetition of so many sequences from the first movie should have made some of the characters wonder if they weren’t living in a broken simulation.</p><p>Both movies start with everyone getting pissed at Kevin after he gets in trouble.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z3TnEtan-4B9XflgCjeGWg.jpeg" /><figcaption>“You’re a piece of shit, Kevin.”</figcaption></figure><p>Then, Kevin gets sent to the attic, where he tells his mother he wished his family disappeared/had his own vacation alone. She tells him that he may get what he wishes for.</p><p>The next morning, both parents wake up late and end up rushing to the airport, leaving Kevin behind in the process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xpnjkfgEnQMfORZ4-oKwQQ.jpeg" /></figure><p>During the flight, Kevin’s mother asks her husband if they aren’t forgetting something. He assures her they aren’t and shortly after, she realizes what happened.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fqSpJ1dx_UdhX60c9ooIpg.jpeg" /><figcaption>Same old neglectful parenting, new hairstyle</figcaption></figure><p>In both movies, Kevin then proceeds to have the greatest time of his life, including watching a made up classic noir movie while enjoying a nice bowl of ice cream.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2Y-OMkxVARgro0B2glP6ng.jpeg" /><figcaption>“Oh hai”</figcaption></figure><p>Meanwhile he’s afraid of a weird creepy person who is actually harmless.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k1dgwk1fGOmSTkacX6Axtg.jpeg" /><figcaption>They try so hard to look friendly. Kevin’s just an asshole who hates old people</figcaption></figure><p>Later, he has fun using the noir films to scare the shit out of some poor saps…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BI5Q1f947Sx107HDfK7aRQ.jpeg" /><figcaption><a href="https://www.youtube.com/watch?v=4dGOfFbzvq4">God, I wish they actually made a real movie from those</a></figcaption></figure><p>…and starts to realize that he misses his family.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ujfDPgHWHg540AQ-U1ugeg.jpeg" /></figure><p>Meanwhile, the Wet Bandits are planning a robbery (houses that are empty for the holidays in Home Alone 1 and a toy store in Home Alone 2).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T6XaMWbexig6A9Bj6bFLWQ.jpeg" /></figure><p>Kevin realizes that the scary character is actually a nice person and during a brief conversation with old dude/bird lady he learns how important families are.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X1R5LP05kXqdrxvlgi92sg.jpeg" /><figcaption>Apparently, it only took him one year to completely forget the valuable lessons learned the first time</figcaption></figure><p>Kevin then proceeds to prepare a bunch of traps to torture and humiliate the Wet Bandits.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kMwhyA2QixUItPoBBg1HIA.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MMP12HxRpgHIvqi_vKpEaA.jpeg" /></figure><p>Despite his heroic attempts, the Wet Bandits outsmart Kevin and finally catch him.</p><p>In the first movie, they intend to bite his fingers off (Jesus Christ!).</p><p>In the second one, they figure they should go a step further and actually shoot him in the head in the middle of NY, cause why not, right?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8vrE7fPkU6BHXt4P3oVFvg.jpeg" /><figcaption>Great character evolution for the Wet Bandits</figcaption></figure><p>All of the sudden, the previously scary character comes out of nowhere, saves the day and the bad guys go to jail.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d3cfQg1kSsRrcSIrWdM6gA.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tGJeQSBcok6bRcHH0vit4w.jpeg" /></figure><p>Kevin ends up getting back together with his mom.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OO8RgYOz7g9m6NQd7FKqLg.jpeg" /></figure><p>In the end, old man solves his personal problems. Lady covered in bird poop stays covered in bird poop but gets a turtle dove from Kevin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5aRLJO1jHFIoyqBuMxRy6w.jpeg" /><figcaption>What a great reward for someone who saved a kid from getting murdered</figcaption></figure><p>Finally, the movie ends with someone off screen yelling at Kevin. He then runs away.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*teEDHzce58MR1n4QxWLTVQ.jpeg" /><figcaption>This is also his face when realized <a href="https://www.youtube.com/watch?v=YXE3Ku-mGrk">the guy that told him “where the lobby is</a>” would become the President of the United States</figcaption></figure><p><strong>3. Ghostbusters 1 &amp; 2</strong></p><p>The first Ghostbusters was a refreshing comedy that used a very unusual mix of laughs and special effects. It also involved some of the biggest comedy legends of the past few decades (Harold Ramis, Dan Aykroyd, and Bill Murray in his most notorious role). It’s no surprise that it almost made 10 times its budget making it the highest grossing movie of 1984.</p><p>In the case of Home Alone, it didn’t really make much sense to write a sequel to such a specific plot. But a Ghostbusters sequel made perfect sense. There were so many different ways to develop new stories within that universe. With all the myths, folklore, mystical creatures and religious texts, they could come up with all kinds of crazy stuff in all kinds of new locations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RYRtEmvk2Pyz1btqunZJmg.jpeg" /><figcaption>”That’s true, but according to the psycho kinetic readings of the ionized magnotheric sternocleidomastoid sample, we should repeat the exact same story instead”</figcaption></figure><p>Both movies start with the Ghostbusters facing financial problems.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pA-txpmWaZ2pt6hmiZ-oOw.jpeg" /><figcaption>Tough life</figcaption></figure><p>In the first one they get fired from the university and ask the bank for a loan to finance their paranormal extermination service, a perfectly reasonable set up. In a desperate attempt at repeating the same arc in the second movie, the Ghostbusters are broke <strong>again</strong> because:</p><p>1 — They were sued for the property damage they caused in the first movie</p><p>2 — Got barred from investigating the supernatural</p><p>Take a moment to appreciate how in the second movie everyone still thinks they are a fraud, even though the entire city saw an army of ghosts and a giant walking marshmallow in the middle of New York a few years back.</p><p>So anyway, in the first stages of both movies, they save the day by capturing a ghost (In a hotel in GB1 and in a courtroom in GB2) launching them into stardom.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tGmccljiBeKhFsw8uwYejQ.jpeg" /><figcaption>No stream crossing, of course</figcaption></figure><p>We are then presented with a classic 80s montage of the Ghostbusters being popular and needed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j_aJnJzLcGkmz6TwmZVw0w.jpeg" /></figure><p>A woman named Dana, whose favorite pastime is avoiding horny dorks…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jbcaowJh8-6Xu1qoCOT0nA.jpeg" /><figcaption>Because 80s</figcaption></figure><p>…has been facing a particular supernatural problem that intrigues the Ghostbusters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d1WbtPFSyTcOVz4xAnxKlQ.jpeg" /><figcaption>“You again?”</figcaption></figure><p>Peter Venkman then proceeds to play the cool member of the team whose job includes hitting on the pretty girl.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8iGek9XOsoIbmSiRN8hjXw.jpeg" /><figcaption>Naturally, their relationship ended after the first movie so they could do the whole “Peter chases Dana” thing again</figcaption></figure><p>Then, some annoying asshole in a suit tries to shut them down.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vx0j2J0GpRlfawPRPQhG5Q.jpeg" /><figcaption>Same old obnoxious antagonist trope, brand new character</figcaption></figure><p>The Ghostbusters also try to convince the mayor about the incoming dangers, but the mayor is pretty skeptical. Again, this happens in both movies. <strong>It’s still the same mayor!</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HUKDUM4LmU_pqTmHJ1LKFA.jpeg" /><figcaption>“Just because you were right all along the first time this happened, I should trust you all of the sudden?”</figcaption></figure><p>Eventually, the douche bag gets them arrested.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2g7eXQjZEI87kdfKGbQZGw.jpeg" /></figure><p>While they’re locked away, we’re presented with another 80s montage, this time showing a lot of freaky shit happening in the city. It’s like a Rocky Montage, but with evil spirits.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tq1Pf0RTSoVPvTg3IPpDdA.jpeg" /><figcaption>”We gotta do what we gotta do.”</figcaption></figure><p>So whaddayaknow, they were right. The mayor asks them for help, and they go save the day in a final boss fight…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Pq5nHG9KnXhsCcHTsnva2A.jpeg" /></figure><p>…that involves Dana and the dork who’s been hitting on her. Louis in GB1 became under the control of an evil doggy thing. Janosz in GB2 became under the control of Viggo, the main antagonist.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DShjgZf4wI3IMT9KQzvJxA.jpeg" /><figcaption>They need to hire some proper image consultants.</figcaption></figure><p>Both battles escalate to some kind of a Megazord creature, albeit playing on opposite sides in each movie.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VoyiKH6Wn3nPSt5dyKfSYg.jpeg" /><figcaption>The Statue of Liberty and sugar. Two classic American symbols.</figcaption></figure><p>The movies end with the Ghostbusters succeeding. Venkman gets the girl and they’re lauded as heroes under the sound of some fine 80s power tunes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*esUgbMIMMJZYkEwxzUlrHQ.jpeg" /><figcaption>And of course, once the apocalyptic equivalent of the honeymoon effect wears off, Peter and Dana will break up.</figcaption></figure><p><strong>4. The Fugitive &amp; U.S. Marshalls</strong></p><p>The Fugitive managed to be both critically acclaimed and a box office success and once again it’s a story that doesn’t leave much room for sequels. Or does it? Hollywood says it does, so I guess it does.</p><p>The thing is, they wanted to bring back Tommy Lee Jones’ character, Samuel Gerard. He even got an Oscar for it. But it seems that the writers felt that what people liked about him, wasn’t his wittiness. It was, of course, his tendency to keep finding himself chasing innocent people who are trying to do the job people like him should have done in the first place. So that’s what we got.</p><p>The movies are so similar that naming the sequel “U.S. Marshalls”, turned out to be the most surprising thing about it.</p><p>Both movies start with a sequence of blurry confusing images scored by an eerie soundtrack showing the murders.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wn2j5lKt6tlxFuGNXb_yJw.jpeg" /><figcaption>No one caught the creep with the shitty camera, though</figcaption></figure><p>Then Kimble (Harrison Ford) and Sheridan (Wesley Snipes) are brought to questioning where they are implicitly accused of murder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bgrp49CRHvrwwSAXoPbviw.jpeg" /><figcaption>“Wait, wut?”</figcaption></figure><p>After accusations are made, they are transported to another prison, Kimble by bus and Sheridan by plane. They both look backward, cause they’re realizing something fishy is going on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MA-W4Cdco1BdQNiNz2ODqQ.jpeg" /><figcaption>‘Sup, gurl</figcaption></figure><p>Some prisoners try to escape in The Fugitive, and some prisoner tries to kill Sheridan in U.S. Marshalls. Shots are fired and the bus/plane crashes…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hrS3frj2NWzJIo1jwVn-Ng.jpeg" /><figcaption>…in what could very well be the exact same location.</figcaption></figure><p>Kimble helps a wounded guard escape the bus before a train hits them.</p><p>Sheridan helps Gerard rescue people before the plane submerges.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZqkyTs2997PkaVx4E4n-7A.jpeg" /><figcaption>See? They’re good people</figcaption></figure><p>Gerard takes over the pursuit from an incompetent sheriff.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V5siQJWluo0KKVQs6EQQwg.jpeg" /></figure><p>After a while, Kimble finds himself by a ledge, held at gunpoint by Gerard. This also happens in U.S. Marshalls, except it’s a bit closer to the ending.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*63T3C0PA3EGn_pGvp-rQYw.jpeg" /></figure><p>Both jump and survive (obviously).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fcmj4O-ELdYV1ktODqQXGQ.jpeg" /><figcaption>“Weeeeeee”</figcaption></figure><p>They escape every time Gerard catches up and use several payphones to ask friends for help.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uTVPAYzugc1LayVmHkK_Fg.jpeg" /></figure><p>For some reason, they also both rent a room specifically from eastern European landlords that Gerard later finds about.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uoZaUuW7AVsP45PYVXybeQ.jpeg" /></figure><p>The movie’s villain, who turns out to be a dirty cop in U.S. Marshalls and a dirty ex-cop in The Fugitive, shoot an honest cop, making everyone assume that the fugitive is also a cop killer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T1X9ajTvQwwCzZyxvNpITA.jpeg" /><figcaption>No special makeup was needed for <a href="https://en.wikipedia.org/wiki/Robert_Downey_Jr.#1996%E2%80%932001:_Career_troubles">Robert Downey Jr’s bleeding nose</a></figcaption></figure><p>After the bad guys get defeated, Gerard and the fugitive become friends and are all like “eh… water under the bridge”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XADOQknYW97yL4ngXn-y-w.jpeg" /><figcaption>”Remember when I tried killing you a couple of times? LOL”</figcaption></figure><p>Also, here’s a picture of Tommy Lee Jones dressed like a chicken in U.S. Marshalls.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XjbO4kRxWNhNiuGqJiYr9A.jpeg" /><figcaption>Surely, it was the only way</figcaption></figure><p><strong>5. Raiders of the Lost Ark and Indiana Jones and the Kingdom of the Crystal Skull</strong></p><p>Indiana Jones is a character mostly known for his famous archeology method:</p><p>1 — Find objects of great archaeological value</p><p>2 — Be captured by the bad guys while doing so</p><p>3 — Escape and lead them to said objects, until they die by themselves in the end</p><p>Both movies start with an intro in which Indy showcases his skills to find something that is taken by the main antagonist.</p><p>Both Belloq and Spalko are intelligent people hired by two of the most terrible people in history, but are also personally interested in what they were hired to find.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PA2PMeemmlJ6o0XPCDij5g.jpeg" /></figure><p>Indy then barely escapes. And goes back home, I guess.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jK_F5ka3uQ8FGbXt9rHqXA.jpeg" /></figure><p>He then returns to his old regular life as a teacher, when Marcus Brody, in Raiders of the Lost Ark, and a character obviously created to fill in Marcus’ void, Jim Broadbent in Crystal Skull, interrupt him. See, Denholm Elliott, the actor who played Marcus originally, died in 1992. It would be a shame to let that prevent writers from following the formula.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yoyBiHAFdS4yHxISL_q6yg.jpeg" /><figcaption>Yup, same storyboards</figcaption></figure><p>At one point, Marcus Brody and Marcus’ replacement enjoy a conversation at Indy’s place while he packs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Uzj8kcPCQk5FdFebNMu1aQ.jpeg" /><figcaption>Broadbent giving a nice twist to Marcus’ classic ‘sitting and listening’, by standing and listening instead</figcaption></figure><p>Anyway, in Raiders two Army Intelligence agents tell Indy that the bad guys (Nazis) are interested in Abner Ravenwood.</p><p>In Crystal Skull, Shia LaBeouf tells Indy that the bad guys (Russians) are interested in Harold Oxley.</p><p>Indy hadn’t seen Ravenwood in 10 years and Oxley in 20 years. Since Ravenwood is actually dead, he ends up meeting his daughter, Marion, who he hadn’t seen in several years, too.</p><p>He deduces that the Nazis/Russians are interested in the Ark of the Covenant/Crystal Skulls in order to use its power as a weapon.</p><p>So Indy starts looking for the coveted object before the bad guys find it, which is pretty ironic because that’s precisely the only reason the bad guys manage to get their hands on the Ark/Skull in the first place. They just take it from him.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aslcrQ9bkJuuuPJTmcj9gQ.jpeg" /><figcaption>Bad guys getting their hands on valuable stuff. Good job, Indy.</figcaption></figure><p>It was mentioned above that Indy finds Marion Ravenwood in Raiders. Well, that also happens in Crystal Skull. It’s funny how in Raiders, she is mad at Indy for having left, and guess what, in Crystal Skull, she is also mad at Indy for having left.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eaOg_aNHd1umQrGQ6n1l0g.jpeg" /><figcaption>The typical “warm” smile of someone who’s pissed</figcaption></figure><p>So eventually, a convoy led by the villains is transporting the coveted object. Indy does what he has to do to retrieve it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eSyCVvELHXFbCsDYnN9CxA.jpeg" /></figure><p>He kicks people out of the trucks, kills a few and destroys everything until he gets the object back, clearly taking the whole “it belongs in a museum” thing a bit too seriously.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FIWTebFIWtxwVXOdzebkcA.jpeg" /><figcaption>Random bad guy thrown off of a moving truck: check</figcaption></figure><p>After all that hard work, the bad guys catch up and take control.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DKc2NM4CJrY4yE_o6smK0g.jpeg" /></figure><p>Eventually, the villain performs a ritual to learn about the power of the Ark/Skulls and Indy heroically lets everyone die by themselves.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6V1Rf1eOhOn_lMgCsRG5qA.jpeg" /><figcaption>Good work, Indy</figcaption></figure><p>After being fascinated at first, the villains quickly become scared, yell horrified and end up disintegrated in flames. Just like anyone who watched Indiana Jones and the Kingdom of Crystal Skull in the theaters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*egFboYl_pvDd2hUjNdS3Qg.jpeg" /><figcaption>Viewers reaction while watching the <a href="http://www.youtube.com/watch?v=Arib8uWMWsM">refrigerator scene</a></figcaption></figure><p>In the end, the good guys contemplate the area where the epic finale occurred.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7yKqAu6u_fuMqXCG0dMt4A.jpeg" /></figure><p>By the way. a lot of Crystal Skull’s plot points were also already present in the third movie of the series, Indiana Jones and The Last Crusade:</p><ul><li>A traitor who wasn’t all that bad, but still dies at the end (Elsa/Mac)</li><li>A group of people interested in protecting the coveted objects (Brotherhood of the Cruciform Sword/a bunch of Amazon natives)</li><li>The long chase involving trucks</li><li>The fact that the bad guys kill themselves and everything falls apart in the end</li></ul><p>So what makes Indiana Jones and the Kingdom of Crystal Skull different is basically the <a href="https://www.youtube.com/watch?v=Arib8uWMWsM">refrigerator scene</a> and Mutt Williams. So… yeah.</p><p><strong>6. Star Wars: Episode IV and Star Wars: Episode VII</strong></p><p>Episode VII came out to the great delight of both fans and critics. Unlike the other entries in this list, this is a sequel that I liked a lot. It’s a pretty good movie. Too bad it had already been made. Sure, that was partly deliberate given that there was a whole new generation of viewers, but still…</p><p>They start with the good guys getting attacked by a bunch of stormtroopers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8sO2fVlhQshMMXWyVoXeIQ.jpeg" /><figcaption>Pew pew!</figcaption></figure><p>In the midst of the chaos, Leia in NH and Poe in TFA, store vital info in a droid and send it away.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t5RH1W9IAB8bS6yXwSnRWA.jpeg" /></figure><p>The masked, voice distorted, dark dressed villain, makes a grand entrance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j4Th6hrVDstor6Y1hPuFJg.jpeg" /></figure><p>After the battle ends, we learn he’s looking for the info that was sent away with the droid. Leia/Poe get captured.</p><p>Meanwhile, the droid finds itself lost in an arid planet…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yI_bPpsOjFepcYkYmeBqGQ.jpeg" /></figure><p>Until the hero finds it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o9h28q87A0_h3VPVhd3kGA.jpeg" /></figure><p>Leia/Poe gets interrogated…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RnLLYpe6jsD33PBGDnPrDA.jpeg" /></figure><p>…while the good guys meet an older experienced character, Obi-Wan in NH and Han Solo in TFA, with whom they see the contents of the crucial information that was stored in the droid.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0Rip9_0yH3-WrhBrsSMbBA.jpeg" /></figure><p>While we’re presented with a bunch of shenanigans involving money owing, daring escapes and canteen musicians (pretty much Han Solo stuff)…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HP9GwPzRs5r81kK1ac-GRg.jpeg" /></figure><p>…we learn that the bad guys seem to forget they’re not in a cartoon and decide to create the most ridiculously powerful weapon they can think of: the Death Star in NH and the Starkiller in TFA.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VSlYt68nSDbDs0H1fLwhvw.jpeg" /><figcaption>There were clearly some improvements in the laser show technology. Well done, Kylo.</figcaption></figure><p>Their purpose? Blow up planets!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3eynwNl3VDw9PeC0zbs4lg.jpeg" /><figcaption>Cold</figcaption></figure><p>Good guys don’t like that kind of thing and end up infiltrating the bases…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*06cY3rHTKVbByifGD5XoVw.jpeg" /></figure><p>…helping the strong female character who had been held prisoner…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l39rORP5Pv1bft9dr5ehig.jpeg" /></figure><p>…and getting the Mentor Dude killed by the Bad Guy in the process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bvQ6ne9dHkZ1fnniNbGqrA.jpeg" /></figure><p>Hero does an impression of crying Tobey McGuire.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*05Bi_nsP2Wt8Th86AQTW8A.jpeg" /></figure><p>Good guys plan assault on Evil Base/Giant-Planet-Destroying-Weapon.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7MqTE8rtyfx8jdR34PJf8g.jpeg" /><figcaption>Wow! How 30 space years can really change hologram technology!</figcaption></figure><p>Leia oversees the thing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Podj-cEJmTi1MAi4PGkPcg.jpeg" /></figure><p>Heroes make use of the bases’ vulnerabilities to destroy them to bits.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mkQZW8dyr63DMEZcqRF0vA.jpeg" /></figure><p>Then they all get together and celebrate the victory. The end.</p><p>It’s most heartbreaking when it’s clearly <strong>just </strong>money and not creative motivation that drives the development of a sequel to a good first movie. That was obviously the case with at least <em>some</em> of these entries. And sure, it’s certainly hard to develop a compelling story without falling into the temptation of repeating what we already know worked. But in most of these sequels, logic had to be absurdly stretched so they could repeat the same tropes by inserting either extremely unlikely circumstances or bizarre character behavior. And we already have plenty of that in <a href="https://en.wikipedia.org/wiki/Donald_Trump">real life</a>.</p><p><strong>Thanks for reading. If you liked this article, feel free to </strong>👏<strong> and comment.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4be199cfef77" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React — Event handling, binding, ES6 classes and public class fields]]></title>
            <link>https://pauloesteves8.medium.com/es6-classes-binding-public-class-fields-and-event-handling-in-react-2e1e39b1d498?source=rss-d2375d1d713------2</link>
            <guid isPermaLink="false">https://medium.com/p/2e1e39b1d498</guid>
            <category><![CDATA[es6]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[front-end-development]]></category>
            <dc:creator><![CDATA[Paulo Esteves]]></dc:creator>
            <pubDate>Sun, 12 Nov 2017 22:11:28 GMT</pubDate>
            <atom:updated>2022-06-14T01:30:45.998Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/502/1*0Ut1XlKGugf4MjkGsjzqqQ.png" /></figure><p>There seems to be a lot of misconceptions about the different methods of setting up event handlers in React, especially about what goes on behind the scenes. Here I tried to group together some of the fundamental aspects that get frequently left out.</p><p>First of all look at these two blocks of code. The first is ES6 with an experimental public class field (the foo function). The other is plain ES5.</p><p>So this…</p><pre>class Button {<br>  constructor() {<br>    this.handleClick = this.handleClick.bind(this);<br>  }</pre><pre>  handleClick() {<br>    console.log(this);<br>  }</pre><pre>  foo() {<br>    console.log(&quot;foo&quot;);<br>  }</pre><pre>  publicClassFieldFunction = function() {<br>   console.log(this);<br>  }<br> }</pre><p>…is the same as this:</p><pre>var Button = function() {<br>  this.handleClick = this.handleClick.bind(this);<br>  this.publicClassFieldFunction = function() {<br>    console.log(this);<br>  }<br>}</pre><pre>Button.prototype.handleClick = function() {<br>  console.log(this);  <br>}</pre><pre>Button.prototype.foo = function() {<br>    console.log(&quot;foo&quot;);<br>}</pre><p>ES6 classes are just syntactic sugar over prototypal inheritance. An instance of Button will have two fields: handleClick and publicClassFieldFunction.</p><p>If we try accessing a non-existing property in that instance, it will go up the next object in prototype chain and look for something with that name. That object is Button.prototype, which has the methods handleClick and foo.</p><p>By looking at the code above you can see that, in the ES6 class syntax, declaring a property like this: handleClick() {...} means that the function will live in the.prototype of the class, which means it will be shared by every instance. Declaring it like this handleClick = function() {...} means that it will be set in the constructor and each instance will have one copy of it.</p><p>That means that there are two different handleClick functions: the one in the constructor and the one in the prototype.</p><p>Now let focus a bit on event handling in React. The documentation suggests this approach:</p><pre>  constructor() {<br>    this.handleClick = this.handleClick.bind(this);<br>  }</pre><pre>  handleClick() {<br>    console.log(this);<br>  }</pre><pre>  render() {<br>    return (<br>      &lt;button onClick={this.handleClick}&gt;&lt;/button&gt;<br>    );<br>}</pre><p><strong>1 — Why is binding required?</strong></p><p>Because this happens:</p><pre>var obj = {<br>  foo: function() {<br>    console.log(this); <br>  }<br>}</pre><pre>obj.foo(); // logs the &#39;obj&#39; object</pre><pre>var newVar = obj.foo;<br>newVar() // logs the &#39;window&#39; object</pre><p>this is evaluated when the code runs. It depends on how the function gets called. If there are no dots (like in newVar()), this will be the window object. In strict mode, it would be undefined. Behind the scenes, React uses their event system and along the way has no way of knowing the instance of the object that should be the context. Instead of letting this be window or undefined, React will bind it to null. To make sure that this points correctly to the instances you can either use .bind or arrow functions.</p><p><strong>2 — In that case, why not use an arrow function inside the render function? That way we could skip the </strong><strong>.bind in the constructor.</strong></p><pre>render() {<br>    return (<br>      &lt;button onClick={(e) =&gt; this.handleClick(e)}&gt;<br>        Click me<br>      &lt;/button&gt;<br>    );<br>  }</pre><p>Yes, arrow functions make sure that this is correctly bound to the instance and that would solve the problem. However, you’re passing a new inline arrow function every time render gets called. That means that there’s always a new reference, which might cause re-rendering.</p><p><strong>3 — Why not binding inside the render function?</strong></p><p>&lt;button onClick={this.handleClick.bind(this)}&gt;</p><p>The bind method returns a new function, so we have the same problem as above.</p><p><strong>4 — What about public class fields?</strong></p><pre>handleClick = () =&gt; {<br>    console.log(&#39;this is:&#39;, this);<br>  }</pre><p>Those work well. The problem is that they’re not officially part of the ECMAScript spec yet. They probably will though. Again, it’s important to point out that public class fields are just a different way of setting properties in the constructor. That is, each instance will get a copy. It’s still suggested in the documentation because performance implications are negligible.</p><p><strong>5 — Well, if public class fields are not part of the spec and are just a different way of setting properties in the </strong><strong>constructor , and arrow functions <em>are </em>officially part of the spec, why not using them directly in the constructor instead?</strong></p><pre>constructor() {<br>    this.handleClick = () =&gt; { console.log(this); };<br>  }</pre><p>The documentation doesn’t suggest doing that, probably to avoid polluting the constructor with large function bodies.</p><p><strong>6 — But by using the recommended .bind version in the constructor…</strong></p><p>this.handleClick = this.handleClick.bind(this);</p><p><strong>…we’re already polluting it. Also, by doing that, we’re writing more by both including a line in the constructor and declaring the function in the prototype with this bit:</strong></p><pre>  handleClick() {<br>    console.log(this);<br>  }</pre><p>True, but there’s a subtle difference due to how the .bind method works. First, just to recapitulate, if you declare the function in the constructor or as a public class field using arrow functions, every instance of the class will have a copy of the exact same function. And if you declare the function using the usual method syntax, it will be placed in the .prototype of the class to be shared by each instance. But what you’re doing with .bind, is creating a new function which wraps around the other one, giving it the instance’s context ( this ). That means that the body of the handler with the actual important logic will live in the prototype object shared by every instance, but each instance will have a new (tiny) function that provides the context.</p><p><strong>7 — Waaaaait… but I thought that…</strong></p><p>this.handleClick = this.handleClick.bind(this);</p><p><strong>… was doing something like </strong><strong>x = x + 1; You know, replacing a value with a new value that gets generated using the previous value. Those two </strong><strong>this.handleClick refer to the same thing, right?</strong></p><p>Nope. The first this.handleClick refers to a property that will be created in every instance, because it’s being set in the constructor. The second this.handleClick refers to an already existing property living in the prototype object of the class. Before that line executes, this.handleClick isn’t an actual property of the instance yet. If you console.log it, it will show up, but only because it will go up the prototype chain and get the one living in the prototype which gets set before instantiation (the actual handler). If you do this…</p><pre>constructor() {<br>    console.log(Boolean(this.handleClick)); // true</pre><pre>    console.log(this.hasOwnProperty(&quot;handleClick&quot;)); // false</pre><pre>    this.handleClick = this.handleClick.bind(this);</pre><pre>    console.log(this.hasOwnProperty(&quot;handleClick&quot;); // true<br>  }</pre><pre>handleClick() {<br>    console.log(this);<br>}</pre><p>… you’ll see that the instance itself will only have its own handleClick property after being set with bound function that wraps the prototype’s handleClick.</p><p>The function body that will get called by every instance is the one living in the prototype after the this.handleClick on the left calls it with the proper context.</p><p>Those two this.handleClick functions don’t have to have the same name at all. Just try doing something like…</p><p>this.handleClickFoo = this.handleClick.bind(this);</p><p>…and then make sure that what is passed to onClick in the render function is the this.handleClickFoo. It still works. A lot of people got confused simply because they have the same name in the documentation.</p><p>Try logging a bound function in the developer tools. You’ll see something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/237/1*bVzbAphjSErUBhbZIMCkOQ.png" /></figure><p>In our case, the [[TargetFunction]] is the one in the prototype object. As for the bound function that wraps it, it will live in each instance providing the instance’s this to the [[TargetFunction]] .</p><p>That’s it. Thanks for reading, if you found this article helpful, feel free to clap so others will see it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2e1e39b1d498" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I changed careers using online courses]]></title>
            <link>https://pauloesteves8.medium.com/changing-careers-by-studying-online-a-review-of-some-of-the-best-resources-ebd6869939b7?source=rss-d2375d1d713------2</link>
            <guid isPermaLink="false">https://medium.com/p/ebd6869939b7</guid>
            <category><![CDATA[udacity]]></category>
            <category><![CDATA[online-education]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[career-change]]></category>
            <category><![CDATA[education]]></category>
            <dc:creator><![CDATA[Paulo Esteves]]></dc:creator>
            <pubDate>Fri, 14 Apr 2017 21:54:29 GMT</pubDate>
            <atom:updated>2018-03-10T19:19:23.373Z</atom:updated>
            <content:encoded><![CDATA[<h4>The story of how I switched to a career in web development, and a short review of some of the resources I used (Udacity, Coursera, Khan Academy)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tgeamWPc8OjbJwJQgwSBNQ.jpeg" /></figure><p>Summer of 2015. After a short stint of 6 months as a marketing intern at a pretty cool start-up in Dublin, I decided to head back to my home country with no real plan.</p><p>As a marketing graduate, I started looking for marketing jobs and, during that period, I felt compelled to check out the new web development courses at Khan Academy, a website that I previously used to learn some basic programming. I went through multiple courses and, in a couple of weeks, I noticed I would spend 5 or 6 hours a day studying that stuff.</p><p>It became harder and harder to ignore the significance of my enjoyment in learning programming. That motivated me to make a decision: instead of spending a couple of years working in marketing while studying programming, I decided to make the commitment to study full time so that I could get it over with after a few months (hopefully without paying for anything).</p><p>That would mean that I had to do something that most people in their mid-twenties, like me, wouldn’t consider doing or, if they would, probably couldn’t. I decided to live with my parents’ for an indefinite period of time.</p><p>With a fresh sense of commitment and especially motivated to get back my autonomy, I cranked up the number of study hours from 5 or 6 a day to somewhere between 8 and 12. This process lasted for a few months, and I ended up going through multiple emotional states: from feeling excited and motivated to having occasional periods of slight despair to feeling like I was losing my ever-weakening sense of sanity, and then back to the excitement and so on. Back and forth. Over and over again. Multiple times (Thank God for mom’s cooking).</p><p>For several years, every time I attempted to learn programming at home, I would feel overwhelmed with how hard it was to learn from poorly formatted tutorial articles. Thankfully, online education went through a period of profound innovation, which changed everything.</p><p>I‘ll now try to describe how it happened while presenting my views and feedback regarding the resources I used.</p><h3><a href="http://www.khanacademy.com/"><strong>Khan Academy</strong></a></h3><p>I first chose Khan Academy, because of how easy it was to get started. The way it works was pretty great too: I would write code and the output would be immediately updated on a small window. A few years before, I would try to learn C++ by reading articles, which was pretty tough if you have no one to help you. This time though, I had a pretty convenient visual support and there wasn’t any compiling/saving/running process, unlike other programming languages or learning methods. That allowed me to focus on learning and learning alone.</p><p>A lot of stuff wasn’t clear for me, though: it was pretty frustrating to me that I seemed to be unable to learn the difference between the native JS syntax and the syntax belonging to third-party libraries (which KA uses). I also found it a bit weird that I didn’t seem to be able to figure out how to make the projects I was working on available anywhere else outside of the Kahn Academy environment.</p><p>Anyway, since I had previously completed the basic JS course, I moved on to everything else: I checked out the courses on HTML/CSS, SQL, and jQuery, and I learned how to use programming to create games. A particularly interesting course was Natural Simulations, where students learn to apply programming to create animations that simulate various phenomena like harmonics, magnetism and particle generation.</p><p>I also did the whole computer science block which included Algorithms and Cryptography.</p><p>Despite being very interesting, some of these courses seemed to be too advanced or hard for Khan Academy’s style of teaching.</p><p><strong>Pros</strong></p><ul><li>Completely free — Khan Academy is supported by donations (similar to the Wikipedia model).</li><li>Immediate feedback — you can immediately see the result of your work when you’re programming, writing code on a box and seeing the output on another.</li><li>Very friendly and lighthearted approach.</li><li>The requirement to build projects and the high number of exercises maximize knowledge retention.</li></ul><p><strong>Cons</strong></p><ul><li>The programming challenges felt poorly designed as content got more advanced.</li><li>The teachers and challenges were sometimes too friendly/childish, which certainly works great for younger students. However, given that some of the material was a bit too hard, it just felt weird. Imagine if concepts like nonperturbative renormalizability and diffeomorphism covariance were discussed on Sesame Street. (I have absolutely no idea what those words mean, by the way).</li><li>It was a bit hard to get help and ask questions. Which is very understandable given that the whole thing is free anyway.</li><li>The way challenges were designed required students to finish them sometimes in very specific ways (you could write correct solutions that wouldn’t be accepted by the grading algorithm).</li><li>It’s very dependent on its own specific environment which makes it a bit hard for students to use their code anywhere else (although it is possible).</li></ul><h3><a href="http://www.udacity.com/">Udacity </a>vs <a href="http://www.teamtreehouse.com/">Team Treehouse</a></h3><p>So after finishing everything I had to finish on Khan Academy, I wanted to move to resources that felt more professional. After trying to figure out what made the most sense for me by reading reviews and opinions, I narrowed the choice down to Udacity and Team Treehouse.</p><p>Team Treehouse seemed very well structured. A somewhat more professional and polished version of Khan Academy. Udacity seemed bigger and a bit messier (at least at the time). In the end, I chose Udacity, because it seemed to be more focused on teaching a new entire skill set instead of specific languages or tools. Also, Udacity’s contents are all free (although only the paid version has coaching, grading, code review, etc), whereas Team Treehouse required a monthly fee (which seemed very affordable, actually).</p><h3>Udacity</h3><p>Since I was in the “There is still a lot of basic stuff to learn before committing to a specific field” part, I decided to sign up for these three particularly well-reviewed courses:</p><p>1 — <a href="https://www.udacity.com/course/intro-to-computer-science--cs101">Introduction to Computer Science</a></p><p>Great course and great teacher. Most of its issues, which are pretty minor, are related to the fact that it was one of the first courses in Udacity, so sometimes it felt a bit dated. I learned a lot nevertheless and laughed plenty of times at the unique style of humor of the teacher, Dave Evans.</p><p><a href="https://www.udacity.com/course/programming-languages--cs262">2 — Programming Languages</a></p><p>Great way to understand how some of the low-level stuff works, but it was a bit too advanced for my purposes. I did my best to finish the challenges on my own but barely completed the final project without checking out the solution. That was fine though, as I wasn’t particularly interested in deepening this subject. The teacher, Westley Weimer, was great and pretty funny too.</p><p><a href="https://www.udacity.com/course/web-development--cs253">3</a><a href="https://www.udacity.com/course/programming-languages--cs262"> — </a><a href="https://www.udacity.com/course/web-development--cs253">Web Development</a></p><p>This one is pretty interesting, because it’s taught by one of the founders of Reddit. His own experience as a developer was frequently used for making some very useful points across, which was pretty fun. However, the whole course felt rushed as it had too many difficult concepts moving too fast. Nevertheless, Steve Huffman as a teacher gave clear explanations.</p><p>After these 3 courses, I felt like I was starting to have a pretty good grasp on the basics of programming. I felt ready to actually focus on what I wanted to do: front-end web development.</p><h3><a href="http://www.coursera.com/"><strong>Coursera</strong></a></h3><p>My goal was to sign up for Udacity’s <a href="https://www.udacity.com/course/front-end-web-developer-nanodegree--nd001">Front End Nanodegree</a> courses but I decided to try out the intro to <a href="https://pt.coursera.org/learn/html-css-javascript">HTML CSS, JS</a> from Coursera after some friends recommended it to me. I felt that learning the same concepts from different sources could be helpful.</p><p>Despite the fact that the teacher was very thorough with his explanations and seemed to clearly understand the point of view of students learning that content, the course felt too traditional and not at all adapted to online learning. Both Khan Academy and Udacity had innovative ways to teach. The former used the aforementioned system of the dual boxes (code and output) and the latter had videos of the teachers’ hands drawing and writing on a whiteboard (a tablet actually) while explaining concepts. Coursera’s course though was not all that different from a filmed lecture. But like I said the content was explained very clearly, which was really nice.</p><p>I learned a lot from this course and I would definitely recommend it, provided you are able to endure what at times felt like a somewhat excruciatingly boring learning experience.</p><h3><strong>Back to Udacity</strong></h3><p>By now, I had spent around 6 weeks learning online. I was finally going to dive into a specific field in a way that was structured to maximize job value. In this case by checking out the courses in <a href="https://www.udacity.com/course/front-end-web-developer-nanodegree--nd001">Udacity’s Front-End Nanodegree.</a></p><p>Again, the contents themselves are free, but everything else is not. I decided to take the risk of not paying for anything and only access the content. Then, if I ended up feeling that an actual certificate and code reviews were useful, I would sign up and submit the projects for evaluation.</p><p>I felt very drawn to the idea behind Nanodegrees: their structure was focused on having students complete several complex projects while learning from related courses. That meant that you had the freedom to create something by yourself and put it in your portfolio (some of those projects are partially set up previously for you, though).</p><p>Online certificates don’t mean much, but your own personal web page displaying some of your projects does. And Udacity knows that. That approach made all the difference for me given that my background had little to do with tech.</p><p>This was the most important part of my learning process, so I’ll give a rundown of how it went. The Nanodegree was separated into 6 projects, which students were required to finish:</p><p><strong>1 — Building a portfolio site</strong></p><p>The whole idea of having a project consisting of building your own portfolio page was brilliant. You would learn both programming and how to develop your own personal brand. The supporting courses themselves could have been a bit better. They’re too focused on best practices and modern approaches, which is awesome but, for beginners who know next to nothing, it feels like everything’s going a bit too fast. Their reasoning is solid though, they feel students can learn the language’s details easily by searching online if they have to. However, the lack of proper introductions to some basic concepts, made me truly appreciate the knowledge I acquired with Coursera and Khan Academy.</p><p>The project’s supporting courses also included some content about responsive design and dealing with responsive images. This stuff is very important, but again, it felt way too early to make students think about these things since the basics were a bit shaky. Honestly, I felt like their approach could have been better from a pedagogical point of view. I frequently felt frustrated at the lack of detailed explanations.</p><p>As for the project, I finished it according to their specifications and improved the design after searching for inspiration online. You can check it out here: <a href="http://pesteves8.github.io/">http://pesteves8.github.io/</a></p><p><strong>2 — Interactive resume</strong></p><p>I was really happy that this course introduced some new important concepts like dynamically loading data on a page. Again, I didn’t feel like things were being clearly explained, though.</p><p>The course introduces several important concepts like third party libraries (jQuery) and using JSON as a data structure, while briefly requiring students to interact a little bit with an external API (Google Maps). The project itself was very useful for me since I actually used it as my online resume. I also made a PDF version from it.</p><p><strong>3 — Classic Arcade Game Clone</strong></p><p>I really loved this one. The contents of the supporting course (<a href="https://www.udacity.com/course/object-oriented-javascript--ud015">Object Oriented Javascript</a>) were way harder, but I didn’t mind at all because the teacher was really, really good. This course cleared out a lot of very confusing concepts about Javascript. As for the project, it was really fun, and months after finishing it, I would still sometimes go back to it to change or add something. I was very thankful for the teacher’s clear explanations. Feel free to play end result: <a href="https://pesteves8.github.io/frontend-nanodegree-arcade-game/">https://pesteves8.github.io/frontend-nanodegree-arcade-game/</a></p><p><strong>4 — Website Optimization</strong></p><p>This one included another couple of courses about very useful concepts that weren’t explained as well as I’d like. However, I thought it was a great idea to include these subjects since most people neglect them and it really helps students stand out when applying for jobs.</p><p><strong>5 — Neighborhood Map</strong></p><p>The supporting course for this project was similar to the one about object oriented Javascript. Great teacher, really slow clear explanations and a great balance between lighter, humorous bits, and more serious stuff. The teacher, Ben Jaffe, seemed to have a pretty good grasp of how students feel along the course. This course wasn’t particularly easy since it introduces <a href="https://en.wikipedia.org/wiki/Single-page_application">single page application</a> (SPA) frameworks.</p><p>I really enjoyed it and felt that I was learning some of the most important concepts that would actually help me land a job.</p><p><strong>6 — Feed Reader Testing</strong></p><p>This one is a small introduction to testing. Nothing much to say. It was short and sweet.</p><p>After that, I also did an optional project called <a href="http://pesteves8.github.io/calorie-tracker/">Calorie Tracker</a>. It required the students to learn a framework called Backbone, by themselves. I ended up doing it because I really wanted to make sure I was good enough, especially since I didn’t have any support, code reviews or certificates.</p><p>Finally, I decided to learn some stuff that I kept seeing mentioned around the Internet (like AngularJS) and ended up doing a project of my own. It’s called <a href="https://pesteves8.github.io/mrmdb">mrMDB</a> and it’s an iMDB, Metacritic and Rottentomatoes aggregator. Given my interest in movies, I just thought of building something that I would use.</p><p>I also made sure I learned some more of the most commonly mentioned tools and concepts that I would find online. Things like AngularJS, ECMAScript 2015, Webpack, CSS pre-processors, modular JS, etc.</p><p>If I remember correctly, it took me about 4 months to finish this Nanodegree, including the extra projects and a lot (and I mean a lot) of interruptions and detours to deepen concepts that came up frequently. By the way, Udacity also had some tips on how to <a href="http://blog.udacity.com/2015/01/essential-tips-stand-linkedin-profile.html">set up your Linkedin profile</a>, which was awesome.</p><p>Despite Udacity’s minor flaws, I can’t stress enough how great their philosophy of teaching is and how important it was for my development. It also seems clear that they are absolutely committed to becoming better and better.</p><p>One last thing: I showed you that you don’t really need to pay 200$ a month, but that would make your lives much easier. So I would encourage you to try it out and see what works best for you.</p><h3>The Outcome</h3><p>After all of this, I started sending some CVs. It took a while, but eventually, I got a couple of responses and, after accepting one of them, I got about 2 or 3 more. That was it, I was in. Then, 6 months after starting my new career, I got a contract renewal and a raise (very validating indeed).</p><p>After that I was earning as much as any other programmer of my level, getting frequently approached on Linkedin and feeling pretty comfortable with the fact that I had a job that I enjoyed in a pretty safe industry. By the way, this job was focused on <a href="http://www.angular.io/">Angular </a>and I was also required to quickly learn and understand back-end development with C#/.NET.</p><p>Since then, I ended up doing the <a href="https://www.udacity.com/course/full-stack-web-developer-nanodegree--nd004">Full Stack Web Developer Nanodegree</a> and, after that one, I did the <a href="https://www.udacity.com/course/senior-web-developer-nanodegree-by-google--nd802">Senior Web Development Nanodegree</a>. I should point out that I didn’t make half the effort on these Nanodegrees, as I did with the Front-End Web Development one. I just wanted to make sure that I would have a better understanding of some concepts that I wasn’t well versed yet.</p><h3>Conclusion</h3><p>So there you have it. In total it took me about 6/7 months of full time studying to actually get a job as a developer without having to get a certificate, paying for anything, or having the networking and support you get when you sign up for offline courses.</p><p>Again, I had the luxury of being able to stay at my parents’ during this period, something that a lot of people with families and bills to pay wouldn’t be able to do. My point is that I’m not really gonna say anything like “Wanna achieve something? It’s simple: work hard, do it! DON’T BE A PUSSY!” or any of that stuff. Each person’s life is different and I’m very much aware of my fortunate circumstances.</p><p>Anyway, before all of this started, I spent a lot of hours searching for information on how to learn online or even if I should invest on a career change at all, so this is the kind of post that I would have liked to read at that time. Hopefully, it can be helpful to some of you.</p><p>I’m really thankful for living in an era where I have resources like Khan Academy and Udacity, both of which have had a very deep impact in my life and I’m honestly excited to see how companies like these will keep impacting the world of online education as they mature. It really seems like great quality education will only become more and more accessible, opening doors that would have otherwise remained shut for people limited by unrelated circumstances.</p><p>Yup, these definitely are exciting times!</p><h4>You found this story useful or entertaining, feel free to clap away so others can find it.</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ebd6869939b7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Webpack vs JSPM]]></title>
            <link>https://pauloesteves8.medium.com/webpack-vs-jspm-a90603c3caf?source=rss-d2375d1d713------2</link>
            <guid isPermaLink="false">https://medium.com/p/a90603c3caf</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[webpack]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[es6]]></category>
            <dc:creator><![CDATA[Paulo Esteves]]></dc:creator>
            <pubDate>Tue, 24 May 2016 00:24:18 GMT</pubDate>
            <atom:updated>2018-03-10T19:20:16.715Z</atom:updated>
            <content:encoded><![CDATA[<h4>This is a just an overview of two of the most commonly used tools for writing code using ECMAScript2015 modules. They also work if you want to use CommonJS (Node.js modules) or AMD (RequireJS).</h4><p>Browserify has been the go-to tool for bundling modular JS for quite a while. However, in the past couple of years, two different tools have been gaining a lot of traction, Webpack and JSPM.</p><p>Here’s a summarized version of what lead me to modular JS, in the first place:</p><p>I started with Bower and people all went “You know what? You should just use Browserify”. So I started checking Browserify out and people all went “Guess what? Webpack is better than Browserify”. And so I started checking out Webpack and people be like “Sup, son? Those tools are too messy, you should try JSPM”. Maybe they didn’t actually talk like that. Memory is a tricky thing.</p><p>Just to be clear, most of these tools work very differently:</p><ul><li>Bower/Gulp are used for the typical script concatenation workflow.</li><li>Browserify and Webpack are bundlers that take modules of JS and create a giant JS file while keeping each module’s namespace separate.</li><li>JSPM simulates the common way browsers will work in a few years. Modules are loaded in browser, as necessary.</li></ul><p>Needless to say, the changes in how the web works will be pretty revolutionary.</p><p>There is a lot of info about browserify, so I’ll leave that one out. Let’s start with JSPM, which was the first one that I tried out.</p><h3>JSPM</h3><p>JSPM did seem like it was the ideal tool. You could start almost immediately, there was no build step, and the code would be ready for when browsers support ES2015 modules.</p><p>JSPM is actually a bunch of tools put together that constitute a framework for building web apps with modular JS. It’s clear that the goal of its creator, Guy Bedford, is to make it as simple as possible, so that developers don’t have to worry about configuration and actually develop their apps.</p><p>So, the actual framework is:</p><ul><li>JSPM — a package manager that uses npm and github to install external packages (replaces bower).</li><li>SystemJS — a library (from the same author) that loads the modules when the page is opened and, from then on, loads new modules as required. This works without a build step, so you don’t actually have to create a giant Javascript file. The code is also transpilated in browser.</li><li>It also has a bundler (like Webpack/Browserify), that ends up being optional (or is it? More on that below)</li></ul><p>Now, if JSPM already loads everything in browser, then why the bundler? This is why this really cool tool ends up being not as useful as it originally sounds.</p><p>Being able to skip a build tool is incredibly cool (feel free to use this slogan, Mr. Bedford). However, it comes at a cost, and it’s pretty steep: <strong>loading a page is really slow</strong>.</p><p>There are 2 causes for the slowness:</p><ul><li>There aren’t many servers using HTTP 2, which allows multiple HTTP requests to happen concurrently without any problem. With the current version, HTTP 1.1, each extra file being loaded at the same time, will increase loading times. With complex apps, this will mean that you can quickly start having dozens of files that will open in the beginning, which ends up being very problematic. However, this is a problem that will go away eventually as HTTP 2 becomes more prevalent.</li><li>Transpilation — A lot of ES6 features aren’t supported by current browsers, including modules. And even if they were, converting would still be required to allow compatibility with older browsers, at least for several years. To solve this, JSPM ends up transpiling everything in browser.</li></ul><p>The convenience of skipping a build tool, means that usually you would have to wait at least a 2 or 3 seconds to load the page. That is usually tolerable in development, but with increasing complexity, loading times also increase. That and the fact that you wouldn’t actually know how long your page takes to load may feel weird during development, since you probably would prefer to always experience the closest to the actual user experience while coding.</p><p>So, JSPM has a bundler to make the app load fast in production. However, during development, a lot of people also end up using it with incremental builds with either a plugin or the watcher feature that is available in JSPM 0.17.</p><h3>Webpack</h3><p>Webpack is just a bundler, similar to Browserify. But a very powerful one. Apart from bundling, it also has some pretty cool features like hot module replacement. A really cool thing about it is that it can almost completely replace gulp as well. You can use it to import css written in sass or less, you can use linting tools, move files, etc. The main downside of it is that, to use these things, you’re gonna have to be really patient. Webpack configuration can be traumatizing.</p><h3>Which to use?</h3><p>Like everything, it will depend on the situation, however I do feel like there is a clear winner for the vast majority of cases and that is <strong>Webpack</strong>.</p><p>It was a bit hard to admit this to myself, because JSPM is a really cool and smart tool, and I love the fact that clearly, one of its goals is to make things really simple for developers, so that they can actually develop.</p><p>So, like many people, I started with JSPM, but ended up migrating to Webpack.</p><p>So here’s how it went:</p><p>Basically I started building a small app that used ES6 (obviously), Angular 1.x, SASS, jshint, PostCSS, Autoprefixer and Bootstrap. Some of these things were total overkill given the simplicity of the app, but it was a good way to test how well JSPM/Gulp and Webpack worked with them.</p><p>I checked out both tools, choose JSPM and started learning it. JSPM’s documentation is very clear and easy to read. Try reading a couple of documentation pages for Webpack and you’ll feel like an idiot.</p><p>I then started building the app and I didn’t really mind the 2/3 second loading time all that much. I felt that everything was working pretty well. And indeed, I built most of the app using JSPM and Gulp without a problem.</p><p>Now, in production I really had to bundle everything. So I did. But then I realized that would have to configure some extra things to use bootstrap properly so that the fonts would be loaded from the bundle.js file. Then I started using the bundler’s watch mode during development and everything was running smoothly and I was happy.</p><p>However, after a while I realized something: to have a nice workflow with JSPM, <strong>I ended up not using the features that make it so special</strong>. That’s when I realized I shouldn’t be using JSPM, when I noticed that I was doing exactly what I would be doing with Webpack, expect that Webpack has some extra features, like the ones that replace Gulp and works with a less amount of files and folders.</p><p>So I moved to Webpack. And boy, that was frustrating. I tried to make everything work without Gulp, but that was really, really tough. Making it work with bootstrap was a nightmare, because it also had to load the fonts.</p><p>The problem is that the configuration is very confusing, definitely not intuitive and the documentation if pretty bad as well. However, there is a pretty good community, that makes up for that.</p><p>Here’s my config file for that project:</p><pre>var autoprefixer = require(‘autoprefixer’);<br>var ExtractTextPlugin = require(“extract-text-webpack-plugin”);<br>var path = require(‘path’);</pre><pre>module.exports = {<br> entry: ‘./app/main.js’,<br> devtool: ‘source-map’,<br> output: {<br>     path: path.join(__dirname, ‘./dist’),<br>     filename: ‘bundle.js’<br>     },<br> module: {<br>     preLoaders: [{<br>         test: /\.js$/, // include .js files<br>         exclude: /node_modules/, // exclude any and all files in      the node_modules folder<br>         loader: “jshint-loader”,<br>         }],<br> loaders: [{<br>     test: /.js$/,<br>     exclude: /node_modules/,<br>     loader: ‘babel-loader’,<br>     query: {<br>         presets: [‘es2015’]<br>        }<br>     }, {<br>     test: /\.css$/,<br>     loader: ExtractTextPlugin.extract(‘style’, ‘css!postcss’)<br>     }, {<br>     test: /\.scss$/,<br>     loader: ExtractTextPlugin.extract(‘style’, ‘css!postcss!sass’)<br>     }, {<br>     test: /\.woff(2)?(\?v=\d+\.\d+\.\d+)?$/,<br>     loader: “url?limit=10000&amp;mimetype=application/font- woff&amp;name=fonts/[name].[ext]”<br>     }, {<br>     test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,<br>     loader: “url?limit=10000&amp;mimetype=application/octet-stream&amp;name=fonts/[name].[ext]”<br>     }, {<br>     test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,<br>     loader: “file?name=fonts/[name].[ext]”<br>     }, {<br>     test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,<br>     loader: “url?limit=10000&amp;mimetype=image/svg+xml&amp;name=fonts/[name].[ext]”<br>     }<br>     ]<br> },<br> postcss: function() {<br>     return [autoprefixer];<br>     },<br> jshint: {<br>     esversion: 6,<br>     emitErrors: false,<br>     failOnHint: false,<br>    },<br> plugins: [<br>     new ExtractTextPlugin(“./bundle.css”)<br>     ]<br>};</pre><p>What this does:</p><ul><li>Bundles JS modules</li><li>Does JS linting</li><li>Converts ES6 JS to ES5 using Babel</li><li>Creates source maps</li><li>Allows .scss imports, converting them to css</li><li>Uses css autoprefixer in the css imports</li><li>Bundles css into one file</li><li>Imports fonts (for bootstrap)</li></ul><p>Now, the important thing is: <strong>it works.</strong> And it does a bunch of stuff that JSPM wouldn’t be able to do (JSPM also has a few plugins, but they are more limited). However, the configuration file is horrendous. Although part of it comes from poor design, a lot of it is just to allow Webpack to be highly customizable. Webpack feels Frankensteinish. It looks like crap and may be scary, but it is nonetheless very powerful.</p><p>You have to be willing to spend some painful hours setting everything up. Most of what you need, you can just copy from the plugins’ docs or tutorials. After a while you can pretty much always use the same config file.</p><p>By the way, one thing that bothered me a lot with Webpack, was the fact that at first, the incremental build feature didn’t work, because I had a parenthesis in my file path. I had to edit the name of a folder to make it work. This happened to me with Windows 10. Now, I do know that Webpack is not all that optimized for windows, but that’s the kind of bug that could make some people waste several hours (like me) trying to figure out the problem while assuming it’s related to the configuration.</p><p>Once everything is set up, with the <em>watcher </em>on, you could almost forget that a tool is being used in the first place. That doesn’t happen with JSPM unless, like previously mentioned, you use workarounds that pretty much make it do the same thing that Webpack would do anyway.</p><p>One pretty good advantage of JSPM is that the bundler uses Rollup. Rollup is also a bundling tool that optimizes files better than Webpack and Browserify, by ditching a lot of unused code that they wouldn’t. However, the smaller file size, doesn’t really make it up for JSPM’s flaws.</p><h3>The future</h3><p>As of the moment of writing, both of these tools have beta versions with a lot of new features coming up.</p><p>JSPM introduced incremental builds (currently, you have to use a plugin to have that), which is awesome, but again, it serves the ironic purpose of allowing you to avoid using what makes JSPM so special.</p><p>Webpack introduced, among other things, reading ES6 modules natively aaaaaand SystemJS support, which again, seems to mean that Webpack will always be a bit ahead. Also, even when browsers support ES6 modules natively, conversion to ES5 will still be required for a few years, due to browser compatibility.</p><p>With a much larger community supporting Webpack, it’s not only a safer choice, but clearly the best one for all but a few use cases.</p><p><strong>When would JSPM be a better choice?</strong></p><p>You should use JSPM if you want to start experimenting with ES6, if you want to write a quick prototype of a project or if your app is really simple and quick to build. Even then, if you start having webpack config files for common situations ready, it would actually be faster using Webpack.</p><p>I don’t like the way webpack neglects the importance of intuitive configuration and clear documentation and I deeply admire the work that has been done with JSPM, but if you actually just want to work and write code, chances are, you will end up needing to use Webpack sooner or later.</p><p>Anyway let’s see how these tools will evolve over time.</p><h3>You found this article useful, feel free to clap so others will find it.</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a90603c3caf" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>