<?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 Mykhailo Didur on Medium]]></title>
        <description><![CDATA[Stories by Mykhailo Didur on Medium]]></description>
        <link>https://medium.com/@lucky_rydar?source=rss-38887a4a9ec1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*H8CZE4hE9Zhoru_Jn_ZGZg.jpeg</url>
            <title>Stories by Mykhailo Didur on Medium</title>
            <link>https://medium.com/@lucky_rydar?source=rss-38887a4a9ec1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 04:01:51 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@lucky_rydar/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[How to Deal with the Rust’s Borrow Checker]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-snippet">Coming from C++? Then you know the freedom &#x2014; and the consequences. C++ lets you shoot yourself in the foot in a spectacular variety of&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/@lucky_rydar/how-to-deal-with-the-rusts-borrow-checker-61f6f2b33fb1?source=rss-38887a4a9ec1------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@lucky_rydar/how-to-deal-with-the-rusts-borrow-checker-61f6f2b33fb1?source=rss-38887a4a9ec1------2</link>
            <guid isPermaLink="false">https://medium.com/p/61f6f2b33fb1</guid>
            <category><![CDATA[rust]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[borrow-checker]]></category>
            <dc:creator><![CDATA[Mykhailo Didur]]></dc:creator>
            <pubDate>Sat, 18 Apr 2026 11:26:07 GMT</pubDate>
            <atom:updated>2026-04-18T11:41:26.895Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Compile-Time State Machines in Rust: Making Invalid States Impossible]]></title>
            <link>https://medium.com/@lucky_rydar/compile-time-state-machines-in-rust-making-invalid-states-impossible-d4de012c67e3?source=rss-38887a4a9ec1------2</link>
            <guid isPermaLink="false">https://medium.com/p/d4de012c67e3</guid>
            <category><![CDATA[robust]]></category>
            <category><![CDATA[state-machine]]></category>
            <category><![CDATA[type-systems]]></category>
            <category><![CDATA[rust-programming-language]]></category>
            <category><![CDATA[rust]]></category>
            <dc:creator><![CDATA[Mykhailo Didur]]></dc:creator>
            <pubDate>Mon, 30 Jun 2025 11:31:58 GMT</pubDate>
            <atom:updated>2025-06-30T11:31:58.611Z</atom:updated>
            <content:encoded><![CDATA[<p>Hey there, fellow Rust enthusiasts!</p><p>I’ve noticed that readers really appreciate when I dive into interesting programming language concepts, so I decided to write about one of Rust’s most powerful features that often goes underappreciated: compile-time state machines. Today we’re exploring how Rust’s type system can prevent entire categories of bugs before your code even runs.</p><h4>Why Runtime Validation is Problematic</h4><p>Before we dive into the solution, let’s understand the problem we’re trying to solve. In traditional programming approaches, we often validate state transitions at runtime. This means writing code that checks whether an operation is valid for the current state, and handling errors when it’s not.</p><p>The fundamental issue with runtime validation is that it creates a significant testing burden. You need to write comprehensive test cases for every possible invalid state transition, ensure your error handling is correct, and hope you’ve covered all the edge cases. Even worse, these bugs only surface when the code actually runs, potentially in production where they can cause real damage.</p><p>Think about an I2C controller that needs to be configured, then initialized, then installed before you can perform read/write operations. With runtime validation, you’d write defensive code checking the state at each step, along with extensive tests to ensure invalid operations fail gracefully. This approach is error-prone and requires constant vigilance from developers.</p><h4>How the Compiler Solves This Problem Through Type Verification</h4><p>The compiler can solve this problem elegantly through type system verification. Instead of checking states at runtime, we encode valid states directly into the type system. The compiler then prevents invalid operations from even compiling, transforming potential runtime errors into compile-time errors.</p><p>This approach is fundamentally superior because the compiler becomes your safety net. You literally cannot write code that performs invalid state transitions. The type system enforces the rules automatically, without any runtime overhead or need for defensive programming.</p><p>When you try to call a method that’s not available in the current state, the compiler gives you a clear error message explaining exactly what went wrong and which states would allow that operation.</p><h4>Building a Compile-Time State Machine</h4><p>Let’s see how this works in practice with our I2C controller example. The key insight is using Rust’s generic types with phantom data to encode states as distinct types that exist only at compile time.</p><p>First, we define our states as simple marker types:</p><pre>pub struct Configured;<br>pub struct Initialized;<br>pub struct Installed;</pre><p>Each state is now a distinct type that the compiler can reason about. Notice we don’t need a trait here — the states are just empty structs that serve as type-level markers.</p><p>Our controller becomes generic over these state types:</p><pre>use std::marker::PhantomData;<br><br>pub struct I2cController&lt;S = Configured&gt; {<br>    config: I2cConfig,<br>    _state: PhantomData&lt;S&gt;,<br>}</pre><p>The PhantomData&lt;S&gt; is Rust&#39;s way of saying &quot;this struct cares about type S for compile-time checking, but doesn&#39;t actually store any data of that type.&quot; The default generic parameter S = Configured means that I2cController::new() will create an I2cController&lt;Configured&gt; by default.</p><p>Now we implement methods that are only available in specific states. Each implementation block targets a specific state type:</p><pre>impl I2cController&lt;Configured&gt; {<br>    pub fn new(config: I2cConfig) -&gt; Self {<br>        Self {<br>            config,<br>            _state: PhantomData,<br>        }<br>    }<br><br>    pub fn initialize(self) -&gt; Result&lt;I2cController&lt;Initialized&gt;, &amp;&#39;static str&gt; {<br>        self.validate_config()?;<br>        <br>        Ok(I2cController {<br>            config: self.config,<br>            _state: PhantomData,<br>        })<br>    }<br>}<br><br>impl I2cController&lt;Installed&gt; {<br>    pub fn read(&amp;self, device_addr: u8, buffer: &amp;mut [u8]) -&gt; Result&lt;(), &amp;&#39;static str&gt; {<br>        // Only available in Installed state<br>        Ok(())<br>    }<br>}</pre><p>The magic happens in the state transitions. The initialize method consumes the Configured controller (notice it takes self, not &amp;self) and returns an Initialized one. This ensures you can&#39;t accidentally use the old controller after initialization, and you&#39;re forced to handle the transition properly.</p><h4>The Power of Compile-Time Verification</h4><p>With this setup, invalid operations simply won’t compile. Here’s what happens when you try to use methods in the wrong state:</p><pre>let config = I2cConfig::new();<br>let controller_configured = I2cController::new(config);<br>controller_configured.read(0x48, &amp;mut buffer);  // ERROR!</pre><p>The compiler catches this immediately with a detailed error message:</p><pre>error[E0599]: no method named `read` found for struct `I2cController` in the current scope<br>   --&gt; src/main.rs:191:27<br>    |<br>69  | pub struct I2cController&lt;S = Configured&gt; {<br>    | ---------------------------------------- method `read` not found for this struct<br>...<br>191 |     controller_configured.read(0x48, &amp;mut buffer);<br>    |                           ^^^^ method not found in `I2cController`<br>    |<br>    = note: the method was found for<br>            - `I2cController&lt;Installed&gt;`</pre><p>Notice how helpful this error message is. The compiler tells you exactly what went wrong and even suggests which type would have the method you’re looking for. It’s pointing out that read exists, but only for I2cController&lt;Installed&gt;, not for your current I2cController&lt;Configured&gt;.</p><p>This compile-time verification means you don’t need to write tests for these scenarios because they’re impossible to express in code. The type system becomes your documentation, your test suite, and your safety net all rolled into one.</p><h4>Real-World Benefits and Use Cases</h4><p>This pattern shines in scenarios where you have complex initialization sequences, protocol implementations, or any system with clear state transitions. Hardware drivers like our I2C example are perfect candidates, but you’ll also find this useful for network protocols, file parsers, database connections, and API clients that require authentication before use.</p><p>The beauty is that once you’ve encoded the valid transitions in your type system, the compiler enforces them everywhere your code is used. Other developers can’t misuse your API even if they try, and new team members get immediate feedback about the correct usage patterns.</p><p>Consider how this applies to a database connection that needs to be opened, authenticated, and then can execute queries. Or a file parser that needs to read headers before it can parse records. In each case, the type system guides users through the correct sequence of operations.</p><p>You can find the complete working example with detailed implementation at <a href="https://github.com/lucky-rydar/compiler-time-state-machine">link</a>.</p><h4>Conclusion</h4><p>Compile-time state machines represent one of Rust’s most elegant solutions to a common programming problem. By moving validation from runtime to compile-time, we eliminate entire categories of bugs, reduce testing overhead, and create APIs that are impossible to misuse.</p><p>The approach requires thinking differently about how you structure your code, but the payoff in reliability and maintainability is enormous. Instead of writing defensive code and comprehensive tests for invalid states, you encode the valid states directly in the type system and let the compiler do the work.</p><p>The error messages become part of your API documentation, guiding users toward correct usage patterns. The impossible becomes unrepresentable, and your code becomes more robust by construction rather than by testing.</p><p>Next time you find yourself writing runtime state validation, consider whether you can encode those states in the type system instead. Your future self will thank you when the compiler catches bugs that would have otherwise made it to production.</p><p>If you found this exploration of Rust’s type system useful, please clap so I know to write more articles like this one!</p><p><a href="https://github.com/lucky-rydar"><strong>Github</strong></a><strong> | </strong><a href="https://www.buymeacoffee.com/mykhailodidur"><strong>Buy me a coffee</strong></a><strong> | </strong><a href="https://www.linkedin.com/in/mykhailo-didur-052610202/"><strong>LinkedIn</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d4de012c67e3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Networking 101: OSI Model Overview]]></title>
            <link>https://medium.com/@lucky_rydar/networking-101-osi-model-overview-8e60be6e7bb7?source=rss-38887a4a9ec1------2</link>
            <guid isPermaLink="false">https://medium.com/p/8e60be6e7bb7</guid>
            <category><![CDATA[tcp-ip]]></category>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[osi-model]]></category>
            <category><![CDATA[udp-protocol]]></category>
            <dc:creator><![CDATA[Mykhailo Didur]]></dc:creator>
            <pubDate>Sat, 11 May 2024 19:09:20 GMT</pubDate>
            <atom:updated>2024-05-11T19:09:20.487Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi mediumers, this article is the start to a new series of articles in which I will describe all the networking fundamentals I would suggest every software engineer to learn.</p><h4>Overview</h4><p>This article will talk about the OSI(Open Systems Interconnection) model. The model gives a helicopter view of all things related to networks.</p><p>Basically the model describes communication between two machines using 7 layers:</p><ol><li>Physical layer —just cables</li><li>Data layer — software representation of phy layer:</li><li>Network — Internet Protocol</li><li>Transport — TCP, UDP, QUIC, SCTP and other</li><li>Session</li><li>Presentation</li><li>Application</li></ol><p>Why did I just skip last 3 layers?</p><p>The reason is that generally they are the same, they represent all the stuff built with transport layer. So, session/representation/application layer include such protocols as: HTTP/HTTPS, RTP, SSH. I would say, protocols that are directly utilized by the user in an application are positioned at session level and above.</p><h4>Core idea of the model</h4><p>Now you see that there are many protocols sorted by layers, but what these layers actually mean? Well, basic rule is that protocol of layer N uses a protocol of layer N-1 except of physical layer, because that is a base.</p><h4>Practical sample</h4><p>Technically it is implemented as a bunch of headers of all the protocols down the model.</p><p>I hope, you have some basic understanding of <strong>UDP</strong>(Unified datagram protocol). Long story short, it allows you to send some payload specifying an IP address and a port of the destination(BTW the header does not requires us to fill an IP, but about this we will speak later).</p><p>So, you need to send a message ‘Hello world!’ and you desided to use UDP for this purpose. UDP is a layer 4 protocol and if you want to form a packet, you need a source and destination ports, length of the packet, its checksum and the data you want to send. So, UDP packet for source port 111 and destination port 222 would look like the following:</p><ul><li>[111, 222, 12, checksum] [‘Hello world!’] <em>// 12 is a length of payload</em></li></ul><p><em>All the detailed information about UDP you can find </em><a href="https://datatracker.ietf.org/doc/html/rfc768"><strong><em>here</em></strong></a><em>. The reference can tell much more about the protocol than I in this article, so I would suggest you to read it right after this article. Basically, on the provided resource you can find an information about each protocol mentioned in this article.</em></p><p>As I mentioned before, each layer must be used to send the packet. So, going down the model we have an IP protocol which specifies source and destination IP addresses, its version, length of payload and some other stuff not really important for now stuff. Resulted IP packet with source IP 10.0.0.2 and destination IP 10.0.0.3 would look like the following:</p><ul><li>[10.0.0.2, 10.0.0.3, 4(IPv4), 20, …other header] [ [111, 222, 12, checksum] [‘Hello world!’] ]</li></ul><p>An interesting thing here is that IP knows nothing about UDP, that is just a payload for him same as any other protocol on layer 4. So, the length would be 20 which is length of UDP header and its own payload. It works on each layer absolutely the same — <strong>each layer down knows nothing about layer above</strong>.</p><p>The next layer down to the hell is data layer which usually represented by the Ethernet protocol. The protocol operates with MAC addresses. Ethernet packet would look like</p><ul><li>[src MAC, dst MAC, length, …] [here all the IP packet]</li></ul><p>Now you computer has enough information about the destination and we are going to send the packet somewhere. Imagine you have connected Ethernet cable to your PC and that is the only link to the internet. Since Ethernet in this case is also a physical protocol, Ethernet module in your computer uses physical stuff to encode the message to some signal. On the other end of the cable another computer decodes it and opens the message layer by layer verifying each to get the message ‘Hello world!’</p><h4>Conclusion</h4><p>The OSI model is a key networking concept which is must have to every software engineer. It outlines how data moves from physical cables to user-facing applications. Each layer uses the protocol of the layer below, forming a protocol stack. We explored this with a UDP ‘Hello world!’ example.</p><p>If you find this article useful, then clap so I would know about this. Also, tet me know in comments if it is good enough format to continue.</p><p><strong>Used resources:</strong></p><ul><li><a href="https://datatracker.ietf.org/">https://datatracker.ietf.org/</a></li></ul><p><a href="https://github.com/lucky-rydar"><strong>Github</strong></a><strong> | </strong><a href="https://www.buymeacoffee.com/mykhailodidur"><strong>Buy me a coffee</strong></a><strong> | </strong><a href="https://www.linkedin.com/in/mykhailo-didur-052610202/"><strong>LinkedIn</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8e60be6e7bb7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Guide over Smart Pointers in C++]]></title>
            <link>https://medium.com/@lucky_rydar/guide-over-smart-pointers-in-c-46ed8b04448c?source=rss-38887a4a9ec1------2</link>
            <guid isPermaLink="false">https://medium.com/p/46ed8b04448c</guid>
            <category><![CDATA[c-plus-plus-language]]></category>
            <category><![CDATA[memory-management]]></category>
            <category><![CDATA[smart-pointer]]></category>
            <dc:creator><![CDATA[Mykhailo Didur]]></dc:creator>
            <pubDate>Mon, 06 Nov 2023 19:56:30 GMT</pubDate>
            <atom:updated>2023-11-06T19:56:30.182Z</atom:updated>
            <content:encoded><![CDATA[<p>Hey there, fellow C++ enthusiast!️</p><p>Welcome to this small guide about C++ smart pointers. Today, we’re diving into the world of these tools that make managing memory in your C++ programs a whole lot easier and much safer.</p><p>In this article, we’ll explore three types of smart pointers and share some practical tips on how to use them like a pro. So, whether you’re a C++ newbie or a seasoned coder, I think this article will be really useful for you.</p><h4>General Smart Pointer</h4><p>As far you know C++ is well known for providing tools that helps you to make segmentation fault or memory leak in different ways. The root problem of such a runtime errors is using raw pointers and other stuff like forgetting to free memory or getting access to wrong piece of memory.</p><p>Generally, mostly all the problems with memory can be fixed by using <strong><em>smart pointers</em></strong>. The idea of them to control an ownership of pointer and automatic memory deallocation.</p><p>Starting from 11 standard of C++ we have three types of pointers: std::unique_ptr, std::shared_ptr and std::weak_ptr. With the help of them you can(<em>and should I think</em>) solve 99% of your every day tasks.</p><h4>Unique pointer</h4><p>Unique pointer is a kind of smart pointers that implements simple mechanism of handling one raw pointer by one owner. The pointer inside cant be copied accidentally to another one. After stack being deallocated the pointer inside will be deleted also.</p><p>In C++ implementation of smart pointers they works absolutely the same way as raw pointers. Here is general example of how you can use smart pointers.</p><pre>#include &lt;iostream&gt;<br>#include &lt;memory&gt;<br><br>int main() {<br>    std::unique_ptr&lt;int&gt; u1(new int(1));<br>    std::unique_ptr&lt;int&gt; u2(new int(2));<br>    std::unique_ptr&lt;int&gt; u3 = std::move(u1);<br>    // std::unique_ptr&lt;int&gt; u4 = u2; // error<br><br>    if(u1) {<br>        // will not be printed as u1 is null<br>        std::cout &lt;&lt; *u1 &lt;&lt; std::endl;<br>    }<br>    if(u2) {<br>        std::cout &lt;&lt; *u2 &lt;&lt; std::endl;<br>    }<br>    if(u3) {<br>        std::cout &lt;&lt; *u3 &lt;&lt; std::endl;<br>    }<br><br>    return 0;<br>}</pre><p>As you can see from the example above, unique pointer cant be copied, it is guaranteed by the compiler. Also, if you are not sure, it would be fine to check out if your std::unique_ptr has a valid address(not a nullptr) so you can access the data.</p><p>The ownership can be also taken using function <em>release </em>with the help of which you can get the pointer and std::uniques_ptr will not hold it. However, I would not suggest to use this function because it could be unsafe.</p><pre>#include &lt;iostream&gt;<br>#include &lt;memory&gt;<br><br>int main() {<br>    std::unique_ptr&lt;int&gt; uniqueInt(new int(42));<br>    std::cout &lt;&lt; *uniqueInt &lt;&lt; std::endl; // 42<br><br>    int* rawPtr = uniqueInt.release();<br>    std::cout &lt;&lt; *rawPtr &lt;&lt; std::endl; // 42<br><br>    if (!uniqueInt) {<br>        std::cout &lt;&lt; &quot;no longer owns the memory.&quot; &lt;&lt; std::endl;<br>    }<br><br>    delete rawPtr;<br><br>    return 0;<br>}</pre><h4>Shared pointer</h4><p><strong><em>Spoiler</em></strong><em>: After deeper look you will understand that this type of pointer works almost the same way as abstract garbage collector but allocated memory being freed right after the moment it is not needed.</em></p><p>The idea of shared pointer is to make it possible for all the owners(more than one) to point to the same data.</p><p><strong>Important: </strong>the memory is deallocated only in case of last shared_ptr object will be deleted so anyone wants this data to continue existing.</p><p>Here is a small example of how it works:</p><pre>#include &lt;iostream&gt;<br>#include &lt;memory&gt;<br><br>int main() {<br>    std::shared_ptr&lt;int&gt; sharedInt = std::make_shared&lt;int&gt;(12);<br><br>    std::cout &lt;&lt; *sharedInt &lt;&lt; std::endl; // 12<br><br>    std::shared_ptr&lt;int&gt; sharedInt2 = sharedInt;<br><br>    *sharedInt = 100;<br><br>    std::cout &lt;&lt; *sharedInt &lt;&lt; std::endl; // 100<br>    std::cout &lt;&lt; *sharedInt2 &lt;&lt; std::endl; // 100<br><br>    return 0;<br>}</pre><p>It also can be easily copied:</p><pre>#include &lt;iostream&gt;<br>#include &lt;memory&gt;<br><br>void printValue(std::shared_ptr&lt;int&gt; sharedInt) {<br>    std::cout &lt;&lt; *sharedInt &lt;&lt; std::endl; // 123<br>}<br><br>int main() {<br>    std::shared_ptr&lt;int&gt; sharedInt = std::make_shared&lt;int&gt;(123);<br>    printValue(sharedInt);<br>    return 0;<br>}</pre><p>And here is an example that shows how deallocating of memory happens. We can check it out using function <em>use_count </em>with the help of which we can know how many owners there are.</p><pre>#include &lt;iostream&gt;<br>#include &lt;memory&gt;<br><br>class MyClass {<br>public:<br>    MyClass(int value) : value(value) {}<br><br>    ~MyClass() {}<br><br>private:<br>    int value;<br>};<br><br>int main() {<br>    std::shared_ptr&lt;MyClass&gt; sharedObj = std::make_shared&lt;MyClass&gt;(42);<br>    std::shared_ptr&lt;MyClass&gt; sharedObj2 = sharedObj;<br><br>    std::cout &lt;&lt; sharedObj.use_count()  &lt;&lt; std::endl; // 2<br>    std::cout &lt;&lt; sharedObj2.use_count() &lt;&lt; std::endl; // 2<br><br>    sharedObj.reset();<br><br>    std::cout &lt;&lt; sharedObj.use_count()  &lt;&lt; std::endl; // 0<br>    std::cout &lt;&lt; sharedObj2.use_count() &lt;&lt; std::endl; // 1<br><br>    sharedObj2.reset();<br><br>    std::cout &lt;&lt; sharedObj.use_count()  &lt;&lt; std::endl; // 0<br>    std::cout &lt;&lt; sharedObj2.use_count() &lt;&lt; std::endl; // 0<br><br>    return 0;<br>}</pre><h4>Weak Pointer</h4><p>Long story short, std::weak_ptr is same as std::shared_ptr but it does not own memory so it can be freed even if there is weak pointer that points to it. Here is how it can be used.</p><pre>#include &lt;iostream&gt;<br>#include &lt;memory&gt;<br><br>int main() {<br>    std::shared_ptr&lt;int&gt; sharedInt = std::make_shared&lt;int&gt;(42);<br>    std::weak_ptr&lt;int&gt; weakInt = sharedInt;<br><br>    std::cout &lt;&lt; &quot;Owners: &quot; &lt;&lt; sharedInt.use_count() &lt;&lt; std::endl;<br><br>    if (auto shared = weakInt.lock()) {<br>        std::cout &lt;&lt; &quot;Value: &quot; &lt;&lt; *shared &lt;&lt; std::endl;<br>    } else {<br>        std::cout &lt;&lt; &quot;Not available&quot; &lt;&lt; std::endl;<br>    }<br><br>    // freeing the shared pointer<br>    sharedInt.reset();<br><br>    if (auto shared = weakInt.lock()) {<br>        std::cout &lt;&lt; &quot;Value: &quot; &lt;&lt; *shared &lt;&lt; std::endl;<br>    } else {<br>        std::cout &lt;&lt; &quot;Not available&quot; &lt;&lt; std::endl;<br>    }<br><br>    return 0;<br>}</pre><p>Output:</p><pre>Owners: 1<br>Value: 42<br>Not available</pre><p>So, weak pointer does not own memory and it can be safely freed. That is pretty simple concept, but I am sure you have no idea why C++ needs it. I will explain it in the next paragraph.</p><h4>Trap with Shared Pointers</h4><p>Imagine you have two objects where each has shared pointer to another as a field. We used them for some time and they are needed to be deallocated. Object1 calls destructor and tries to deallocate first its field of shared pointer of Object2, then destructor of Object2 is called and it deallocates first its field of shared pointer of Object1. Oh no, that’s a trap!</p><p>Here is an example of such a situation:</p><pre>#include &lt;memory&gt;<br>#include &lt;iostream&gt;<br><br>class B;<br><br>class A {<br>public:<br>    std::shared_ptr&lt;B&gt; b_ptr;<br><br>    A() {<br>        std::cout &lt;&lt; &quot;A constructor&quot; &lt;&lt; std::endl;<br>    }<br><br>    ~A() {<br>        std::cout &lt;&lt; &quot;A destructor&quot; &lt;&lt; std::endl;<br>    }<br>};<br><br>class B {<br>public:<br>    std::shared_ptr&lt;A&gt; a_ptr;<br><br>    B() {<br>        std::cout &lt;&lt; &quot;B constructor&quot; &lt;&lt; std::endl;<br>    }<br><br>    ~B() {<br>        std::cout &lt;&lt; &quot;B destructor&quot; &lt;&lt; std::endl;<br>    }<br>};<br><br>int main() {<br>    {<br>        std::shared_ptr&lt;A&gt; a = std::make_shared&lt;A&gt;();<br>        std::shared_ptr&lt;B&gt; b = std::make_shared&lt;B&gt;();<br><br>        a-&gt;b_ptr = b;<br>        b-&gt;a_ptr = a;<br>    }<br><br>    return 0;<br>}</pre><p>Output:</p><pre>A constructor<br>B constructor</pre><p>Destructors will never be called so the memory will not be deallocated.</p><p>To avoid such a situation you must use class std::weak_ptr the main function of which is not to pretend on data if it is gonna be allocated.</p><p>Here is an example where I use weak pointer to fix the issue:</p><pre>#include &lt;memory&gt;<br>#include &lt;iostream&gt;<br><br>class B; // Forward declaration<br><br>class A {<br>public:<br>    std::shared_ptr&lt;B&gt; b_ptr;<br><br>    A() {<br>        std::cout &lt;&lt; &quot;A constructor&quot; &lt;&lt; std::endl;<br>    }<br><br>    ~A() {<br>        std::cout &lt;&lt; &quot;A destructor&quot; &lt;&lt; std::endl;<br>    }<br>};<br><br>class B {<br>public:<br>    std::weak_ptr&lt;A&gt; a_weak_ptr;<br><br>    B() {<br>        std::cout &lt;&lt; &quot;B constructor&quot; &lt;&lt; std::endl;<br>    }<br><br>    ~B() {<br>        std::cout &lt;&lt; &quot;B destructor&quot; &lt;&lt; std::endl;<br>    }<br>};<br><br>int main() {<br>    std::shared_ptr&lt;A&gt; a = std::make_shared&lt;A&gt;();<br>    std::shared_ptr&lt;B&gt; b = std::make_shared&lt;B&gt;();<br><br>    a-&gt;b_ptr = b;<br>    b-&gt;a_weak_ptr = a;<br><br>    // The shared_ptr cycle is broken, and memory will be deallocated properly when the references are no longer needed.<br><br>    return 0;<br>}</pre><p>Now destructors are called and all the memore is freed:</p><pre>A constructor<br>B constructor<br>A destructor<br>B destructor</pre><h4>Conclusion</h4><p>In summary, C++ smart pointers are handy tools that help manage memory in a safer and more efficient way. By using std::unique_ptr, std::shared_ptr, and std::weak_ptr, programmers can make memory handling easier. Remember, std::weak_ptr can help prevent memory issues when objects depend on each other, ensuring that your C++ programs run smoothly and reliably.</p><p>Hope you liked this article and it was useful for you. If so, then please clap so I will know about that.</p><p><strong>Used resources:</strong></p><ul><li><a href="https://en.cppreference.com/w/">https://en.cppreference.com/w/</a></li><li><a href="https://www.learncpp.com/cpp-tutorial/circular-dependency-issues-with-stdshared_ptr-and-stdweak_ptr/">https://www.learncpp.com/cpp-tutorial/circular-dependency-issues-with-stdshared_ptr-and-stdweak_ptr/</a></li></ul><p><a href="https://github.com/lucky-rydar"><strong>Github</strong></a><strong> | </strong><a href="https://www.buymeacoffee.com/mykhailodidur"><strong>Buy me a coffee</strong></a><strong> | </strong><a href="https://www.linkedin.com/in/mykhailo-didur-052610202/"><strong>LinkedIn</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=46ed8b04448c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Never Manjaro Linux again]]></title>
            <link>https://medium.com/@lucky_rydar/never-manjaro-linux-again-18af345fd78d?source=rss-38887a4a9ec1------2</link>
            <guid isPermaLink="false">https://medium.com/p/18af345fd78d</guid>
            <category><![CDATA[manjaro-linux]]></category>
            <category><![CDATA[pacman]]></category>
            <category><![CDATA[experience]]></category>
            <dc:creator><![CDATA[Mykhailo Didur]]></dc:creator>
            <pubDate>Sat, 04 Nov 2023 15:14:18 GMT</pubDate>
            <atom:updated>2023-11-04T15:14:18.024Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello, everyone,<br>I’m excited to share my experiences with you about using Manjaro Linux. It’s been quite a journey, one that started with enthusiasm but took a surprising turn.</p><p>In this Medium article, I’ll take you through my time with Manjaro Linux. I’ll share the highs, lows, and why I’ve reached the point where I can confidently say, “I won’t use Manjaro Linux again.”</p><h4>Rolling Releases Can Be Unpredictable</h4><p>Are you tired of living on the edge with your Linux operating system? That was my story when I ventured into the world of Manjaro Linux. Don’t get me wrong; there were aspects I loved about it. However, one lesson I learned the hard way is that rolling releases can be unpredictable, and that’s a double-edged sword.</p><p><strong>Manjaro, the Arch Cousin</strong><br>First things first, Manjaro is a rolling release Linux distribution, which means it’s always evolving and doesn’t have those hard version numbers you might be used to with other operating systems. It’s derived from Arch Linux, and that’s where the unpredictability factor comes into play.</p><p><strong>Riding the Bleeding Edge<br></strong>The rolling release concept is like a free pass to the candy store, giving you access to the latest and greatest software. It’s like being the first in line for the coolest gadgets or fashion trends. But, let me tell you, the newest software can be a bit like that trendy fashion choice — stylish, but not always practical.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*T6eU-2zJB3BDfosf" /></figure><p><strong>The Unstable Rope<br></strong>One day, you’re enjoying the thrill of having the latest updates, and the next, your system throws a fit. It’s like walking on a tightrope — exciting, but a fall can be disastrous. The newest software might be riddled with bugs or compatibility issues, and that’s when you’re left scrambling for a safety net.</p><p><strong>Recovery Mode<br></strong>I found myself using live CD to recover my Linux around 5 time during the year. It’s like going back in time and undoing the latest updates, hoping that it would fix the chaos.</p><p>So, the rolling release concept is a bit like playing with fire. It’s thrilling and keeps you on your toes, but there’s always that risk of getting burned. While Manjaro offers fantastic features and flexibility, it’s not for the faint of heart. If you’re looking for a more stable and predictable Linux experience, you might want to steer clear of the rolling releases. In my journey with Manjaro, I’ve had my share of ‘never again’ moments, and I’ve learned that predictability has its own charm.</p><h4>Pacman (short from “package manager”)</h4><p>When it comes to Manjaro Linux, you can’t ignore Pacman. Trust me, it’s not a video game character, but a super quick tool for managing software. It’s like the Usain Bolt of the software world, getting things done in a flash.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*me6domd7lqXZ6NpD" /></figure><p><strong>So Fast, You Won’t Believe It</strong></p><p>Pacman is incredibly fast. Whether you’re installing programs, updating your software, or handling the technical stuff, it does it all in no time. You won’t have to wait around like you do with slower software helpers like apt or dnf.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*35dEgcSEY-hAlZYj-cyjwg.png" /><figcaption><a href="https://michael.stapelberg.ch/posts/2019-08-17-linux-package-managers-are-slow/">https://michael.stapelberg.ch/posts/2019-08-17-linux-package-managers-are-slow/</a></figcaption></figure><p><strong>AUR: The Amazing Software Collection</strong></p><p>Manjaro has something cool called the Arch User Repository (AUR). It’s like a hidden treasure chest of software, and you can find almost anything you need there. If you’ve ever looked for a special piece of software that’s not in the usual places, AUR is your best friend. Having access to this fantastic resource is a big plus.</p><p><strong>The Issue with Interruptions</strong></p><p>But there’s a tiny problem with Pacman. If your software update gets interrupted, maybe due to a power cut or your computer acting up, it can be a bit tricky. It’s like trying to finish a puzzle, and then someone messes it up. After you restart your computer, you might need to do recovery from live CD to fix the OS. It made me not to trust the upgrades and be ready to use flash drive with Manjaro.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*ukrJ6CEjxLI6rTe9" /><figcaption>after pacman upgrade</figcaption></figure><h4>Conclusion</h4><p>To sum it up, my experience with Manjaro Linux had its ups and downs. Manjaro offers quick updates and a large software collection through the Arch User Repository (AUR), but the unpredictability of rolling releases and the risk of issues during updates made me to hate using it. If you like having the newest stuff and can handle some problems now and then, Manjaro is fine. But if you want a steady and dependable Linux system, you should look at other options.</p><p>BTW, after my mixed experience with Manjaro, I decided to switch to Fedora, and I’ve been using it for the past six months. I can certainly share my experience with this distribution as well.</p><p>If you are pleasured reading this article, you can subscribe. Then you can clap to make this article more popular so more people could find this article in their recommendations.</p><p><a href="https://github.com/lucky-rydar"><strong>Github</strong></a><strong> | </strong><a href="https://www.buymeacoffee.com/mykhailodidur"><strong>Buy me a coffee</strong></a><strong> | </strong><a href="https://www.linkedin.com/in/mykhailo-didur-052610202/"><strong>LinkedIn</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=18af345fd78d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ESP32 Studying Path — I2C Driver Example for AHT10]]></title>
            <link>https://towardsdev.com/esp32-studying-path-i2c-driver-example-for-aht10-48de0c2571d3?source=rss-38887a4a9ec1------2</link>
            <guid isPermaLink="false">https://medium.com/p/48de0c2571d3</guid>
            <category><![CDATA[i2c-bus-master-controller]]></category>
            <category><![CDATA[esp32-tutorial]]></category>
            <category><![CDATA[c]]></category>
            <category><![CDATA[temperature-sensor]]></category>
            <category><![CDATA[device-drivers]]></category>
            <dc:creator><![CDATA[Mykhailo Didur]]></dc:creator>
            <pubDate>Fri, 20 Oct 2023 19:36:36 GMT</pubDate>
            <atom:updated>2023-10-28T20:17:38.680Z</atom:updated>
            <content:encoded><![CDATA[<h3>ESP32 Studying Path — I2C Driver Example for AHT10</h3><p>Hello mediumers. I continue to write articles about my studying path of how to program ESP32 based device drivers.</p><p>The goal of this article is to explain how I2C bus works in general and show on example of AHT10 temperature sensor how it can be used on ESP32 for writing device drivers.</p><p>All the sources are here on Github Gists: <a href="https://gist.github.com/lucky-rydar/2f39c09dd095924b24e2a8db385e1176">link</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*Pe2rX6DYeVdeqoy8C2mMLg.jpeg" /></figure><h4>How I2C works?</h4><p>First I would start from what is the purpose of such a bus.</p><p>That is used to control devices with transferring small amounts of data. I mean such devices as temperature sensor, small display etc.</p><p>The architecture of the bus is server-client or more common name is master-slave as shown on the image belove.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/1*187-krDAiEThBbf-STChfg.png" /></figure><p>The bus considers usage of two wires: SCL and SDA. The purpose of SDA is data transferring, forward of backward. On the other hand SCL carries clock signal. Te frequency of signal depends on which speed you chose to use the bus. On the scheme there is Vdd wire with pull-up resistors that are needed to pull-up 1 to the SCL and SDA.</p><h4>Setting Up I2C on ESP32</h4><p>Before we dive into working with the AHT10 temperature sensor, we need to set up the I2C communication on the ESP32. I2C (Inter-Integrated Circuit) is a widely used protocol for connecting various peripheral devices to microcontrollers. It allows for easy and efficient data exchange between the ESP32 and external components, like sensors and displays.</p><p>To configure the ESP32 as an I2C master, you will need to define the I2C configuration settings. In the provided code sample, we have the following configuration parameters:</p><pre>i2c_config_t i2c_config = {<br>    .mode = I2C_MODE_MASTER,<br>    .sda_io_num = GPIO_NUM_21,<br>    .scl_io_num = GPIO_NUM_22,<br>    .sda_pullup_en = GPIO_PULLUP_ENABLE,<br>    .scl_pullup_en = GPIO_PULLUP_ENABLE,<br>    .master.clk_speed = 100000<br>};</pre><ul><li>mode: We set the ESP32 to operate as an I2C master.</li><li>sda_io_num and scl_io_num: These parameters specify the GPIO pins used for the SDA (data) and SCL (clock) lines, respectively. In this example, we are using GPIO_NUM_21 for SDA and GPIO_NUM_22 for SCL.</li><li>sda_pullup_en and scl_pullup_en: Enabling pull-up resistors on the SDA and SCL lines is essential for reliable I2C communication. This setting ensures that the lines are pulled high when not actively transmitting data.</li><li>master.clk_speed: This parameter determines the clock speed of the I2C bus. In this case, it&#39;s set to 100,000 Hz (100 kHz). You can adjust this value to match the requirements of your I2C devices.</li></ul><p>Once the configuration settings are defined, you need to initialize the I2C driver using the following code:</p><pre>i2c_driver_install(I2C_NUM_0, I2C_MODE_MASTER, 0, 0, 0);</pre><ul><li>I2C_NUM_0: This specifies the I2C port to be used. You can use different ports (0 or 1) on your ESP32, depending on your hardware setup.</li><li>I2C_MODE_MASTER: This parameter ensures that the I2C driver is set up for master mode.</li><li>The last three arguments can be left as 0 for default settings.</li></ul><p>With the I2C configuration and initialization in place, your ESP32 is ready to communicate with I2C devices such as the AHT10 temperature sensor. This step is crucial for establishing a stable connection between the ESP32 and the sensor, enabling data exchange and sensor control.</p><h4>AHT10 Temperature Sensor Overview</h4><p>The AHT10 temperature sensor relies on specific commands to perform actions such as initialization, measurement, and soft reset. Below are the command set implementations used for the AHT10 sensor:</p><pre>#define AHT10_INIT_CMD 0xE1<br>#define AHT10_MEASURE_CMD 0xAC<br>#define AHT10_SOFT_RESET_CMD 0xBA</pre><ul><li>AHT10_INIT_CMD (0xE1): This command initializes the AHT10 sensor, preparing it for measurement.</li><li>AHT10_MEASURE_CMD (0xAC): When sent to the sensor, this command triggers a measurement, causing the AHT10 to read temperature and humidity data.</li><li>AHT10_SOFT_RESET_CMD (0xBA): The soft reset command allows you to restart the AHT10 sensor without cutting power, ensuring that it returns to a known state.</li></ul><p>These commands are essential for interacting with the AHT10 temperature sensor, enabling you to control its operation and obtain data as needed.</p><p>Once you’ve initiated a measurement using the AHT10_MEASURE_CMD command, the AHT10 sensor provides a response in the form of data. It includes 8 bits of the AHT10 state, 24 bit of relative humidity data and 24 bit of temperature. The state can be extracted due to the following table:</p><p>Bit[7] — Busy indicator — 0 or 1<br>Bit[6:5] — Working mode<br> 1. 00 Currently NOR<br> 2. 01 Currently CYC<br> 3. 1x Currently CMD<br>Bit[3] — Calibration state — 0 or 1</p><h4>I2C Read/Write Operations</h4><p>To interact with the AHT10 temperature and humidity sensor, you need to use I2C. In this part I will show how to do basic read/write operations to communicate with the device.</p><p>The code provided demonstrates a function named write_cmd that can be used to send commands to the AHT10 sensor. Let&#39;s break down how this function operates step by step.</p><pre>void write_cmd(uint8_t device_cmd) {<br>    i2c_cmd_handle_t cmd = i2c_cmd_link_create();<br>    i2c_master_start(cmd);<br>    i2c_master_write_byte(cmd, (AHT10_ADDR &lt;&lt; 1) | I2C_MASTER_WRITE, true);<br>    uint8_t data[3] = {device_cmd, 0x33, 0x00};<br>    i2c_master_write(cmd, data, 3, true);<br>    i2c_master_stop(cmd);<br>    esp_err_t err = i2c_master_cmd_begin(I2C_NUM_0, cmd, 1000 / portTICK_PERIOD_MS);<br>    if (err != ESP_OK) {<br>        ESP_LOGE(&quot;aht10&quot;, &quot;write_cmd: i2c_master_cmd_begin failed\n&quot;);<br>    }<br>    i2c_cmd_link_delete(cmd);<br>}</pre><p>Start I2C Communication:</p><p>Initialize an I2C command handle with i2c_cmd_link_create.</p><ul><li>Begin the I2C transaction by sending the start condition using i2c_master_start.</li></ul><p>Address the AHT10 Sensor:</p><ul><li>Send the AHT10 sensor’s I2C address with the write bit set using function i2c_master_write_byte (it can be used for both writing data and writing first byte with address and write bit).</li></ul><p>Send the Command and Data:</p><ul><li>Transmit the data to the AHT10 sensor, conforming to the AHT10 datasheet i2c_master_write.</li></ul><p>Conclude the Transaction:</p><ul><li>End the I2C transaction with a stop condition i2c_master_stop (stop command by specification).</li></ul><p>Execute the Command:</p><ul><li>Use i2c_master_cmd_begin to execute the command and communicate with the AHT10 sensor.</li></ul><p>You can use i2c also for reading purposes. The difference is that instead of writing data after address byte you use i2c_master_read to read the data.</p><h4>Extracting measurement data from AHT10</h4><p>First, before getting some data we need to initialize the device and and ask it to start a measurement with the following code:</p><pre>write_cmd(AHT10_INIT_CMD);<br>write_cmd(AHT10_MEASURE_CMD)</pre><p>Then you can read the data from the device and write it to a structure:</p><pre>esp_err_t err;<br><br>i2c_cmd_handle_t cmd = i2c_cmd_link_create();<br><br>err = i2c_master_start(cmd);<br>err = i2c_master_write_byte(cmd, (AHT10_ADDR &lt;&lt; 1) | I2C_MASTER_READ, true);<br><br>uint8_t read_data[AHT10_READ_DATA_SIZE] = {0};<br>err = i2c_master_read(cmd, read_data, AHT10_READ_DATA_SIZE, I2C_MASTER_ACK);<br>err = i2c_master_stop(cmd);<br><br>err = i2c_master_cmd_begin(I2C_NUM_0, cmd, 1000 / portTICK_PERIOD_MS);<br>if(err != ESP_OK) {<br>    return false;<br>}<br><br>i2c_cmd_link_delete(cmd);<br><br>ret-&gt;status.busy = aht10_is_busy(read_data[0]);<br>ret-&gt;status.mode = aht10_get_working_mode(read_data[0]);<br>ret-&gt;status.calibrated = aht10_is_calibrated(read_data[0]);<br><br><br>uint32_t humidity = 0;<br>uint32_t temperature = 0;<br><br>humidity = read_data[1];<br>humidity &lt;&lt;= 8;<br>humidity |= read_data[2];<br>humidity &lt;&lt;= 4;<br>humidity |= read_data[3] &gt;&gt; 4;<br><br>temperature = read_data[3] &amp; 0x0F;<br>temperature &lt;&lt;= 8;<br>temperature |= read_data[4];<br>temperature &lt;&lt;= 8;<br>temperature |= read_data[5];<br><br>// convert to real values<br>ret-&gt;humidity = (float)humidity * 100 / TWO_IN_20;<br>ret-&gt;temperature = (float)temperature * 200 / TWO_IN_20 - 50;</pre><p>Presented above function can be found on Github Gists <a href="https://gist.github.com/lucky-rydar/2f39c09dd095924b24e2a8db385e1176">page</a> as aht10_get_data . The function does the following steps:</p><ul><li>asks the device to measure temperature and humidity</li><li>reads all the data from a device to a byte array</li><li>first byte is written to a structure that describes a state of the device</li><li>then 24 bits are read as humidity</li><li>last 24 bits are read as temperature</li><li>convert temperature and humidity due to formulas in datasheet</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/287/1*A2t0ehXWSFiFDvmVG3aEOQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/290/1*i1YgsoJlgaAEU9c5KYEk1g.png" /></figure><h4>Demo</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/314/1*6WXpHRmQ6t0HAwHU29w-Aw.png" /></figure><p>Last 4 messages I touched the sensor with my finger so the temperature grown up. The values look pretty real as for my room environment.</p><h4>Conclusion</h4><p>In conclusion, this article provided a comprehensive guide on setting up the I2C communication on an ESP32 and interfacing with the AHT10 temperature sensor. It explained the fundamentals of I2C communication, the essential commands for the AHT10 sensor, and demonstrated how to perform basic read and write operations. The code samples and step-by-step explanations make it easier for ESP32 enthusiasts to work with such sensors, enabling them to access accurate temperature and humidity data. With this knowledge, you can embark on various projects involving ESP32-based devices and sensors with confidence. Happy coding!</p><p>If you want me to make an overview for BH1750 light sensor(<a href="https://gist.github.com/lucky-rydar/ce5017f9d1831e5b14589fbf536064a3">link to driver source</a>), then ask me about that in comments</p><p><a href="https://github.com/lucky-rydar"><strong>Github</strong></a><strong> | </strong><a href="https://www.buymeacoffee.com/mykhailodidur"><strong>Buy me a coffee</strong></a><strong> | </strong><a href="https://www.linkedin.com/in/mykhailo-didur-052610202/"><strong>LinkedIn</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=48de0c2571d3" width="1" height="1" alt=""><hr><p><a href="https://towardsdev.com/esp32-studying-path-i2c-driver-example-for-aht10-48de0c2571d3">ESP32 Studying Path — I2C Driver Example for AHT10</a> was originally published in <a href="https://towardsdev.com/">Towards Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ESP32 Studying Path — Driver for KY-023 Joystick]]></title>
            <link>https://towardsdev.com/esp32-studying-path-driver-for-ky-023-joystick-2b09a97879e8?source=rss-38887a4a9ec1------2</link>
            <guid isPermaLink="false">https://medium.com/p/2b09a97879e8</guid>
            <category><![CDATA[joystick]]></category>
            <category><![CDATA[freertos]]></category>
            <category><![CDATA[esp32]]></category>
            <category><![CDATA[espressif]]></category>
            <dc:creator><![CDATA[Mykhailo Didur]]></dc:creator>
            <pubDate>Sat, 10 Jun 2023 19:55:55 GMT</pubDate>
            <atom:updated>2023-10-28T20:17:22.269Z</atom:updated>
            <content:encoded><![CDATA[<h3>ESP32 Studying Path — Driver for KY-023 Joystick</h3><p>As a student looking to improve my skills, I am interested in creating apps based on the ESP32 microcontroller. This article is the first in a potential series where I will share my journey and what I’ve learned along the way. In this article, I’ll show you how to create a driver for the KY-023 joystick module, which is ideal for capturing user input.</p><p>The ESP32 microcontroller is perfect for IoT development because it’s low-cost and low-power. It has Wi-Fi and Bluetooth built-in, making it a popular choice.</p><p>One of the best features of the ESP32 is that it’s compatible with FreeRTOS. This is a real-time operating system for microcontrollers that simplifies the development of complex apps by providing APIs for multi-threading, sync, and memory management.</p><p>In this article, I’ll show you how to create a driver for the KY-023 joystick module. This module is ideal for capturing user input in a variety of applications. We’ll start by explaining how the joystick module works and then show you how to create a driver that can read button status and joystick position.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/1*qXD_ozT5PF_z3R4326G1HQ.jpeg" /></figure><h4>KY-023 Overview</h4><p>The KY-023 joystick module is a device that captures user input in a variety of applications. It operates more like a complex resistor with a button than an interface such as I2C or SPI. The joystick module has three input pins: 3.3V, GND, and output pins for X-axis, Y-axis, and button. These output pins are analog pins, and their output can be easily handled by the ADC (Analog to Digital Converter) on the ESP32. With this module, you can capture the position of the joystick in two dimensions and whether the button is pressed or not.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*m_HDYbczLMMAnwW8uI2-nA.png" /></figure><p>Generally, information about a device can be found in a datasheet, which provides detailed specifications for the module. In the case of the KY-023 joystick module, the datasheet provides information about the pinout, electrical characteristics, and other important details that are required for creating a driver for the module. Here is the specification for the KY-023 I used for my project: <a href="https://naylampmechatronics.com/img/cms/Datasheets/000036%20-%20datasheet%20KY-023-Joy-IT.pdf">link</a>.</p><h4>Environment Setup</h4><p>To work with the ESP32 microcontroller, I am using Manjaro Linux and the Espressif framework. The framework is simple to use on Linux because it can be downloaded even as an extension for VS Code. In my case I will install it as a console app. The Espressif framework has support of FreeRTOS, which is a real-time operating system for microcontrollers. It also includes several drivers for usage of GPIO, ADC, and interfaces such as I2C or SPI, which are very common for driver development.</p><h4>Hardware Setup</h4><p>As expected the hardware setup must include KY-023 joystick and ESP32. KY-023 is connected to 3.3V and ESP32 is connected t my laptop via USB.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*jGrrJQLZDUvqGD6F2AAbQg.jpeg" /></figure><h4>Driver Implementation</h4><p>As it was said before, KY-023 on input has 3.3V and on output there are three analog pins. The way to read their value is to use ADC(Analog to Digital Convertor) driver on ESP32.</p><p>To start working with ADC we need first configure the type of value we read. We should specify the size of value with the function <em>adc1_config_width</em> like this:</p><pre>adc1_config_width(ADC_WIDTH_BIT_12);</pre><p>In our specific case we will read 12-bit values, that means the 3.3V is equal to 4095. This config will be set to all the pins.</p><p>The next step is to choose and configure ping on the board. On the following image I have chose pins 32, 35 and 34 for reading x-axis, y-axis and button state.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/827/1*ZuQCgbLiGEMlbtmRPQs09Q.jpeg" /></figure><p>Here is the code I used to configure these pins:</p><pre>adc1_config_channel_atten(ADC1_CHANNEL_4, ADC_ATTEN_DB_12);<br>adc1_config_channel_atten(ADC1_CHANNEL_7, ADC_ATTEN_DB_12);<br>adc1_config_channel_atten(ADC1_CHANNEL_6, ADC_ATTEN_DB_12);</pre><p>There are two parameters used in the function: channel id and attenuation value. Attenuation description due to Espressif framework documentation:</p><blockquote>The default ADC full-scale voltage is 1.1 V. To read higher voltages (up to the pin maximum voltage, usually 3.3 V) requires setting &gt;0 dB signal attenuation for that ADC channel.</blockquote><p>In my case my KY-023 powered with 3.3V, so this is the maximum, minimum is 0V. So I changed attenuation to 12Db because I need digital value near the average compared to maximum in 12bit integer(as we set previously). In case of usage smaller value or even 0Db, the signal will be near the maximum value almost all the time.</p><p>The last and the simplest function is actually to read the signal from pin. It can be used like this:</p><pre>int v = adc1_get_raw(ADC1_CHANNEL_4);</pre><p>The only argument required is channel id. The result is written to ‘v’, which can be printed then.</p><h4>Demo</h4><p>I have wrote some more code to use KY-023 in the most comfortable way. The actual driver I used for the demonstration: <a href="https://gist.github.com/lucky-rydar/62afd03bccaed945408d667fd605a791">link</a>.</p><p>Well, let me show how it works.</p><p>Here the data from pins when I do not touch the joystick</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/272/1*i0KiSDRzZb-6sF84oz61pg.png" /></figure><p>X and Y is near half of 4095. In case joystick moved to left the X value gonna go to 0 as demonstrated in the following image:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/250/1*vJ9kCqXg0FKgz5CSzwbnbA.png" /></figure><p>Let’s push button with no moves on X and Y axis:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/279/1*_Hy597gW9SymE9s18jvEAA.png" /></figure><p>Looks great. The driver works as expected.</p><h4>Conclusion</h4><p>Now you understand how KY-023 works inside and how it can be monitored on ESP32 and other FreeRTOS based devices. Hope, I will continue writing articles about other devices I have: AHT10, LED display, radio transreceiver.</p><p>If you like this article, please do not forget to clap. Thanks</p><p><a href="https://github.com/lucky-rydar"><strong>Github</strong></a><strong> | </strong><a href="https://www.buymeacoffee.com/mykhailodidur"><strong>Buy me a coffee</strong></a><strong> | </strong><a href="https://www.linkedin.com/in/mykhailo-didur-052610202/"><strong>LinkedIn</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2b09a97879e8" width="1" height="1" alt=""><hr><p><a href="https://towardsdev.com/esp32-studying-path-driver-for-ky-023-joystick-2b09a97879e8">ESP32 Studying Path — Driver for KY-023 Joystick</a> was originally published in <a href="https://towardsdev.com/">Towards Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Parallel Quick Sort on C++]]></title>
            <link>https://medium.com/@lucky_rydar/parallel-quick-sort-on-c-a3526ba8b532?source=rss-38887a4a9ec1------2</link>
            <guid isPermaLink="false">https://medium.com/p/a3526ba8b532</guid>
            <category><![CDATA[quicksort]]></category>
            <category><![CDATA[c-plus-plus-language]]></category>
            <category><![CDATA[concurrency]]></category>
            <category><![CDATA[parallelization]]></category>
            <category><![CDATA[parallel-computing]]></category>
            <dc:creator><![CDATA[Mykhailo Didur]]></dc:creator>
            <pubDate>Wed, 26 Apr 2023 08:49:15 GMT</pubDate>
            <atom:updated>2023-04-26T08:51:04.004Z</atom:updated>
            <content:encoded><![CDATA[<p>Hey there fellow coders! Are you tired of waiting for your sorting algorithms to finish executing on large datasets? Well, have no fear because parallel algorithms are here! In this article, we’ll be diving into the world of parallel quicksort in C++. We’ll explore how parallel algorithms can significantly speed up our sorting processes and create lightning-fast applications. So buckle up and get ready to optimize your code like a pro!</p><h4>Why that is important?</h4><p>So why is parallel quicksort such an important topic? Well, first of all, it’s no secret that sorting large amounts of data can be a time-consuming process. By utilizing parallel algorithms, we can break down the sorting process into smaller, more manageable chunks that can be executed simultaneously. However, it’s worth noting that each algorithm requires a unique approach to parallelization. There is no one-size-fits-all solution when it comes to parallelizing algorithms, and quicksort is no exception. That’s why understanding the parallelization process for quicksort is crucial for any programmer looking to optimize their sorting algorithms.</p><h4>Sequential version of qsort</h4><p>Before we dive into the parallel version of quicksort, let’s take a look at the sequential version. Quicksort is a divide-and-conquer algorithm that works by selecting a pivot element from the array and partitioning the other elements into two sub-arrays, according to whether they are less than or greater than the pivot. The sub-arrays are then recursively sorted. This process continues until the entire array is sorted.</p><p>In terms of time complexity, the worst-case scenario for quicksort is O(n²), which occurs when the partitioning process always selects the smallest or largest element as the pivot. However, on average, quicksort has a time complexity of O(n*log n), which is faster than other sorting algorithms such as selection sort or bubble sort.</p><p>One of the main issues with the sequential version of quicksort is that it has two independent sub-tasks that must be executed in a specific order. This can lead to slow performance when sorting very large datasets. Additionally, the recursive nature of the algorithm can lead to stack overflow errors if the depth of recursion is too large.</p><p>On the diagram you can see the proof of my words:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*bIJvejLlEshkf-ehYJJlWQ.png" /></figure><p>As you can see, the subtasks are not required to be synchronized at all because they do not affect each other.</p><h4>Parallelize over std::async</h4><p>One way to parallelize quicksort is to use the std::async function in C++. This allows us to create tasks that run asynchronously in separate threads, which can significantly speed up the sorting process.</p><p>However, when we execute a large number of threads within the scope of a single algorithm, it can put a lot of strain on the operating system. This is because each thread requires its own resources, such as memory and CPU time. As a result, if we create too many threads, it can lead to resource contention and slow down the overall performance of the system. In the next example of parallelization we will se how to fix this</p><p>To address this issue, we can use a technique called fork-join parallelism. This involves dividing the work into smaller, more manageable tasks, and then executing them in parallel using multiple threads. Once all the threads have completed their work, we join the results back together to obtain the final output.</p><p>The code demonstrating how it could be implemented is below:</p><pre>template &lt;typename T, int sync_size = 10&#39;000&gt;<br>void qsort_async_util(std::vector&lt;T&gt;&amp; v, int left, int right)<br>{<br> int i = left;<br> int j = right;<br> T pivot = middle_of_three(v[left], v[(left + right) / 2], v[right]);<br><br> while (i &lt;= j)<br> {<br>  while (v[i] &lt; pivot)<br>   i++;<br>  while (v[j] &gt; pivot)<br>   j--;<br>  if (i &lt;= j)<br>  {<br>   std::swap(v[i], v[j]);<br>   i++;<br>   j--;<br>  }<br> }<br><br> std::future&lt;void&gt; left_future;<br> std::future&lt;void&gt; right_future;<br><br> if (left &lt; j)<br> {<br>  if (j - left &lt; sync_size) {<br>   qsort_async_util(v, left, j);<br>  }<br>  else {<br>   left_future = std::async(std::launch::async, [&amp;v, left, j]() { qsort_async_util(v, left, j); });<br>  }<br> }<br> if (i &lt; right)<br> {<br>  if (right - i &lt; sync_size) {<br>   qsort_async_util(v, i, right);<br>  }<br>  else {<br>   right_future = std::async(std::launch::async, [&amp;v, i, right]() { qsort_async_util(v, i, right); });<br>  }   <br> }<br><br> if (left_future.valid())<br>  left_future.wait();<br> if (right_future.valid())<br>  right_future.wait();<br>}<br><br>template &lt;typename T, int SZ = 10&#39;000&gt;<br>void qsort_async(std::vector&lt;T&gt;&amp; v)<br>{<br> qsort_async_util&lt;T, SZ&gt;(v, 0, v.size() - 1);<br>}</pre><p>As you can see from the example, each util function call sorts given piece of vector over pivot value. Then it creates two threads that do the same. The calls will be proceeded asynchronously until the size of sub-array become less than ‘sync_size’. It was implemented in a such way because it some time point resources needed to sort the sub-array will be less than than resources needed for creating thread.</p><h4>Parallelize with thread pool</h4><p>The previous code example showcased how to parallelize quicksort using the std::async function in C++, which creates tasks that run asynchronously in separate threads. However, creating too many threads can oveload the operating system and slow down performance. To address this issue, a more efficient approach is to use a thread pool instead of individual threads for each task. The thread pool creates a fixed number of threads and distributes tasks among them, which avoids resource contention and the overhead of managing many threads. For our implementation, we will use the thread pool provided by the Boost.Asio library, which can significantly improve the performance of our parallelized quicksort algorithm while avoiding resource-related issues.</p><p>Here is the code example of the implementation of quick sort that uses thread_pool:</p><pre>template &lt;typename T, int sync_size = 10&#39;000&gt;<br>void qsort_pool_util(std::vector&lt;T&gt;&amp; v, int left, int right, boost::asio::thread_pool&amp;&amp; tp) {<br> int i = left;<br> int j = right;<br> T pivot = middle_of_three(v[left], v[(left + right) / 2], v[right]);<br><br> while (i &lt;= j) {<br>  while (v[i] &lt; pivot)<br>   i++;<br>  while (v[j] &gt; pivot)<br>   j--;<br>  if (i &lt;= j) {<br>   std::swap(v[i], v[j]);<br>   i++;<br>   j--;<br>  }<br> }<br><br> if (left &lt; j) {<br>  if (j - left &lt; sync_size) {<br>   qsort_pool_util(v, left, j, std::move(tp));<br>  }<br>  else {<br>   boost::asio::post(tp, [&amp;v, left, j, &amp;tp]() { qsort_pool_util(v, left, j, std::move(tp)); });<br>  }<br> }<br> if (i &lt; right) {<br>  if (right - i &lt; sync_size) {<br>   qsort_pool_util(v, i, right, std::move(tp));<br>  }<br>  else {<br>   boost::asio::post(tp, [&amp;v, i, right, &amp;tp]() { qsort_pool_util(v, i, right, std::move(tp)); });<br>  }<br> }<br>}<br><br>template &lt;typename T, int SZ = 10&#39;000&gt;<br>void qsort_pool(std::vector&lt;T&gt;&amp; v) {<br> boost::asio::thread_pool tp(std::thread::hardware_concurrency());<br> qsort_pool_util(v, 0, v.size() - 1, std::move(tp));<br> tp.join();<br>}</pre><p>What is general difference? The first one is that we do not wait forked tasks, but just push them into the thread pool that is used on per algorithm call. I have tried using it like it could be implemented in Java with the help of ForkJoinFramework to join tasks, but actually it didn’t work because all the threads was busy by several tasks that were waiting for other that was pushed and were waiting for that ones which were running in threads right now. It was kind of dead lock that we should avoid. So, as all the tasks calls can be ran asynchronously in the same queue as pushed, I do not wait them to execute, but wait for all tasks to be executed in root quick sort.</p><p>The implementation with thread pool improved performance of the algorithm compared to use std::async average on 11% that I think is amazing result.</p><h4>Performance table</h4><p>On the table below it is demonstrated how much time it takes to do a quick sort where it is compared sequential version and two parallel that are described in the article. On my 6 cores 12 threads i7–8750h average boost for ‘std::async qsort’ is 4,07 to 4,42 depending on ‘sync size’ and actual array size. As for ‘pool’ implementation, the performance is around 4,53 to 4,99 that is average 11% faster than previous version.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KGBarVkMrhJkTCC_.png" /></figure><h4>Repo</h4><p>The project is hosted on github so you can check it by your own:<br><a href="https://github.com/lucky-rydar/tpo-cw">https://github.com/lucky-rydar/tpo-cw</a></p><h4>Conclusion</h4><p>So, during the article it was described two ways of how we can implement parallel version of such a common algorithm as Quick sort on C++. It was demonstrated the results of performance test that shown actual boost of using thread pool compared to std::async and other unmanaged ways to use threads.</p><p>Hope, this article was interesting and useful for you. If you like my work, make sure you are following me on Medium and you will not skip new articles and posts. Do not forget to clap if you are reading this, it motivates me to write more about interesting things in programming world.</p><p><a href="https://github.com/lucky-rydar"><strong>Github</strong></a><strong> | </strong><a href="https://www.buymeacoffee.com/mykhailodidur"><strong>Buy me a coffee</strong></a><strong> | </strong><a href="https://www.linkedin.com/in/mykhailo-didur-052610202/"><strong>LinkedIn</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a3526ba8b532" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Road Map to Become a Junior Software Engineer from Zero in a Year]]></title>
            <link>https://medium.com/@lucky_rydar/road-map-to-become-a-junior-software-engineer-from-zero-in-a-year-1df7af6ee69f?source=rss-38887a4a9ec1------2</link>
            <guid isPermaLink="false">https://medium.com/p/1df7af6ee69f</guid>
            <category><![CDATA[c-plus-plus-language]]></category>
            <category><![CDATA[roadmaps]]></category>
            <category><![CDATA[studying]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[self-improvement]]></category>
            <dc:creator><![CDATA[Mykhailo Didur]]></dc:creator>
            <pubDate>Sat, 15 Apr 2023 20:54:58 GMT</pubDate>
            <atom:updated>2023-10-20T21:04:53.888Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6m4ZZkeow24G9o8j" /><figcaption>Photo by <a href="https://unsplash.com/@arttravelling?utm_source=medium&amp;utm_medium=referral">oxana v</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Hi! in this article I am going to show you the road map of how to become a junior software engineer. The first steps are the hardest ones because you haven’t learned how to study, what you are interested in the most in programming and so on. In this article I am going to help you to start fast as a newbie software engineer.</p><h4>Intro</h4><p>This article is mainly based on my own experience. You can check that on my LinkedIn profile there are only around 2 years of experience as a software engineer. But, to get the first job offer I spent a few less than 3 years of self development. You should know that I started doing programming as a 14 y.o. guy. The studying I did was not really regular and structured, it was rather interesting and unusual hobby than something serious. There were no thoughts about 300kk$ per nanosecond.</p><p>Now, I see that these three years of learning coding and programming could be spent much more efficient than it actually was. So, in this article I will tell you how to learn coding faster.</p><h4>Step Zero</h4><p>On this step I assume you are absolute zero in programming. You know that there are some programming languages that help us to make computer do what you want and that is it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*63PlaAO8f6lqqgie" /><figcaption>Photo by <a href="https://unsplash.com/@longphan?utm_source=medium&amp;utm_medium=referral">Long Phan</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>First you need to choose which programming language you gonna use. Actually, on the first steps it does not matter because for studying you can use whatever you want. Keep in mind that the programming language is a tool, you do not merry it. But I really recommend you to use C/C++ because it has really massive legacy part(mainly for C) that would allow you to use any library you need for your project. On the other hand, with modern C++ you will be able to contribute into projects that are in demand on the market. About types of the projects later in this article.</p><p>In the next paragraphs this article gonna explain how to become a software engineer based specifically on C/C++ as an example. If you are interested in programming of websites or mobile development, the road map must be extended specifically for you.</p><h4>Basic Language Usage</h4><p>First of all you need to learn very basic interface of the programming language you chose. I mean such a basic statements as function, variable, if else, while, classes, pointers, lambdas, directives, templates etc. I used for that <a href="https://www.sololearn.com/">Sololearn</a>, that is the service that have small courses about many programming languages. It has a list of lessons for each programming language about features they have. I would recommend you to complete the course about C and C++ or just the last one. Do not be shy and try to use learned basics in Visual Studio on your own PC. If you do not understand what you are doing, feel free to google what you are interested in. !!! Do not underestimate asking your own questions on S<a href="https://stackoverflow.com/">tackoverflow</a>.</p><h4>Problem Solving</h4><p>After getting some practices with basic language structures you can write some useless pieces of code that can be explained as a code that does not do something useful.</p><p>The next step of your adventure is to learn how to solve the problem. It is very important not just to code, but to find the fastest and cheapest problem resolution. For training yourself in this sphere I can propose you such a services as <a href="https://leetcode.com/">LeetCode</a> or <a href="https://www.codewars.com/">Corewars</a>. I used Codewars mostly, so I will tell you how it works in scope of this service. Well, you have a profile with your rating. On the page with tasks you can find problems for resolving which you get some points to your rating. Also you can check how other developers solved the same problem, pay attention to the problems that are resolved with the least amount of code, usually that is the smartest ways to solve the task.</p><ul><li><a href="https://leetcode.com/">LeetCode - The World&#39;s Leading Online Programming Learning Platform</a></li><li><a href="https://www.codewars.com/dashboard">Codewars - Achieve mastery through coding practice and developer mentorship</a></li></ul><p>Such a services as LeetCode are used by programmers to get prepared for interview in FAANG(big tech) companies. So, remember this tools, it will help you to get first job offer.</p><h4>Algorithms and Data Structures</h4><p>While working on tasks on the web sites provided in the previous paragraph at some time you will get tasks associated with complex <strong><em>algorithms and data structures</em></strong><em> </em>such as <em>std::list(linked list)</em>, <em>std::vector</em>, <em>std::map(binary tree)</em>, <em>std::unordered_map(hashtable)</em>, <em>std::stack</em>, <em>std::queue</em> etc. As for algorithms, most known and used are <em>std::find </em>and <em>std::sort</em>.<em> </em>Here you need to run deeper into theory, I guess, there is no interview where you will not be asked about how these things work, so I would recommend you to read the book that will be attached below and of course implement all of them.</p><p><a href="https://www.amazon.com/Grokking-Algorithms-illustrated-programmers-curious/dp/1617292230">Grokking Algorithms: An Illustrated Guide for Programmers and Other Curious People</a></p><p>In the book provided above you will receive basic knowledge about <strong><em>algorithms and data structures</em></strong>, why they are such an important thing for modern and professional programmers. In general, this book will introduce you to big O notation and how to make your program work faster with a specific mechanisms.</p><h4>Discrete Math(very optional)</h4><p>I would call it deeper dive into a nature of algorithms and data structures. Usually, such a discipline is taught in university, but if you do not have a high degree in software engineering or similar you can search for some courses about this theme on Coursera, Edx etc. The following course looks good to start with:</p><p><a href="https://www.coursera.org/specializations/discrete-mathematics">Introduction to Discrete Mathematics for Computer Science</a></p><p>Ideally, you are required to get knowledge about a graph, tree, searching methods in a graph like BFS, DFS, A* and a state machine.</p><h4>Deeper into Computer Science</h4><p>In my opinion one of the most valuable things to understand is how your operating system works. I mean all the parts: scheduler, file system, memory management module, drivers, networking and others. For this purpose I would recommend you to read books of Andrew S. Tanenbaum, who is creator of Unix-like operating system called <strong>Minix</strong>.</p><p>The book about OS development history, architecture and purpose of such a systems:</p><p><a href="https://www.amazon.com/Modern-Operating-Systems-Andrew-Tanenbaum/dp/013359162X">Modern Operating Systems</a></p><p>It is useful to know how networking works, I would recommend also a book of Tanenbaum:</p><p><a href="https://www.amazon.com/Computer-Networks-5th-Andrew-Tanenbaum/dp/0132126958">Computer Networks 5th By Andrew S. Tanenbaum (International Economy Edition)</a></p><p>Natalia and Viktor Olifers book about networking:</p><p><a href="https://www.amazon.com/Computer-Networks-Principles-Technologies-Protocols/dp/0470869828">Computer Networks: Principles, Technologies and Protocols for Network Design</a></p><h4>Not C/C++ Technical Skills</h4><p>Except of knowing how to use a programming language you need to have some related skills like the following: Linux as for the user, command line interface, Bash, Python, Git, Sql, Docker, Make, CMake. That is a very minimum for starting your first job as a software engineer.</p><h4>Libraries and Frameworks</h4><p>Generally there is a big platform for C++ called <strong><em>Qt</em></strong> that allows you to make desktop application, GUI, work with networking easily and so on.</p><p>As for useful libraries I suggest you to check Boost. As you know raw C++ doesn’t have too many features. Boost libraries extends a lot functionality of the language. Most known lib is Boost.Asio for working with networking. Some of libraries becomes a part of C++ standard, so you can be sure that they can be trusted.</p><p>Also you can find some libraries for C++ on the following page:</p><p><a href="https://en.cppreference.com/w/cpp/links/libs">A list of open source C++ libraries</a></p><p>CppReference is a resource that provides you all the information about C++ even for different versions of standards and various implemetations of compilers.</p><h4>Start a Pet Project</h4><p>I have an article about how building your own ‘X’ can improve your skills significantly. Use the link to read it:</p><p><a href="https://medium.com/@lucky_rydar/mastering-programming-through-diy-how-building-your-own-x-can-teach-you-valuable-skills-de345ee3b19d">Mastering programming through DIY: How building your own ‘X’ can teach you valuable skills</a></p><p>It is not necessary to create something existing. I hope at this stage you have enough experience to create some application that can be used right now as calculator, task manager and others.</p><h4>Programming for Making Money</h4><p>It could be a surprise for you, but actual work is much different from the style of programming I have already provided in this article. I would say coding and programming are different things.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*IKU3tZjLpFabbpN5N1Y1bQ.jpeg" /></figure><p>Several things that you are required to be prepared for on a real work are: requirements, testing, CI/CD or common name for all of them is software development life cycle. I am going to explain each.</p><p>I would start with requirements, because in commercial programming everything you do is done because you customer wants so. Generally you need to know that there are business analytics or product owners which ask you to do something. Their requirements can be displayed as a document that describes how developing software should act in a different cases and what functionality it is required to be implemented.</p><p>Next point is testing. We have a lot of ways to check if the requirements were met with the help of testing. I will show a small example of how it works with QA engineer. After requirements elicitation QA read and analyse it to understand how resulted implementation can be tested. After some thinking he or she writes a list of <em>test cases</em> that should be passed. From time to time QA executing these test cases manually or automatically(if there is an automation) and let developers know what is wrong with the product. As a developer you also must know how to write unit or integration tests because as a junior level engineer you will have a lot of experience with them.</p><p>Testing types:</p><p><a href="https://www.perfecto.io/resources/types-of-testing">The Complete Guide to Different Types of Testing | Perfecto by Perforce</a></p><p>CI/CD can be interpreted as continuous integration and deployment. That is a kind of automation that helps programmers to deliver their products automatically. In the best case it happens without human participation. For example, you have a website. After each new feature implemented it passes tests on CI/CD and is deployed on a specific machine in production to make it accessible for users. As a a software engineer you will have an experience with docker that is one of the most used in containered deployment.</p><h4>Software Engineer but not an ‘X’ framework developer</h4><p>During self development keep in mind that you are a software engineer. Be ready to solve the task you are not studied for. Each time you solve such one you are getting better. Feel free to discover something new for you in my articles.</p><h4>Summary</h4><p>This article described the hole path ‘from zero to hero’. I hope that in a result of this article you have got a job of dream as a software engineer.</p><p>If you like my work make sure you are followed to not skip my next articles. I have spent really a lot of time to write this article, so do not forget to clap 👏 to support me. Thanks</p><h4>Mentoring(advertising of me)</h4><p>I want to propose you my mentoring and in exchange you can support me on buy me a coffee:</p><p><a href="https://www.buymeacoffee.com/mykhailodidur/e/130133">Mentoring</a></p><p><a href="https://github.com/lucky-rydar"><strong>Github</strong></a><strong> | </strong><a href="https://www.buymeacoffee.com/mykhailodidur"><strong>Buy me a coffee</strong></a><strong> | </strong><a href="https://www.linkedin.com/in/mykhailo-didur-052610202/"><strong>LinkedIn</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1df7af6ee69f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Blockchain identification overview: How you own your crypto-money?]]></title>
            <link>https://towardsdev.com/blockchain-identification-overview-how-you-own-your-crypto-money-396cf5017bd4?source=rss-38887a4a9ec1------2</link>
            <guid isPermaLink="false">https://medium.com/p/396cf5017bd4</guid>
            <category><![CDATA[identification]]></category>
            <category><![CDATA[rsa]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[bitcoin]]></category>
            <dc:creator><![CDATA[Mykhailo Didur]]></dc:creator>
            <pubDate>Wed, 12 Apr 2023 19:20:18 GMT</pubDate>
            <atom:updated>2023-11-06T18:42:00.232Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi! As you know, cryptocurrency is pretty known in dark side of the internet and a lot of the bitcoin capital centralized in illegal business. Why is that so popular among criminals? — because the system allows you to be anonymous. But how you can own money in the distributed system and do not share your personal data? In this article I am going to tell you how bitcoin authorization works.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/739/1*qvxAee3vGmdm9KK3YNE1VQ.jpeg" /></figure><h4>Classical banking</h4><p>Let me start with showing how classical banking works in general. In a bank you cant own an account without sharing your personal information with the bank. All the operations are monitored and controlled by the bank. It has too much power, isn’t it? Here is the diagram that describes relations of bank with it’s clients:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/234/1*GMJoynIvonCd9eP9uZux6w.jpeg" /></figure><p>Each client of the bank uses it as trusted mediator that owns money and all of your information. It is mostly known for most of you, so I will not continue explainig.</p><h4>Decentralized banking</h4><p>I would call any kind of crytocurrency as decentralized banking. So, as for that, in such a system each user is a copy of the bank(it can be called as peer). Here is a diagram of relations between users:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/274/1*hGuofQ74RMl8V5S_OvhejQ.jpeg" /></figure><p>All of them can do transactions and other keep the history of them. But where is trusted authority that can approve that actually this person can do some operation? The system required a mechanism that would allow the users to ‘sign’ operations. The most popular way to solve such a problem is <strong>asymmetric encryption</strong>. Most popular algorithm of such an encryption is RSA. I suppose you know how RSA works in genereal, but for those who don’t you will explain in general.</p><h4><strong>Asymmetric encryption</strong></h4><p>The idea of the algorithm is to use two keys: public and private. The keys can be generated with such an utility as ssh-keygen on Linux. Both public and private keys can be used to encrypt or decrypt data. Encrypting data with public key and decrypting with private is mostly used in messengers or any other applications where the data must be hiden from public.</p><p>Reverse usage of keys is used for making signatures. Imagine you wanna do a transaction in the blockchain network without mining(it is not used for user verification). The transaction data would include sender id(as your public key) and receiver id(also public key). Also it includes the anount of money you want to send. The message we got must be hashed with sha256 or something. Then received hash must be encrypted with your private key, the signature will be attached to your transaction data. As a result we have such a structure of our transaction:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/442/1*k5Z3qpu7LooUUQfaE0nHbA.jpeg" /></figure><p>After ‘send’ button is pushed, other peers will receive the message. Now, how other people would verify the legality of the operation. They do the hash operation with sha256 as we chose for our blockchain, do the encryption of signature with public key attached as sender id and compare got hashes(the must be equal). Usually in such a big systems as bitcoin it is not necessary to get approve from all the peers, that is okey to get it from 10–20 other users.</p><p>The operation is approved and has been pushed to the end of blockchain after mining as a block. Now you paid for your coffee and can enjoy it)).</p><h4>The end</h4><p>You also can <a href="https://www.buymeacoffee.com/mykhailodidur">pay for my coffee</a>. Hope you found my article interesting and useful. Do not forget to clap if you like my work, it makes me motivated to continue telling people something interesting. Thanks for your attention, bye</p><p><a href="https://github.com/lucky-rydar"><strong>Github</strong></a><strong> | </strong><a href="https://www.buymeacoffee.com/mykhailodidur"><strong>Buy me a coffee</strong></a><strong> | </strong><a href="https://www.linkedin.com/in/mykhailo-didur-052610202/"><strong>LinkedIn</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=396cf5017bd4" width="1" height="1" alt=""><hr><p><a href="https://towardsdev.com/blockchain-identification-overview-how-you-own-your-crypto-money-396cf5017bd4">Blockchain identification overview: How you own your crypto-money?</a> was originally published in <a href="https://towardsdev.com/">Towards Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>