<?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 Daniel Ramos Acosta on Medium]]></title>
        <description><![CDATA[Stories by Daniel Ramos Acosta on Medium]]></description>
        <link>https://medium.com/@danielramosacosta?source=rss-19f9e334e705------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*Fkf-evPc--XRLEn5vEEfIg.jpeg</url>
            <title>Stories by Daniel Ramos Acosta on Medium</title>
            <link>https://medium.com/@danielramosacosta?source=rss-19f9e334e705------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 11:18:56 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@danielramosacosta/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[Is TypeScript better than JavaScript?]]></title>
            <link>https://medium.com/@danielramosacosta/is-typescript-better-than-javascript-5cfecd64458d?source=rss-19f9e334e705------2</link>
            <guid isPermaLink="false">https://medium.com/p/5cfecd64458d</guid>
            <category><![CDATA[refactoring]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[maintainability]]></category>
            <dc:creator><![CDATA[Daniel Ramos Acosta]]></dc:creator>
            <pubDate>Wed, 15 Apr 2020 10:13:55 GMT</pubDate>
            <atom:updated>2020-04-15T10:17:56.498Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sqIvGBcbebbm3ttA" /><figcaption>Photo by <a href="https://unsplash.com/@glenncarstenspeters?utm_source=medium&amp;utm_medium=referral">Glenn Carstens-Peters</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Since I started developing web applications, I have been hearing comments like “TypeError: Cannot read property &#39;something&#39; of undefined<em>, again</em>??&quot; or &quot;<em>Each time I touch something, something else breaks!</em>&quot;. Today, I want to talk about TypeScript: a technology that enables a huge amount of tools that ultimately improves the developer experience to a very superior level. The result? Better delivery of highly scalable, and, in the end, finer software.</p><h3>What is TypeScript at all?</h3><blockquote>TypeScript is JavaScript that scales. TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. — TypeScript Docs</blockquote><p>For me, TypeScript is just a type linting tool. It is not another compile-to-js language that aims to “<em>fix JavaScript</em>”. Instead, it sits on top of it, giving you insight on the types. Kind of the same work that ESLint does by giving you feedback if you use bad practices.</p><h3>If you are JavaScripting, you are already TypeScripting</h3><p>I bet you are using some editor or IDE like VSCode. In that case, you are already using TypeScript.</p><p>VSCode internally uses TypeScript’s engine to give you recommendations, even if you are using plain old JavaScript. While the snippet of code that you are working on is easy enough, it will provide IntelliSense recommendations.</p><p>If you use JSDoc for creating documentation, the TypeScript engine can read these comments to help you with your code types.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*CArmkP27WF5InKKuTE4e2A.gif" /></figure><h3>Much more!</h3><p>If you want to know more about TypeScript, like null safety, automatic refactors, check out the full post at <a href="https://acidtango.com/thelemoncrunch/is-typescript-better-than-javascript/?utm_source=google&amp;utm_medium=post&amp;utm_campaign=post-medium&amp;utm_content=post-medium">“Is TypeScript better than Javascript” at The Lemon Crunch, by Acid Tango</a>.</p><p>Please give me there your thoughts! I will be glad to hear them all!</p><p>Cheers! 👋👋</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5cfecd64458d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deno is the new Node?]]></title>
            <link>https://medium.com/lean-mind/deno-node-js-killer-718c8969770b?source=rss-19f9e334e705------2</link>
            <guid isPermaLink="false">https://medium.com/p/718c8969770b</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[deno]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Daniel Ramos Acosta]]></dc:creator>
            <pubDate>Tue, 25 Sep 2018 08:40:20 GMT</pubDate>
            <atom:updated>2018-12-21T11:22:56.969Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*85Edt0bX6YTHa7sN" /><figcaption>Photo by <a href="https://unsplash.com/@markusspiske?utm_source=medium&amp;utm_medium=referral">Markus Spiske</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>About 3 months ago, <a href="https://en.wikipedia.org/wiki/Ryan_Dahl">Ryan Dahl</a> (the inventor of Node.js) gave a talk in JSConf called “<a href="https://www.youtube.com/watch?v=M3BM9TB-8yA">10 Things I Regret About Node.js</a>”, were he regrets several design decisions he took over Node.js. About during the half of his talk, he showed us an experimental prototype called Deno that aimed to fix Node.js problems.</p><p>Deno has reached <a href="https://github.com/denoland/deno/releases">v0.1</a> and I think that it’s on the right way to replace Node.js in the future.</p><h3>What are the main issues with Node.js?</h3><h4>Any program can write to the filesystem and the network</h4><p>This might be a security problem, especially when intalling untrusted packages from npm. <a href="https://blog.npmjs.org/post/163723642530/crossenv-malware-on-the-npm-registry">The </a><a href="https://blog.npmjs.org/post/163723642530/crossenv-malware-on-the-npm-registry">crossenv incident</a> is an example. If crossenvhad not had writing permissions, this would not have happened.</p><h4><strong>Bad ageing async APIs</strong></h4><p>Promises were included in 2009 but removed in february 2010 from Node.js. This has provoked that many libraries out there are still using callbacks as their way to manage async code.</p><h4><strong>The build system (GYP)</strong></h4><p>Using GYP to build a module that links to a C library is a big pain. In order to have a sane DX you’ll have to use node-gyp (a layer on top of GYP) and maybe other layers (like <a href="https://www.npmjs.com/package/nan">nan</a>). I’ve tried this by myself <a href="https://github.com/DanielRamosAcosta/aura-sdk">with a small</a> project and yes, it’s a pain.</p><h4>The module system and npm</h4><p>The main problem here is that the module system isn’t compatible with browsers so our code isn’t fully isomorphic. This is mainly caused by two reasons: storing dependencies in node_modules and having a package.json.</p><h3>What is Deno?</h3><blockquote>“Deno is a secure TypeScript runtime built on V8”</blockquote><blockquote><em>― </em><a href="https://github.com/denoland/deno#a-secure-typescript-runtime-built-on-v8"><em>Ryan Dahl</em></a></blockquote><p>As Typescript is a superset of Javascript, it’s also a runtime for Javascript.</p><p>Deno is a new project created by <a href="https://en.wikipedia.org/wiki/Ryan_Dahl">Ryan Dahl</a> (the inventor of Node.js) that aims to fix Node.js design mistakes that I’ve mentioned before.</p><h3>Deno’s top features</h3><h4>Security</h4><p>Deno by default won’t allow performing delicate actions, like reading environment variables or writing into the file system. We need to pass specific flags</p><p>Deno process runs in a “non-privilege” mode by default, and for accessing delicate things like environment variables</p><p>All the code runs without filesystem write, environment and network permissions. To allow this we must invoke demo with the --allow-write and --allow-net.</p><p>All communications between Deno’s privileged process and v8 are by message passing (previously written in Go, now migrated to Rust). This allows a single auditable point for all communications.</p><h4>Module system</h4><p>No package.json, no node_modules. Source files can be imported using a relative path, an absolute path or a fully qualified URL of a source file:</p><pre>import { test } from &quot;https://unpkg.com/deno_testing@0.0.5/testing.ts&quot;<br>import { log } from &quot;./util.ts&quot;</pre><p>All source files are cached by default. If we need to refresh our dependencies we can use the argument --reload. This is like the browsers’ F5.</p><h4>TypeScript support out of the box</h4><p>TypeScript is supported by default in Deno. Yup. No gotchas. Without any config.</p><h3>Trying out Deno v0.1.4</h3><p>First, we need to download Deno binary:</p><pre>$ mkdir deno-test &amp;&amp; cd deno-test<br>$ wget https://github.com/denoland/deno/releases/download/v0.1.4/deno_linux_x64.gz<br>$ gunzip -c deno_linux_x64.gz &gt; deno<br>$ chmod u+x deno<br>$ ./deno --version<br>deno: 0.1.4<br>v8: 7.0.247-deno</pre><p>Now we can create our typescript file and execute it:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d2b4321007bc34fa3b2ad8c285576e36/href">https://medium.com/media/d2b4321007bc34fa3b2ad8c285576e36/href</a></iframe><pre>$ ./deno myscript.ts<br>Hello world</pre><p>We can also try URL imports. The only requirement for this is to have the .ts file extension at the end of the URL.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f6cad2236811d7a7dbee158b3093a177/href">https://medium.com/media/f6cad2236811d7a7dbee158b3093a177/href</a></iframe><pre>$ ./deno myimport.ts<br>Downloading <a href="https://gist.githubusercontent.com/DanielRamosAcosta/ad514503b1c7cf8290dadb96a5fddee9/raw/4733e267f05d20110ba962c4418bab5e98abfe93/factorial.ts">https://gist.githubusercontent.com/DanielRamosAcosta/ad514503b1c7cf8290dadb96a5fddee9/raw/4733e267f05d20110ba962c4418bab5e98abfe93/factorial.ts</a><br>3628800</pre><p>When executing the script, it’ll download and cache the module. If we want to refresh this cache, we can invoke Deno with --reload, which is the equivalent to F5 or Ctrl+R.</p><p>Here is a more advanced example, using a shallow implementation of the axios library:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d523a91b6204efeabc54b54218c92feb/href">https://medium.com/media/d523a91b6204efeabc54b54218c92feb/href</a></iframe><p>The only gotcha is, that VSCode isn’t able to load the typings from the remote, so in the editor we’ll get the following error:</p><pre>An import path cannot end with a &#39;.ts&#39; extension.</pre><p>But the code still works and gives the correct output:</p><pre>./deno --allow-net axios-test.ts<br>User name: Leanne Graham</pre><h3>Conclusion</h3><p>There still a long time until Deno reachs a production-ready state, but I think it’s on the right path in order to be a better Javascript runtime than Node.js.</p><p>Thanks for reading! 👋👋</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=718c8969770b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lean-mind/deno-node-js-killer-718c8969770b">Deno is the new Node?</a> was originally published in <a href="https://medium.com/lean-mind">Lean Mind</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Testing RxJS Observables with Marble Diagrams]]></title>
            <link>https://medium.com/lean-mind/testing-rxjs-observables-with-marble-diagrams-c2e45820c5cb?source=rss-19f9e334e705------2</link>
            <guid isPermaLink="false">https://medium.com/p/c2e45820c5cb</guid>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[rxjs]]></category>
            <dc:creator><![CDATA[Daniel Ramos Acosta]]></dc:creator>
            <pubDate>Wed, 15 Aug 2018 13:31:20 GMT</pubDate>
            <atom:updated>2018-08-15T13:31:20.478Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6hm7LEurefvYhcZacjBYnQ.jpeg" /><figcaption>Marbles Diagrams will help us testing RxJS Obaservables (📷 from <a href="https://www.wallpaperup.com/416164/marbles_glass_circle_bokeh_toy_ball_marble_sphere_(11).html">WallpaperUp</a>)</figcaption></figure><p>Testing RxJS might be a hard task, specially when we have a complex pipeline with lots of time assertions. In this article we’ll explore how can we make these tests easier to reason about using Marble Diagrams, but first:</p><h3>What are Marble Diagrams?</h3><p>Marble Diagrams are visual representation for events emitted over the time. For example, this is the diagram corresponding to an emission from 0 to 3 over the time:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/1*Wk7qlhVr9VeJq4GtGfKTxg.png" /><figcaption>You can take a look at this diagram at <a href="https://rxviz.com/">rxviz.com</a>, a very usefull website for generaating these diagrams.</figcaption></figure><p>Now that we have this basic time interval we can transform the data, for example multiplying each number by two:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q0RgnR0HItln7Cfi2SnUyQ.png" /><figcaption>Diagram was generated with <a href="http://flames-of-code.netlify.com/blog/rx-marbles/">rx-marbles</a></figcaption></figure><p>This means that there exists a function called <em>numTwoTimes</em> that will map each of the values of the source observable to its multiplication by two. This is the implementation:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/844bf079e228e68a48701e00627fe452/href">https://medium.com/media/844bf079e228e68a48701e00627fe452/href</a></iframe><p>You can learn more about Marble Diagrams at <a href="http://reactivex.io/rxjs/manual/overview.html#marble-diagrams">reactivex.io</a>.</p><h3>Testing RxJS without Marbles Diagrams</h3><p>In order to test our function, we have to send it values through an observable, so we’ll create an observable that emits 4 values over the time, and then subscribe to the observable and check that the emitted values are right:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ec2b9414c4aaa80f6e6c05df860e9fb1/href">https://medium.com/media/ec2b9414c4aaa80f6e6c05df860e9fb1/href</a></iframe><p>This example might look simple at first, but we are not testing the time of the emissions (that would be very hard), despite it takes 3 seconds to execute the test.</p><h3>Testing with marble diagrams</h3><p>To test with marble diagrams, we need to represent this diagram using ASCII characters, so the previous example becomes:</p><pre>-a–b–c-|<br>numTwoTimes<br>-x-y-z-|</pre><pre>values = { a: 1, b: 2, c: 3, x: 2, y: 4, z: 6 }</pre><p>From this snippet, we can extract several things:</p><ul><li>-: Means a frame of time, that is by default 10ms.</li><li>character: It’s a single emitted value, it’s like a variable name with its value defined at the values object.</li><li>|: It represent the completation of the observable.</li></ul><p>So with this ASCII marble diagram, we can rewrite our tests as the following:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2fe61ec7fe7526cd695a7dcdcfb61464/href">https://medium.com/media/2fe61ec7fe7526cd695a7dcdcfb61464/href</a></iframe><p>This way we are asserting not only the values, but also the timing of the emissions. Also, we fix the time of the execution, as RxJS’s TestSheduler uses virtual time, so tests are actually synchronous!</p><h3>Conclusion</h3><ul><li>It’s easier to test Observable behavior, specially the time of the emitted values.</li><li>It’s easier to read, as you only have to look at the diagram instead of reading the code.</li><li>It’s faster, as it uses virtual time to simulate delays, intervals, etc…</li></ul><p>You can take a look for more avanced examples and concepts (like error handling or grouping emissions) at this repo:</p><p><a href="https://github.com/DanielRamosAcosta/rxjs-marble-testing">DanielRamosAcosta/rxjs-marble-testing</a></p><p>Thanks for reading! 👋👋</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c2e45820c5cb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lean-mind/testing-rxjs-observables-with-marble-diagrams-c2e45820c5cb">Testing RxJS Observables with Marble Diagrams</a> was originally published in <a href="https://medium.com/lean-mind">Lean Mind</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>