<?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 Marcin Wróblewski on Medium]]></title>
        <description><![CDATA[Stories by Marcin Wróblewski on Medium]]></description>
        <link>https://medium.com/@mwroblewski?source=rss-77ce809a9615------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*paUNta_aULFmZ1yn.</url>
            <title>Stories by Marcin Wróblewski on Medium</title>
            <link>https://medium.com/@mwroblewski?source=rss-77ce809a9615------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 15:59:22 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mwroblewski/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[Bring types to your JS codebase]]></title>
            <link>https://mwroblewski.medium.com/bring-types-to-your-js-codebase-8814915f43ba?source=rss-77ce809a9615------2</link>
            <guid isPermaLink="false">https://medium.com/p/8814915f43ba</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[visual-studio-code]]></category>
            <category><![CDATA[es6]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Marcin Wróblewski]]></dc:creator>
            <pubDate>Sun, 06 Jun 2021 13:25:58 GMT</pubDate>
            <atom:updated>2021-06-06T13:25:58.376Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HHjYhNBMuQTIdH-gMQUdyA.jpeg" /></figure><p>JavaScript is known for it’s flexiblity which is a double-edged sword. <a href="https://wtfjs.com/">Many</a>, <a href="https://github.com/denysdovhan/wtfjs">many</a> WTF JS articles was written about it and <a href="https://auth0.com/blog/javascript-whats-new-es2020/">many</a> articles lists a ton of new features that each ECMAScript release provides to developers.<br>Do you think that you use all of them? Can they help you be more productive or are those just bells and whistles?</p><p>I would like to show you more in-depth use-case of defaults in JS that with some help from <a href="https://code.visualstudio.com/">VS Code</a> will enable you bring types to your JS app without new toolset like TypeScript or Flow requires.</p><h3>Guess a type by the default value</h3><p>Consider this function definition:</p><pre>function summary (elements, reportMode) {...}</pre><p>That can you say about the arguments that are passed in?</p><ul><li>elements is probably an array of some values,</li><li>reportMode is (probably?) a boolean.</li></ul><p>There are some context pieces to gather from function and argument names but e.g. is reportMode required for the summary to work? Or does elements should be array or maybe a Set?</p><p>Those questions can be answered by the code, and I don’t mean that you have to analyze function body to do so. Just add some default values.</p><p>Consider this redefinition:</p><pre>function summary (elements = [0], reportMode = false) {...}</pre><p>Now you know for sure that reportMode should be a boolean and that it is optional since if you will not provide any value as the second argument it’ll be fine since it will fill itself with a false and not undefined (which is still falsy in checks but e.g. can make logging obscure). Also, elements should be an array of numbers. Maybe it’ll work with other iterable structures but you know for sure that original author prepared function body with a assumption that an array will be passed there.</p><p>It’s all great, but it gets even better if you see how VS Code is able to pick up this information and show you some related docs and generate autocomplete:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*azp5C5Pzt0POOti6OR_Ygw.png" /><figcaption>Code with IntelliSense enumerating avaliable function on Array type with drop-in docs</figcaption></figure><p>As a bonus, VS Code’s IntelliSense predicted that I would use reportMode in if statement thanks to it’s knowledge, that reportMode is a boolean! No more lurking the web docs to check if filter on array throws out elements that match or keeps them in the result.</p><p>Including an element in array feeded the IDE with even more data that can benefit the programmer, look:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mnLRgxR2RFtiV1kzto8Gsw.png" /><figcaption>Code with IntelliSense enumerating avaliable functions on array elements</figcaption></figure><p>Working on elements does come with it’s own types IntelliSense. Did you know that .toFixed() has an upper limit for fraction digits? <br>“<em>Yeah, probably it does</em>” I hear you say, but now we know the the limit is 20! Inclusive! No need to remember it and <em>lower</em> risk about forgetting it.</p><p>Just to make the point clearer, here’s how much more of a Notepad the VS Code was before the defaults applied:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KTx6XZl-TRkWKtOOzD1SPA.png" /><figcaption>Code with IntelliSense that knows only function and argument names</figcaption></figure><p>VS Code without defaults is like, “<em>Uhm, I don’t know, maybe you want to write stuff you already did, again?</em>” and with defaults can predict what you will write next!</p><p>The most important thing is that you can start using defaults (given your target system supports ES6 which is 5 years old, so I <em>really</em> hope it does) today without any additional tooling and every user of your code will benefit.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8814915f43ba" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[3-minute guide to Dart for JS developers]]></title>
            <link>https://mwroblewski.medium.com/5-minute-guide-to-dart-for-js-developers-e550b8b4e733?source=rss-77ce809a9615------2</link>
            <guid isPermaLink="false">https://medium.com/p/e550b8b4e733</guid>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Marcin Wróblewski]]></dc:creator>
            <pubDate>Wed, 10 Feb 2021 20:44:45 GMT</pubDate>
            <atom:updated>2021-02-11T08:17:32.035Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KMoV4YDcRKL1GJs_gn9nyA.jpeg" /></figure><p>Were you ever interested in Flutter but never started because learning a whole new programming language for one framework felt like a overcommitment? Read through few examples and see for yourself that it’s not the case and knowing JavaScript or TypeScript is enough to get started with Flutter.</p><h3>JS/TS vs Dart</h3><p>Dart’s syntax does have a few false friends for the JS/TS developers. Fear not though, as this guide will bring your attention to them allowing you to avoid such syntax.</p><h4>Semicolons</h4><p>The big issue when starting a new JS/TS project and configuring linter —” should we mark the end of each command or not&quot; does not exist in Flutter projects.<br>Semicolons are required in Dart.</p><blockquote>It might be a subject to change in the future however, here’s the discussion <a href="https://github.com/dart-lang/language/issues/69">https://github.com/dart-lang/language/issues/69</a> about the topic.</blockquote><h4>const != const</h4><p>Probably the most frequently made mistake when coming to Dart with JS background is defining immutables with const keyword. Especially because const is a valid Dart keyword but have different effect for the stored value.<br>Equivalent to JavaScript’s const is a final.</p><p>const in Dart represents a compile-time declared value, not an unchangeable one.</p><h4>Comparison operator ===</h4><p>JavaScript’s attempt at making developer’s life easier by automatically casting values compared with == operator sure was a great idea but turned out to be confusing for many. === came to the rescue for JS but Dart programmes never had the issue.<br>There are no === operator in Dart, == is the equivalent thanks to the Dart’s type system.</p><h4>Promise is Future</h4><p>In Dart, an idea of a task that will be finished later and can be awaited for is called Future, unlike in JS/TS where developers are making Promises all over the place.</p><h4>async keyword positioning</h4><p>async keyword enabling await syntax in the function body is placed <strong>after</strong> the function name:</p><pre>example() async {...}</pre><h4>Fat arrow functions</h4><p>This code in Dart</p><pre>example() =&gt; true;</pre><p>means that the example() function will return true and can have only one operation performed. For multistep operations, use:</p><pre>example() {<br> .. steps ..<br> return true;<br>}</pre><p>It works for lambdas too, like so</p><pre>onEventHappened = () { .. do stuff .. }</pre><p>this in Dart is not as confusing as in JS so one way of defining lambdas is enough 😉</p><h4>Method return types</h4><p>Unlike in TS, return types are defined before function declaration:</p><pre>bool example() {<br> return true;<br>}</pre><h4>Modules</h4><p>Neither export keyword or module.exports object are present in Dart. Everything that is in the root level of the .dart file can be imported in other modules. To hide elements from other modules predicate the name of the element with _, effectively making it private for the module.</p><pre>const importableByOtherModules = 100;<br>const _hiddenFromOtherModules = 101;</pre><h4>String templates</h4><p>In Dart, you can use templates in both &#39;&#39; and &quot;&quot; strings like so</p><pre>print(’${method()}, $variable’)</pre><p>No backticks are required (or even supported).</p><h3>Conclusions</h3><p>As you can see, switching from JavaScript to Dart can be quick and easy. When you’re comfortable with the basics you can go deeper in Dart’s type system, threads or others optimisations. Here’s great Google’s guide <a href="https://flutter.dev/docs/get-started/flutter-for/web-devs">https://flutter.dev/docs/get-started/flutter-for/web-devs</a> for switching JS developers and the Dart overview <a href="https://dart.dev/overview">https://dart.dev/overview</a> — both are worth reading when you’re interested in Flutter development.</p><blockquote>This is an extended part of a free Flutter workshop <a href="https://flutter-intro-workshop.web.app/docs/">https://flutter-intro-workshop.web.app/docs/</a> for begginers.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e550b8b4e733" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>