<?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 Ramesh Vyas on Medium]]></title>
        <description><![CDATA[Stories by Ramesh Vyas on Medium]]></description>
        <link>https://medium.com/@rameshovyas?source=rss-487aab2176d6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*tRjqO7lJgVVKNx-8Evzpug.png</url>
            <title>Stories by Ramesh Vyas on Medium</title>
            <link>https://medium.com/@rameshovyas?source=rss-487aab2176d6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 02:57:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rameshovyas/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[Rust Ownership: The Essential Guide]]></title>
            <link>https://medium.com/@rameshovyas/rust-ownership-the-essential-guide-5dc32eec9dcd?source=rss-487aab2176d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/5dc32eec9dcd</guid>
            <category><![CDATA[rust]]></category>
            <category><![CDATA[ownership]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[guides-and-tutorials]]></category>
            <category><![CDATA[rustlang]]></category>
            <dc:creator><![CDATA[Ramesh Vyas]]></dc:creator>
            <pubDate>Fri, 22 Sep 2023 17:37:17 GMT</pubDate>
            <atom:updated>2023-09-22T17:37:17.082Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*38CgY57KaQXBi7b3" /><figcaption>Photo by <a href="https://unsplash.com/@jefflssantos?utm_source=medium&amp;utm_medium=referral">Jefferson Santos</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Introduction</h3><p>Ownership in Rust programming language is a way of managing memory that helps to prevent bugs related to memory leaks.</p><p>In this article I will provide an essential guide to Rust ownership.I will cover the basics of ownership, what it is and why it is important and how to use it effectively. I will also discuss the common ownership mistakes and how to avoid them.</p><p>If you are learning Rust then this article is for you to get started with Rust ownership.</p><h3>What is Ownership in Rust?</h3><p>Rust doesn&#39;t use the conventional way of managing memory as used by other programming languages like C, C++ or Java, where either the user explicitly frees the memory or there is a garbage collector.</p><p>Rust uses a different approach of memory management, this is the <strong>system of ownership</strong>.</p><p>Rust ownership are set of rules that governs memory management in Rust programming language. These rules are enforced when a Rust program is compiled, which means the program will not compile if any of the rules is violated.</p><h3>Why Memory Management?</h3><p>It is very important to keep track of which memory is being used by program data because the program’s behavior completely depends on this only.</p><p>We have two type of data memory in systems programming languages such as Rust : <strong>Stack and Heap</strong>. Managing data in stack is fast because we never have to search for location to store and retrieve data to and from stack as it is always from a fixed location known as <strong>TOP of stack</strong> and the size of each data item on stack is always predefined or we can say fixed at the time of compilation.</p><p>On the another hand data with dynamic sizes means data with unknown size at compile time are given space on <strong>Heap</strong>. Unlike Stack, Heap is not an organized data structure and we depend on <strong>operating system</strong> to find appropriate location on heap for our data to be stored.</p><p>The operating system searches appropriate space and mark that location as <strong>“in use”</strong> and returns a pointer containing the base (starting) address of that location. This process is known as <strong>allocating memory</strong>. If you are familiar with C or C++ you might have used <strong>malloc()</strong> or <strong>new</strong> for allocating memory dynamically. Hence accessing data in heap is slower.</p><h3>What role ownership have?</h3><p>Ownership in Rust is to keep track of which part of code is using what location on heap, so that it can minimize the duplicacy and can also clean up the unused data on the heap to avoid memory leak so that we don’t run out of space.</p><h3>Rules of Ownership in Rust</h3><ul><li>Every value in Rust program is associated with a variable and we call it as its <strong>owner</strong>.</li><li>We can have only one owner of a value at a time.</li><li>The value will be dropped as soon as the owner goes out of scope.</li></ul><pre>{<br>    // x is not valid here<br>    let x = 10;<br>} // x is not valid here also as the scope ends</pre><p>The above code uses a basic data type and for basic data types Rust uses stack and when ever the scope overs the data are popped from the stack.</p><p>To understand more about ownership we will be taking example of <strong>string</strong> data type, which is more complex data type which is given sapce in heap.</p><p>For dynamic memory allocation we have to do following steps :</p><ul><li>Request operating system for allocating memory.</li><li>Return back or free this memory when we have done with that.</li></ul><pre>let mut s = String::from(&quot;Save the&quot;);<br>s.push_str(&quot; Bees&quot;);</pre><p>The first line of code in above example is creating a string variable with the string literal “Save the” and in the second line we are using <strong>push_str</strong> which appends another string literal “ Bees” to the string s.</p><p>So when we used String::from we allocated the memory with the size of string literal provided as argument.</p><p>If we would have used languages other than Rust then either the garbage collector have been used or we have to explicitly recall the dynamically allocated memory as we were doing in C when we used <strong>free</strong> or in C++ <strong>delete</strong>.</p><p>But in Rust the memory is automatically recalled as soon as the variable that owns the memory goes out of scope.</p><p>A special function <strong>drop</strong> is called by Rust whenever the scope goes out.</p><p>Let us see another example and see how Rust treats this :</p><pre>let mut s1 = String::from(&quot;Trees&quot;);<br>let s2 = s1;</pre><p>It seems the above code is very simple first line is creating a dynamic memory named s1 and second line is making a copy of it, but this is not true in this case.</p><p>In Rust a string is composed of three parts: a pointer to memory location, the length of string and capacity of string. <strong>Length</strong> specifies how much memory is being currently used and <strong>Capacity</strong> specifies how much amount of bytes the operating system have allocated to this string.</p><p>When we assign s1 to s2 the pointer, length and capacity are copied, and these are on stack. The data on the heap are not copied. This is shown in the figure 1 below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/708/1*Hyb4bmDw3RllXGeeDX2URw.jpeg" /><figcaption>Rust Ownership Figure 1</figcaption></figure><p>If the variable goes out of scope Rust will call the <strong>drop</strong> function and will clears the memory. In case of figure 1 both s1 and s2 will try to clear the same memory location, which is not memory safe.</p><p>Rust will not do this, instead Rust will consider s1 to be no longer valid when we do this s2=s1 and hence Rust doesn&#39;t need to free anything.</p><pre>let s1 = String::from(&quot;Trees&quot;);<br>let s2 = s1;<br>println!(&quot;{}&quot;, s1); // this is error as s1 is invalid here, it has been moved</pre><p>Here Rust will say “move to a shallow copy”. Our problem is solved here as only s2 is valid, and when it will go out of scope only it will try to de allocate the memory so we do not have any <strong>double free errors</strong>.</p><p>Rust never creates <strong>deep copies</strong> of any data. If we explicitly want deep copies of data like shown in figure 2 below then we have to use <strong>clone</strong> method.</p><pre>let s1 = String::from(&quot;Trees&quot;);<br>let s2= s1.clone();</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/689/1*GxmIVOt6DqWpmpXQ90EDhw.jpeg" /><figcaption>Rust Ownership Figure 2</figcaption></figure><p>This is not true in case of stack data i.e data whose size is known during compile time.</p><pre>let a = 10;<br>let b = a;<br>println!(&quot;{} {}&quot;, a, b);</pre><p>Both a and b are valid in this case because a and b are integer and will be stored at Stack and not Heap.</p><h3>Conclusion</h3><p>Thus we have seen that Rust ownership is a powerful concept that can help us to write safe and reliable code. By understanding and using ownership effectively, we can avoid common bugs such as memory leaks and dangling pointers.</p><p>I hope this article has been helpful. If you have any questions or feedback, please feel free to leave a comment.</p><p>You can also refer to my <a href="https://github.com/rameshovyas/Rust_By_Practice_Solutions">Rust by Practice Repository</a> for Rust practice codes.</p><p>Thank you so much for your valuable time.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5dc32eec9dcd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Connection-Oriented Communication in Bluetooth: Explaining ATT and GATT in Bluetooth]]></title>
            <link>https://medium.com/@rameshovyas/connection-oriented-communication-in-bluetooth-explaining-att-and-gatt-in-bluetooth-1482e3c54550?source=rss-487aab2176d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/1482e3c54550</guid>
            <category><![CDATA[gatt]]></category>
            <category><![CDATA[bluetooth-low-energy]]></category>
            <category><![CDATA[att]]></category>
            <category><![CDATA[bluetooth]]></category>
            <category><![CDATA[wireless]]></category>
            <dc:creator><![CDATA[Ramesh Vyas]]></dc:creator>
            <pubDate>Sat, 18 Mar 2023 11:53:09 GMT</pubDate>
            <atom:updated>2023-03-18T13:40:14.285Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article we will be closely looking into how BLE devices communicate with each other and how data transmission happens between BLE devices.This article will help you in your BLE application development journey.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sWGbyQ1tlbugFnr-nRGRCw.png" /></figure><h4>How Communication is Established ?</h4><p>In Bluetooth Low Energy(BLE) one of the devices will have to take a role of peripheral and another as central, so when a peripheral role device is ready to connect it enters in to <strong>advertisement mode</strong> by broadcasting advertisement packets.<br>So what are advertisements ? Advertisements are the data packets sent by a peripheral device on air via special channels known as primary advertisement channels : 37, 38 and 39.</p><p>Once a master(central) device has scanned this advertisement and if the central wants to connect with this peripheral it will send a connection request to the peripheral, the peripheral then starts the connection and this way the connection is established.</p><p>As we have already seen in BLE communication a device can act as either <strong>central</strong> or a <strong>peripheral</strong>. Commonly used central devices are our smartphones that have capability to scan for the peripheral devices such as light bulbs, smart watches etc.</p><p>Every BLE communication happens in two modes: <strong>Advertisement Mode</strong> and <strong>Communication Mode</strong>. In the advertisement mode the peripheral advertises data packets that a central devices is interested <a href="http://in.in/">in.In</a> this mode no paring is required as the peripheral advertises its services and the central scans and captures these advertisement packets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*Hgx8pa-bfhWguMjFcZZhog.png" /></figure><p>When a peripheral device has been scanned and connected with the central device then they enter the Communication Mode and now data can be transmitted between them. The data transmission is through various services exposed by the peripheral device.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*r5b0a55wmRFxUmMEjpbDhQ.png" /></figure><p>Services plays the main role for communication between devices. A service describes a feature exposed by a peripheral device and each service is identified by a Universal Unique Identifier (UUID).</p><p>To understand more about data transfer between BLE devices we need to understand more about ATT and GATT.</p><p>GATT is acronym for <strong>Generic Attribute</strong> Profile which specifies how data transfer is done between two connected BLE devices using Services and data protocol known as Attribute Protocol(ATT).</p><p>Once a dedicated connection is established between two BLE devices then only GATT comes into the picture that means to make use of GATT a dedicated connection between devices is must.</p><p>To get connected the two devices already have gone through the advertisement mode which is based on GAP(Generic Access Profile). GAP is responsible for making a communication channel between two BLE devices.</p><p>After the connection is established BLE devices can have bi-directional persistent data transfer.</p><h4>How Data Transmission Takes Places?</h4><p>We have seen how connection is established between two BLE devices, now we will discuss about how data transmission takes place between two BLE devices, how two devices talk with each other after a dedicated connection is established between them.</p><p>Before data being transmitted we need to first define roles of a device and this is done by ATT Protocol. The roles defined by ATT protocol follows client server architecture of communication and with each role the device got some responsibilities.</p><p><strong>Server</strong> stores and exposes the data that can be read and written by a client for example a heartbeat tracker. <strong>Client</strong> on the other hand is a device that wants to consume the data exposed by the server mostly a smart phone.</p><p>The roles are contextual, anyone can act as server and as a client depending on the situation. For example lets suppose we want to set the system clock of peripheral device then in this case smartphone will act as server and the heartbeat tracker as client.</p><h3>ATT Protocol and Server Role</h3><p>We know that a device with server role will act as a data provider or we can say it will act as a database so it requires a standard way to store and organize such data, also there must be a standard way to access these data.</p><blockquote><em>ATT Protocol is responsible for providing a server device such kind of functionalities to store the data and make them available to have a standard access.</em></blockquote><p>ATT Protocol make us of a data structure known as <strong>Attribute</strong> to organize data in the server device.<br>Every attribute data structure have following fields :<br><strong>Attribute Handle</strong> : A 16 bit unique identifier for each attribute on server, a client can refer to.</p><p><strong>UUID</strong> : This is again a unique identifier which defines the type of attribute specifying data stored in the attribute value.</p><p><strong>Attribute Value</strong> : The actual data stored in the attribute, for example a temperature reading.</p><p><strong>Permission</strong> : The various methods that are permitted to access by the client. For example Read/Write permissions.</p><p>The server device contains a table of attributes each record having a unique handle for each attribute, so we can consider an attribute as a record in a Relational Database.</p><p>Another model of storing data is the hierarchical model in which data is not stored in sequential table but as a non linear data tree.This type of model was introduced for faster access of data.</p><h4>GATT (Generic Attribute Profile)</h4><p>The GATT layer is responsible for defining this hierarchy which specifies how data is stored in ATT server. It provides a framework for creating a hierarchical relationship among data stored on ATT servers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*IoekHQ6UC8XH-a7swE7tYg.png" /></figure><p>The GATT framework is a tree like framework having four layers.<br>Level 0 Root layer known as Profile<br>Level 1 Services : Treated a children of Profile<br>Level 2 Characteristics : Treated a children of Services<br>Level 3 Values for Characteristics.</p><p><strong>Characteristics</strong> also termed as attribute, this is a generic name given for all type of data exposed by the server. It is a basic storage unit that can be read and written from and to the server. It represents a piece of information a server wants to expose. For example <strong>Battery Level</strong></p><p><strong>Services</strong> can be considered as group of one or more characteristics, it is used for organizing and not for storing. It is a conceptual entity that is meant to group related attributes. For example Battery Service that can have <strong>Battery Level</strong> as an characteristics.</p><p><strong>Profile</strong> are more concern with defining the behavior of a device. It is used to standardized the data exposed by the server ensuring that the devices that have same profile can communicate.</p><p>Hope this article described most of the aspects of how Bluetooth communication is done and how data is organized during BLE communication. I tried my level best to explain BLE communication and data organization in BLE devices. Thank you once again for your valuable time.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1482e3c54550" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding the Benefits of Real-Time Operating Systems (RTOS) for Embedded Systems Design]]></title>
            <link>https://medium.com/@rameshovyas/real-understanding-the-benefits-of-real-time-operating-systems-rtos-for-embedded-systems-design-a8705d57cb48?source=rss-487aab2176d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/a8705d57cb48</guid>
            <category><![CDATA[realtime-operating-system]]></category>
            <category><![CDATA[embedded]]></category>
            <category><![CDATA[internet-of-things]]></category>
            <category><![CDATA[embedded-systems]]></category>
            <category><![CDATA[embedded-linux]]></category>
            <dc:creator><![CDATA[Ramesh Vyas]]></dc:creator>
            <pubDate>Fri, 10 Mar 2023 10:35:37 GMT</pubDate>
            <atom:updated>2023-03-10T14:16:06.989Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aWK66VqrFTrOYcQd" /><figcaption>Photo by <a href="https://unsplash.com/@zanilic?utm_source=medium&amp;utm_medium=referral">Zan</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>When we talk about computer system we are not only talking about the hardware and peripheral devices but also about its most important component which is its operating system. An operating system is responsible for controlling and coordinating hardware components among application programs. An operating system makes use of the hardware in an efficient manner so that it can be used optimally to provide more throughput.</p><p>When we are designing embedded systems we have to deal with micro-controllers that are a single chip computer and thus have many constraints compared to a general purpose computer. Embedded systems are employed where we have a dedicated job to be performed like controlling temperature of room. We cannot use a general purpose operating system here we need to either design a specific OS of the platform or to use a Real Time Operating System specifically designed for embedded development.</p><p>In this article I will be sharing what I have learnt about RTOS during the phase of my embedded systems development journey so far.</p><h3>What is RTOS</h3><p>As a traditional embedded systems developer we design applications that mostly run around a sequential loop and different state machines. This sequential infinite loop and interrupt model is great when we have a small number of functionalities but when functionalities grows it becomes more tedious to manage tasks. Here comes an RTOS to rescue.</p><p>RTOS is a type of operating system which is used in the system where the response time is very much critical. An RTOS is an operating system used in systems where we have large number of external events or interrupts to be processed under fixed deadlines. These applications can be industrial control, Air-traffic Control, Voice call switching networks.</p><p>RTOS can be furture categorized into following categories :</p><ul><li>Hard RTOS</li><li>Soft RTOS</li></ul><p>Hard RTOS cannot miss any critical deadlines<br>and guarantees the task to be completed in the specified time period. Example, Medical Imaging Systems, Air Traffic Control Systems.</p><p>Soft RTOS is permitted to occasionally miss its deadlines. Example multimedia systems.</p><h3>Why we should use RTOS</h3><p>Although writing applications for micro-controllers using native assembly language is faster and code base is also small but it is very much tedious task so using a high level programming Language like ‘C’ is universally accepted because developing applications in high level programming languages takes much less effort.<br>We can also develop a custom RTOS for our applications but this is not an optimal solution many vendors uses this to keep their system proprietary but when it comes to handle scale up applications it is very difficult.</p><p>In this era of embedded system development where touch screen user interfaces and internet access is a mandatory requirement for every device not using Real Time Operating Systems is not a good choice, because the readily available RTOS makes it easier to focus more on the application by taking charge of other hustles you may have to design whether it be task scheduling or supporting standard communication protocols you say and it have everything for you.</p><h3>Advantages RTOS Brings to Your Design</h3><p>So it is clear that if your system is more complex and have more functionalities then using RTOS is a better decision. In this section we will be discussing about the reasons why we should employee RTOS to our design.</p><h4>Portability of Your Application</h4><p>RTOS abstracts the underline hardware access by providing standard APIs this makes your application independent of hardware platform used and thus making your application portable and cross platform available.</p><h4>Standard Communication Stacks</h4><p>A standard RTOS will provide your application a pre tested standard network and communication stacks such as TCP/IP , Serial communication, USB interface out of the box you need not to worry about all of these which makes application development fast and more standardized.</p><h4>Makes efficient use of processor</h4><p>A typical embedded system is a loop based polling system that keeps processor busy in checking whether an interrupt has occurred or not, this keeps CPU idle doing nothing. RTOS brings multitasking interrupt driven systems thus idle polling is eliminated.</p><h4>Multitasking Design Pattern</h4><p>RTOS provides a preemptive multitasking design, thus making every real time event independent of each other. This feature is very important when in future you want to scale your application since every event is independent and addition of new events will hardly effect response time of other events. Thus your application become more scalable and you can design more complex applications very easily if you use RTOS.</p><h3>Conclusion</h3><p>By using available RTOS you are making your application more adaptive to emerging technical specifications much faster, whether is is internet connectivity or touch user interfaces or creating mesh network of devices.</p><p>Thank you for your precious time, hope this article provided you an idea why we should employee RTOS for our next design. Have a nice day ahead, keep learning.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a8705d57cb48" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[5 Reasons Why Coding Is a Valuable Skill for Kids]]></title>
            <link>https://medium.com/@rameshovyas/why-your-kid-should-learn-coding-5-reasons-why-you-as-a-parent-should-urge-your-kid-to-learn-b397c14caf68?source=rss-487aab2176d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/b397c14caf68</guid>
            <category><![CDATA[for-parents]]></category>
            <category><![CDATA[learn-to-code]]></category>
            <category><![CDATA[programming-for-children]]></category>
            <category><![CDATA[coding-for-kids]]></category>
            <category><![CDATA[learning-and-development]]></category>
            <dc:creator><![CDATA[Ramesh Vyas]]></dc:creator>
            <pubDate>Fri, 03 Feb 2023 11:51:15 GMT</pubDate>
            <atom:updated>2024-11-10T04:55:34.334Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fwOSAdKl0CsOcu5j" /><figcaption>Photo by <a href="https://unsplash.com/@neonbrand?utm_source=medium&amp;utm_medium=referral">Kenny Eliason</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><blockquote>Every parent wants to give their kids the greatest chance possible for success in the future and to encourage their academic development during their formative years.</blockquote><p>As a young child, I was utterly fascinated by computers. The weekly hour-long computer class was a highlight, though sharing it with a partner often felt like a bittersweet compromise.</p><p>Time has changed, computers are every where and every child have access to this super invention of human. I’m naming it extraordinary because it empowers you to give your imaginations wings.</p><p>Although computers are amazing, they can not do anything without our instructions, yeah you heard it correctly, they are dumb slaves of our mind. We can make them do what we want them to do for us, interesting isn’t it?</p><p>To make use of this dumb machine we need to provide them with a set of predefined instructions and these sets of instructions are known as programs. So programming a machine means to provide instructions to a machine so that it can do what we intend it to do for us, amazing!</p><p>Programming is a way how we can communicate with a machine so that we can make use of it for our daily purpose. These days programming is more specifically known as coding. So to make use of computers you must learn how to code.</p><p>Thus coding allows us to provide an automated solution to a problem that we use to do in our day to day life. More specifically coding teaches us how to think, analyze situations and break the problem into smaller sub problem to get a concrete solution.</p><p>In this article we will see benefits of coding for kids. What are the specific skills that kids can learn from coding? How can these skills benefit them in school, in their careers, and in their personal lives?</p><p>Here we will see what are the benefits of coding, I will present you with five reasons how coding skills can impact your child’s life forever.</p><p><strong>Coding Helps in Enhancing Thinking</strong></p><p>During the process of coding your child will learn how to break down the problem into small steps and develops a mindset of approaching to solution to a problem in different way. So it enhances how to think differently and that mindset make them much smarter when they encounter problems in daily life too. So coding makes your kid to think of solutions for the problems.</p><p><strong>Develop Professional Trade Early In Life</strong></p><p>It has been seen that most of the professional developer started their coding journey during their school days. In this increasing digital age, if kids starts learning how to code in early stage it will help develop their professional trade early.</p><p><strong>Encourages To Remain Persistent</strong></p><p>A computer program is designed to automate and model a real life system, a program is acceptable only when it delivers solution to all the requirements, so unless every issue has been resolved a programmer has to remain persistent during this journey. This encourages persistence in your child for all problems in their life as not to go away from the problem until you get it solved. This mindset is growth mindset and always pushes your child towards solving issues they encounter in their life and career.</p><p><strong>Becomes More Creative</strong></p><p>Kids are more creative then adults because they are always towards <strong>how things works</strong>, the imaginations in their mind keeps them more creative then we adults because we are more towards <strong>what</strong> and not <strong>how</strong>. With coding kids are always in experimental phase, they experiment different ways to solve problems. After solving a problem they remain curious of trying new solutions, they ask themselves , “Can I do this in that way? Will that work?”.</p><p>The most great part of computers is that the feedback is instant, and that attracts kids more to explore new ways to solve problems. In this way kids becomes more creative.</p><p><strong>Encourages Them To Use Technology for Learning</strong></p><p>Now a days parents are very much concern about the type of content their kids are accessing from the internet, as the availability of every type of content whether it is games, cartoons, actions or any other that their kids are consuming. Entertainment is okay but when they get addicted to some irrelevant content it is dangerous, parental control of devices can reduce this at certain amount but the things can go adverse.</p><p>When a child starts using computer to code, it is more likely he or she will be using technology to learn new skills and not to miss use it.</p><p>I can say that coding may be one of the most constructive hobbies your child can adopt as it can help them to build a mindset which is more productive, persistent and creative.</p><p>Other than that learning to code will always opens door for great career in their future. As a parent you should encourage your child to learn coding.</p><p><strong>Suggestion — Start the Journey with Python Programming</strong></p><p>It is said that Python is Kids Friendly Language. Due to its easy learning curve it will be a great start for your kid’s coding journey. The constructs of the language are very simple and your kid will not find it difficult to communicate with computer. Python will definitely be a fun and kids like fun only.</p><p>Hope to see you all encouraging your kid(s) to start their coding journey by today.</p><blockquote>Kids can feel free to refer my github <a href="https://github.com/rameshovyas/30-Days-of-Python-Exercises">repository</a> during their learning journey. Thank you for your precious time, hope this write-up has helped you.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b397c14caf68" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Step by Step Guide to Create an API Proxy Server in Node JS]]></title>
            <link>https://medium.com/@rameshovyas/step-by-step-guide-to-create-an-api-proxy-server-b1ec19bc36e1?source=rss-487aab2176d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/b1ec19bc36e1</guid>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[node-js-tutorial]]></category>
            <category><![CDATA[proxy-server]]></category>
            <category><![CDATA[proxy]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Ramesh Vyas]]></dc:creator>
            <pubDate>Thu, 25 Aug 2022 08:49:45 GMT</pubDate>
            <atom:updated>2022-08-25T15:28:40.557Z</atom:updated>
            <content:encoded><![CDATA[<p>Every time we create an application that needs to call an external API, we have to expose our public api key in the URL while making an api call, which is not good idea.</p><p>What we can do to solve this problem? We can create a proxy server in between our application and the actual api server, and this server have our api key to make a request on behalf of us.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*VgtKGZ4IdCe2lQMQvLjxQQ.png" /><figcaption>API Proxy Server or API Relay Server Overview</figcaption></figure><p>In this article we will be creating an API proxy server also known as a relay server so that the public key is not exposed while calling an api.</p><p>We will be using <strong>Node js</strong> for our proxy but the concept remains the same in any technology you choose for your ease.</p><p>We will be building a generalize proxy where we need to provide the public apis and to demonstrate this we will be using openweathermap api to confirm this proxy server is working, you can use any other api also to test.</p><p>To follow along you need to have access to <a href="https://openweathermap.org/api">openweathermap</a> if you don’t have access then please create an account and get your own public key first.</p><p>First of all we need to create an empty directory for our new project, let us name it as <strong>api-proxy</strong></p><pre>mkdir api-proxy</pre><p>Now open this directory in any code editor of your choice and initialize a node js project in it using the following command.</p><pre>npm init -y</pre><p>This will create the package.json file for us where we will be adding all of the dependencies and scripts for this application.</p><p>We need to add certain dependencies to our project.</p><pre>npm i express dotenv needle cors</pre><p><strong>express</strong> is for creating our proxy server, <strong>dotenv</strong> allows us to create environment variables files where we will be storing our api key and other parameters, <strong>needle</strong> is a ligt weight http client that allows our server to make http request on behalf of us to the actual server, we could have also used the nodefetch but needle is supper simple and light weight to do this task, <strong>cors</strong> for cross platform origin enabling.</p><p>The concept is client makes an http request and our proxy will use needle to make http request to the actual server acting as a relay in between, and thus hiding the actual api key from public.</p><p>We also need to install nodemon so that our script can run automatically whenever we change anything to code and we need not to worry about terminating the server and executing again when ever we make any changes.</p><pre>npm i -D nodemon</pre><p>After adding all dependencies we now need to create start script in the scripts section of package.json.</p><pre>&quot;scripts&quot;: {<br>    &quot;start&quot;: &quot;node index&quot;,  // Production script<br>    &quot;dev&quot; : &quot;nodemon index&quot; // Development script<br>  },</pre><p>Let start writing our server, and for this we need to create <strong>index.js</strong> in our project’s root directory.</p><p>Also create a <strong>.env</strong> file in the project’s root directory and add following configurations in this file.</p><pre>// API Base url for openweather map api <br>API_URL = &#39;http://api.openweathermap.org/data/2.5/weather&#39;;</pre><pre>//key variable name<br>API_KEY_VARIABLE = &#39;appid&#39;;</pre><pre>//Your own api key <br>API_KEY_VALUE = &#39;PLACE YOUR API KEY HERE&#39;;</pre><p>Now put the following code in your index.js file :</p><pre>const express = require(&#39;express&#39;);<br>const cors = require(&#39;cors&#39;);<br>const url = require(&#39;url&#39;);</pre><pre>require(&#39;dotenv&#39;).config();</pre><pre>const needle = require(&#39;needle&#39;);</pre><pre>const app = new express();</pre><pre>const PORT = process.env.PORT || 4000;</pre><pre>//Enable CORS<br>app.use(cors())</pre><pre>// Enviornment variable <br>const API_URL = process.env.API_URL<br>const API_KEY_VARIABLE = process.env.API_KEY_VARIABLE<br>const API_KEY_VALUE = process.env.API_KEY_VALUE</pre><pre>//create the route<br>app.get(&quot;/api&quot;, async (req,res) =&gt; {<br>    try{  <br>        <br>         <br>        const params = new URLSearchParams({<br>            [API_KEY_VARIABLE] : API_KEY_VALUE,<br>            ...url.parse(req.url,true).query //Query parameters passed to the proxy e.g city here<br>        })    <br>        //Call the actual api here using needle<br>        const apiResponse = await needle(&#39;get&#39;,`${API_URL}?${params}`);<br>        const data = apiResponse.body;<br>        res.status(200).json(data);<br>    }<br>    catch(ex) {<br>        res.status(500).json({ex});<br>    }<br>    </pre><pre>});<br>app.listen(PORT , () =&gt; console.log(`Proxy server listening at port ${PORT}`));</pre><p>The code above is very simple and have a single route <strong>/api</strong> , in this we are parsing the query paarmeters passed from client application and concatinating them with the secret api key from environment variables.</p><p>After this we have created the full URL of the actual api using API_URL and params and made a <strong>get</strong> request using <strong>needle</strong>, which returns the actual response from the remote api, which we send to the client again.</p><p>Check the reposne using following http request from any http client or browser of your choice.</p><pre>GET <a href="http://localhost:4000/api?q=Jodhpur">http://localhost:4000/api?q=Jodhpur</a></pre><p>In this way we have hidden the api key from public view and relayed the request to the actual server and response to the client application. See the below requests for both.</p><pre>//api call without proxy<br>http://api.openweathermap.org/data/2.5/weather?q=Jodhpur&amp;appid={put your api key here}</pre><pre>//api call with proxy<br>http://localhost:4000/api?q=Jodhpur</pre><p>The code is very generic, although we have tested it with the openweathermap api you can use it with any api of your choice by changing the environment variables and query parameters.</p><p>Hope this article has helped you to understand how we can proxy requests using Node JS. The complete code is available at my <a href="https://github.com/rameshovyas/api-proxy/blob/master/index.js">github repository</a>. Thank you for your time and support.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b1ec19bc36e1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Create Dynamic Web Page That Displays JSON Data, in Rust Using Actix-Web and Handlebars.]]></title>
            <link>https://medium.com/@rameshovyas/how-to-create-dynamic-web-page-that-displays-json-data-in-rust-using-actix-web-and-handlebars-7e89e041fc8a?source=rss-487aab2176d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/7e89e041fc8a</guid>
            <category><![CDATA[actix-web]]></category>
            <category><![CDATA[handlebars]]></category>
            <category><![CDATA[rustlang]]></category>
            <category><![CDATA[json]]></category>
            <category><![CDATA[rust]]></category>
            <dc:creator><![CDATA[Ramesh Vyas]]></dc:creator>
            <pubDate>Tue, 16 Aug 2022 17:32:09 GMT</pubDate>
            <atom:updated>2022-08-18T13:39:38.642Z</atom:updated>
            <content:encoded><![CDATA[<p>This is a very simple demonstration how we can use Actix Web and Handlebars to render a webpage that displays JSON data in Rust. This article will make you understand how Actix Web can be used to create simple HTTP server and how to handle a HTTP request. We will also get familiar with Handlebars and how to compile and render JSON data in a template using Handlebars.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4yXcNURlgnxEp462" /><figcaption>Photo by <a href="https://unsplash.com/@artnok?utm_source=medium&amp;utm_medium=referral">Nicolas Picard</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>First of all we will have to create an empty Rust project with the help of cargo using the following command.</p><pre>cargo new actix-web-blog</pre><p>Now we need to add actix-web as a dependency of your project, this can be done by adding the following lines to our Cargo.toml file.</p><pre>[dependencies]<br>actix-web = &quot;4&quot;</pre><p>We also need to add few more dependencies so that we we are able to serialize the JSON data and can render JSON data to a web page at runtime with the help of handlebars. Following is the list of dependencies we will be adding to our Cargo.toml file.</p><ul><li>actix-file : For serving static files</li><li>serde_json : To serialize/deserialize JSON data.</li><li>handlebars : Templateing engine for JSON data.</li></ul><p>Following will be the dependencies section of our Cargo.toml file:</p><pre>[dependencies]<br>actix-web = &quot;4&quot;<br>actix-files = &quot;0.6.2&quot;<br>serde_json = &quot;1.0.83&quot;<br>handlebars = { version = &quot;4.3.3&quot;, features = [&quot;dir_source&quot;] }</pre><p>Edit <a href="http://main.rs/">main.rs</a> file and write the code as below :</p><pre>use actix_web::{web,HttpServer,HttpResponse,App};<br>use actix_files::{Files};<br>use serde_json::json;<br>use handlebars::Handlebars;</pre><pre>async fn home(hb: web::Data&lt;Handlebars&lt;&#39;_&gt;&gt;) -&gt; HttpResponse {<br>    let posts = json!({<br>       <br>        &quot;posts&quot;:[<br>            {<br>                &quot;title&quot;:&quot;How to generate free energy using Wind&quot;,<br>                &quot;author&quot;:&quot;Ramesh Vyas&quot;,<br>                &quot;image_path&quot;:&quot;/static/images/wind.jpg&quot;<br>            },<br>            {<br>                &quot;title&quot;:&quot;Why Bees are important for human beings&quot;,<br>                &quot;author&quot;:&quot;Nirvana&quot;,<br>                &quot;image_path&quot;: &quot;/static/images/bee.jpg&quot;<br>            },<br>            {<br>                &quot;title&quot;:&quot;Try vegan for your rest life!&quot;,<br>                &quot;author&quot;:&quot;Shiva&quot;,<br>                &quot;image_path&quot;:&quot;/static/images/calf.jpg&quot;<br>            },<br>            <br>        ]<br></pre><pre>    });</pre><pre>    let body = hb.render(&quot;posts&quot;, &amp;posts).unwrap();<br>    HttpResponse::Ok().body(body)<br></pre><pre>}</pre><pre>#[actix_web::main]<br>async fn main() -&gt; std::io::Result&lt;()&gt; {<br>    let mut hbars = Handlebars::new();<br>    hbars<br>        .register_templates_directory(&quot;.html&quot;, &quot;./static/&quot;)<br>        .unwrap();<br>    let hbars_ref = web::Data::new(hbars);</pre><pre>    <br>    HttpServer::new( move || {<br>        App::new()<br>            .app_data(hbars_ref.clone())<br>            .service(Files::new(&quot;/static&quot;, &quot;static&quot;).show_files_listing())<br>            .route(&quot;/&quot;, web::get().to(home))<br>    })<br>    .bind(&quot;127.0.0.1:8080&quot;)?<br>    .run()<br>    .await<br>}</pre><p>For simplicity of this article I have taken static JSON data, which can also be populated from any external source (database, file…).</p><p>Using handlebars we have parsed this JSON and page body is created with the parsed data. The page body is sent to the client when ever this endpoint (/) is accessed.</p><p>In the main function we have create HTTP server and have bidden the ‘/’ route with a handler function (home).</p><p>Also we have registered the static files directory so that handlebars can find the required template (posts.html). Using this template we have created a response page which is sent to the browser whenever specified route is accessed.</p><p>Figure below shows the actual output :</p><figure><img alt="Dynamic Webpage in Rust using Actix-Web and Handlebars" src="https://cdn-images-1.medium.com/max/1024/1*LDzPC5jgVX4UDxPjpiWdrw.png" /></figure><p>You can find the complete source code at my <a href="https://github.com/rameshovyas/actix-web-blog/tree/master">GitHub repository</a>. Thank you once again for your time.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7e89e041fc8a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Step by Step Guide To Build Your Own Zip Utility in Python]]></title>
            <link>https://medium.com/@rameshovyas/a-step-by-step-guide-to-build-your-own-zip-utility-in-python-2a1a78bfb4cd?source=rss-487aab2176d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/2a1a78bfb4cd</guid>
            <category><![CDATA[guides-and-tutorials]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[cli]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[python3]]></category>
            <dc:creator><![CDATA[Ramesh Vyas]]></dc:creator>
            <pubDate>Sat, 06 Aug 2022 03:58:07 GMT</pubDate>
            <atom:updated>2022-08-06T08:22:49.999Z</atom:updated>
            <content:encoded><![CDATA[<h4>Sending files via internet needs to be compressed in a single zip file, although there are many professional and free tools available for this task, but as a programmer we always try to do it by our own. I have tried a very simple CLI tool for compressing files into a single zip file using Python. I thought it would be good to share this with you all as it might be useful for someone out there.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Uty7twt1LlPyptS2" /><figcaption>Photo by <a href="https://unsplash.com/@cdr6934?utm_source=medium&amp;utm_medium=referral">Chris Ried</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>This is a very simple <strong>cli zip utility</strong> that accepts <em>source directory</em>, <em>file filters</em> like *.txt, *.py etc and target <em>zip filename</em> as command line arguments. It do checks for the validity of source directory and whether it exists or not, if everything sound okay it iterates the source directory with the specified filter and creates a zip file as specified in target filename.</p><p>I have used Python to achieve this. Python Standard Library provides us with many built in modules and classes to perform tasks that makes our work easier.</p><p>For this application I have used <strong>zipfile</strong> and <strong>pathlib</strong> Library, along with <strong>sys</strong> and <strong>os</strong> modules.</p><p>zipfile module have <strong>ZipFile</strong> class that have methods to create and read a zip file, pathlib module have class <strong>Path</strong> that have methods to iterate through a specified path and get individual file at a specified path.</p><p>First of all I have checked the number of command line arguments specified and if it does not matches the desired count I have displayed proper message and how to use this utility. Following is message you will receive if command line argument count is not correct.</p><pre>Invalid use of zip utility<br>USAGE: zip.py &lt;source folder&gt; &lt;filter eg. *.py / *.txt / *.*&gt; &lt;target .zip filename&gt;</pre><p>After that I have checked for the validity and existence of the source directory and if everything is fine I have created a zipfile with the name specified in command line arguments with the help of <strong>ZipFile</strong> class.</p><pre>with ZipFile(sys.argv[3],&quot;w&quot;) as zip</pre><p>After creating the zip file I have iterated the source directory recursively with the filter applied and added individual file to the target zip file.</p><p>I have also displayed a user friendly message for the number of files zipped into the target zip file.</p><p>Here is the complete source code of this utility you can download the code from my <a href="https://github.com/rameshovyas/zip-utility-in-python">GitHub repository</a> also.</p><pre># A simple CLI tool to compress specified files in a target zip file <br># Author : Ramesh Vyas</pre><pre>from zipfile import ZipFile<br>from pathlib import Path<br>import sys<br>import os</pre><pre>argc = len(sys.argv)<br>#Variable for directory filter (*.txt / *.py etc..)<br>filter=&quot;&quot;<br># Count number of files zipped<br>count=0<br>if(argc==4):<br>    if(Path(sys.argv[1]).is_dir and os.path.exists(sys.argv[1])):        <br>        if(sys.argv[2] == &quot;&quot;):                <br>            filter=&quot;*.*&quot;<br>        else:    <br>            filter = sys.argv[2]    </pre><pre>        with ZipFile(sys.argv[3],&quot;w&quot;) as zip:            <br>            for path in Path(sys.argv[1]).rglob(filter):<br>                count+=1<br>                zip.write(path)<br>                <br>        print(f&quot;{count} files zipped to {sys.argv[3]}&quot;)<br>    else:<br>        print(f&quot;{sys.argv[1]} is not a valid directory&quot;)    <br>else:<br>    print(&quot;Invalid use of zip utility&quot;)    <br>    print(&quot;USAGE: zip.py &lt;source folder&gt; &lt;filter eg. *.py / *.txt / *.*&gt; &lt;target .zip filename&gt;&quot;)</pre><p>Thank you for your time, hope this article has helped you in your coding journey. Thank you once again and have a nice day ahead. <strong>Plant and Save a Tree</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2a1a78bfb4cd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tauri - Toolkit For Developing Desktop Applications With Rust Backends]]></title>
            <link>https://medium.com/@rameshovyas/tauri-toolkit-for-developing-desktop-applications-with-rust-backends-840c779a9722?source=rss-487aab2176d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/840c779a9722</guid>
            <category><![CDATA[cross-platform]]></category>
            <category><![CDATA[frontend-development]]></category>
            <category><![CDATA[rust]]></category>
            <category><![CDATA[desktop-app]]></category>
            <category><![CDATA[user-interface]]></category>
            <dc:creator><![CDATA[Ramesh Vyas]]></dc:creator>
            <pubDate>Sun, 24 Jul 2022 12:49:58 GMT</pubDate>
            <atom:updated>2022-07-26T16:26:12.584Z</atom:updated>
            <content:encoded><![CDATA[<h3>Tauri - Toolkit For Developing Desktop Applications With Rust Core</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Es7YR78dlk8v3Mxs" /><figcaption>Photo by <a href="https://unsplash.com/@domenicoloia?utm_source=medium&amp;utm_medium=referral">Domenico Loia</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>What is Tauri?</h3><p>Tauri is a Rust based cross platform toolkit for developing desktop applications using any front-end framework of your choice. You can use pure HTML, CSS and JavaScript if you are unfamiliar with any of the available modern front-end frameworks.</p><p>Tauri uses Node.js for its CLI which makes it easier to create and maintain applications.</p><h3>Security First Approach</h3><p>Tauri enables users to take every precaution so that the surface area presented to users is always minimized, this means Tauri enables us to choose which endpoint we need to make available outside. It also allows us to choose whether we want a localhost server or not. This makes Tauri to deliver a secure app.</p><p>Unlike electron Tauri only ships binaries and not the ASAR files, which makes applications more secure.</p><h3>No Server</h3><p>Tauri allows us to create an user interface using web technology without using any server to communicate with a backend, thus there is no TCP port that could have been sniffed. In this way Tauri reduces the surface area for potential attacks.</p><h3>Dynamic AOT Compilation</h3><p>This is a process of compiling a higher level language into lower level language during build time so as to reduce runtime overheads. Tauri uses Dynamic AOT compilation thus the code generated is unique for every session making Tauri app more secure.</p><h3>Use of Rust Language</h3><p>Tauri uses Rust in its backend, which itself is very much fast and memory safe, making apps more secure.</p><h3>Functional ALSR</h3><p>Tauri uses Functional Address Space Layout Randomaization technique to randomize at runtime, confirming no two sessions will be same. Static attacks are prevented by the use of UID for function pointers.</p><p>Tauri uses OTP salt to encrypt message communication between the front end and the backend.</p><h3>De-compilation is not easy</h3><p>Tauri does not ships ASAR files, it ships binaries during build. This makes reverse engineering process typical and time consuming, making app more secure.</p><h3>Content Security Policy</h3><p>Tauri injects Content Security Policy to the index.html of our user interface preventing execution of any unauthorized code.</p><h3>Open Source</h3><p>Open source means freedom, applications build with Tauri are certifiable and can be included in GNU/Linux distributions — open source in a true sense.</p><h3>How it Works</h3><p>Tauri is polyglot which means its applications can be developed in several languages. Tauri allows developers to create a wide variety of applications.</p><p>Tauri is a tool that is used to build desktop applications using HTML and Rust rendered in a Webview.</p><p>Tauri application is very small because no runtime is shipped along with the final app as it is always a compiled binary in Rust language.</p><p>Tauri is not a virtual environment instead it is a toolkit for developing Webview OS applications.</p><p>Tauri uses WRY — a cross platform Webview rendering library written in Rust, to make OS system calls.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=840c779a9722" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Step-By-Step Guide To Create A Full Stack Web Application Using ‘Deno Fresh’ Framework]]></title>
            <link>https://medium.com/@rameshovyas/a-step-by-step-guide-to-create-a-full-stack-web-application-using-deno-fresh-framework-901cd3c5d929?source=rss-487aab2176d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/901cd3c5d929</guid>
            <category><![CDATA[denojs]]></category>
            <category><![CDATA[javascript-frameworks]]></category>
            <category><![CDATA[deno]]></category>
            <category><![CDATA[fresh]]></category>
            <category><![CDATA[full-stack]]></category>
            <dc:creator><![CDATA[Ramesh Vyas]]></dc:creator>
            <pubDate>Thu, 30 Jun 2022 09:23:36 GMT</pubDate>
            <atom:updated>2022-06-30T09:23:36.612Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bKpxLRTQ9Q3Ss09Y" /><figcaption>Photo by <a href="https://unsplash.com/@goshua13?utm_source=medium&amp;utm_medium=referral">Joshua Aragon</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>What is Deno ?</h3><p>Deno is a modern and secure JavaScript, TypeScript, and WebAssembly runtime written in Rust that uses V8 engine underthehood.</p><p>It is was originally created by Ryan Dahl yes you heard it correctly the same person who has created Node js. Later Deno Land Inc and contributors continued this project for production ready systems.</p><p>Deno is very secure as resources like files, network and environment cannot be accessed if you do not explicitly enable that.</p><p>Deno has out of the box support for typescript which makes it more powerful. It also has built in tools for inspecting dependencies (deno info), code formatting (deno fmt).</p><p>The most appealing thing is that it ships with a single executable with no dependencies.</p><p>Deno is also powerful in the sense that it can import modules from any location on the web, whether it may be your personal web server, CDN or GitHub, which makes it much easier to consume third-party modules.</p><p>Deno built in tool chain allows developers to be more productive as it saves time that was wasted in searching third party modules.</p><p>Deno is going to build a platform that is what a startup or a company needs, a complete package from development to deployment and Deno is trying to do that, which is amazing. As per my observation, Deno is working on improving Typescript and Javascript by using Rust as their core technology.</p><h3>What is Fresh ?</h3><p>Fresh is a new full stack Javascript framework built for Deno. You will say, another day another Javascript framework, but this one is special as it is very much different from other full stack frameworks available. First of all, it is for Deno by default and may be after certain customization, it can get it to Node js. Fresh is typescript by default.</p><p>The documentation Fresh says that they do not ship any kind of Javascript by default because client side Javascript is very expensive as it slows down the UX, which means Fresh uses a lot of Server Side Rendering and ships 0KB of Javascript to the client by default.</p><p>Fresh uses a model known as Islands Architecture, by Jason Miller, which states that no Javscript should be shipped to the client side unless the developer explicitly opts in to do that for any specific component.</p><p>Fresh is basically a routing framework with a built-in templating engine, which means pages are only rendered as and when they are requested on a server. For rendering and templating, Fresh uses Preact (a low footprint -3KB React alternative) and TSX on both client and server side.</p><p>One more thing which makes Fresh special and different from other full stack frameworks is that fresh does not have any build system, which means the code that we write is directly executed on both server and client side and translation from Typescript to Javascript is done just-in-time when it is needed. Thus, deployment of Fresh application is always instantaneous, which makes it much faster.</p><h3>Creating your first Fresh app</h3><p>Before creating a new Fresh application, you need to have <strong>Deno</strong> installed in your system. Deno can be installed in various ways as described in its <a href="https://deno.land/#installation">install guide</a>. We will be using the following command to install Deno in our system.</p><pre>curl -fsSL https://deno.land/install.sh | sh</pre><p>After we have completed installing Deno we will scaffold a new <strong>Fresh</strong> application by the following code.</p><pre>deno run -A -r https://fresh.deno.dev my-app</pre><p>The above script generates a minimal boilerplate Fresh project in your current folder. The figure below shows the directory structure of the minimal Fresh application just generated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/393/0*df3MGr4yhxHJyQ11.png" /></figure><p>From the above folder structure that, four files are necessary to run your Fresh application.</p><ol><li><strong>dev.ts</strong> : Entry point of your project in <strong>development mode</strong>. File name could be any but it is convention to keep it as dev.ts.</li><li><strong>main.ts</strong> : Entry point of your project in <strong>production mode</strong>. This file is linked when we deploy our project to Deno Deploy, again you can choose any name not necessarily <em>main.ts</em> it is just a convention.</li><li><strong>fresh.gen.ts</strong> : This is your project’s manifest file containing information about various routes and islands of our Fresh project.</li><li><strong>import_map.json</strong> : Project’s import map file used to manage dependencies of project.</li></ol><p>One more file <strong>deno.json</strong> is generated during this scaffolding process. This file tells Deno about the location of <strong>import map</strong> so that it becomes easy for Deno to manage dependencies. Also, a <strong>“start”</strong> task is registered to run our project, otherwise that could have been done by using <strong>deno run</strong> command.</p><p>Few important folders also get created and they are as follows:</p><ul><li><strong>routes</strong>: All of the routes of our application resides in this folder. The file name corresponds to the path of the page that has to be accessed.</li><li><strong>islands</strong> : All interactive islands of our projects reside in this folder and the name of each file correcsponds to respective island of our project.</li><li><strong>static</strong> : Contains all static files that are delivered as it is.</li></ul><h3>Running our application</h3><p>Now its time to run our project on our local machine, for this we will have to issue the folowing command in our <strong>Fresh</strong> project’s folder :</p><pre>deno task start</pre><p>By default application port is <strong>8000</strong> we can also change this in <strong>main.ts</strong> as below :</p><pre>await start(manifest, { render, port:3000 });</pre><p>Now your application will be listening at port 3000 instead default 8000.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/932/0*1fR5Xk2VWMtQAqHs.png" /></figure><h3>Creating new Route</h3><p>Routes are used to encapsulate the logic behind handling various requests to a particular path in our project. It could be an API request or a request to render simple HTML page. In this article we will be using routes to render simple HTML page.</p><p>As we have previously seen, that for each path in our project we need to create a file of <strong>same name</strong> in our <strong>routes</strong> folder or directory. For example, if we need a path for <strong>/about</strong> we will have to create a file <strong>about.js</strong> in our <strong>routes</strong> directory.</p><p>This system is known as <em>File System Routing</em>.</p><p>In our Fresh project route files renders HTML, JavaScript or TypeScript in the form of JSX or TSX components.</p><p>For now we are going to create a route to handle <strong>/about</strong> page for this we need to create a new file <strong>routes/about.tsx</strong>.</p><p>After creating new route our project’s folder structure looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/396/0*gBPsUVK3O8Bz3yoT.png" /></figure><p>After creating route for <em>*/about</em> <em>we have left with declaring a component using JSX that will be rendered everytime a user requests for </em>/about*.</p><p>Place the following code in about.tsx file that we have created recently.</p><pre>// routes/about.tsx</pre><pre>/** @jsx h */<br>import { h } from &quot;preact&quot;;</pre><pre>export default function AboutPage() {<br>  return (<br>    &lt;main&gt;<br>      &lt;h2&gt;About&lt;/h2&gt;<br>      &lt;p&gt;Hello, you are in our about us page.&lt;/p&gt;<br>    &lt;/main&gt;<br>  );<br>}</pre><p>Do not get confused with the first two lines they are just boiler-plated JSX pragma code for ensuring JSX is rendered correctly.</p><p>Now you can navigate to /about page by following</p><p><a href="http://localhost:3000/about">localhost:3000/about</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/627/0*13P2ixz7AJVSSFrs.png" /></figure><p>In this way you can create simple and static routes / pages for your Fresh project. Hope you enjoyed this article. You can find the source code for this artcile in <a href="https://github.com/rameshovyas/simple-fresh1.0-project">my GitHub repository</a>. Thank you for your time and support. Have a nice day ahead.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=901cd3c5d929" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How the source code gets translated into binaries for a target Micro-controller.]]></title>
            <link>https://medium.com/@rameshovyas/understanding-the-process-of-translating-source-code-into-binaries-for-a-target-micro-controller-4e8370ccbea?source=rss-487aab2176d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/4e8370ccbea</guid>
            <category><![CDATA[guides-and-tutorials]]></category>
            <category><![CDATA[how-to]]></category>
            <category><![CDATA[embedded-systems]]></category>
            <category><![CDATA[binary-code]]></category>
            <category><![CDATA[compilers]]></category>
            <dc:creator><![CDATA[Ramesh Vyas]]></dc:creator>
            <pubDate>Thu, 26 May 2022 10:47:29 GMT</pubDate>
            <atom:updated>2022-05-27T02:02:03.735Z</atom:updated>
            <content:encoded><![CDATA[<p>The step by step process of translating source code into machine code for micro-controllers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*G0dQopTOmybPGnK-" /><figcaption>Photo by <a href="https://unsplash.com/@s_tsuchiya?utm_source=medium&amp;utm_medium=referral">S. Tsuchiya</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>As we all are familiar with the fact that every digital computer needs instructions in the format a machine understands, obviously which is binary. In this article I will try to elaborate the process how our source code get converted into executable binaries for the target micro-controller we use in our embedded system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/256/1*J2L6HQHYh4afVswpGPFK-Q.png" /></figure><p>The figure above explains the step by step procedure how our source code gets converted into executable binary after going through various stages.</p><h3>First Step : Compilation of Source Code</h3><p>The first step in this process is translating the source code written in any high level language, like C or C++ into machine understandable opcodes. These opcodes are different for different machines (processors) depending upon the architecture and word-length. It is the duty of compiler to translate source code into proper binary opcodes. Since every machine have different opcodes this translation may vary from processor to processor.</p><h3>Cross Compilation</h3><p>We write our source code on a PC for a particular embedded board having our target processor. Since we need to generate the executable binary on the native machine where we have developed the source program, we need a compiler that can translate this source code into binary executable for the target processor and not for the native machine in which we have designed the source program, this is known as <strong>cross compilation</strong>.</p><h3>Second Step: Linking the Object Code</h3><p>The figure above shows that the job of compiler or cross compiler is just to translate the source code into object code and store in object files. These object files contains the instructions that are to be executed by the target processor.</p><p>Our source code is generally divided into three sections :</p><ul><li>.text : The actual code.</li><li>.data : Initialized global variables.</li><li>.bss : Uninitialized global variables.</li></ul><p>This organization of high level language makes it easier to code but at the end we need a single binary to get executed on the target machine. This is done by the linker. The linker combines all object files into a single binary file.</p><h3>Third Step: Locating the correct memory addresses.</h3><p>It is very important to locate or stamp the exact addresses of the code so that <strong>.text</strong> section can be loaded to the micro-controller’s flash memory, and <strong>.data</strong> section to the RAM as soon as the we power up the micro-controller. This is the duty of locator.</p><p>Before the main() function starts many nationalizations are made, these includes initialization of various peripherals, copying initialized variables from flash memory to RAM, initializing the <strong>stack</strong> and <strong>heap</strong> and finally calling the main(). This is all done by a <strong>startup code</strong> which transfers control to the main() function as soon as the machine is powered on. The startup code resides in a special file and generally resides at location 0x0000. As soon as the machine is powered on it get executed and takes control to the point where main() function resides.</p><p>The locating process is applicable in embedded programs only as on PCs the operating system does this for us, known as program loading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4e8370ccbea" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>