<?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 Ilia Emprove on Medium]]></title>
        <description><![CDATA[Stories by Ilia Emprove on Medium]]></description>
        <link>https://medium.com/@emprovedev?source=rss-f508572db32c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*_JCezMytcx8jYQNInO0zrg.jpeg</url>
            <title>Stories by Ilia Emprove on Medium</title>
            <link>https://medium.com/@emprovedev?source=rss-f508572db32c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 20:25:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@emprovedev/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[Built 3D browser game and Survived]]></title>
            <link>https://medium.com/@emprovedev/built-3d-browser-game-and-survived-a386a4f9f340?source=rss-f508572db32c------2</link>
            <guid isPermaLink="false">https://medium.com/p/a386a4f9f340</guid>
            <category><![CDATA[game-development]]></category>
            <dc:creator><![CDATA[Ilia Emprove]]></dc:creator>
            <pubDate>Sun, 15 Jun 2025 19:18:27 GMT</pubDate>
            <atom:updated>2025-06-23T08:56:14.585Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dYP6l0rZh9k7NXTy4Ku6rQ.png" /></figure><p>I decided to make a mini-game for my nephew as a birthday present. I have a good understanding of 3D modeling, audio processing (I was into music at university) and, of course, programming in browsers. So I didn’t think long, I chose <strong>BabylonJs</strong>, there is support for the <strong>Havok </strong>physics engine. Before that, I already had experience with the framework and some FPS developments. I’ll tell you about the process and the difficulties I encountered. The whole project took about a <strong>month of work</strong> in the evenings and mornings.</p><p><strong>Play online:</strong> <a href="https://emprove.dev/rdn/">https://emprove.dev/rdn/</a></p><h3>Character controller</h3><p>I used a <strong>physics engine</strong> for walking, jumping. Wrote my <strong>own controller</strong>. BJS has a third-party solution <a href="https://doc.babylonjs.com/features/featuresDeepDive/physics/characterController/">https://doc.babylonjs.com/features/featuresDeepDive/physics/characterController/</a>, perhaps if you decide to try making your own game, you should pay attention to this solution. I was interested in understanding how the control works, because in all games the control logic on the physics engine is approximately the same. Namely, there are test rays that determine on what surface the player is (ground ray) or whether he can grab an object (target ray). Movement can be implemented either by impulses (more “lazy” control) or linearVelocity, if maximum control is needed. I went for the linearVelocity option, because it is the most common.</p><h3>3D models and scene</h3><p>First for all, I spent <strong>several days on stocks</strong> trying to download some low-poly appropriate stuff. No luck. <strong>Model by your own</strong> (low-poly!) is better quality, right what you need and faster.</p><p>I did the entire scene and 3D modeling in Blender. <strong>BJS has a GLB format importer</strong>, which is exported directly from Blender, I’ll tell you about the difficulties a little later.</p><p>I’m surprised <strong>how well it works</strong>. BJS supports automatic InstancedMesh. In Blender, you just need to copy the mesh as an instance and it will automatically enter the engine as InstancedMesh.</p><p>Textures, materials, animations and even lights— <strong>all this</strong> can be set up in Blender.</p><p><strong>3D modeling took me at least 50%</strong> of the entire development time. Of course, this greatly depends on skill, <strong>I had to learn a lot in parallel</strong> with coding.</p><p>It is very important to<strong> immediately decide on the style of graphics</strong>, make sketches and a library of basic models. Otherwise, you, like me, will <strong>get lost on this x2 x3 time</strong>, when you have to constantly redo something. It is not always possible to do everything well in advance, because at least there is no understanding of how to produce a good frame time later.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UBoU_Xtbo9pzWIL4ekCYmQ.jpeg" /></figure><p>I tried <strong>AI mesh generation</strong>. It’s suitable for sculpts. The <strong>quality </strong>of the generated complex or geometric meshes is <strong>unacceptable</strong>. Anyway, it is still require <strong>additional manual steps</strong> like Decimate modifier in Blender to cut down from 100k polygons to 3–5. <strong>Texture generation is useless</strong> because all AI can’t draw delighted textures. Substance 3D sampler has “delighting” filter which works great (using AI under the hood) but overall result is poor.</p><h3>Coding</h3><p><strong>Respect </strong>to the <strong>BabylonJS </strong>community. I first got acquainted with version 4.0 with this engine. All the developments were <strong>painlessly transferred</strong> to version 8.9.0. Can you imagine that 4 major releases passed almost unnoticed, nothing broke? With threejs, such a miracle will definitely not happen.</p><p>The project supports the ability to teleport through prepared scenes. You can walk through loading screens or select scenes in main menu if there are &gt;= 2 of them.</p><p>Building via <strong>ViteJS</strong>. There is <strong>PWA support</strong>.</p><p>Network resources size (<strong>gzip</strong>):<br>Init engine ~1.0 MB<br>Total with loaded scene ~3.9 MB</p><p>With brotli it would be even less. But i didn’t enable it.</p><h3>Sound design</h3><p>Of course, first of all, I <strong>went to the stocks</strong>. After a couple of hours of picking <strong>through the trash</strong>, I realized that in my case for simple sounds it is much easier, faster and better to record all the sounds myself. I recorded the sounds of nature on a mobile phone voice recorder in the forest, I achieved the creaking of the door at home in humid weather. Some effects were recorded on a kalimba. Other effects were also recorded using improvised objects. I used StudioOne and condenser microphone. Mp3 variable bitrate saves a lot on traffic.</p><h3>Difficulties</h3><h4>Blender -&gt; GLB coordinate system</h4><p>BJS and GLB/Blender use different coordinate systems and a simple “+Y up” checkbox before exporting to GLB is not enough.</p><p>To work normally with imported meshes, you need to get rid of the __root__ node, which makes scale *= -1, i.e. mirrors by one coordinate. But with animations, object capture and working with transformation matrices in general (position, rotation) it becomes unbearable. To fix it, you need to do the following:</p><pre>// fix gltf to bjs coordinate system<br>const rootNode = scene.getNodeByName(&quot;__root__&quot;);<br>rootNode.getChildren().forEach((m) =&gt; {<br>(m as Mesh).setParent(null);<br>});<br>rootNode.dispose();</pre><p>Unfortunately, I have not found a better solution. Maybe you can tell me.</p><h4>Cross-browser</h4><p>For example, in Firefox I have not yet been able to fix the control problems on mobile devices — a problem with pointer events. <strong>In some browsers, something works wrong in small ways</strong>. I have not tested it very widely, only the latest versions of the main browsers: Opera, Chrome, Brave, Firefox, X browser. And desktop and mobile browsers can also differ greatly.</p><p>In general, it is <strong>quite expensive to support desktop and mobile at the same time</strong>. This is why I do not like heavy-browser-development. Of coarse, there are BrowserStack, Lambdatest, etc. I don’t have a goal to support all browsers and platforms — this is a hobby project.</p><h4>Asynchronous</h4><p>In terms of asynchronous JS (TS), it can be difficult to work. If you forget to await somewhere, you will get vague errors. That is, the code does not wait for something and that’s it, the problem. <strong>Maybe it’s a skill issue</strong>, I guess. You will be mostly right. But it’s like with html and css: no matter how skilled you are, you have to switch to the browser 100 times to check if everything is displayed correctly.</p><h4>Player controller</h4><p><strong>Rewrote many times</strong>. It can be improved endlessly. Above I gave a link to the controller from the Havok team, perhaps you should immediately consider it, and not write your own, like me. But I did it out of curiosity.</p><h4>Deterministic Lockstep</h4><p>Had to <strong>abandon Deterministic Lockstep</strong>. In the browser, <strong>requestAnimationFrame()</strong> is always called with the monitor refresh rate. For me it is 144Hz. And it turns out that if you set lockstep 1/60, then with a probability of &gt; 50% you will have a desynchronization of the monitor refresh rate and the physics engine simulation. It looks like 60 FPS is drawing you 20, although in fact the engine shows 60 FPS. <strong>The gameplay becomes jerky</strong>. For example, Apex Legends uses 20Hz physics simulation. Gamedevs, tell me how this problem is solved in “adult” engines?</p><p>I tried to make <strong>my own accumulator (deltaT)</strong>, and not use the built-in one. Interpolate visuals of the player’s movements based on frame time and perform the physical step manually. On my mobile with <strong>freezes and unstable FPS it only got worse</strong>, in addition, unresponsive, wadded controls were added.</p><p><strong>Too many turbulence:</strong> variable frame time, monitor Hz, physics engine Hz, and also prediction for several steps (“substeps” engine option). In general, I did not manage it.</p><h4>Stators, friezes</h4><p>I still couldn’t optimize the game so that the frame time was stable on my mobile, Snapdragon 695. Perhaps this CPU just can’t handle even such simple graphics. So this lead us to the next huge section: <strong>optimization</strong>.</p><h3>Optimization</h3><h4>Webp</h4><p>Saves well on texture weight, and accordingly on GPU memory. I recompressed all textures and images from jpg to webp. For sure compressed all png.</p><h4>Texture Atlas</h4><p>For game cards, I made <strong>one texture</strong> and cut UV in runtime. I had to manually adjust it to the card grid, because I couldn’t find a normal texture atlas png on the Internet. Either the grid is crooked, or the quality is wrong, or there is no transparent layer, or it weighs too much, etc.</p><h4>HDR vs Cubemaps</h4><p>HDR are quite heavy, they are not very easy to get for specific needs, relatively recognizable rendering/lighting style. That’s why I <strong>rendered the skybox myself in Blender</strong> and then <strong>sliced ​​it into a cubemap</strong> using some third-party web tool.</p><h4>MaxFPS</h4><p>On a local network, the engine eats up 100% of the CPU and you can fry eggs if you don’t limit it by frames. This is done like this: <strong>engine.maxFPS = 60</strong>. Thanks to the engine for this option.</p><h4>Draw Calls</h4><p>A draw call occurs when materials and a mesh are submitted to the GPU for drawing. At he beginning of optimization <strong>I had 550 DC</strong>, which I managed to <strong>drop to 70–80</strong>. This includes the MeshMerging technique and the refusal of real-time shadows and much, much more.</p><h4>Shadows</h4><p>I had to <strong>refuse dynamic shadows</strong> (from clouds), because they <strong>ate too many draw calls</strong>. The number of DCs was immediately multiplied by 3, from 100 to 300. They consume a lot of resources. There is a hack in the form of creating two light sources: dynamic shadows (clouds and other objects) and separate ShadowGenerator for static objects. But there is a problem… shadows overlap each other so that at the intersection they are 2 times darker. There is a solution in the form of a custom shader that excludes pixels of the second shadow, which already has a shadow. But these are all crutches in my opinion. I did not manage it, in general.</p><p>What I did. <strong>Baking shadows</strong> when the whole scene loaded:</p><pre>shadowGenerator.getShadowMap().refreshRate = RenderTargetTexture.REFRESHRATE_RENDER_ONCE;<br>sunLight.autoUpdateExtends = false;</pre><p>REFRESHRATE_RENDER_ONEVERYTWOFRAMES, for example, gives CPU spikes, which manifests itself in ragged gameplay. Because shadows are rendered every second frame.</p><h4>Instances</h4><p>Instances are a basic optimization technic, since they allow you to draw a bunch of identical meshes in <strong>1 Draw Call</strong>. For example, for mobile games, it is advisable to <strong>keep DCs up to 100</strong>.</p><p>It should be noted that changing the scale of one instance immediately adds +1 DC on top, because for the GPU it becomes 2 different objects. Position, rotation can be freely used.</p><h4>Thin instances</h4><p>It will not be possible to import automatically, but I tried to dispose all instances and resaw them in runtime to Thin instances. This works well, but when you have dozens of mesh types that require different settings (shadow casting, physics, collisions), including different optimizations, then it will not be possible to describe all this in one enumeration. Also ThinInstance has a variety of limitations: <a href="https://doc.babylonjs.com/features/featuresDeepDive/mesh/copies/thinInstances#support">https://doc.babylonjs.com/features/featuresDeepDive/mesh/copies/thinInstances#support</a>.</p><h4>LOD (Level of Detail)</h4><p>Easily implemented in the engine, but it becomes more work in the 3D editor.</p><h4>WebGPU</h4><p>I have a git branch where I switched the engine from WebGL2 to WebGPU. WebGPU even <strong>works surprisingly well in BJS</strong>. I spent a couple of days tinkering with bugs and it was even bearable. But still, <strong>a lot of warnings and errors poured into the console</strong>. Unfortunately, I didn’t have the desire and time to fix this. WebGPU is still too raw. What will happen in Safari is scary.</p><p>Summary: <strong>cross-browser + cross-platform + WebGPU = hell</strong>.</p><h4>Draco Decoder</h4><p>The scene file without compression weighs 4 MB, with compression 1.5 MB.</p><h4>Tree-shaking</h4><p>Doesn’t always work, something has to be imported by force.</p><h4>Physics issues</h4><p>I spent several days trying to figure out why the player sometimes fell into textures at startup. I blamed bugs in the WASM implementation of the physics engine. It turned out that the <strong>bug was specific</strong> to mobile Chrome version 131. I didn’t really check it on other browsers, because it was difficult due to the floating problem, and mobile debugging via cable was configured only in Chrome. Deploying blindly every time was not successful. On the desktop, everything was ok.</p><p>These are just the main difficulties I encountered.<strong> In addition, there were 100500 other troubles.</strong></p><h3>Game UI</h3><p>Interfaces can be made in html, some React / Vue / Svelte. But then you will not have VR / XR support (<a href="https://doc.babylonjs.com/features/featuresDeepDive/gui/#comparison-of-gui-options">https://doc.babylonjs.com/features/featuresDeepDive/gui/#comparison-of-gui-options</a>). In the future, I want to experiment with VR, so I made it on 3D GUI right away. Making interfaces on Babylon 3D GUI is not that easy. They have <a href="https://doc.babylonjs.com/toolsAndResources/guiEditor">https://doc.babylonjs.com/toolsAndResources/guiEditor</a>, but I haven’t tried it yet.</p><h3>Main menu / Playable scene switching</h3><p>I used an approach that consists of creating <strong>two scenes that are rendered as needed</strong>. Each scene has its own camera.</p><h3>Coloring</h3><p>The engine has color curves, but they will not provide high-quality coloring. By default, the picture is faded, gamma 2.2. Therefore, you will have to color in any case. It’s good that Photoshop has the ability to export adjustment layers to <strong>LUT</strong> color tables. This is another +100 kb on average as the weight of a <strong>.3dl</strong> file.</p><h3>Night mode</h3><p>I got the idea that there should be <strong>smooth change (animated) </strong>of day to night in the final scene, so that it would be cozy and the fireworks would be visible. <strong>It took me a week</strong>, because it turned out that changing the time of day is a very expensive matter. I had to adjust all the materials, textures, sounds, lighting. There are <strong>many specific points</strong>, such as the fact that PBRMaterial by default has maxSimultaneousLights up to 5 pcs and for a long time I could not understand why there was no lighting from some lights.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SM-BMOmNmoHeyyoGOR-ddg.png" /></figure><h3>Networking model (bonus)</h3><p>Someday I will definitely write a game with network support and will have to enable lockstep. The topic of synchronizing the game world with physics can be read in a good article: <a href="https://mas-bandwidth.com/choosing-the-right-network-model-for-your-multiplayer-game/">https://mas-bandwidth.com/choosing-the-right-network-model-for-your-multiplayer-game/</a>.</p><h3>Android build (bonus)</h3><p>I tried to build for Android using <strong>Tauri </strong>(<a href="https://v2.tauri.app/">https://v2.tauri.app/</a>). Out of the box app weights 45 MB (extra 41 MB compared to web). Tauri was interesting in terms of performance because it uses native OS WebView for rendering and not relying on a browser. Unfortunately, I didn’t saw any performance gain. Anyway the fact that builded app works fine is amazing.</p><h3>AI coding</h3><p><strong>Worst experience ever</strong>. 3/4 tasks AI can’t do right. Even workable. So I’m using LLM time to times when I get stuck in some issue. No more AI for JS gamedev. I have tried many models, paid ones. All feels the same.</p><h3>Conclusion</h3><p><strong>Creating games is difficult</strong>. 3D games in browsers on WebGL2 are three times more difficult. On the other hand, <strong>what are the alternatives if you want 3D graphics without downloading a separate application</strong>? The entire app takes up to 4.0 MB. I know that Unity can build for WebGL, but I have not tried it myself. Have you tried it? Share your experience.</p><p>Source code is available under the MIT license. <a href="https://github.com/emprove/bjs-fps-game">https://github.com/emprove/bjs-fps-game</a></p><p><em>Thanks for reading!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a386a4f9f340" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tests are your friends]]></title>
            <link>https://medium.com/@emprovedev/tests-are-your-friends-6dc4d38562fc?source=rss-f508572db32c------2</link>
            <guid isPermaLink="false">https://medium.com/p/6dc4d38562fc</guid>
            <category><![CDATA[software-testing]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Ilia Emprove]]></dc:creator>
            <pubDate>Wed, 08 Jan 2025 09:55:10 GMT</pubDate>
            <atom:updated>2025-01-08T09:55:10.577Z</atom:updated>
            <content:encoded><![CDATA[<p>Every day we use a huge amount of software without even realizing it. It is important to understand that all people are connected to each other by the results of their own labor. Obviously, we are software developers continuously make an impact for all regular consumers of our apps. Tests are a major step forward in terms of life happiness with help of software quality, and here’s why.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X_yVHa4IyGbDw8XnlXDlLQ.jpeg" /></figure><h3>Types of tests</h3><p>First of all let’s get a fast dive into types of tests. I will not tediously describe all types, there is plenty of such information on the Internet. I will mention only the most basic ones in my opinion.</p><p>When we determine the <strong>order of tests</strong>, we want to reduce the speed of finding errors first. It is logical to distribute test layers from the most isolated and fast to more complex and slow: Unit -&gt; Functional -&gt; E2E.</p><h4>Unit</h4><p>If you have a lot of math, small stateless functions, numerouos valueobjects, there you go. Otherwise don’t waste your time.</p><h4>Functional</h4><p>Some call it a Feature. For simplicity, I will mean by Functional a superset of Integration. They are tightly coupled. This type of tests is <strong>the ground</strong>.</p><p>Often, it is the Functional tests that take up the most space. Because they are a <strong>balance between their ability to find errors and the labor costs of correcting them</strong>.</p><p>With functional tests you <strong>don’t need to touch UI</strong> (and vise versa), setting up device, database to cover use cases, pass middlewares, validation, load balancers, session, authentication, authorization etc. It’s called end-to-end (e2e) tests and typically such kind of tests should be performed when service’s functional tests have written and passed.</p><h4>E2E (end-to-end)</h4><p>The type of tests we have been practicing since the beginning of our careers. It is automated in a CI environment, but when developing manually, it is extremely tedious to emulate CI. Without primary Functional ones, they are very inconvenient and labor-intensive, since you have to manually work through all the cases and go through the full chain from UI to the database over and over again.</p><p>E2E is great, comprehensive approach, but time consuming and will slow down your development process if you skip functional tests.</p><h4>Performance</h4><p>Helps catch errors in a concurrent environment under load. Even with 10 RPS, unexpected bugs may appear. Good software is software that is resilient to failure in moments of high load.</p><h3>Tests benefits</h3><h4>Confidence</h4><p>Tests gives you confidence in what you have written.</p><p>When you have confidence in your code, <strong>you are less stressed, better able to understand and meet deadlines.</strong></p><h4>Easier developing</h4><p>You can mock real gateways, services, db, cache, etc. while <strong>keep focus on domain logic</strong>. Modern software is distributed. Write first what you need to rather then configure all dependencies. Keep your development process inside-out (Onion Architecture).</p><p>In tests, you can <strong>use many use cases, adding as needed</strong>. With manual E2E testing, it is simply impossible to constantly run all 5–10 cases manually with each API change.</p><h4>Purpose clarity</h4><p>Tests give you example of <strong>often use cases</strong> of the app functionality.</p><h4>Refactoring &amp; resilience</h4><p>Application with tests much more flexible in terms of upgrades, refactors. <strong>You don’t suffer to change</strong> something because tests will guide you. It is very important point unless you write simple one page app.</p><p>Tests <strong>force you to think modular</strong>, about parts of your app and code overall. As a result, <strong>well organized modules</strong> can be easier tested without major changes when the times come.</p><h3>In conclusion</h3><p>Tests improve the quality of the application <strong>several times</strong>. But there is a <strong>nuance</strong>. If you do not understand business scenarios well, you will not describe the test cases fully enough. <strong>Tests do not guarantee the operability</strong> of the application <strong>until all possible scenarios of the system behavior are described</strong>, especially in distributed systems with an asynchronous type of communication between services.</p><p><strong>Without tests</strong>, the application is unlikely to have a good architecture, to be stable in the <strong>turbulent world of requirements</strong> and is unlikely to please developers every day.</p><p>Tests are your friends, don’t be afraid of them.</p><p><em>Thanks for reading!</em></p><p><em>*Android friends that will do the work for you once you tell them.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6dc4d38562fc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I’m a Bad Programmer]]></title>
            <link>https://medium.com/@emprovedev/im-a-bad-programmer-16f8551eb830?source=rss-f508572db32c------2</link>
            <guid isPermaLink="false">https://medium.com/p/16f8551eb830</guid>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Ilia Emprove]]></dc:creator>
            <pubDate>Sat, 26 Oct 2024 10:16:20 GMT</pubDate>
            <atom:updated>2024-11-15T17:24:24.474Z</atom:updated>
            <content:encoded><![CDATA[<p>This is my revelation. An attempt to convince myself that I’m on the right path.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Tb7vyKBFt5SJYpS_1jdeFg.jpeg" /></figure><p>I could argue that nothing is impossible. But that would be complacency. Yes, I can learn many things, but will I succeed in much? Obviously not. So I reason about myself and the external environment, trying to find growth points, rather than adapting to the market.</p><h3>No bachelor degree in computer science</h3><p>If I had a second life, I would definitely study computer science instead of getting a degree in machine tool engineering. Actually, <strong>I would like to have 10 lives.</strong></p><h3>Jack of all trades, not quite a master</h3><p>PHP, Go, JS/TS, SQL, UI/UX, HTML, CSS, CI/CD. A little bit Python, Java, tried C#. System design. I do many things and not really dive deep to all of them. I’m convinced that you can succeed best in something you are <strong>passionate about</strong>. My nature prevents me from being in the top in everything.</p><h3>Weak in algorithms</h3><p>I can write Binary Search, Quick Sort, can implement hash table. Used LCS once. That’s all. I would like to know more! I just rarely had to use them in practice. Anyway, algorithms are fun and I plan to study (the top) 10.</p><h3>Weak in Big O</h3><p>I find it difficult to understand the time complexity of a script. Sure I know the basics. To be effective — no. I’m focused on performance, but not obsessed.</p><p>I’m avoiding nested for loops :).</p><h3>Not reading books</h3><p>At the beginning of my career I read books on PHP. I really want to read at least one on Go. To be honest, I don’t think books can teach me how to solve problems. Maybe I didn’t faced up with tasks that need deeper understanding of technology. But <strong>I don’t downplay the value of books</strong> as a means to writing more efficient code.</p><h3>I use LLM</h3><p>But LLM s*cks. Copilot is wasting my time and angry me in 3/4 of tasks. ChatGPT o1 is the one I can delegate research activities. You know what? Often it’s <strong>faster to google than prompt for AI </strong>when it’s needed to do something harder than 2+2. Only you know full context of the task. So there is nothing better than focusing on the issue and letting your brain do its job.</p><h3>No SOLID please</h3><p>These principles are very often asked in interviews. I’ll promise you when the time comes I’ll answer accurate. Then I’ll forget. When I forget, my intuition stays with me.</p><p>I do not programm in OOP. I <strong>hate full OOP</strong> code in terms of web apps. I do Functional Object-Oriented Programming (<strong>FOOP</strong>) like Go does.</p><p>SOLID principles cant be implemented all-in-one everywhere. In real world all decisions we make is <strong>about tradeoffs</strong>. Sometimes we need to <strong>get the job done, sometimes to abstract</strong>.</p><h3>Average IQ</h3><p>I’m not thinking fast. But trying to compensate in quality and wide knowledge.</p><h3>Disgust to React</h3><p>You shoud know js/css/html first. So why to learn new language (as a React, is) rather than use low level ones? <strong>ORM, JSX, null </strong>— complicates things instead of simplifying them.</p><h3>Who am I?</h3><p>A farmer with passion to what I’m doing.</p><p>Trying to be better in what who I am.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=16f8551eb830" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Go, let me cycle.]]></title>
            <link>https://medium.com/@emprovedev/go-let-me-cycle-bc0abf3491d0?source=rss-f508572db32c------2</link>
            <guid isPermaLink="false">https://medium.com/p/bc0abf3491d0</guid>
            <category><![CDATA[go]]></category>
            <category><![CDATA[golang]]></category>
            <dc:creator><![CDATA[Ilia Emprove]]></dc:creator>
            <pubDate>Fri, 25 Oct 2024 06:52:51 GMT</pubDate>
            <atom:updated>2025-01-04T07:45:06.773Z</atom:updated>
            <content:encoded><![CDATA[<p>“Import cycle not allowed” error — the first that was blow my mind in Go. It forced me to learn how to proper structure my Go app. It took going through a bunch of projects on GitHub to dive into application architectures for the tenth time, emerging from the abyss with “N-layer Architecture” with some of DDD concepts: Entity, Repository, Service, Usecase.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iM84pd06QYcnDyzOn5Dkfg.jpeg" /></figure><p>You can find source code here: <a href="https://github.com/emprove/go-app-arch">https://github.com/emprove/go-app-arch</a>.</p><p>The issue: Go restricts to cross-import packages that will depend on each other. I know this optimization is for compiler performance. So once I calmed down, I found this limitation useful to improve architecture skills.</p><p>I wanted to rewrite REST API of the family e-commerce platform built from scratch.</p><blockquote>Important: There are no ideal structure for applications which business logic is unknown yet. You can’t draw a horse if you’ve never seen one. You should create a new application based on known conditions. Layered Architecture just a good starting point.</blockquote><h3>What I came to</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YDbX5kpnNrPCZ_LlR_IBQw.png" /></figure><ul><li>HTTP<strong> </strong>may have several servers: REST, GraphQL, gRPC etc. Each server has it is own App instance, Handlers, Router with Middlewares.</li><li>Presentation layer could bypass Application. Application layer could bypass Business. Don’t use layer as dumb data passing.</li><li>Services, UseCases, Repositories<strong> </strong>should implement interfaces to adhere to loose coupling between layers and for easier testing.</li><li>Service must not contain another Service. Make a Usecase.</li><li>Repository typically uses the inline struct defined inside the function when retrieving data from the DB. The rows are then mapped using the Mapper to an Entity/[]Entity or DTO and returned t o the Service/Usecase.</li><li>Repository should use DB models on insert operation.</li><li>Singular package name is preferred over plural. Motivation: singular is shorter; consistent over all app packages.</li><li>Postgres package provides database connection, table models reflecting DB tables. Create own packages for other databases, e.g. MySQL, MongoDB.</li><li>Gateways are an external API services.</li><li>Validation of DTO arguments, passed from Handler to Usecase/Service should be performed inside <em>Business</em> layer to prevent duplication inside both CLI commands and HTTP Handlers.</li></ul><p>The key is to keep the structure as simple as possible, but with a little room for expansion.</p><p><em>Thank you for reading!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bc0abf3491d0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Less painful PHP]]></title>
            <link>https://medium.com/@emprovedev/less-painful-php-1b7c5b9f5443?source=rss-f508572db32c------2</link>
            <guid isPermaLink="false">https://medium.com/p/1b7c5b9f5443</guid>
            <category><![CDATA[php]]></category>
            <dc:creator><![CDATA[Ilia Emprove]]></dc:creator>
            <pubDate>Mon, 21 Oct 2024 09:45:07 GMT</pubDate>
            <atom:updated>2025-06-09T10:59:19.382Z</atom:updated>
            <content:encoded><![CDATA[<p>I’m switching to Go and want to share with you my experience after almost 10 years of development in PHP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UV0NA_5CXVes2JxMyytUGg.jpeg" /></figure><p>I will put <strong>Level of Impact</strong> in the tip’s title where:</p><ul><li>L1 — mandatory. Highest impact on the app quality.</li><li>L2 — required. Should following.</li><li>L3 — strong recommended. Lowest but not low.</li></ul><h3>General tips</h3><h4>Use Domain model (DDD) *(L1)</h4><p>DDD helps you and your stakeholders speak a <strong>ubiquitous language</strong> by involving the business side in the architecture/hierarchy of entities/aggregates.</p><p>DDD forces you to <strong>avoid database-driven design</strong>.</p><p>Entity, Repository, Service. All roads lead to some sort of DDD by personal understanding DDD concept, but these three pillars are understood equally by everyone.</p><ul><li>Entity — typically represent mutable object with identification. Don’t put heavy business logic here — use ValueObjects instead.</li><li>Repository — data source (db, cache). Responsible for retrieving data from source, data manipulation (mapper).</li><li>Service — business logic. But avoid anemic model. Functions are good unless it becomes core business point of truth.</li><li>ValueObjects — business logic. Aka rich model.</li></ul><p>Use independent <strong>composition of Services</strong> if you need to execute methods of one Service in another. Often it is called Usecase.</p><h4>Use plain SQL *(L1)</h4><p><strong>ORM literally is a mistake</strong> for 99% cases. Query Builder is also weird because it’s a transition approach between plain SQL and ORM. The problem with QB is it basically used for complex queries with many filters. I think utility functions is better in this case than periodically open QB docs trying to achieve same result as for plain SQL. Eventually you will be forced to write raw statements for QB.</p><p><strong>Just write SQL</strong>. It’s <strong>powerful enough, efficient</strong> for all your needs. With SQL you can use the power of <strong>jsonb_build_object, jsonb_agg</strong> to minimize/combine script mapper with structured result from SQL query.</p><ul><li>For simple queries <strong>ORM is useless</strong>. It might look simple for simple statements but <strong>SQL is even simpler</strong>.</li><li>For complex queries <strong>ORM is a pain</strong>. In many cases achieving the same results as with plain SQL is impossible. At least <strong>ORM is an inefficient black box.</strong></li></ul><p>Eloquent (Active Record pattern). Slow, memory consumption. Even junior devs should skip it and use simple SQL. Sure I know about batch, chunks to reduce memory usage.</p><p>Doctrine (mostly mapper). Using Unit of Work. UoW is good for batch processing, but come on, it manages state in memory in PHP process that will die after request complete. Doctrine cache system speed up runtime tasks but caching for simple db queries? What?! Please no cache. What is the point? Use SQL and be happy.</p><p><strong>ORM is an abstraction that complicates things when it is meant to simplify them.</strong></p><blockquote>Backend web apps tightly work with databases. Which is why I’ve devoted a lot of letters to this paragraph.</blockquote><h4>Use the most strict typing as possible *(L1)</h4><p>Out of the box PHP is a poor maintainable language itself due to dynamic typings and non-strict conventions. Don’t make your life harder.</p><ul><li>declare(strict_types=1) — must have.</li><li>readonly properties — if property should not be changed by design simple show this concept to other collegues.</li><li>always declare type of method parameters, function return values. Use union types.</li></ul><h4>Use linters , static analyzers, codestyle *(L1)</h4><p>Integrate in <strong>CI pipeline, git hooks</strong>. <strong>PHPCS, PHPSTAN</strong>. Helps to bound developer’s flight of fancy. It is required in PHP. Also <strong>PER-CS2.0 </strong>(latest cs) or whatever codestyle reduces cognitive load. <strong>Force to format everything.</strong> I wrote why attractivness of a code is very important in my article “Good Code, Bad Code.”.</p><h4>Deep think about naming *(L1)</h4><p>Name of function, variable, class is the first what we read. It should <strong>clear and accurate describe the puprose</strong>. I often see functions that describe one thing but do another. Don’t scare to refactor name later when function changed.</p><h4>Avoid strong relying on Frameworks and packages *(L2)</h4><p>Write your own implementations of functionality you need. You could take basic from framework: routing, middlewares, DI container, env config, db layer, validation, cache, localization, event and queue system, tests, console commands, maybe security. More specific tools I will suggest you to write by yours.</p><p><strong>Frameworks both a gift and a curse</strong>. Framework standardizes consumer API but ties your hands and feet when your app growing up.</p><p>Third-party <strong>packages do not allow you to keep core services up to date</strong>. Because dependencies are not updated as quickly, and sometimes they are not updated at all. And if you also have a bunch of dependencies, the <strong>project will probably</strong> <strong>never receive major updates</strong>.</p><h4>Use fixed versions of dependencies *(L2)</h4><p>I have encountered several situations where updating a <strong>patch version</strong> (semver) of a dependency was <strong>broke the service</strong>.</p><p>I want to make sure that local packages are in sync with production and there is no way to accidentally update them locally. <strong>Don’t trust the composer.lock file.</strong></p><p>Periodically create backlog tasks and <strong>update dependencies manually</strong>, and then <strong>run all sorts of tests</strong>.</p><h4>Avoid custom Exceptions *(L2)</h4><p>Try-Catch might become <strong>confusing, hard to debug and reproducing app state</strong>. Custom Exceptions (extended from \Exception) mask the location of the error. Pass original error message and details upper. Otherwise, you’ll <strong>sweep the dust under the carpet</strong>. Keep errors simple, catch them centralised. Let the app show where the pain is.</p><h4>Don’s use dynamic name of functions and classes *(L2)</h4><p>Hard to read and understand. Error-Prone. Hard to debug and maintain. Inhibits refactoring.</p><pre>$action = &#39;login&#39;;<br>$functionName = &#39;handle&#39; . ucfirst($action);<br>$functionName();<br><br>function handleLogin()<br>{<br>    echo &#39;Handling login...&#39;;<br>}</pre><pre>$classType = &#39;Admin&#39;;<br>$className = &#39;User&#39; . $classType;<br>$object = new $className();</pre><ul><li>When you refactor the <em>UserAdmin </em>class to <em>AdminUser</em>, the code using dynamic class names will break, but an IDE won’t be able to catch this issue.</li><li>Highlighting and referencing within IDE will not work.</li><li>You cant dive deeper to method of function with Ctrl + click.</li></ul><h4>Use array/object shapes doc *(L3)</h4><p>This helps a lot to easy knew what structure of array function returns. PHPStan doc type.</p><pre>@return array{&#39;foo&#39;: int, &quot;bar&quot;: string}<br><br>@return object{&#39;foo&#39;: int, &quot;bar&quot;: string}</pre><h4>Lack of local scope *(L3)</h4><p>PHP <strong>doesnt have local scope of variables denoted by curly braces {}</strong>. It is annoying to debug — you are watching on many variables that is not related to your breakpoint’s purpose. Try to minimize variables quantity in a method, <strong>keep method simple</strong>. It takes skill to know when to break a function into several, complicating readability (you’ll have to jump between methods and keep them in your head), and when to neglect the ease of debugging in favor of fitting the entire body of a method on one screen.</p><h4>Avoid return array then list() variables *(L3)</h4><p>PHP doesn’t support function multiple return values. This is implementing as array return [$var1, $var1]. Then list($foo, $bar). There are many problems:</p><ul><li>impossible declare type of variables inside array with native PHP syntax. Consider PHPStan.</li><li>variable name on the consumer side will very, depends of developer’s choose. Names non-consistent across app.</li><li>when variable doesn’t need, it is skipped like this: list($foo, , $bar). It looks and reads awful.</li><li>no highlighting of returned values, their quantity.</li></ul><p><strong>Return DTO if you need large dataset.</strong></p><p>I prefer to use language syntax when it’s spossible neither relying on IDE, additional “smart” tools.</p><h3>OOP tips</h3><h4>Use Interfaces *(L1)</h4><p>Codebase will be much more flexible. Using class instance as a method’s parameter makes method kind of immutable.</p><h4>Avoid inheritance *(L1)</h4><p>PHP is used for web applications. Web applications do not need OOP.</p><ul><li>Inheritance complicates relations and rise coupling.</li><li>Inheritance slows down your code.</li></ul><p>Use interfaces instead.</p><h4>Use DTO (value objects) *(L1)</h4><p>When function accepts too many parameters. Managing, changing many function’s parameters is a pain. Even with named arguments. If you really like or need to pass many parameters use of <strong>named arguments</strong> is required.</p><h4>Use getters/setters *(L1)</h4><p>Easy referencing. You can find exact places where setting up class properties. As well as put some logic (not side effects!) in setters.</p><h4>Avoid relying on class state *(L1)</h4><p>Every <strong>function should be self-sufficient (pure)</strong>. Better readability, easy unit testing.</p><pre>class BadStringManipulator<br>{<br>    private $text;<br><br>    public function __construct($text)<br>    {<br>        $this-&gt;text = $text;<br>    }<br><br>    public function toUpperCase()<br>    {<br>        return strtoupper($this-&gt;text);<br>    }<br>}</pre><pre>class GoodStringManipulator<br>{<br>    public function toUpperCase($text)<br>    {<br>        return strtoupper($text);<br>    }<br>}</pre><p>If you need to pass some data to anonymous functions: “use ($var)”.</p><pre>$multiplier = 3;<br>$multiplyByThree = function ($number) use ($multiplier) {<br>    return $number * $multiplier;<br>};<br><br>echo $multiplyByThree(10);</pre><h4>Avoid magic methods *(L1)</h4><p>I saw many times __invoke(). It’s so weird to call class as method. Sometimes it’s useful but confusing. Using __invoke in system design is a bad pattern. Other magic methods also hide (business) logic in black box. Follow the principle: <strong>Everything explicit is better than implicit.</strong></p><h4>Use “final” keyword *(L1)</h4><p>Overall codebase with “final” classes more maintainable due to strict control of inheritance. <strong>Use intefraces, composition</strong> instead. Mocking final class is hard, but it is rarely needed.</p><pre>final class DontUseUnfinilizers {}</pre><h4>Avoid static functions *(L2)</h4><p>Using static functions can be tempting, but it<strong> leads to a blurring of OOP principles</strong>. It’s hard to mock. It introduces some caveats with late static binding while inherit from parent class. <strong>Use Dependency Injection if you need utility functions. </strong>Write domain service, don’t feed your entities.</p><h3>Summary</h3><p>Use plain SQL, avoid inheritance, use Interfaces, strict typing, avoid static and magic methods, custom exceptions, use PHPCS + PHPStan, PER-CS2.0, good naming, structure app in DDD, limit framework power, minimize open source packages.</p><p>That is the most impactful things that will make your PHP app maintainable, fast and enjoyable to work with.</p><p><em>Thank you for reading!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1b7c5b9f5443" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[TDD is a good exercise. That’s all.]]></title>
            <link>https://medium.com/@emprovedev/tdd-is-a-good-exercise-thats-all-0eaab209fdcc?source=rss-f508572db32c------2</link>
            <guid isPermaLink="false">https://medium.com/p/0eaab209fdcc</guid>
            <category><![CDATA[tdd]]></category>
            <category><![CDATA[oop]]></category>
            <category><![CDATA[php]]></category>
            <dc:creator><![CDATA[Ilia Emprove]]></dc:creator>
            <pubDate>Sun, 20 Oct 2024 14:59:35 GMT</pubDate>
            <atom:updated>2024-12-01T07:53:24.689Z</atom:updated>
            <content:encoded><![CDATA[<p>I would like to share the experience I have gained from several years of practicing TDD in PHP.</p><p>It’s simple: TDD <strong>structures your mind</strong> and code to be testable from start.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hXc9639sIwEfmToDCbAlqA.jpeg" /></figure><p>TDD <strong>teaches you to think in terms of interfaces</strong> before you start actual coding. I have many times immediately start to code after read a task. This works 50/50. Sometimes I know how system should look, sometimes prediction completely fails. That is because of laziness and self-confidence. Failures taught me an important rule —<strong> think well</strong>, plan, outline interfaces, API, methods, and only then start coding. It helps you to understand the <strong>nature of the problem you ary trying to solve</strong>.</p><p>TDD is also teaching to have <strong>stamina</strong>.</p><h3>Generally speaking about tests</h3><p>Without tests you can not be confident that your <strong>code is working in expected way</strong>. Tests make an application <strong>reliable to changes</strong>.</p><p>“Tests slow down development.” It’s not related directly to TDD, but in general be careful when someone speaks as such. Produced code by this one might not be testable at all. Tests prevent the speed of development <strong>from getting out of control in the long term</strong>.</p><p>Tests give developers <strong>confidence</strong> in the changes they make, which helps them <strong>not to write a new abstraction/function</strong>, but to <strong>improve the existing one</strong>, keeping codebase <strong>duplicate-free of functionality</strong>.</p><p>The problem with PHP is it mostly <strong>OOP-style</strong>. You are writing objects/classes for all things. This <strong>pushes you to use object’s state properties</strong>, <strong>makes methods be a dependant of a class state</strong>. When you read such methods you cant get it easily what kind of variables method use. Relying on a class state makes unit testing hard.</p><p>And then comes TDD, which teaches you to <strong>minimize tight coupling of class methods at the very beginning</strong>.</p><h3>Conclusion</h3><p><strong>Make things work</strong>. When API is stable, <strong>write tests on this code</strong>. Obviously it’s a perfect dev lifecycle. So try TDD first, make your own opinion, meet the limitations of this approach, get bruises etc., <strong>to know how to write code in testable way</strong>. In PHP you need more self-control than in Go, for example. Because of powerful <strong>OOP</strong>. <strong>The force must be curbed.</strong></p><p>TDD just an exercise. First, learn to think structurally, systemically. <strong>Start from the general to the specific</strong>. Then you will not need TDD.</p><p><em>Thank you for reading!</em></p><p><em>Your claps gives me a lot of encouragement as I feel like I’m not alone in fighting corporate machine while trying to make the daily working life of a people more enjoyable.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0eaab209fdcc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Go vs PHP. Practical outlook.]]></title>
            <link>https://medium.com/@emprovedev/go-vs-php-practical-outlook-69b814e0f564?source=rss-f508572db32c------2</link>
            <guid isPermaLink="false">https://medium.com/p/69b814e0f564</guid>
            <category><![CDATA[php]]></category>
            <category><![CDATA[golang]]></category>
            <dc:creator><![CDATA[Ilia Emprove]]></dc:creator>
            <pubDate>Mon, 14 Oct 2024 10:12:56 GMT</pubDate>
            <atom:updated>2024-11-03T06:09:38.546Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6SNwNIFp7FFUsibfAjDg5A.jpeg" /></figure><p>I often encounter questions about whether Go or PHP is better. The short answer might be: each language has its own use; either use the language that your team knows better; or match the programming language to the problem you need to solve; or base it on the labor market and its cost; or use the one you enjoy writing in more. In fact, at the end of this article I will answer truly short. I am well aware that every company or individual developer will have their own agruments for and against. Today I want to share my experience. I have been working with PHP for 9 years, with Go for 1 year. Of course, you must disagree with something, otherwise my opinion becomes the only correct one, which is basically impossible.</p><h3>PHP</h3><p>Until about 2017–2018, when VueJS 2 gained popularity, PHP was a really useful tool to implement backend and frontend in one project using template engines (Blade, Twig). With the popularization of js frameworks PHP became used exclusively for the backend. Actually, as well as any server-side language. The purpose of server-side languages became more obvious: <strong>implementation of business logic</strong>. That’s why at the moment I consider and compare server-side languages from the position of solving business logic tasks, communicating with databases and external services. In this respect, PHP has lost its advantage. Server software requires stability, speed of execution and most importantly, ease of support. If large and complex services are not written in PHP, the language will not develop enough in these directions, it will remain in the niche of startups. Is PHP used in heavy projects nowadays? Well, only if it is historically so and there is simply no priority to rewrite the application. Gas pedal tricks like Roadrunner are being implemented. Which, by the way, is written in Go. As a result, these crutches further narrow the opportunities to write a large, scalable application. Microservices — yes. Resilient — no.</p><p>PHP “out of the box” <strong>allows you to write sloppy code</strong> because there is no static typing, no static analyzer, and to be honest, codestyle is neglected too. Most data structures are implemented through arrays. Many developers take advantage of this because they are used to leaving crumbs on the dinner table. PHP forces you to write in OOP style. <strong>OOP noodles, when facilitated by dynamic typing</strong>, quickly become unreadable and unsupported. OOP is great, but not in PHP, which is used for simple web applications. PHP 8 has slightly better typing, but it’s still the same ubiquitous arrays. The problem is that new versions of PHP try to be backwards compatible with previous versions and that’s great, but even after switching to a new version, the team keeps writing the same old way. It’s not so much about people, but about the language, which condones laziness.</p><p>Code written in PHP will differ from developer to developer, from team to team, from project to project. That’s because PHP allows it.</p><p>PHP is often praised for frameworks like Laravel and Symfony. There is no doubt that these are awesome tools. Both frameworks are rich in built-in functionality. In practice, however, <strong>you won’t use more than half of it</strong>. As your application grows, you’ll still need to write your own tools because <strong>you’ll need performance, ease of support, security, extensibility</strong>. A lot of things. Off-the-shelf solutions won’t be able to provide all the needs. That’s why big companies have a lot of specific tools written for a specific need, infrastructure, technology.</p><ul><li>When a project is just starting, you need a minimum of functionality. You can write it yourself.</li><li>When the project reaches medium size community packages are not fast enough, secure enough, and developers have to spend time reading not the best third-party documentation instead of writing code.</li><li>On large projects, dependence on opensource solutions tends to minimize.</li></ul><p>So, <strong>is it worth using large frameworks</strong> if soon a significant part of the codebase will at best hang idle and in reality complicate development?</p><p>Laravel has a wonderful system of Queues (workers). I have written relatively logic- and queue-laden applications in Laravel. The framework does its job well. If you avoid ORM, facades, magic methods and magic in general, it is a pleasure to work with Laravel. Until you need to process a lot of data. Symfony is about the same for me.</p><p>Learning curve is the same as for Go. I’m just saying. So <strong>I don’t admit PHP advantage in easy and development speed.</strong></p><p>Don’t get me wrong. <strong>You can write a nice web application</strong> in PHP, REST API, etc. But as it grows, the application will be slow, support deliver headaches with its dynamic typing, ubiquitous arrays and a ton of value objects with getters/setters. Yes, you can, but it will come at a cost. <strong>Implementing the features and immersing new people into the project will be time consuming.</strong></p><h3>GoLang</h3><p>After PHP, many people may be scared off by static typing, and the number of structs is already unusually large at the start. Errors “import cycle not allowed” can blow your mind. <strong>Go makes you think about architecture</strong>. You will have to implement DDD and analyze examples of other projects. You may also be surprised by the lack of enum.</p><p>Go is often more maintainable due to <strong>strict typing and conventions</strong>. Static typing is what 90% of PHP developers would like to see, according to one survey.</p><p>I liked Go because it gives a <strong>minimum of freedom, a minimum of syntactic sugar</strong>. Go doesn’t have full-blown, annoying OOP. Often code written in Go looks the same regardless of the skill set of the developers.</p><p>Golang has a wider range of applications than PHP. Effective CLI, data processing, CPU-bound tasks. It allows you to write programs for Arduino, Raspberry.</p><p>Performance. I rewrote a RESTful API for a family online store. Go application keeps ~20000 req/sec, while PHP (Lumen — lightweight Laravel) only ~1000 req/sec.</p><p>As for performing long-running tasks in the background (queue, workers), there are many third-party packages for this in Go or you can implement it yourself. <strong>There is no urgent need for a framework.</strong></p><p>Makes DevOps life easier. Go app is a simple binary file. While PHP required image with runtime and all vendor, project files to be as is on filesystem. Docker image of my app is 3.5 MB (go build -ldflags=”-s -w”). While PHP (alpine-based) is about 300 MB. With UPX tool compression we can get 4x smaller binary size (1 MB).</p><p><strong>Simplicity. Boring. Really?</strong> I think it’s because the language doesn’t give freedom. No ternary operator, no OOP, no OOP state management (I hate it in PHP), no function’s default parameter values, all structures must be typed. I hear people scold simplicity, as if everything is so simple that the code grows on nothing from every sneeze. There is some truth in it. There are a lot of utility functions, functional-style programming. But <strong>minimum third-party dependencies, maximum transparency and codebase control</strong>. I like it. In practice, this approach allows you to concentrate on writing business logic, and the speed of implementing features does not go into space over time, as in the case with PHP. I think everyone likes doing things rather than digging for hours in a haystack. <strong>For me Go is fun</strong>, because I could and tend to write my own “framework”, thinking of architecture, research approaches etc.</p><h3>Concurrency. Parallelism.</h3><p>I’ll put this in a separate section because these differences are very significant between PHP and Go. And in everyday tasks, we very often need to parallelize.</p><p>In both PHP and Go, there are tools to run tasks both concurrently and in parallel, using the available CPU cores.</p><p><strong>PHP</strong>. PHP-FPM is a canonical stable process manager. There are others, such as Roadrunner (Go), Swoole (C++). PHP has significant differences in this regard compared to Go. Each PHP-FPM process occupies a dedicated area in memory where the entire application is loaded. In this approach, <strong>communication between processes is not possible</strong>. This means that you cannot send and receive data from one process to another. This means that <strong>you cannot synchronize threads</strong>. It also means that a single PHP-FPM process will only handle one request and load the entire application into memory time after time, which is <strong>very resource intensive</strong>. You can use the Laravel `queue:work` command to run workers in memory. But this obliges you to use the framework. You can write your own solution, for example, based on while-do and under load encounter unpredictable behavior, because <strong>PHP is not designed to hang in memory for a long time</strong>. Why, if there is Go? Using third-party tools like GNU Parallel also looks like overhead and doesn’t solve all problems. You can use Roadrunner, Swoole, FrankenPHP (Caddy) and struggle with bugs.</p><blockquote>Why, when there is Go?</blockquote><p><strong>Go</strong>. Goroutines + Channels + Scheduler. These three things solve three problems: concurrent execution, synchronization and execution in CPU threads. <strong>Everything works out of the box. Convenient, productive, safe.</strong></p><h3>Summary</h3><h4>Go</h4><ul><li>Smaller bundle/image size</li><li>Easier to deploy</li><li>Much better performance</li><li>Safe, easy of use concurrency and parallelism</li><li>Efficient, easier working with long-running tasks</li><li>Wider application usage</li><li>Better maintainability and productivity</li><li>Community philosophy follows simplicity</li><li>Great Stdlib, no need of frameworks</li></ul><h4>PHP</h4><ul><li>Not bad up to medium-size business-logic projects, REST APIs</li><li>Suitable for low load services</li><li>Many community packages, e-commerce frameworks, boilerplates</li><li>Great Laravel</li><li>Harder to maintain</li><li>OOP noodles with bothersome state management</li><li>Ubiquitous “black box” arrays</li></ul><h3>Conclusion</h3><p>I still like PHP 8. It’s ok to develop/maintain applications <strong>if they are written carefully with PHP 8 capabilities</strong>.</p><p>The short answer is: <strong>use Go for new projects. </strong>PHP doesn’t have an advantage.</p><p>Just try new things. Learn by your own.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=69b814e0f564" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Scrollbars Hell]]></title>
            <link>https://medium.com/@emprovedev/scrollbars-hell-2fd28abe0a57?source=rss-f508572db32c------2</link>
            <guid isPermaLink="false">https://medium.com/p/2fd28abe0a57</guid>
            <category><![CDATA[ux]]></category>
            <dc:creator><![CDATA[Ilia Emprove]]></dc:creator>
            <pubDate>Sun, 08 Sep 2024 13:43:27 GMT</pubDate>
            <atom:updated>2024-10-23T05:07:07.779Z</atom:updated>
            <content:encoded><![CDATA[<p>What the hell is going on with scrollbars?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7GZCGmC5hJ2civ5MsYTfjg.jpeg" /></figure><h3>Shades of disaster</h3><h4>Thin</h4><p>Narrow scrollbars force me to aim. I am not in a shooter game.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/212/1*LdgbPf05KWSQu_OKyiS-3A.gif" /><figcaption>Aiming is a bad UX</figcaption></figure><h4>Disappearing</h4><p>Hello on mouse in, goodbye on mouse out.</p><p>I want to know how much content block contains. Hiding scrollbars confuse me. Doubled disaster when there are disappearing horizontal and vertical scrollbars at the same time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/340/1*qYmK4_PUmv1_4e95JAwT5Q.gif" /><figcaption>How much is the fish?</figcaption></figure><h4>Fake width</h4><p>Ah, got you! Rare thing, but stupid. Example below captured from latest PHPStorm. Now I’m using VSCode. I was too lazy to write an issue.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/259/1*ALSwsNCDX_PgH6oSVuiUSQ.gif" /><figcaption>Seems like actual scrollbar’s position a half width to the right</figcaption></figure><h4>Transparent</h4><p>I don’t have eagle eyesight. Don’t make me distinguish halftones.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/259/1*yHcTTa456bLR6QwrXPpqkA.gif" /><figcaption>Sad</figcaption></figure><h4>Hidden —&gt; Appears</h4><p>When you hide scrollbars <strong>when there is no content, then when it appears</strong>, content shift layout occurs. I think everyone has encountered this. I prefer to draw the scrollbar, even if it is in fact non-functional.</p><h4>Hidden forever</h4><p>This screenshot I took from Medium android mobile App. There are two issues: 1) <strong>no scrollbars</strong> even while scrolling, 2) <strong>horizontal scroll interrupting</strong> on vertical scroll. App tries to do both moving and scroll while fails horizontal. Maybe it is a bug on my phone, but I confident this is possible to fix on the App side.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/419/1*Gpka2c-7PiLMs13Zj8JA9g.jpeg" /></figure><h3>Conclusions</h3><p>We are in the <strong>era of big screens and lots of pixels</strong>. Why try to make usability 5px worse? Or make it semi-transparent; Or hide it; Not drawing at all; Interrupting scroll focus. Or, my God, combine all these sorrows together!</p><p>In favor of trends, we forget about the main thing — usability. I hope round checkboxes will also return to squares.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2fd28abe0a57" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Good Code, Bad Code]]></title>
            <link>https://medium.com/@emprovedev/good-code-bad-code-0f4646d07f65?source=rss-f508572db32c------2</link>
            <guid isPermaLink="false">https://medium.com/p/0f4646d07f65</guid>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Ilia Emprove]]></dc:creator>
            <pubDate>Mon, 05 Aug 2024 19:20:36 GMT</pubDate>
            <atom:updated>2024-10-22T07:01:44.686Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article I will try to tell you what priorities should be set when developing software. I don’t like blablabla introductions, self-presentations and so on. So let’s get straight to the point.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GziK8S6t9ubLX9McfjNXSA.jpeg" /></figure><p>I highlight four pillars in software development:</p><ul><li>Attractiveness</li><li>Convenience</li><li>Performance</li><li>Predictability</li></ul><p>In a matter of priorities:<br><strong>Attractiveness -&gt; convenience -&gt; performance -&gt; predictability.</strong></p><p>It’s all the same for backend and frontend.</p><h4>Attractivenes.</h4><p>If something looks bad, we even dont touch it. It scares.</p><h4>Convenience.</h4><p>Is something that helps you do something rather than struggling to do it.</p><h4>Performance.</h4><p>System feedback allows to speed up the implementation of features and fixing bugs. Thus, we can make a sustainable, predictable system quickly and easily.</p><h4>Predictability.</h4><p>You may ask me why predictability has lowest priority even for backend? Backend is a functionality part of a system; things must work first you will say. Well, if we prefer predictability over attractiveness then our main goal is to build fast at any cost. Our software becomes ridiculous.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*stX-Ns613mTViM3nu2dPXg.jpeg" /></figure><p>I will try to explain why I believe developer experience is the most important aspect of software development.</p><h3>Text level</h3><p>Visual impact is huge when we look at something. Then we touch it, use it and wait for response. Detecting -&gt; interaction -&gt; feedback. That is how we learning whatever.</p><blockquote><strong>People write code for people and not for machines</strong></blockquote><p>It is important that the organization of the text is attractive. Like the structure of a newspaper or magazine. We must immediately understand <strong>where everything is located and by what parameters it is grouped</strong>.</p><p>When the code looks attractive, we want to get to know it further. And then comes understanding. When everything is structured logically, it is easier and more pleasant to learn what is happening in the program. When it is clear, the code is easy to use. <strong>Easy to use — fast feature delivering.</strong></p><p>When we pull a new project from Git, we look at the folders and files. If we can quickly group the parts of the system, then such a system seems beautiful. We like to find patterns in everything.</p><blockquote><strong>pretty code = good code = understandable code</strong></blockquote><p>Beauty surrounds us everywhere. Software is also part of that environment.</p><h3>What is ugly?</h3><p>Legacy is not an old code, it is complexly organized code. If new architectural patterns, code style, naming are added to the program without control, then the program can be classified as legacy in a matter of months of development.</p><p>I believe that neatness is the main skill that a SWE (software engineer) should have. <strong>Neatness means striving to organize and group things around.</strong> Of course, this can be partially solved by a static analyzer, code style and other nuts, but an untidy SWE will write untidy code. A review will not help here. No one will spend hours on your MR. Do you hope to rewrite everything in the future? Let’s be honest, conceptual refactoring is a thankless task, no one seriously does it. It is unlikely that there will be volunteers to rake up your multi-year monolith of incomprehensible architecture with business logic woven into it like a crystal web. By doing everything in a slapdash manner now, you are carving your name into the stone vault.</p><h3>Weeell?</h3><p>When developing <strong>backend </strong>we should be focused on <strong>developer experience</strong>. Of course, dont forget to write tests.</p><p>When developing <strong>frontend </strong>we should be focused on <strong>pretty look</strong>. Of course, dont forget about user experience.</p><p><strong>Be brave to make things simple</strong>, I know you are kung fu master, but please, dont show it to me unless you have strong research.</p><p>Oversimplifying is much better than overengineering.</p><p>Prefer neat engineers over “10x” developers.</p><p>Of course, you should focus on the <strong>purpose of the software</strong>.</p><p><em>If you are interested, next time I can tell you about my vision of hiring good engineers.<br>Thank you for reading. Please argue with me if you disagree with something.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0f4646d07f65" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>