<?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 Kevin Da Silva on Medium]]></title>
        <description><![CDATA[Stories by Kevin Da Silva on Medium]]></description>
        <link>https://medium.com/@kevin-da-silva?source=rss-5b76b54e16c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*6b_P2ZOjBK878t6h</url>
            <title>Stories by Kevin Da Silva on Medium</title>
            <link>https://medium.com/@kevin-da-silva?source=rss-5b76b54e16c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 15:09:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kevin-da-silva/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[Nice programming tools I tried in 2024]]></title>
            <link>https://kevin-da-silva.medium.com/nice-programming-tools-i-tried-in-2024-e4e5093c5af0?source=rss-5b76b54e16c------2</link>
            <guid isPermaLink="false">https://medium.com/p/e4e5093c5af0</guid>
            <category><![CDATA[developer-tools]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Kevin Da Silva]]></dc:creator>
            <pubDate>Tue, 17 Dec 2024 21:27:48 GMT</pubDate>
            <atom:updated>2024-12-17T21:27:48.386Z</atom:updated>
            <content:encoded><![CDATA[<p>Hey guys I finally had time and peace of mind to come back to medium to write my first article in 2024 I know I’ve been missed got kinda busy dealing with a ton of stuff, but for this article I would like to share a few cools tools I used this year that maybe you would enjoy as well!</p><h4><a href="https://fastapi.tiangolo.com/">FastApi</a></h4><p>FastApi is a web framework for the python language, I came across their website recently, found it really similar to express.js and decide to learn it, I spent an entire Saturday morning building a <a href="https://github.com/KevinDaSilvaS/itamaraty-inventory">REST api</a> that reads the items inventory of the Itamaraty(Brazilian international relations ministery) from a csv file, adds it in bulk to an sqlite and allows search by item id or item group trough GET endpoints, I felt really productive coding in it and the learning curve was very smooth.</p><h4><a href="https://orm.drizzle.team/">DrizzleORM</a></h4><p>I used DrizzleORM in test project for a company I was interviewing at, it was the first time I used it, I kinda liked the way it worked even with plain js files, liked the way the query builder worked, but didn&#39;t liked much the way it made joins as I noticed it was repeating data instead of grouping it like if I want to get all posts by user in a join instead of returning:</p><pre>{ user: {userid: 1}, posts: [...posts] }<br></pre><p>It was returning:</p><pre>[ <br>  { user: {userid: 1}, post: {postId: 1, userId: 1} },<br>  { user: {userid: 1}, post: {postId: 2, userId: 1} }<br>]</pre><p>But it’s a nice new tool for dealing with dbs.</p><h4><a href="https://zod.dev/">Zod</a></h4><p>Used Zod a s library to validate request bodys and to typecheck in data structures, it was a real nice tool to integrate and use, really enjoyed it.</p><h4><a href="https://docs.bullmq.io/">BullMQ</a></h4><p>BullMQ is a queue system that runs on top of redis and it’s perfect for when you have recurrent jobs to do like a job that runs once a day or when you need to add a conditional statement like: Ack this job if certain condition is present, It´s a super tool that made me retire the OS cronjobs, now I only use BullMQ for that.</p><h4><a href="https://modules.vlang.io/cli.html">Cli</a></h4><p>I used the cli module for the V programming language, I was buiding a more complex CLI and decided to go with the module already present in the language, and creating the commands was very straightforward, you can add the commands you want and a default command to run when no option is passed and It’s done and you may focus on the functionalities instead of the cli part, separating your application from the interface</p><p>And these were five cool programming tools I used this year that maybe you would like to try before the end of 2024 and check if is good enough for you, thank you for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e4e5093c5af0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Vlang tutorials — playing with WebSockets]]></title>
            <link>https://kevin-da-silva.medium.com/vlang-tutorials-playing-with-websockets-1eefc84035fa?source=rss-5b76b54e16c------2</link>
            <guid isPermaLink="false">https://medium.com/p/1eefc84035fa</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[vlang]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[sockets]]></category>
            <dc:creator><![CDATA[Kevin Da Silva]]></dc:creator>
            <pubDate>Sat, 23 Dec 2023 16:40:22 GMT</pubDate>
            <atom:updated>2023-12-23T16:40:22.220Z</atom:updated>
            <content:encoded><![CDATA[<h3>Vlang tutorials — playing with WebSockets</h3><p>Hey, guys here I am back again with one more fast-paced Vlang tutorial, this time covering a bit more of the net module web socket support.</p><p>In this tutorial, I will cover the basic setup of both client and server and how to connect them through WebSockets</p><h3>The server</h3><p>Let’s start with setting up the server, we will have to create a new file called <strong><em>server.v</em></strong> and import <strong><em>net</em></strong> and <strong><em>net.websocket</em></strong>:</p><pre>import net.websocket as socket<br>import net</pre><p>To start up a server we need to call the new_server function from the web socket, the docs say we have to pass the following params:</p><pre>fn new_server(<br>   family net.AddrFamily, <br>   port int, <br>   route string, <br>   opt ServerOpt) <br>&amp;Server</pre><p>So let’s create first the address family, for this example, I want to use IP4, so I will set it as ip:</p><pre>addr := net.AddrFamily.ip  </pre><p>for <strong><em>opt </em></strong>I will just use the default implementation:</p><pre>opt := socket.ServerOpt {}</pre><p>For port and route, I will use <strong><em>3000 </em></strong>and <strong><em>/hi</em></strong>, so our <strong><em>new_server </em></strong>setup should look like this:</p><pre>mut server := socket.new_server(addr, 3000, &quot;/hi&quot;, opt)</pre><p>For teaching purposes I will use only two server callbacks to show how the module works: <strong><em>on_connection </em></strong>to get when a client connects and <strong><em>on_message </em></strong>to be able to process client input</p><p>First let’s make our server able to tell us when a client connected:</p><pre>server.on_connect(fn(mut _ socket.ServerClient) !bool {<br> println(&quot;client connection&quot;)<br> return true<br>})!</pre><p>We just pass a function as a parameter and print that a client connected to our server, relatively simple, let’s make it a bit spicier and get the user input:</p><pre>server.on_message(fn (mut _ socket.Client, msg &amp;socket.Message) ! {<br> payload := msg.payload<br> if payload.len &gt; 0 {<br>  println(payload.bytestr())<br> }<br>})</pre><p>We also use a function as a parameter to be able to get the message, notice that before printing the message I check if the payload has bytes in it or if it’s just empty, if not empty I convert it to a string because in this example we will just work with strings, but I could be working with JSON or other encoding formats.</p><p>Now we just have to call the listen method to be able to <strong><em>listen </em></strong>to the incoming connections:</p><pre>server.listen()!</pre><p>By that point, our <strong><em>server.v</em></strong> should contain the following contents:</p><pre>import net.websocket as socket<br>import net<br><br>opt := socket.ServerOpt {}<br><br>addr := net.AddrFamily.ip <br><br>println(addr)<br><br>mut server := socket.new_server(addr, 3000, &quot;/hi&quot;, opt)<br><br>server.on_connect(fn(mut _ socket.ServerClient) !bool {<br> println(&quot;client connection&quot;)<br> return true<br>})!<br><br>server.on_message(fn (mut _ socket.Client, msg &amp;socket.Message) ! {<br> payload := msg.payload<br> if payload.len &gt; 0 {<br>  println(payload.bytestr())<br> }<br> <br>})<br><br>server.listen()!</pre><h3>The client</h3><p>The client is way more simple to set up than the server and we can make it work in just a few lines of code</p><p>Create a new file <strong><em>client.v</em></strong> and import <strong><em>net.websocket</em></strong>:</p><pre>import net.websocket as socket</pre><p>To create a client we have to use the <strong><em>new_client</em></strong> function with the following params:</p><pre>fn new_client(address string, opt ClientOpt) !&amp;Client</pre><p>Let´s first set the opt that consists basically of using the default struct:</p><pre>opt := socket.ClientOpt {}</pre><p>And now it´s just connect the client to the server url:</p><pre>mut client := socket.new_client(&quot;ws://127.0.0.1:3000/hi&quot;, opt)!</pre><p>Now to connect to the server and print the message <strong><em>“client connection”</em></strong> on the server we have to call the connect method:</p><pre>client.connect()!</pre><p>And to send the string message to the server we have to call the <strong><em>write_string </em></strong>method</p><pre>client.write_string(&quot;hi from client&quot;)!</pre><p>And to be able to listen to the server we just have to call <strong><em>listen </em></strong>on the client as well:</p><pre>client.listen()!</pre><p>By now our <strong><em>client.v</em></strong> should look like this:</p><pre>import net.websocket as socket<br><br>opt := socket.ClientOpt {}<br><br>mut client := socket.new_client(&quot;ws://127.0.0.1:3000/hi&quot;, opt)!<br><br>client.connect()!<br><br>client.write_string(&quot;hi from client&quot;)!<br><br>client.listen()!</pre><p>And to run it we need to open up two terminal windows and hit the commands:</p><pre>v run server.v //to start the server<br>v client.v // to start the client</pre><p>And that’s how you make sockets work with Vlang, hope you liked it!</p><p>Happy holidays, bye :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1eefc84035fa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[2023 in code - My year retrospective in programming]]></title>
            <link>https://kevin-da-silva.medium.com/2023-in-code-my-year-retrospective-in-programming-545c011573e8?source=rss-5b76b54e16c------2</link>
            <guid isPermaLink="false">https://medium.com/p/545c011573e8</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[retrospectives]]></category>
            <dc:creator><![CDATA[Kevin Da Silva]]></dc:creator>
            <pubDate>Sun, 17 Dec 2023 16:27:01 GMT</pubDate>
            <atom:updated>2023-12-17T22:13:24.805Z</atom:updated>
            <content:encoded><![CDATA[<p>Hey guys I have been missing in the last few months, I was having a break until I felt comfortable enough to write again, and I wasn’t very excited to talk about tech so often(everything was AI, AI, gpt, AI, layoffs, AI, crisis, crying, AI which is super overwhelming), but here’s a thing that motivated me to write about, my retrospective in terms of coding, to tell a bit more of what I coded this year.</p><p>At the beginning of the year, I was in a consulting firm coding microservices in typescript with nest.js, and Postgres, which wasn’t an experience I liked much, not related to the tech but to my management which was horrible and super incompetent.</p><p>In January I learned GRPC and built a todo app service in Haskell + MU + Mongodb, which was cool, I loved coding GRPC APIs with Haskell</p><p>Also at the beginning of the year, I set myself the goal to learn a systems language and started learning a bit more of Rust.<br>At least in the consulting firm opportunity I was working, I had the chance to face a problem related to compression and had to test other programming languages and benchmark then, I tried node.js, Elixir, Vlang, and Rust, Vlang was the best in terms of getting things done and getting a good compression result, due to having a compression module in the standard library.</p><p>After a few chapters of the Rust book I started finding the language very complex and bureaucratic to get things done, and I started missing my garbage collector and quit learning Rust, and let it for the future me to learn it.</p><p>In March I was laid off from the consulting firm I was working on and stopped coding in typescript for a while, while unemployed I started interviewing at other companies while I got more involved with the Vlang community</p><p>Involved more with V I wanted to write more about it and teach it to other developers, so I read the book Introducing Go, due to Golang being very similar to Vlang, and learned Go and the way it was being taught and converted the first five chapters of the book into five chapters on my series teaching Vlang.</p><p>While interviewing I coded in Node.js again in a take-home test for Mercado Libre, which was a proxy application, to proxy rest APIs, was a cool project I enjoyed coding it.</p><p>I came back to Go and built a tictactoe game and a URL shortener app using Gin and Redis</p><p>I also coded in Elixir to another take-home test for SWAP, which was a web service that receives requests and processes then async after a time interval I liked this test because I experimented with other things beyond the test like rate limits and concurrent running process, but unfortunately SWAP never gave me a proper feedback, just said they really liked my solution and disappeared</p><p>In May I got an offer and started working for a company on an AI project which involved me to code in node.js, adonis, and Postgres, but also in Python and pytorch to integrate hugging face models with the user input.</p><p>Also, I took an incredible course on digital image processing, the course was taught in octave, but I didn’t wanted to learn a new language just for that, so decided to use Julia instead, and it was an incredible decision, Julia is a wonderful language for dealing with matrix stuff what fitted really well into processing images.</p><p>In September I came back to V to finish a URL shortener app I started building, I had to stop it in the past due to V not having a Redis driver that was working, fortunately for me coachonko built a driver for it and I was able to finish the project!</p><p>After it I came back to my journey of trying to learn a systems language and decided to try to learn C, it was more simple so it would probably be more comprehensible for me, but it didn’t go so well, it was so raw that it didn’t have a length function to get the length of an array, the lack of minimal functions, made me get frustrated with C.</p><p>Then I instead decided to learn C++, but in the same week I gave it a try at Zig and found it really cool, seemed like a nice language, with a good standard library, and I even built a tictactoe game in Zig.<br>I learned Zig like the basics of the language, allocators, enums, etc. However due to Zig ecosystem being so small and emergent I stopped my learning there because the support to async modules would be implemented only in the next stable release and I didn’t have a package manager to work with Zig, but it’s a really promising language and I want to come back to it in 2024.</p><p>After that, the Unity community exploded its bubble and the bad news came to me, I graduated in digital games and got curious about what the game development people were doing, and in November and December I decided to learn the basics of Godot 4 so I coded a few scripts in GDScript as well, but I built no games in it(yet).</p><h4>What I’m into for next year</h4><p>I will probably give a try in older languages like Prolog, FORTRAN, and why not Cobol, would be a different experience I guess</p><p>Also maybe I will come back to Rust and Zig, or finally learn C++</p><p>I dont know maybe learning some physics stuff or trying out some random Apache foundation open-source software</p><p>Or most probably I will throw all the brainstorming in the thrash and take my usual curiosity-driven approach to new programming topics</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=545c011573e8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Vlang tutorials — logs]]></title>
            <link>https://kevin-da-silva.medium.com/vlang-tutorials-logs-f21b1a1b84c1?source=rss-5b76b54e16c------2</link>
            <guid isPermaLink="false">https://medium.com/p/f21b1a1b84c1</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[vlang]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[go]]></category>
            <dc:creator><![CDATA[Kevin Da Silva]]></dc:creator>
            <pubDate>Tue, 24 Oct 2023 22:15:49 GMT</pubDate>
            <atom:updated>2023-10-24T22:15:49.248Z</atom:updated>
            <content:encoded><![CDATA[<h3>Vlang tutorials — logs</h3><p>Hi guys It’s been a looooong time since my last blog post, I decided to make my comeback with one more tutorial on how to use a feature in Vlang, today’s feature is a feature I noticed a few weeks ago and immediately applied to one of my projects, you probably already guessed we are talking about the <strong><em>log </em></strong>module.</p><p>The <strong><em>log </em></strong>module is a module to add logs to your application, and I will showcase how to use it by adding logs into a <a href="https://github.com/KevinDaSilvaS/v-shortener">url shortener</a> app that I wrote in V.</p><p>The first log I added was to print in the terminal when the server has started:<br><a href="https://github.com/KevinDaSilvaS/v-shortener/blob/main/shortener.v"><strong><em>shortener.v</em></strong></a></p><pre><br>module main<br><br>import vweb<br>import server<br>import log<br><br>fn main() {<br>    log.info(&#39;server running&#39;)<br>    vweb.run_at(server.new_shortener(), vweb.RunParams{<br>        port: 8081<br>    }) or { panic(err) }<br>}</pre><p>To make it work I just imported the module log:</p><pre>import log</pre><p>And called the info function with the info message that the server has started:</p><pre>log.info(&#39;server running&#39;)</pre><p>After informing the server status I started to add logs in controllers and services:<br><a href="https://github.com/KevinDaSilvaS/v-shortener/blob/main/controllers/controllers.v"><strong><em>controllers.v</em></strong></a></p><pre>module controllers<br><br>import structs as s<br>import requests as r<br>import httperrors as he<br>import services<br>import log<br><br>pub fn create_link(req_body r.CreateLinkRequest) s.ResponseObject&lt;s.Response&gt; {<br>    log.info(&#39;[CONTROLLER] - create_link function&#39;)<br>    if req_body.is_empty() {<br>        log.warn(&#39;request without body&#39;)<br>        return he.create_response_error(<br>            &#39;fields link_name(string) or link_url(https://medium.com/string) should not be empty&#39;,<br>            400)<br>    }<br><br>    return services.create_link(req_body)<br>}<br><br>pub fn get_link(link_name string) s.ResponseObject&lt;s.Response&gt; {<br>    log.info(&#39;[CONTROLLER] - get_link function&#39;)<br>    return services.get_link_url(https://medium.com/link_name)<br>}</pre><p>As usual in controllers.v I added two info in both functions create_link, get_link informing that I reached that respective function in the controllers file.</p><p>But notice that in the create_link I added a warning if the request body is empty, because if it is It’s not an error on the server, but on the client, so it’s a warning.</p><p>Soon we will see how to deal with errors that occur in the server, but first, let´s take a look at the services file:<br><a href="https://github.com/KevinDaSilvaS/v-shortener/blob/main/services/services.v"><strong><em>services.v</em></strong></a></p><pre>module services<br><br>import structs as s<br>import requests as r<br>import repository as repo<br>import httperrors as he<br>import time<br>import log<br><br>pub fn create_link(req_body r.CreateLinkRequest) s.ResponseObject&lt;s.Response&gt; {<br>    log.info(&#39;[SERVICE] - create_link function&#39;)<br>    db := repo.setup()<br>    if !db.save(req_body.link_name, req_body.link_url) {<br>        log.error(&#39;lost connection with database&#39;)<br>        return he.create_response_error(&#39;unable to reach database&#39;, 500)<br>    }<br>    <br>    created_link := s.Response(s.CreatedLink{<br>        link_name: req_body.link_name<br>        creation_date: time.now().hhmmss()<br>    })<br><br>    return s.ResponseObject&lt;s.Response&gt;{<br>            code: 201<br>            body: created_link<br>            format: s.FileFormats.json<br>        }<br>}<br><br>pub fn get_link_url(https://medium.com/link_name%20string) s.ResponseObject&lt;s.Response&gt; {<br>    log.info(&#39;[SERVICE] - get_link_url function&#39;)<br>    db := repo.setup()<br>    result := db.get(link_name)<br>    if !result.success {<br>        log.warn(&#39;${link_name} not found&#39;)<br>        return he.create_response_error(&#39;url not found&#39;, 404)<br>    }<br><br>    page_link := result.data<br>    script := &#39;&lt;script&gt;window.location.href = &quot;${page_link}&quot;&lt;/script&gt;&#39;<br>    response := s.Response(script)<br><br>    return s.ResponseObject&lt;s.Response&gt;{<br>            code: 200<br>            body: response<br>            format: s.FileFormats.html<br>        }<br>}</pre><p>In services, I also added infos informing that we reached the respective functions in the services module, and also added a warning in the get_link_url function when a link URL is not found, but if we take a look at the create_link function we can notice that in this case an error log is emitted because if we can’t communicate with Redis to save a link it means that is a server error, and to inform a server error I used:</p><pre>log.error(&#39;lost connection with database&#39;)</pre><p>I found logs a useful tool to have in the standard library that worked very well with my web server, in case you want to learn more about it I recommend reading the documentation about it <a href="https://modules.vlang.io/log.html">here</a>!</p><p>Hope you liked it, see ya ;)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f21b1a1b84c1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[V for Go programmers —Functions]]></title>
            <link>https://kevin-da-silva.medium.com/v-for-go-programmers-functions-65601b792b4c?source=rss-5b76b54e16c------2</link>
            <guid isPermaLink="false">https://medium.com/p/65601b792b4c</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[vlang]]></category>
            <category><![CDATA[golang]]></category>
            <dc:creator><![CDATA[Kevin Da Silva]]></dc:creator>
            <pubDate>Mon, 24 Apr 2023 12:20:27 GMT</pubDate>
            <atom:updated>2023-04-24T12:20:27.498Z</atom:updated>
            <content:encoded><![CDATA[<p>As we are following the order in <a href="https://www.oreilly.com/library/view/introducing-go/9781491941997/"><strong>“Introducing Go”</strong></a><strong> </strong>applied to<strong> </strong>Vlang, today’s chapter is chapter six, <em>“Functions”</em> which for a functional programmer like it’s probably the most exciting chapter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h-9jxo2Gvw-Sw0ldL1793A.png" /></figure><blockquote>Functions</blockquote><p>Functions in V work as the following:<br>First, we define the body of the function</p><pre>fn my_function() {<br> <br>}</pre><p>Notice that we use the snake case convention in V as opposed to the Go camel case or Pascal case when working with module functions.</p><p>If our function has parameters we can define them by typing their identifiers and their corresponding types:</p><pre>fn my_function(x int, y bool) {<br> <br>}</pre><p>If the types of our params are the same we can do like Go and express the following:</p><pre>fn my_function(x, y int) {<br> <br>}</pre><p>In case we need to return something we have to inform the return type after the closing parenthesis character</p><pre>fn my_function(x, y int) int {<br>  return x+y<br>}</pre><p>And in case I need a variable amount of parameters, V also supports variadic functions</p><pre>fn my_function(args ...int) {<br> for arg in args  {<br>  println(arg)<br> }<br>}</pre><p>Or if I need a closure:</p><pre>fn my_function() fn(int, int) int {<br>   return  fn(x, y int) int {<br>     return x + y  <br>   }<br><br>}</pre><p>I can even curry functions:</p><pre>fn curry_sum(x int) fn(int) int {<br> return fn [x] (y int) int {<br>  return x+y<br> }<br>}</pre><p>Notice that I had to use [x] to specify the inner function that I want to use variables declared in the outer scope.</p><p>V has support for recursion too and it’s very straightforward:</p><pre>fn recursion_it(times int) int {<br> if times &gt; 0 {<br>  return times + recursion_it(times-1)<br> }<br> <br> return 0<br>}</pre><p>A recursive function that sums the parameter it receives while counting down the number of times it should be called.</p><blockquote>Pointers</blockquote><p>As Go V also has a very similar approach to pointers, but it has a few differences that we will cover below, but for now have a taste of how it works:</p><pre>fn main() {<br> mut x := 5<br> zero(mut &amp;x)<br> println(x) //should be 0<br>}<br><br>fn zero(mut xptr &amp;int) {<br>  xptr = 0<br>}</pre><p>The main difference is that in order to pass a point as a parameter I don’t use “*” in the zero function instead I use “&amp;”, and the second detail is that to work with pointers I have to declare the value I’m working on as mut when I declare x, call zero in main and declare a pointer as a parameter, otherwise it would output an error because constants cant be changed.</p><p>It changes a bit, but it’s very similar to what Go has.</p><blockquote>Exercises</blockquote><ul><li>Write a function that takes an integer and halves it and returns true if it was even or false if it was odd. For example, half(1) should return (0, false) and half(2) should return (1, true).</li><li>Write a function with one variadic parameter that finds the greatest number in a list of numbers.</li><li>Write a make_odd_generator function that generates odd numbers.</li></ul><blockquote><a href="https://kevin-da-silva.medium.com/v-for-go-programmers-arrays-and-maps-a2e5f6ffa860"><strong><em>&lt;- CHAPTER 5</em></strong></a></blockquote><p>And we did it, one more chapter done!</p><p>We successfully learned how functions work in V and kept going this series, hope to see you in the next article!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=65601b792b4c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[V for Go programmers — Arrays, and Maps]]></title>
            <link>https://kevin-da-silva.medium.com/v-for-go-programmers-arrays-and-maps-a2e5f6ffa860?source=rss-5b76b54e16c------2</link>
            <guid isPermaLink="false">https://medium.com/p/a2e5f6ffa860</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[vlang]]></category>
            <dc:creator><![CDATA[Kevin Da Silva]]></dc:creator>
            <pubDate>Tue, 18 Apr 2023 11:29:16 GMT</pubDate>
            <atom:updated>2023-04-24T12:23:43.788Z</atom:updated>
            <content:encoded><![CDATA[<h3>V for Go programmers — Arrays, and Maps</h3><p>Covering one more topic in Vlang based on the chapters of the book <a href="https://www.oreilly.com/library/view/introducing-go/9781491941997/"><strong>“Introducing Go”</strong></a>, and following the order of the book, today’s is the fifth chapter, <em>“Arrays, Slices, and Maps”</em> respectively.</p><blockquote>Arrays</blockquote><p>Arrays and slices are pretty much the same thing in V, considering V groups the two of them:</p><pre>mut arr := []int<br>arr &lt;&lt; 3 // [3]<br>arr &lt;&lt; 2 // [3,2]<br>arr.len // 2<br>arr[2] = 5</pre><p>And fixed size arrays:</p><pre>mut v := [3]int{}<br>v[2] = 13<br><br>println(v) // [0,0,13]</pre><p>Arrays in V also can be created with a default value:</p><pre>v := []int{len: 3, init: 3}<br><br>println(v) // [3, 3, 3]</pre><p>And also I can use the “it” keyword to populate the array:</p><pre>v := []int{len: 3, init: it+1}<br><br>println(v) // [1, 2, 3]</pre><p>“it” represents the current index being populated starting at 0, with the facility of the “it” keyword we can for example revert an array:</p><pre>v := []int{len: 3, init: it+1}<br>println(v) // [1, 2, 3]<br><br>v2 := []int{len: v.len, init: v[v.len-it-1]}<br>println(v2) // [3, 2, 1]</pre><p>Now more properly getting into slices:</p><pre>nums := [0, 10, 20, 30, 40]<br>println(nums[1..4]) // [10, 20, 30]<br>println(nums[..4]) // [0, 10, 20, 30]<br>println(nums[1..]) // [10, 20, 30, 40]</pre><pre>array_1 := [3, 5, 4, 7, 6]<br>mut array_2 := [0, 1]<br>array_2 &lt;&lt; array_1[..3]<br>println(array_2) // [0, 1, 3, 5, 4]</pre><p>V even supports negative indexes:</p><pre>a := [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]<br>println(a#[-3..]) // [7, 8, 9]</pre><blockquote>Maps</blockquote><p>Maps work pretty much the same as in Go, you defined the type of your key and the type of your value:</p><pre>mut m := map[string]int{} <br>m[&#39;one&#39;] = 1<br>m[&#39;two&#39;] = 2<br>println(m[&#39;one&#39;]) // 1</pre><p>Or an immutable map:</p><pre>numbers := {<br> &#39;one&#39;: 1<br> &#39;two&#39;: 2<br>}<br>println(numbers)</pre><blockquote>Exercises</blockquote><ul><li>Write a program that finds the smallest number in this list: x := [ 48,96,86,68, 57,82,63,70, 37,34,83,27, 19,97, 9,17]</li></ul><blockquote><a href="https://kevin-da-silva.medium.com/v-for-go-programmers-variables-and-control-structures-e4e25d0e165d"><strong><em>&lt;- CHAPTER 3,4</em></strong></a><strong><em> | </em></strong><a href="https://kevin-da-silva.medium.com/v-for-go-programmers-functions-65601b792b4c"><strong><em>CHAPTER 6 -&gt;</em></strong></a></blockquote><p>And that’s how you work with arrays and maps in V.</p><p>Thank you for reading one more chapter in this series on V, hope to see you in the next one!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a2e5f6ffa860" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[V for Go programmers — Variables and Control Structures]]></title>
            <link>https://kevin-da-silva.medium.com/v-for-go-programmers-variables-and-control-structures-e4e25d0e165d?source=rss-5b76b54e16c------2</link>
            <guid isPermaLink="false">https://medium.com/p/e4e25d0e165d</guid>
            <category><![CDATA[go]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[vlang]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Kevin Da Silva]]></dc:creator>
            <pubDate>Wed, 12 Apr 2023 12:39:08 GMT</pubDate>
            <atom:updated>2023-04-18T11:29:33.605Z</atom:updated>
            <content:encoded><![CDATA[<h3>V for Go programmers — Variables and Control Structures</h3><p>Covering more topics in V based on the book <a href="https://www.oreilly.com/library/view/introducing-go/9781491941997/"><strong>“Introducing Go”</strong></a>, today we are gonna cover two chapters variables(chapter 3) and control structures(chapter 4) because both topics are very straightforward and easier to grasp in V.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h-9jxo2Gvw-Sw0ldL1793A.png" /></figure><h4>Variables</h4><p>Variables in V are pretty simple, and are equal to the Go definition:</p><pre>my_var := 32<br>othervar := true</pre><p>And that’s it, V doesn&#39;t have an equivalent for var or for multi assignments.</p><blockquote>But what about constants?</blockquote><p>Every variable in V is a constant(immutable) by default.</p><blockquote>But what if I need to change a value of a variable?</blockquote><p>It’s quite easy you just have to use the <em>“mut”</em> keyword:</p><pre>mut my_var := 32<br>my_var = 45</pre><p>And that’s how variables work in V.</p><h4>Control Structures</h4><p>Now let’s cover conditional and repetition structures in V and their styles</p><blockquote>The loop</blockquote><p>To loop things in V we can use the <em>“for”</em> keyword:</p><pre>languages := [&quot;Elixir&quot;, &quot;Go&quot;, &quot;Haskell&quot;, &quot;JavaScript&quot;]<br>for lang in languages{<br> println(lang)<br>}</pre><p>To get the index of an element in the loop:</p><pre>languages := [&quot;Elixir&quot;, &quot;Go&quot;, &quot;Haskell&quot;, &quot;JavaScript&quot;]<br>for index, lang in languages{<br> println(&quot;${index} =&gt; ${lang}&quot;)<br>}</pre><p>Ranges and loops in V:</p><pre>for i in 0 .. 5 {<br> print(i)<br>}</pre><p>Equivalent to while loops:</p><pre>mut i := 0<br>for i &lt;= 100 {<br> i+=1<br>}</pre><p>Infinite loop:</p><pre>for {<br>  println(&quot;looping&quot;)<br>}</pre><p>C like for loop:</p><pre>for i := 0; i &lt; 10; i += 1{<br> if i == 6 {<br>  continue<br> }<br> println(i)<br>}</pre><blockquote><a href="https://www.youtube.com/watch?v=qLGwIHjhboA">Is it true</a></blockquote><p>If expressions in V are also identical to Go ifs</p><pre>if 30 &lt; 50 {<br> println(&#39;30 less than 50, crazy math&#39;)<br>} else if 30 &gt; 50{<br> println(&#39;That seems more reasonable&#39;)<br>} else {<br> println(&#39;Wait what?&#39;)<br>}</pre><p>I also can attribute an if statement to a variable:</p><pre>num := 32<br>s := if num % 2 == 0 { &#39;even&#39; } else { &#39;odd&#39; }</pre><blockquote>It´s a match</blockquote><p>V doesn&#39;t have a switch structure but has something that in my opinion is way better, the match structure:</p><pre>os := &#39;windows&#39;<br>match os {<br> &#39;darwin&#39; { println(&#39;macOS.&#39;) }<br> &#39;linux&#39; { println(&#39;Linux.&#39;) }<br> else { println(os) }<br>}</pre><p>The match operator consists of a more approachable pattern-matching structure for a language that is not in the functional paradigm.</p><p>I also can attribute a match statement to a variable:</p><pre>number := 2<br>s := match number {<br> 1 { &#39;one&#39; }<br> 2 { &#39;two&#39; }<br> else { &#39;many&#39; }<br>}</pre><blockquote>Others</blockquote><p>V also has other operators like Defer, In, and GoTo, wich will not be covered in this article due to being less used, but I will let the link for the documentation <a href="https://github.com/vlang/v/blob/master/doc/docs.md#statements--expressions">here</a> in case you need it in the future.</p><blockquote>Exercises</blockquote><ul><li>Write a program that prints out all the numbers between 1 and 100 that are evenly divisible by 3 (i.e., 3, 6, 9, etc.).</li><li>Write a program that prints the numbers from 1 to 100, but for multiples of three, print “Fizz” instead of the number, and for the multiples of five, print “Buzz.” For numbers that are multiples of both three and five, print “FizzBuzz.”(Tip: I have implemented it in another article <a href="https://medium.com/@kevin-da-silva/one-problem-five-solutions-fizz-buzz-40192b9a9b18">here </a>in case you need help)</li></ul><blockquote><a href="https://medium.com/@kevin-da-silva/v-for-go-programmers-types-5533556e02fa"><strong><em>&lt;- CHAPTER 2</em></strong></a><strong><em> | </em></strong><a href="https://kevin-da-silva.medium.com/v-for-go-programmers-arrays-and-maps-a2e5f6ffa860"><strong><em>CHAPTER 5 -&gt;</em></strong></a></blockquote><p>And here we covered two chapters with one article, thank you for reading one more episode in this series and for giving V a chance, hope to see you again. Bye!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e4e25d0e165d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[V for Go programmers — Types]]></title>
            <link>https://kevin-da-silva.medium.com/v-for-go-programmers-types-5533556e02fa?source=rss-5b76b54e16c------2</link>
            <guid isPermaLink="false">https://medium.com/p/5533556e02fa</guid>
            <category><![CDATA[vlang]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[golang]]></category>
            <dc:creator><![CDATA[Kevin Da Silva]]></dc:creator>
            <pubDate>Tue, 11 Apr 2023 12:21:41 GMT</pubDate>
            <atom:updated>2023-04-24T12:25:08.586Z</atom:updated>
            <content:encoded><![CDATA[<h3>V for Go programmers — Types</h3><p>Still following the structure of the book <strong>“Introducing Go”</strong>, the second chapter is about types, V is also a statically typed language.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h-9jxo2Gvw-Sw0ldL1793A.png" /></figure><h4><strong>Numbers</strong></h4><p>V has different ways to represent numbers into many categories:</p><pre>               Number<br>           /          \<br>    Integers           Floats<br>        /                \<br>i8    i16              f32 f64<br>int  i64  <br>u8    u16  <br>u32  u64 </pre><h4>Integers</h4><p>Like Go, V separates signed integers from unsigned ones by the u character(u8, u16, u32, u64), to distinguish between numbers that can be negative or not, also notice that integers in V don’t have an i32 type, instead, there is an int type, because in V a default int type will always be an i32.</p><h4>Floats</h4><p>And for the floats, we just have two distinctions, an f32 and f64 to represent decimal numbers with more or less precision.</p><h4>Example</h4><p>Let’s write an example program using numbers.</p><pre>println(&quot;1 + 1 = = ${1+1}&quot;)</pre><p>V also supports other mathematical operators like / for division, * for multiplication, — for subtraction, % for the remainder, and other useful functions in the <a href="https://modules.vlang.io/math.html">math </a>module.</p><h4>Strings</h4><p>Like Go, strings in V are also represented by double-quoted characters:</p><pre>&quot;this is a string&quot;<br>&quot;this is the length&quot;.len // outputs the length of a string<br>&quot;this is the first byte of the string&quot;[0] // outputs the byte 116<br>&quot;the first character&quot;[0].ascii_str() //outputs `t`</pre><h4>Runes</h4><p>In the last example you may have noticed that the output wasn’t a string it was quoted with: ``</p><p>Because the output wasn’t a string at all it was a rune a type that stores only one character, similar to the type char in many other languages:</p><pre>`🚀` // rune<br>`🚀`.str() // converts rune to string<br>`🚀`.bytes() // return a list of bytes</pre><h4>Booleans</h4><p>The booleans equivalent in V are true and false:</p><pre>true<br>false<br>true &amp;&amp; true<br>false || true<br></pre><h4>Other types</h4><p>V also has other less used types like isize and usize, that are platform-dependent, the size is how many bytes it takes to reference any location in memory</p><p>And voidptr which is most commonly used to interface with C.</p><blockquote><a href="https://medium.com/@kevin-da-silva/v-for-go-programmers-getting-started-90affdd274f3"><strong><em>&lt;- CHAPTER 1</em></strong></a><strong><em> | | </em></strong><a href="https://medium.com/@kevin-da-silva/v-for-go-programmers-variables-and-control-structures-e4e25d0e165d"><strong><em>CHAPTER 3 &amp; 4 -&gt;</em></strong></a></blockquote><p>And these are the types in V, hope it was useful to you, I don’t yet how many episodes I will write in this series, probably as much as I get tired of writing</p><p>Thank you for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5533556e02fa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[V for Go programmers — Getting Started]]></title>
            <link>https://kevin-da-silva.medium.com/v-for-go-programmers-getting-started-90affdd274f3?source=rss-5b76b54e16c------2</link>
            <guid isPermaLink="false">https://medium.com/p/90affdd274f3</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[vlang]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[golang]]></category>
            <dc:creator><![CDATA[Kevin Da Silva]]></dc:creator>
            <pubDate>Mon, 10 Apr 2023 12:27:11 GMT</pubDate>
            <atom:updated>2023-04-11T16:21:54.812Z</atom:updated>
            <content:encoded><![CDATA[<h3>V for Go programmers — Getting Started</h3><p>Hi everyone, recently I got in touch with a book, called <a href="https://www.oreilly.com/library/view/introducing-go/9781491941997/"><strong>“Introducing Go”</strong></a> and many aspects of Go are very lookalike <a href="https://vlang.io/">V</a>, and the approach to Go learning seems like an interesting approach to also learning V, so based on <strong>“Introducing Go”</strong> I decided to start a new series called Introducing V, in order to share knowledge on V and compare the respective nuances with Go.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h-9jxo2Gvw-Sw0ldL1793A.png" /><figcaption>v logo</figcaption></figure><h4><strong>Getting Started</strong></h4><p>So to get this series started, the first chapter in<strong>“Introducing Go” </strong>is called <strong>“Getting Started”</strong>, which shows details about setup and a hello world program:</p><pre>package main<br>import &quot;fmt&quot;<br>// this is a comment<br>func main() {<br> fmt.Println(&quot;Hello, World&quot;)<br>}</pre><p>To learn how to install V the documentation has a pretty good explanation <a href="https://github.com/vlang/v/blob/master/doc/docs.md">here</a>, and for text editors, I recommend vs code with the V extension.</p><p>Or alternatively you can use the <a href="https://play.vlang.io/">V playground</a> online.</p><p>Hello V:<br>To do a simple hello world in V we don’t have to declare a function or import modules, we just have to:</p><pre>module main<br><br>println(&quot;Hello, World&quot;)</pre><p>The module keyword is equivalent to package in Go that is equivalent to class keyword<strong> </strong>in a OO language, it works to separate code into modules</p><p>We didn’t have to import <strong><em>fmt</em></strong> to be able to do a hello world which is a point for V, but in case we need to import modules we just have to do the following:</p><pre>module main<br><br>import os<br><br>println(os.home_dir())<br>println(os.ls(&quot;./&quot;) or {[]})<br>println(&quot;Hello, World&quot;)</pre><p>We didn’t needed a function until now, but if we want to declare one we just have to use the following syntax:</p><pre>module main<br><br>import os<br><br>fn main() {<br> println(os.home_dir())<br> println(os.ls(&quot;./&quot;) or {[]})<br> println(&quot;Hello, World&quot;)<br>}</pre><p><em>for more details on the os module and its functions click </em><a href="https://modules.vlang.io/os.html"><strong><em>here</em></strong></a></p><p>Comments in V are pretty much the same as in Go,<strong><em> //</em></strong> for one line comments and <strong><em>/* */</em></strong> for multi-line comments:</p><pre>// Im one line comment<br>fn main() {<br> println(os.home_dir())<br> println(os.ls(&quot;./&quot;) or {[]})<br> /* multi line comment starting here<br> and here<br> ooh and here too */<br> println(&quot;Hello, World&quot;)<br>}</pre><p>The end of each chapter of <strong>“Introducing Go” </strong>also has some exercises, so I will paste the ones that make more sense at the end of every chapter:</p><ul><li><em>Modify the program we wrote so that instead of printing Hello, World it prints Hello, my name is followed by your name</em></li></ul><p>And we covered the first chapter, and got started successfully with V, thank you for reading and soon I will be posting more chapters for this series!</p><p>Hope to see you soon, happy easter!</p><blockquote><a href="https://kevin-da-silva.medium.com/v-for-go-programmers-types-5533556e02fa"><strong><em>CHAPTER 2 -&gt;</em></strong></a></blockquote><p>Also I’m actively looking for a new job opportunity, so if you know something that seems to fit my profile I would love to chat more</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=90affdd274f3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[One problem five solutions — DNA to RNA]]></title>
            <link>https://kevin-da-silva.medium.com/one-problem-five-solutions-dna-to-rna-ec07294850d5?source=rss-5b76b54e16c------2</link>
            <guid isPermaLink="false">https://medium.com/p/ec07294850d5</guid>
            <category><![CDATA[haskell]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[elixir]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Kevin Da Silva]]></dc:creator>
            <pubDate>Thu, 02 Feb 2023 22:47:37 GMT</pubDate>
            <atom:updated>2023-02-02T22:47:37.363Z</atom:updated>
            <content:encoded><![CDATA[<h3>One problem five solutions — DNA to RNA</h3><p>Hi everyone, this is the first episode of the year in this series where we select one problem and see five different solutions for them written in different programming languages.</p><p>I was looking for a cool problem to showcase here, then I received an email from exercism featuring the functional February to promote functional programming languages, and I started looking for the problems in the Elixir track, and I found the DNA to RNA problem:</p><blockquote>Given a DNA strand, return its RNA complement (per RNA transcription). <br>Both DNA and RNA strands are a sequence of nucleotides. <br>The four nucleotides found in DNA are adenine (A), cytosine (C), guanine (G) and thymine (T). <br>The four nucleotides found in RNA are adenine (A), cytosine (C), guanine (G) and uracil (U). <br>Given a DNA strand, its transcribed RNA strand is formed by replacing each nucleotide with its complement:</blockquote><blockquote>G -&gt; C<br>C -&gt; G<br>T -&gt; A<br>A -&gt; U</blockquote><p>For a simple problem that requires a map from one value to another, let’s check the implemented solutions.</p><h4>Elixir</h4><p>Due to this problem being found in the Elixir track, I will start with it</p><pre>defmodule RnaTranscription do<br>  def to_rna(dna) do<br>    to_string(dna)<br>    |&gt; String.split(&quot;&quot;, trim: true)<br>    |&gt; Enum.map(fn &quot;G&quot; -&gt; &quot;C&quot;<br>                   &quot;C&quot; -&gt; &quot;G&quot;<br>                   &quot;T&quot; -&gt; &quot;A&quot;<br>                   &quot;A&quot; -&gt; &quot;U&quot;<br>                end)<br>    |&gt; Enum.join(&quot;&quot;)<br>    |&gt; to_charlist()<br>  end<br>end</pre><p>I really loved how the problem was expressed into a sequence o pipes, first, the function receives a <strong><em>charlist</em></strong> in <strong><em>dna</em></strong>, then we turn the <strong><em>charlist </em></strong>to a string, and with a string in our hands we split it, value by the value of the sequence, and after turning it into a list we map it with a function that checks:</p><p><em>if the value received is a G return C<br>if the value received is a C return G<br>if the value received is a T return A<br>if the value received is an A return U</em></p><p>After mapping each value in the list we join it to turn the list into a string, after it we just have to turn the string into a <strong><em>charlist </em></strong>again</p><h4>Haskell</h4><p>The Haskell solution is by far the most elegant and beautiful solution in this article, it was very simple, concise, and precise in tackling the problem</p><pre><br>toRna [] = &quot;&quot;<br>toRna (&#39;G&#39;:xs) = &#39;C&#39;:toRna xs<br>toRna (&#39;C&#39;:xs) = &#39;G&#39;:toRna xs<br>toRna (&#39;T&#39;:xs) = &#39;A&#39;:toRna xs<br>toRna (&#39;A&#39;:xs) = &#39;U&#39;:toRna xs</pre><p>In Haskell strings are a list of chars so if we receive an empty list we return an empty string, if the list is populated we take the first value and the remaining of the list in the <strong><em>xs</em></strong> variable, then we just have to pattern match the value to check if it is a G, C, T or A, once pattern matched we just have to append the converted value to the head of the list and recursively call <strong><em>toRna </em></strong>with the remaining of the list.</p><h4>Julia</h4><p>The first Julia solution for this problem is a solution Im not proud of:</p><pre>function sequenceencoder(x)<br>    if x == &quot;G&quot;<br>        &quot;C&quot;<br>    elseif x == &quot;C&quot;<br>        &quot;G&quot;<br>    elseif x == &quot;T&quot;<br>        &quot;A&quot;<br>    elseif x == &quot;A&quot;<br>        &quot;U&quot;<br>    end<br>end<br><br>function torna(dna)<br>    splitedSequence = collect(eachsplit(dna, &quot;&quot;))<br>    if first(splitedSequence) == &quot;&quot;<br>        return &quot;&quot;<br>    end<br>    encodedseq = map(sequenceencoder, splitedSequence)<br>    join(encodedseq)<br>end</pre><p>I wasn&#39;t happy with this solution and was gonna ask for help to improve it, but when I was doing the same solution in Javascript I got really inspired by it and made a similar approach to the solution in Julia, using a Dict:</p><pre>function torna(dna)<br>    encoder = Dict(<br>        &quot;G&quot;=&gt;&quot;C&quot;,<br>        &quot;C&quot;=&gt;&quot;G&quot;,<br>        &quot;T&quot;=&gt;&quot;A&quot;, <br>        &quot;A&quot;=&gt;&quot;U&quot;<br>    )<br>    <br>    splitedSequence = collect(eachsplit(dna, &quot;&quot;))<br>    encodedseq = map(x -&gt; get(encoder, &quot;$x&quot;, &quot;&quot;), splitedSequence)<br>    join(encodedseq)<br>end</pre><p>Way more simple and easy to read and maintain</p><h4>Javascript</h4><p>As I mentioned in the Julia solution, this solution will also have a similar approach, but I have to say that I got pretty happy with the final result in Javascript, and I was able to achieve the solution with just one Object and function chaining.</p><pre>const toRna = dna =&gt; {<br>    const encoder = {<br>        &quot;G&quot;: &quot;C&quot;,<br>        &quot;C&quot;: &quot;G&quot;,<br>        &quot;T&quot;: &quot;A&quot;, <br>        &quot;A&quot;: &quot;U&quot;<br>    }<br>    return dna.split(&quot;&quot;)<br>            .map(x =&gt; encoder[x])<br>            .reduce((acc, x) =&gt; `${acc}${x}`, &quot;&quot;)<br>}</pre><p>Also notice that in the Javascript solution, we used a <strong><em>reduce </em></strong>instead of a <strong><em>join </em></strong>function, where we have to concatenate the accumulator(a string) with our current element in the sequence.</p><h4>Vlang</h4><p>The last solution for this article is the vlang solution:</p><pre>fn to_rna(dna string) string {<br> runes := dna.runes() <br> return runes.map(fn (x rune) string {<br>  return match x {<br>    `G` { &quot;C&quot; }<br>    `C` { &quot;G&quot; }<br>    `T` { &quot;A&quot; }<br>    `A` { &quot;U&quot; }<br>    else { &quot;&quot; }<br>   }<br> }).join(&quot;&quot;) <br>}</pre><p>Its a well looking solution, where we turn our <strong><em>dna </em></strong>string into a list of chars(in vlang its called runes), after it we just map the list and validate it with a match similar to the pattern matching in the Elixir and Haskell solutions once we are done we just turn a list of strings into one single string with the <strong><em>join </em></strong>function</p><p>Also notice that when we match we are not matching for a string instead we are matching a rune, and when matched we return a string to be able to join it later.</p><p>And here we are to the end of one more article for this series, I think its cool to compare multiple approaches to a common problem, gives a sense of comprehension and wisdom, but besides I like to do it in general Its not very easy to find problems to solve in advance, so if you have suggestions of problems you would like to showcase here feel free to comment.</p><p>Thank you again for reading and for further detail on the solutions here is the<a href="https://gist.github.com/KevinDaSilvaS/fe6057b96313a6e9edc110d0ee9aa07c"> gist</a> I made containing the solutions, test cases and a description of the problem.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ec07294850d5" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>