<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Programming Archives | Programming Zen</title>
	<atom:link href="https://programmingzen.com/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>https://programmingzen.com/category/programming/</link>
	<description>Meditations on programming, startups, and technology</description>
	<lastBuildDate>Sun, 17 Mar 2024 18:20:37 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
<site xmlns="com-wordpress:feed-additions:1">1397766</site>	<item>
		<title>I&#8217;m Supposed to Know</title>
		<link>https://programmingzen.com/im-supposed-to-know/</link>
					<comments>https://programmingzen.com/im-supposed-to-know/#respond</comments>
		
		<dc:creator><![CDATA[Antonio Cangiano]]></dc:creator>
		<pubDate>Sun, 17 Mar 2024 18:18:27 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[copilot]]></category>
		<category><![CDATA[learning to program]]></category>
		<category><![CDATA[psychology]]></category>
		<category><![CDATA[tips for young programmers]]></category>
		<category><![CDATA[watsonx code assistant]]></category>
		<guid isPermaLink="false">https://programmingzen.com/?p=2745</guid>

					<description><![CDATA[<p>There are many obstacles to learning but a key one I see repeatedly is: I&#x2019;M SUPPOSED TO KNOW. Let&#x2019;s say that you&#x2019;re trying to accomplish something technical and you don&#x2019;t remember how but can easily look it up, if you feel like you&#x2019;re supposed to know it, you&#x2019;re less satisfied with your ability to get it done. You feel like an impostor. This mindset actively&#xA0;discourages the act of looking up information, which is essential for learning. Imagine that you&#x2019;re a web developer working on a project that requires the implementation of SSO/IdP. A voice inside tells you, &#x201C;I&#x2019;m a professional </p>
<p>The post <a href="https://programmingzen.com/im-supposed-to-know/">I&#8217;m Supposed to Know</a> appeared first on <a href="https://programmingzen.com">Programming Zen</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>There are many obstacles to learning but a key one I see repeatedly is: I’M SUPPOSED TO KNOW.<br><br>Let’s say that you’re trying to accomplish something technical and you don’t remember how but can easily look it up, if you feel like you’re supposed to know it, you’re less satisfied with your ability to get it done. You feel like an impostor.</p>



<p>This mindset actively&nbsp;discourages the act of looking up information, which is essential for learning.</p>



<p>Imagine that you&#8217;re a web developer working on a project that requires the implementation of SSO/IdP. A voice inside tells you, &#8220;I&#8217;m a professional web developer. I&#8217;m supposed to know how to do this already.&#8221;</p>



<p>You might spend hours trying to figure it out entirely on your own instead of taking advantage of all the help you can get. And this further adds to your feelings of inadequacy or your Impostor Syndrome.</p>



<p>I suspect technologies like Copilot and watsonx Code Assistant will really challenge those who struggle with this. Remember, it doesn’t matter if you had to look it up. If you got it done, you got it done. This isn’t the Olympics where outside help disqualifies you. Looking up things is an integral part of being a programmer.</p>



<p>(I readily acknowledge that these tools are useful but still being developed and their suggestions can still be inaccurate or suboptimal, but I think the point stands.)<br><br>Embrace the mindset that “it’s okay not to know everything; get it done” and such tools become playgrounds for learning and being more productive. If you take the “I’m supposed to know” approach you’ll just see them as crutches and miss out on their potential. Always watch out for psychological barriers. They can make or break you.</p>
<p>The post <a href="https://programmingzen.com/im-supposed-to-know/">I&#8217;m Supposed to Know</a> appeared first on <a href="https://programmingzen.com">Programming Zen</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://programmingzen.com/im-supposed-to-know/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2745</post-id>	</item>
		<item>
		<title>What to Study to Become a Web Developer</title>
		<link>https://programmingzen.com/what-to-study-to-become-a-web-developer/</link>
					<comments>https://programmingzen.com/what-to-study-to-become-a-web-developer/#comments</comments>
		
		<dc:creator><![CDATA[Antonio Cangiano]]></dc:creator>
		<pubDate>Tue, 16 Jun 2020 21:41:44 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[beginners]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[how to become a programmer]]></category>
		<category><![CDATA[how to become a web developer]]></category>
		<category><![CDATA[how to get a developer job]]></category>
		<category><![CDATA[programming advice]]></category>
		<category><![CDATA[tech stack]]></category>
		<category><![CDATA[tips for young programmers]]></category>
		<category><![CDATA[what to study]]></category>
		<guid isPermaLink="false">https://programmingzen.com/?p=2603</guid>

					<description><![CDATA[<p>In this third article of my, How to Become a Web Developer and Get a Job guide, we&#x2019;ll discuss what to study to become a web developer. In the previous article on front-end vs back-end developers, I covered the existence of front-end and back-end technologies, which in turn have many options to choose from. Too many options, in fact. How do we go about choosing what to study? And what about all the other stuff web developers tend to know, such as the command line, Git, and other developer tools? When you are beginning in this field, not only you </p>
<p>The post <a href="https://programmingzen.com/what-to-study-to-become-a-web-developer/">What to Study to Become a Web Developer</a> appeared first on <a href="https://programmingzen.com">Programming Zen</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>In this third article of my, <a href="https://programmingzen.com/how-to-become-a-web-developer-and-get-a-job/">How to Become a Web Developer and Get a Job</a> guide, we&#8217;ll discuss what to study to become a web developer.</p>



<p>In the previous article on <a href="https://programmingzen.com/front-end-vs-back-end-developer/">front-end vs back-end developers</a>, I covered the existence of front-end and back-end technologies, which in turn have many options to choose from.</p>



<p>Too many options, in fact. How do we go about choosing what to study? And what about all the other stuff web developers tend to know, such as the command line, Git, and other developer tools?</p>



<p>When you are beginning in this field, not only you do not know a wide range of things, you are likely also unaware of what you don&#8217;t yet know.</p>



<p>As such, my goal for this section of the guide is to give you a list of things you should get acquainted with, along with some rationale for why you&#8217;d opt for those versus other possible choices.</p>



<p>This list of what to study to become a web developer is necessarily incomplete (I don&#8217;t even list learning to debug), but fear not! You will pick up other skills and tools organically in the process of studying these key topics.</p>



<p>In the next article in the guide, we&#8217;ll discuss how to go about learning those needed elements as well.</p>



<h2 class="wp-block-heading">What to study for front-end development</h2>



<p>As far as the web is concerned, front-end means three main technologies:</p>



<ul class="wp-block-list"><li><strong>HTML</strong>: The structure of your web pages;</li><li><strong>CSS</strong>: The styling of your web pages;</li><li><strong>JavaScript</strong>: To make your web pages more useful and interactive.</li></ul>



<p>You need to become familiar with all three of these areas if you’re going to have much of a hope of getting job as a web developer.</p>



<p>If you don&#8217;t plan to become a front-end developer, you might get away with a superficial knowledge of CSS (and to some extent JavaScript). However, you should still have a fundamental understanding of both.</p>



<p>For CSS, you should become acquainted with both the <em>Flexbox model</em> and <em>Grid layout</em>. While these terms might not mean much to you yet, they will become familiar as soon as you take a course, read a book, or peruse documentation on CSS.</p>



<p>If you plan on becoming a front-end developer, then you need to be quite decent at CSS.</p>



<p>Learn HTML, CSS, and JavaScript regardless of what development role (e.g., front-end, back-end, or full-stack) you may ultimately end up taking on in your career.</p>



<p>In the beginning of your journey, simply focus on these three in their plain/vanilla form. For example, don&#8217;t try to go for fancy JavaScript frameworks like React and Vue right out of the gate.</p>



<p>The only frameworks you might want to explore at this stage are CSS ones like Bootstrap and TailwindCSS, and an old school JavaScript library (i.e., jQuery), to see what they have to offer over vanilla CSS and JavaScript.</p>



<p>What they don&#8217;t do is introduce a whole host of new and confusing concepts (like React does), which are best tackled once you have a decent mastery of the front-end trifecta (i.e., HTML, CSS, and JavaScript).</p>



<h2 class="wp-block-heading">What to study for back-end development</h2>



<p>After you’ve spent a couple of months grasping the fundamentals of HTML, CSS, and JavaScript, I&#8217;d recommend that you start exploring a back-end development language and framework.</p>



<p>You&#8217;ll quickly find that front-end alone limits the type of web applications you can build a fair bit. Want to permanently save and retrieve the data the user gave you? You need back-end tools.</p>



<p>Adding back-end development skills will allow you to create much more useful web applications, as well as to better understand the other side of the coin.</p>



<p>This is useful even if you decide to specialize in front-end development because you&#8217;ll most likely be working with back-end developers and interacting with their work from your front-end code.</p>



<p>So far there hasn&#8217;t been much controversy in this article. Just about everyone can agree that learning HTML, CSS, and JavaScript is a must. Some will fight me on my suggestion of putting off React or Vue until later (or think that looking into jQuery in 2020 is silly), but nothing as of yet has been truly controversial.</p>



<p>Sides are about to be drawn, however, as I proceed to tell you what to study for the back-end side of things. There are countless possible options out there. At least a dozen of which are squarely reasonable choices.</p>



<p>Some of the most worthwhile candidates include:</p>



<ul class="wp-block-list"><li><strong>Python and Django</strong></li><li><strong>JavaScript and Express.js</strong></li><li><strong>Ruby and Ruby on Rails</strong></li></ul>



<p>If you already know, or have a hunch, that you will focus on front-end development, I recommend using a JavaScript server-side framework like Express.js.</p>



<p>This will further solidify your JavaScript skills and will enable you to build complete web applications (and APIs that your front-end can then consume).</p>



<p>I&#8217;m personally not a huge fan of server-side JavaScript (or JavaScript in general), but if you know that you want to become a front-end developer you must become as skilled as you possibly can in JavaScript. It is, hands down, the number one skill that you’ll need to master in this field.</p>



<p>I would skip the JavaScript and Express.js stack if any of the followings apply to you:</p>



<ul class="wp-block-list"><li>You didn&#8217;t particularly enjoy JavaScript while learning it for front-end;</li><li>You are unsure whether front-end development is right for you;</li><li>CSS and JavaScript offended your sensibilities and you are now seeking refuge in back-end development where you&#8217;ll be less likely to work with either of these technologies;</li><li>You want to learn something new and a different programming language is likely to make your profile more appealing to employers.</li></ul>



<p>If that&#8217;s you, I recommend that you consider Python and its associated framework, Django.</p>



<p>Python is one of the most popular programming languages in the world and it is quite pleasant to work with. Nowadays, it is almost a given that most well-rounded programmers will know Python.</p>



<p>It&#8217;s also the ideal language to have at the ready, should you develop an interest in data science and machine learning down the line.</p>



<p>The most popular frameworks to build web applications in for Python are Flask and Django. Ideally, you&#8217;ll want to learn both, but to begin with, I would suggest you focus on Django.</p>



<p>Why Django? It&#8217;s highly productive which means that you&#8217;ll be able to create fancier web applications with less work, which can be quite motivating when you are starting out. It also ships with a lot of sensible conventions that will in turn teach you how to structure and how to think about the architecture of your web application.</p>



<p>Flask is excellent too and likely the better tool if one is focusing on building small apps and APIs. That said, it is best used once you have a better understanding of how web applications work.</p>



<p>What about Ruby and Ruby on Rails? They are also an excellent choice and my favorite among the options listed here. However, Ruby is not quite as popular as Python, and it is mostly used within the scope of web development.</p>



<p>With Python you get a very similar programming language, plus access to all the data science goodies that are not readily available in Ruby.</p>



<p>Should you decide to pick up Ruby and Ruby on Rails down the line, it will be quite easy coming from a Python and Django background.</p>



<p>As you go through this process, regardless of the language and framework you choose, you must become well acquainted with the <em>REST paradigm</em> which will teach you about <em>HTTP requests</em> and <em>responses</em>, <em>HTTP methods</em>, and <em>response codes</em>.</p>



<h2 class="wp-block-heading">What about databases?</h2>



<p>You&#8217;ll also need to become acquainted with databases. For the most part, you&#8217;ll have to master the fundamentals of:</p>



<ul class="wp-block-list"><li><strong>MongoDB</strong>: A document-based database;</li><li><strong>PostgreSQL</strong>: An SQL/relational database.</li></ul>



<p>Mongo is overused. However, it is common and easy enough to learn, so it can certainly be worth picking up. PostgreSQL, on the other hand, is fantastic and an obvious recommendation.</p>



<p>Once you have an SQL foundation in place, you can switch with relative ease to other relational databases, should a project or employer require it.</p>



<h2 class="wp-block-heading">Miscellaneous things</h2>



<p>The front-end and back-end stacks outlined above are enough to make you useful and capable of landing your first job in tech.</p>



<p>There are however several other skills which are taken for granted. If you are not too familiar with them, you&#8217;ll want to invest some time in learning these areas as well.</p>



<ul class="wp-block-list"><li><strong>Git and GitHub</strong>: to store, edit, keep track of changes, share, and release code.</li><li><strong>Basic Linux shell commands</strong>: think <code>ls</code>, <code>cat</code>, <code>echo</code>, <code>source</code>, <code>ps</code>,<code>top</code>, <code>grep</code>, <code>find</code>, <code>curl</code>, etc.</li><li><strong>A code editor</strong>: I recommend <em>Visual Studio Code</em> unless you already have a different favorite. Learn how to use it efficiently, including leveraging popular plugins. For example, plugins that enable you to autocomplete your code, <em>linters</em> to ensure that it follows idiomatic style and formatting, and more.</li><li><strong>Regular Expressions</strong>: quite complex but also handy both within your code and when searching/transforming text via the command line (or within your code editor).</li><li><strong>Web security</strong>: you should be able to prevent common security issues like <em>SQL injection</em>, <em>Cross-Site Scripting</em> (XSS), <em>Cross-Site Request Forgery</em> (CSRF), etc.</li></ul>



<p>I suspect you&#8217;ll pick up many of these skills automatically as you study the rest of the stuff mentioned earlier on.</p>



<p>Just make sure to supplement as needed so that you are not entirely unfamiliar with any of the concepts listed here.</p>



<h2 class="wp-block-heading">More advanced front-end and back-end skills</h2>



<p>Once you have all of these skills above under your belt, you might be ready to tackle more advanced areas.</p>



<p>If you decide to become a front-end developer, I suggest looking into:</p>



<ul class="wp-block-list"><li><strong>Accessibility</strong>;</li><li><strong>User Experience (UX)</strong> principles;</li><li><strong>SEO</strong> (Search Engine Optimization);</li><li>Building <strong>responsive web applications</strong> (web apps that scale to the user&#8217;s device resolution);</li><li><strong>Wireframing</strong> with <em>Figma</em> or <em>Adobe XD</em>;</li><li>Styling with <strong>Sass</strong>;</li><li><strong>Webpack</strong>;</li><li><strong>React/Redux</strong> or <strong>Vue/Vuex</strong>.</li></ul>



<p>If you decide to become a back-end or full-stack developer, I&#8217;d recommend exploring more in depth:</p>



<ul class="wp-block-list"><li><strong>Algorithms</strong>: learn more about traditional algorithms and data structures concepts often taught in computer science university courses, including the concept of Big O notation.</li><li><strong>SQL</strong>, going beyond the language by looking at more advanced features modern relational databases have to offer (triggers, stored procedures, etc).</li><li><strong>Flask</strong> (if you opted for Python) or <strong>Sinatra</strong> (if you opted for Ruby).</li><li><strong>GraphQL</strong>: go beyond REST and see what all the buzz is about.</li><li>Deployment and scaling with <strong>containers</strong> using tools like <em>Docker</em> and <em>Kubernetes</em>.</li></ul>



<p>Note that for all of the technologies I’ve mentioned here, this list is still not an exhaustive one by any means. This is by design, as it really doesn&#8217;t need to be all-encompassing. Most professional web developers have not mastered every entry on this list.</p>



<p>So, if you decide to become a front-end developer, mostly ignore the advanced back-end stuff, and focus on the front-end skills.</p>



<p>Conversely, if you decide to become a back-end developer, focus on the advanced back-end skills by studying, practicing, and building projects without worrying too much about the advanced front-end skills side of things.</p>



<p>You just need to become really good at the key components for the role you decide to take, while not being entirely unfamiliar with the rest of the entries on this list.</p>



<h2 class="wp-block-heading">What&#8217;s next?</h2>



<p>Now that you know what you should be studying, we need to address how to actually go about studying it.</p>



<p>Do you need a degree to become a web developer? Should you enroll in a development bootcamp? We&#8217;ll cover these questions and much more in the next article in this multi-part guide.</p>



<p>Stay tuned and don&#8217;t forget to subscribe, if you haven’t done so ready.</p>
<p>The post <a href="https://programmingzen.com/what-to-study-to-become-a-web-developer/">What to Study to Become a Web Developer</a> appeared first on <a href="https://programmingzen.com">Programming Zen</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://programmingzen.com/what-to-study-to-become-a-web-developer/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2603</post-id>	</item>
		<item>
		<title>Front-End vs Back-End Developer</title>
		<link>https://programmingzen.com/front-end-vs-back-end-developer/</link>
					<comments>https://programmingzen.com/front-end-vs-back-end-developer/#comments</comments>
		
		<dc:creator><![CDATA[Antonio Cangiano]]></dc:creator>
		<pubDate>Mon, 25 May 2020 19:41:51 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[beginners]]></category>
		<category><![CDATA[front-end vs back-end]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[how to become a web developer]]></category>
		<category><![CDATA[how to get a developer job]]></category>
		<category><![CDATA[programming advice]]></category>
		<category><![CDATA[tips for young programmers]]></category>
		<guid isPermaLink="false">https://programmingzen.com/?p=2579</guid>

					<description><![CDATA[<p>This is the second article of my How to Become a Web Developer and Get a Job guide. Within it, we&#x2019;ll discuss what coding is, as well as the difference between being a front-end vs back-end developer. If you want to learn to code so that you can become a web developer, welcome. You&#x2019;re in the right place. Before we discuss what kind of web developer positions are available and what the differences between front-end, back-end, full-stack, and DevOps are, I&#x2019;m going to take the scenic route and start with what coding is. This is necessary because I make virtually </p>
<p>The post <a href="https://programmingzen.com/front-end-vs-back-end-developer/">Front-End vs Back-End Developer</a> appeared first on <a href="https://programmingzen.com">Programming Zen</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>This is the second article of my <a href="https://programmingzen.com/how-to-become-a-web-developer-and-get-a-job/">How to Become a Web Developer and Get a Job</a> guide. Within it, we&#8217;ll discuss what coding is, as well as the difference between being a front-end vs back-end developer.</p>



<p>If you want to learn to code so that you can become a web developer, welcome. You&#8217;re in the right place.</p>



<p>Before we discuss what kind of web developer positions are available and what the differences between front-end, back-end, full-stack, and DevOps are, I&#8217;m going to take the scenic route and start with what coding is.</p>



<p>This is necessary because I make virtually no assumptions about your existing knowledge. If you are an absolute beginner, this is the guide for you.</p>



<h2 class="wp-block-heading">What is coding?</h2>



<p>Coding is the act of writing code to program machines like computers and mobile devices. OK, what is code then? Code is the set of precise instructions we give to said machines to execute the actions we want them to take.</p>



<p>The instructions need to be precise because computers, unlike humans, cannot make a bunch of assumptions on the basis or prior experience.</p>



<p>If I asked you to draw a house, you&#8217;d probably start jotting down something reminiscent of what a 5 year old would draw. You&#8217;ll start with a box, add a pointy roof, a door, a window, etc. If you are really artistically inclined, you might draw a 3D version that looks nicer. In either case, you will be able to handle my generic, open-ended request and deliver something that satisfies it.</p>



<p>Generally speaking, the computer cannot assume what the house should look like, as you would. How thick should the lines be? What color (if any at all) should be used? How big should the house be? What style? And so on.</p>



<p>In short, a computer didn&#8217;t draw houses in kindergarten. Yes, it can draw amazingly intricate houses with fantastic degrees of detail, but you&#8217;ll need code that very precisely instructs it to do so.</p>



<p>Consider the calculator application that is installed by default on your computer.</p>



<div class="wp-block-image"><figure class="aligncenter size-full"><img data-recalc-dims="1" fetchpriority="high" decoding="async" width="464" height="642" src="https://i0.wp.com/programmingzen.com/wp-content/uploads/2020/05/calculator.png?resize=464%2C642&#038;ssl=1" alt="Front-End vs Back-End Developer - Calculator example" class="wp-image-2585" title="The Calculator app on MacOS" srcset="https://i0.wp.com/programmingzen.com/wp-content/uploads/2020/05/calculator.png?w=464&amp;ssl=1 464w, https://i0.wp.com/programmingzen.com/wp-content/uploads/2020/05/calculator.png?resize=217%2C300&amp;ssl=1 217w" sizes="(max-width: 464px) 100vw, 464px" /><figcaption>The Calculator application on MacOS</figcaption></figure></div>



<p>A programmer wrote a bunch of code so that when you click on the Calculator icon, the computer launches the application on your screen, presenting you with a series of numbers and operators to choose from.</p>



<p>As you interact with the application, for example by pressing <code>6</code>, <code>x</code>, <code>7</code> and <code>=</code>, the computer, instructed by the programmer&#8217;s code, will know what to do. (Namely, multiplying the two numbers and displaying the result for you.)</p>



<h2 class="wp-block-heading">What&#8217;s the difference between a program and an application?</h2>



<p>Some computer programs do not have a visual user interface at all, in which case we do not call them applications. </p>



<p>That&#8217;s the main difference between a program and an application. They both require code, but only applications have some kind of visual user interface that the user can interact with.</p>



<p>The user interface (UI) doesn&#8217;t have to be a window within your desktop operating system (e.g., Windows or MacOS). It can be on your mobile device or even a web page that you access through a web browser like Chrome or Firefox.</p>



<h2 class="wp-block-heading">Different types of applications and developers</h2>



<p>An application that you access on your desktop computer is called… drum roll… a desktop application. One that you access on your mobile device (e.g., Apple or Android smartphone) is called a mobile application. And one that you access through a web browser? You guessed it, a web application.</p>



<p>It turns out that the type of code we must write to create these different types of applications is somewhat different depending on the type of application we are creating.</p>



<p>Many of the concepts are the same but the programming languages, libraries (essentially, prewritten code), tools, and problems you&#8217;ll face as a programmer will be different depending on which platform you are targeting.</p>



<p>This is why professional programmers will often specialize in one or maybe two of these types of application development. So, you can be a desktop developer (less common these days), a mobile developer, or a web developer. </p>



<p>Sometimes, you&#8217;ll hear the term &#8220;app developer&#8221; which is a synonym for a mobile developer, given that &#8220;app&#8221; is often used to specifically refer to mobile applications.</p>



<p>Some programmers specialize even further, and are just iOS developers or Android developers, depending on the type of mobile devices they target.</p>



<p>Since not all programs are applications, it&#8217;s worth noting that there are many other types of developers who don&#8217;t work on applications. </p>



<p>For example, those who work on the operating system itself, programs that facilitate networks of computers to communicate, or code that enables hardware components to communicate with each other.</p>



<h2 class="wp-block-heading">The Web won</h2>



<p>There are plenty of viable careers to be had in mobile and other types of development, however since the aim of this guide is to help you become a web developer, we are going to focus on this particular subset of the development landscape.</p>



<p>Twenty-five years ago, the majority of developers were desktop developers (or a specialized version, like a Windows developer).</p>



<p>Over the past two decades, the web exploded in popularity. So it might reassure you to know that today the overwhelming majority of programmers are web developers.</p>



<p>The web is certainly not going anywhere, so the skills you acquire will serve you well for a long time to come.</p>



<h2 class="wp-block-heading">Static vs dynamic pages</h2>



<p>Alright, let&#8217;s focus on web applications. What are they and how do they work?</p>



<p>Let&#8217;s start with a simple web page, rather than a full-blown web application. When you visit <a rel="noreferrer noopener" href="https://antoniocangiano.com/" target="_blank">https://antoniocangiano.com</a>, my homepage, you are visiting a very simple static page.</p>



<p>My homepage is a so-called &#8220;static page&#8221; because it doesn&#8217;t dynamically change. For example, it doesn&#8217;t pull the data from a database like when you search for a product on Amazon.</p>



<p>It&#8217;s just a static document containing some text, images, and links organized in a somewhat logical and pleasing (if minimalist) manner.</p>



<p>When the web first come about in the early 90s, that&#8217;s all it was for the most part. A bunch of static pages linking to each other.</p>



<p>When server-side dynamic web pages became common, it transformed the web. We could now, among other things, collect information from the user, store it in a database, and dynamically display to the user content on the basis of their request.</p>



<p>You could even customize the page that was rendered to the user on the basis of who was logged in, for example.</p>



<p>Over time, these capabilities evolved to a point where web applications can deliver rich desktop-like interfaces and user experience.</p>



<p>Technically, this blog you are reading is a web application written in HTML, CSS, JavaScript, and PHP. It allows me to log in as an administrator and write blog posts. It allows you to comment, search for posts, subscribe to my <a href="https://programmingzen.com/feed" target="_blank" rel="noreferrer noopener">RSS feed</a>, see related content, and much more.</p>



<p>Web applications can be as simple as a plain todo list or as complex as the online version of Microsoft Excel or an elaborate video game.</p>



<h2 class="wp-block-heading">How does requesting a static page work</h2>



<p>When you type <code>https://antoniocangiano.com/</code> in your browser&#8217;s address bar and press enter, the following steps take place:</p>



<ul class="wp-block-list"><li>A DNS (Domain Name System) server is called to translate the hostname <code>antoniocangiano.com</code> to an IP (Internet Protocol) address where the site is actually hosted. You can think of DNS as white pages for the internet, where instead of people&#8217;s names being mapped to their phone numbers, you get website names mapped to their servers&#8217; IP addresses. Knowing the IP address of the server hosting the site will allow your browser to send the request to the right server among the millions of servers available on the internet.</li><li>The request you made tells the server that you want to get the page/information available at <code>/</code>. The server will grab the <code>index.html</code> file for my site and send it back to your browser as a response. (On a static site, <code>/</code> will typically render <code>index.html</code> just like <code>/about</code> would render the content of <code>about.html</code>. This is by convention and not always the case.)</li><li>Within that HTML file, I also reference a CSS file on the server, some images, and a little bit of client-side JavaScript. Your browser will request all of these elements from the server, and ultimately render the HTML page for you to see.</li></ul>



<p>(This is a simplification, but conceptually these are the major steps.)</p>



<p>There is no back-end development going on here. HTML, CSS, and client-side JavaScript are all front-end development technologies.</p>



<p>HTML provides the structure and content of the page. CSS determines the style of the page (font size, spacing, padding, colors, etc.). And JavaScript determines some behaviors of the page as you interact with it.</p>



<p>In the case of my homepage, when you move your mouse over the icons at the top, you&#8217;ll see a little tooltip pop up appear. That&#8217;s a bit of JavaScript in action.</p>



<p>I clarified that it&#8217;s client-side JavaScript because nowadays there is also server-side JavaScript which is indeed in the scope of back-end development. When I say &#8220;client-side&#8221;, I mean JavaScript that is executed by your browser.</p>



<h2 class="wp-block-heading">How does requesting a dynamic page work</h2>



<p>Web applications are collections of dynamic pages (and sometimes dynamic and static pages). Requesting a dynamic page is conceptually similar to requesting a static page, but behind the scenes there are a few more steps taking place.</p>



<p>For example, let&#8217;s say that you enter &#8220;iPad&#8221; in the search box of this site and press enter. You&#8217;ll notice in the address bar that you&#8217;ve made a request for <code>https://programmingzen.com/?s=ipad</code>.</p>



<p>There is no <code>ipad.html</code> file on the server, given that you could have typed anything into the search field.</p>



<p>(Ignore caching for the sake of this simplification, if you are already familiar with the concept.)</p>



<p>So behind the scenes, instead of locating the static file and issuing it in response for the browser to render, there are two extra steps:</p>



<ol class="wp-block-list"><li>The web server understands that you want posts related to the iPad. So the dynamic page will send a request to a database server that contains all my posts. Using a language called SQL (Structured Query Language), it will ask for a list of posts containing the word &#8220;iPad&#8221;.</li><li>With that information available, the web server will execute the code in the dynamic page which will use the list of posts to formulate a response which includes a series of neatly arranged iPad-related posts.</li></ol>



<div class="wp-block-image"><figure class="aligncenter size-full is-resized"><img data-recalc-dims="1" decoding="async" src="https://i0.wp.com/programmingzen.com/wp-content/uploads/2020/05/ipad-results-1.png?resize=613%2C384&#038;ssl=1" alt="The iPad results for my blog" class="wp-image-2597" width="613" height="384" title="The iPad results for my blog" srcset="https://i0.wp.com/programmingzen.com/wp-content/uploads/2020/05/ipad-results-1.png?w=2450&amp;ssl=1 2450w, https://i0.wp.com/programmingzen.com/wp-content/uploads/2020/05/ipad-results-1.png?resize=300%2C188&amp;ssl=1 300w, https://i0.wp.com/programmingzen.com/wp-content/uploads/2020/05/ipad-results-1.png?resize=1024%2C642&amp;ssl=1 1024w, https://i0.wp.com/programmingzen.com/wp-content/uploads/2020/05/ipad-results-1.png?resize=768%2C481&amp;ssl=1 768w, https://i0.wp.com/programmingzen.com/wp-content/uploads/2020/05/ipad-results-1.png?resize=1536%2C963&amp;ssl=1 1536w, https://i0.wp.com/programmingzen.com/wp-content/uploads/2020/05/ipad-results-1.png?resize=2048%2C1284&amp;ssl=1 2048w, https://i0.wp.com/programmingzen.com/wp-content/uploads/2020/05/ipad-results-1.png?w=2120&amp;ssl=1 2120w" sizes="(max-width: 613px) 100vw, 613px" /><figcaption>The page dynamically generated from my &#8220;iPad&#8221; search</figcaption></figure></div>



<p>Ultimately, what&#8217;s sent to your browser is still a bunch of HTML, CSS, and JavaScript. However, it didn&#8217;t come from a file on your server. It was dynamically generated based on information stored in the database.</p>



<p>Imagine for a moment that some posts on my site were available only to subscribers. The code of the dynamic page would need to check whether the person is logged in or not, whether they are a subscriber, and then alter the response accordingly.</p>



<p>If the user is a subscriber, include subscriber-only iPad posts in the list, if they are not, exclude those posts and just return the free ones available to everyone.</p>



<p>As you can imagine, the ability to dynamically generate the response depending on certain conditions is quite powerful and is the basis of how web applications work.</p>



<h2 class="wp-block-heading">Front-End vs Back-End technologies</h2>



<p>In terms of technology, what did we add to the HTML, CSS, and JavaScript front-end stack? We added code to the dynamic pages which can then make calls to a database and generate a customized response. PHP and SQL code in my case.</p>



<p>This code can be written in a variety of programming languages, however. Some popular examples are Python, Ruby, Java, Elixir, and even server-side JavaScript.</p>



<p>We&#8217;ll discuss <a href="https://programmingzen.com/what-to-study-to-become-a-web-developer/">why you&#8217;d use one language over another or which to choose</a> to land a job, in the next installment of this guide. For now, know that back-end development will require you to be familiar with a server-side programming language.</p>



<p>You&#8217;ll also need to know SQL and be familiar with how databases work.</p>



<p>Truth be told, back-end developers will need to know quite a bit more than just another programming language and databases.</p>



<p>For example, they&#8217;ll typically leverage a web framework like Ruby on Rails, Django, Flask, or Express.js to be more productive and write fewer lines of code to implement the features needed by the web application.</p>



<p>So you&#8217;ll also need to develop familiarity with whichever framework is most popular for your language of choice.</p>



<p>A lot of front-end developers are not writing plain JavaScript either. They too have to worry about frameworks and libraries, typically for JavaScript (and even CSS). Popular JavaScript options are React, Vue, Angular, and Ember.js.</p>



<p>Front-end developers will also need to worry about accessibility and providing a good user experience (UX) for the end-user. Huge topics that have dedicated specialists in their own right.</p>



<p>We&#8217;ll cover what you need to study in the <a href="https://programmingzen.com/what-to-study-to-become-a-web-developer/">next article</a> of this guide.</p>



<h2 class="wp-block-heading">Front-End vs Back-End developers</h2>



<p>While it is good to have an understanding of both front-end and back-end, most web developers end up specializing in either front-end or back-end.</p>



<p>Historically, front-end development had a certain stigma. It was perceived as easier. These days, I don&#8217;t believe this is a valid stance anymore.</p>



<p>The capability of web interfaces has grown dramatically over the years and so did the complexity of technologies leveraged to build such interactive and rich user interfaces.</p>



<p>It&#8217;s worth noting that back-end developers&#8217; salaries still tend to be higher than front-end developers&#8217; ones. But this might be at least in part because the majority of beginner web developers start with front-end technologies.</p>



<p>After all, you can&#8217;t be a back-end developer without knowing the fundamentals of HTML, CSS, and JavaScript, but you could in theory be a good front-end developer without knowing server-side languages and SQL.</p>



<p>Of course, exposure to both sides of the Web development line is always beneficial.</p>



<h2 class="wp-block-heading">Full-Stack developer</h2>



<p>Full-Stack developers are unicorns born in an enchanted forest located where the Hanson and the Eich rivers meet.</p>



<p>More seriously, it&#8217;s rare for someone to be amazing at both front-end and back-end development, but there are plenty of developers who are competent at both.</p>



<p>Larger companies tend to prefer specialized people, because they have the resources to hire larger teams that will include both front-end and back-end developers.</p>



<p>Startups and other smaller businesses might only be able to have one or two developers on hand, and therefore might find a full-stack developer who can build the entire web application to be a more practical option.</p>



<h2 class="wp-block-heading">DevOps specialists</h2>



<p>Writing web applications is only one part of the equation. You then need to deploy them somewhere on the internet so that they&#8217;re available to the public. (Pushing code to production, to use common lingo.)</p>



<p>You also need strategies to keep them running smoothly and handle updates and new releases of the code you write.</p>



<p>In smaller operations, this often falls on the web developer&#8217;s shoulders. Over the years, however, the role of <a rel="noreferrer noopener" href="https://en.wikipedia.org/wiki/DevOps" target="_blank">DevOps</a> engineer became its own profession.</p>



<p>Today, larger organizations will hire DevOps specialists/engineers to work alongside developers and system operators/administrations to ensure the best deployment practices.</p>



<p>As you work on becoming a web developer, you&#8217;ll inevitably pick up some of the skills possessed by DevOps. However, you don&#8217;t need to become a DevOps expert, unless you discover that it&#8217;s what you enjoy the most and decide to pursue that as your career.</p>



<h2 class="wp-block-heading">Which one should you choose?</h2>



<p>It&#8217;s way too early for you to commit to becoming a front-end, back-end, or full-stack developer.</p>



<p>The best you can do is learn the fundamentals and then decide on the basis of what you enjoy the most, what comes more naturally to you, and ultimately what you tend to be good at.</p>



<p>Some people might struggle with grokking databases but are capable of creating wonderful user interfaces. Others might be very good at solving algorithmic problems but fail miserably at putting together a user-friendly UI.</p>



<p>You&#8217;ll find out where you fit very soon.</p>



<h2 class="wp-block-heading">What&#8217;s next?</h2>



<p>In the next article of this <a href="https://programmingzen.com/how-to-become-a-web-developer-and-get-a-job/">How to Become a Web Developer and Get a Job</a> guide, we&#8217;ll cover the <a href="https://programmingzen.com/what-to-study-to-become-a-web-developer/">technology stacks I recommend</a> to maximize your chances of becoming a professional web developer and landing a job.</p>



<p>I&#8217;ll also discuss which languages, technologies, and tools you need to study to break into this industry. </p>



<p>That master list can act as a road map of skills you must acquire in the upcoming months to become a web developer.</p>
<p>The post <a href="https://programmingzen.com/front-end-vs-back-end-developer/">Front-End vs Back-End Developer</a> appeared first on <a href="https://programmingzen.com">Programming Zen</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://programmingzen.com/front-end-vs-back-end-developer/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2579</post-id>	</item>
		<item>
		<title>How to Become a Web Developer and Get a Job With No Experience (Guide)</title>
		<link>https://programmingzen.com/how-to-become-a-web-developer-and-get-a-job/</link>
					<comments>https://programmingzen.com/how-to-become-a-web-developer-and-get-a-job/#comments</comments>
		
		<dc:creator><![CDATA[Antonio Cangiano]]></dc:creator>
		<pubDate>Thu, 14 May 2020 20:12:18 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[how to become a programmer]]></category>
		<category><![CDATA[how to become a web developer]]></category>
		<category><![CDATA[how to get a developer job]]></category>
		<category><![CDATA[programming advice]]></category>
		<category><![CDATA[tips for young programmers]]></category>
		<guid isPermaLink="false">https://programmingzen.com/?p=2520</guid>

					<description><![CDATA[<p>In this guide, I&#x2019;ll teach you how to become a Web Developer and in turn how to get a job in our industry. I&#x2019;ll split the guide into a series of articles. Once the guide is complete, I will also make it available for free to my subscribers in PDF, EPUB, and MOBI format. Who is this guide for This guide is for anyone who wants to become a Web Developer and get a job as a professional developer. The &#x201C;how to become a Web Developer&#x201D; portion of the guide is going to be specific to web development, but even </p>
<p>The post <a href="https://programmingzen.com/how-to-become-a-web-developer-and-get-a-job/">How to Become a Web Developer and Get a Job With No Experience (Guide)</a> appeared first on <a href="https://programmingzen.com">Programming Zen</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>In this guide, I’ll teach you <strong>how to become a Web Developer</strong> and in turn how to get a job in our industry.</p>



<p>I’ll split the guide into a series of articles. Once the guide is complete, I will also make it available for free to my subscribers in PDF, EPUB, and MOBI format.</p>



<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img data-recalc-dims="1" decoding="async" src="https://i0.wp.com/programmingzen.com/wp-content/uploads/2020/05/How-to-Become-a-Web-Developer-and-Get-a-Job.png?resize=600%2C338&#038;ssl=1" alt="How to Become a Web Developer and Get a Job" class="wp-image-2530" width="600" height="338" srcset="https://i0.wp.com/programmingzen.com/wp-content/uploads/2020/05/How-to-Become-a-Web-Developer-and-Get-a-Job.png?w=600&amp;ssl=1 600w, https://i0.wp.com/programmingzen.com/wp-content/uploads/2020/05/How-to-Become-a-Web-Developer-and-Get-a-Job.png?resize=300%2C169&amp;ssl=1 300w" sizes="(max-width: 600px) 100vw, 600px" /></figure></div>



<h2 class="wp-block-heading">Who is this guide for</h2>



<p>This guide is for anyone who wants to become a Web Developer and get a job as a professional developer.</p>



<p>The “<strong>how to become a Web Developer</strong>” portion of the guide is going to be specific to web development, but even those seeking to become other types of developers will likely benefit from its insight.</p>



<p>The “<strong>how to get a job as a developer</strong>” portion is much more generic and will serve you well regardless of your chosen specialization.</p>



<p>I’m writing this guide with two kinds of people in mind. Young people hoping to become professional developers and existing professionals who are hoping to switch careers (or who may be returning to the workforce in the case of stay-at-home parents).</p>



<p>These are the kinds of people I have personally helped in the past and those I have the most experience with. Nevertheless, the advice provided throughout this series should be suitable for anyone whose goal is to land a developer job.</p>



<h2 class="wp-block-heading">Requirements</h2>



<p>I’ll take for granted that you have used a computer before and are somewhat web-savvy. As a litmus test of the sort, I’m assuming you know that Google Chrome and Mozilla Firefox are two browsers and can install an extension/add-on (or could figure it out by Googling it).</p>



<p>I’m also going to assume that you’re smart but not necessarily a genius like I am. That’s a joke, by the way, I’m not a genius. I’m a super genius. 🙂</p>



<p>Jokes aside, the media has created a certain stereotype of what a programmer looks like. The asocial genius wearing a hoodie can be an intimidating benchmark for those starting out.</p>



<p>The truth is developers come in all shapes, sizes, and forms. And although developers are reasonably smart people, being exceptionally gifted is by no means a requirement. You <a href="https://massivesci.com/articles/programming-math-language-python-women-in-science/" target="_blank" rel="noreferrer noopener">don&#8217;t even necessarily need</a> to be good at math.</p>



<p>Technical ability, as we’ll discuss more in-depth soon, is also not the only desirable trait of a great developer. Your communication skills and ability to collaborate are just as, if not more, important. </p>



<h2 class="wp-block-heading">Who am I</h2>



<p>I’m a Software Development Manager and AI Advocate at IBM. I’ve been a professional Web Developer for 20 years.</p>



<p>Within IBM, I’m known as the guy who got the company to adopt Rails and Django, in the early days of these technologies, and more recently I’ve been gradually doing the same for Elixir and Phoenix. (If you don’t know what any of this means, no worries, we’ll cover your options soon.)</p>



<p>Over the years, I’ve provided advice to countless people who were hoping to make it into our industry, many of whom I’ve personally mentored.</p>



<p>For the past twelve years, I’ve been doing the candidate selections for my team. As a result, I must have reviewed thousands of résumés, interviewed hundreds of developers, and hired a few dozen applicants.</p>



<p>I’m also the author of a couple of technical books. One on <a href="https://amzn.to/3fSiVc7" target="_blank" rel="noreferrer noopener">Rails for Microsoft developers</a> (painfully obsolete at this point) and one on <a href="https://pragprog.com/titles/actb2/" target="_blank" rel="noreferrer noopener">Technical Blogging</a> (current and quite useful to those seeking to advance their career in tech).</p>



<p>Among too many other things, I’m also the author of a popular <a href="https://www.coursera.org/learn/building-ai-powered-chatbots" target="_blank" rel="noreferrer noopener">chatbot course</a> that’s been taken by over 100,000 people worldwide on <a href="https://cognitiveclass.ai/" target="_blank" rel="noreferrer noopener">Cognitive Class</a> (a volunteer initiative for which I’m the marketing manager), Coursera, and edX.</p>



<p>This is not to brag (like many of us, I tend to feel underaccomplished at times), but rather to say there is a method to my madness and that my approach appears to have helped a lot of people. I’m hoping that it will help you as well.</p>



<h2 class="wp-block-heading">A disclaimer on how to become a Web Developer</h2>



<p>“How to become a Web Developer” doesn’t mean that I will teach you how to program in HTML, CSS, JavaScript, etc. I could do that, but this svelte guide would become a 1,200-page tome in no time flat. And it would likely be one that would echo a lot of resources that are already available elsewhere.</p>



<p>Instead, I’m going to tell you what to study, along with how and why to study it. I will also point out various useful books and resources where you can learn more about the technical topics I mention.</p>



<p>I’ll give you the roadmap, but I won’t be doing the actual studying for you. 🙂</p>



<p>This is all very doable though, fear not. There are millions of developers, most of who are not any more special than you are. However, it would be a lie to say that there won’t be a lot of work involved on your part.</p>



<p>It will be, but if you’re not afraid of some elbow grease, a better career (and possibly life) awaits you on the other side of that dedicated effort.</p>



<h2 class="wp-block-heading">Why would you want to become a developer</h2>



<p>Instead of elaborate arguments trying to sell you on the profession, I’m going to list a few quick, bullet points in favor of becoming a Web Developer in the 2020s.</p>



<ul class="wp-block-list"><li><strong>Web development is future-proof.</strong> AI will take over a lot of jobs, but most developer jobs won’t be automated away any time soon.</li><li><strong>Web development can be remote.</strong> Most forms of software development, not just web development, can be carried out remotely. So you’re less likely to lose your job if, as if it’s currently the case with COVID–19, you are forced to be inside for extended lengths of time. There are, of course, other variables at play, but this improves your odds of remaining employed.</li><li><strong>Web development is creative</strong>. You’ll be able to engage both the analytical side and the more creative parts of your brain.</li><li><strong>Web development is fun</strong>. Two aspects that make web development really fun are being able to instantly see the results of your work (right in your web browser) and the ability to share it with the world at large. All this, without them having to install anything on their devices.</li><li><strong>Web development doesn’t require a degree</strong>. A degree in Computer Science or Software Engineering is certainly helpful and provides many useful fundamentals. However, it’s by no means required to become a Web Developer or to get a job as a Web Developer.</li><li><strong>Web development pays well</strong>. Try getting a job that pays six figures without a degree in most other fields; they&#8217;ll laugh as they escort you out of the interview room. Sure, your first web development job is unlikely to pay six figures, but you can still expect a generous salary right out of the gate from many companies (in the US, a junior developer will earn, on average, <a rel="noreferrer noopener" href="https://www.indeed.com/career/junior-developer/salaries" target="_blank">$66,695 per year</a>). </li></ul>



<p>Those are some of the major perks but, as you’ll find out if you go through this process, the work itself can definitely be its own reward as well. </p>



<p>Of course, your landlord expects dollars not your sense of accomplishment and self-satisfaction. But thankfully, web development covers you there as well.</p>



<h2 class="wp-block-heading">What to expect next</h2>



<p>This first article in our series is primarily an introduction to what is to come in future entries.</p>



<p>Here are some of the topics that I’ll cover next:</p>



<ul class="wp-block-list"><li><a href="https://programmingzen.com/front-end-vs-back-end-developer/">Front-End VS Back-End Developer</a>: Front-End Developer, Back-end Developer, Full-Stack Developer, DevOps: what are the options, and what do they entail?</li><li><a href="https://programmingzen.com/what-to-study-to-become-a-web-developer/">What set of web development technologies you should study</a>. The ones that maximize your chances of getting a job as a web developer.</li><li>How to study for your chosen web development stack (including specific books, courses, and resources).</li><li>Résumés, Github, and project portfolios.</li><li>Using social media and blogging to stand out from the crowd and attract job offers.</li><li>Finding the right jobs and applying for them.</li><li>Mastering the interview process.</li></ul>



<p>For now, remember that you can do this. Together we can get you in shipshape for your future web development job.</p>



<p>And please don’t forget to subscribe below to ensure you receive the next installments of this guide.</p>
<p>The post <a href="https://programmingzen.com/how-to-become-a-web-developer-and-get-a-job/">How to Become a Web Developer and Get a Job With No Experience (Guide)</a> appeared first on <a href="https://programmingzen.com">Programming Zen</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://programmingzen.com/how-to-become-a-web-developer-and-get-a-job/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2520</post-id>	</item>
		<item>
		<title>Removing Duplicates From a List in Elixir</title>
		<link>https://programmingzen.com/remove-duplicates-from-list-elixir/</link>
					<comments>https://programmingzen.com/remove-duplicates-from-list-elixir/#comments</comments>
		
		<dc:creator><![CDATA[Antonio Cangiano]]></dc:creator>
		<pubDate>Thu, 07 May 2020 04:27:39 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[elixir]]></category>
		<category><![CDATA[elixir-cookbook]]></category>
		<category><![CDATA[Enum]]></category>
		<category><![CDATA[List]]></category>
		<category><![CDATA[recursion]]></category>
		<category><![CDATA[tips]]></category>
		<guid isPermaLink="false">https://programmingzen.com/?p=2486</guid>

					<description><![CDATA[<p>Thanks to the Enum module, in Elixir we can trivially remove duplicates from a list. In the following example, we take a list of integers and pass it to the Enum.uniq/1 function which removes duplicates from the list without altering the original order of the remaining elements. If you are trying to only remove consecutive duplicate elements, then there is Enum.dedup/1: (Note: We append /1 simply as a notation indicating the arity of a function, that is how many arguments it accepts. my_func/1 accepts one argument, my_func/2 two, and so on.) Enum is full of helpful functions when working with </p>
<p>The post <a href="https://programmingzen.com/remove-duplicates-from-list-elixir/">Removing Duplicates From a List in Elixir</a> appeared first on <a href="https://programmingzen.com">Programming Zen</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Thanks to the <code>Enum</code> module, in Elixir we can trivially remove duplicates from a list.</p>



<p>In the following example, we take a list of integers and pass it to the <code>Enum.uniq/1</code> function which removes duplicates from the list without altering the original order of the remaining elements.</p>



<pre class="wp-block-code"><code>list = &#91;1, 2, 2, 3, 3, 1, 2, 4]
Enum.uniq(list) # Returns &#91;1, 2, 3, 4]</code></pre>



<p>If you are trying to only remove consecutive duplicate elements, then there is <code>Enum.dedup/1</code>:</p>



<pre class="wp-block-code"><code>list = &#91;1, 2, 2, 3, 3, 1, 2, 4]
Enum.dedup(list) # Returns &#91;1, 2, 3, 1, 2, 4]</code></pre>



<p>(Note: We append <code>/1</code> simply as a notation indicating the <em>arity</em> of a function, that is how many arguments it accepts. <code>my_func/1</code> accepts one argument, <code>my_func/2</code> two, and so on.)</p>



<p><a rel="noreferrer noopener" href="https://hexdocs.pm/elixir/Enum.html" target="_blank">Enum is full of helpful functions</a> when working with collection data types that implement the <code>Enumerable</code> protocol (e.g., lists, maps, ranges, streams, etc.) and it&#8217;s worth getting acquainted with.</p>



<h2 class="wp-block-heading">Removing duplicates using recursion</h2>



<p>Alright, Elixir does the heavy lifting for us in this case, but how would we go about removing duplicates from a list in Elixir without using <code>Enum.uniq/1</code>? I mean from scratch, simply using recursion without relying on <code>Enum</code>, sets, <code>:lists.usort/1</code>, etc. </p>



<p>It is worth asking such a question to both exercise our recursion muscle (something that doesn&#8217;t come naturally to most programmers) and so that we&#8217;re ready to handle conceptually similar problems that do not have pre-made functions but could benefit from a recursive solution.</p>



<p>There are likely a few ways to implement this, but this what sprang to mind when I thought about it:</p>



<pre class="wp-block-code"><code>defmodule MyList do
  def uniq(&#91;]), do: &#91;]

  def uniq(&#91;head | tail]) do
    &#91;head | for(x &lt;- uniq(tail), x != head, do: x)]
  end
end</code></pre>



<p>Calling <code>MyList.uniq(list)</code> will then return the same list without duplicates as <code>Enum.uniq(list)</code>did. (Although, it&#8217;s worth noting, that we implemented a <code>List</code>-specific version of the <code>uniq/1</code> function).</p>



<p>Let&#8217;s see how this works. If the list is empty (i.e., <code>[]</code>) we obviously return an empty list, as there is nothing to remove. This is our base case for the recursion.</p>



<p>If the list is not empty, it will have a head and a tail, and we use Elixir&#8217;s pattern matching to bind the first element of the list passed to the function to <code>head</code> and the rest of the elements to the list <code>tail</code>. </p>



<p>Note that a proper list with a single element will simply have an empty list as its tail. So writing <code>[3]</code> is equivalent to writing <code>[3|[]]</code> where <code>3</code> is the head, <code>[]</code> is the tail, and <code>|</code> is the cons operator (short for constructor operator, as it&#8217;s used to construct lists).</p>



<p>So far so good. Here is where things get a little trickier. Let&#8217;s analyze this line:</p>



<pre class="wp-block-code"><code>    &#91;head | for(x &lt;- uniq(tail), x != head, do: x)]</code></pre>



<p>The code is wrapped in square brackets <code>[...]</code>which means that we are returning a list. Then you&#8217;ll notice the <code>|</code> <em>cons</em> operator. So we are constructing a list that has <code>head</code> as its first element and whatever the rest of that line of code does, as its tail.</p>



<p>This makes sense if you think about it. Sure, the list might have duplicates, but the first element will always be included. If a duplicate of the first element exists, that&#8217;s the one that is going to be removed and not the first element.</p>



<p>So we are building a list and the first element of the original list is also the first element of our deduplicated list. What goes into the rest of the list?</p>



<h3 class="wp-block-heading">Comprehensions</h3>



<p>We see a <code>for</code>. Unlike many programming languages, <code>for</code> is not a loop keyword in Elixir. Rather, it is used for comprehensions (a form of syntax sugar to generate lists from existing collections). Syntax, which is not too different from mathematical notation.</p>



<p>Here is a simple example of how to use them:</p>



<pre class="wp-block-code"><code>for x &lt;- &#91;1, 2, 3, 4], do: x + x # Returns &#91;2, 4, 6, 8]</code></pre>



<p>&#8220;For each element <code>x</code> in <code>[1, 2, 3, 4]</code> do <code>x + x</code> and put the result in a list.&#8221;</p>



<p>It also accepts filters, which allows us to specify a condition:</p>



<pre class="wp-block-code"><code>for x &lt;- &#91;1, 2, 3, 4], x &lt; 3, do: x + x # Returns &#91;2, 4]</code></pre>



<p>In this example, the condition is that <code>x</code> is smaller than <code>3</code>, so only the first two elements, which are lesser than <code>3</code>, get doubled and added to the resulting list.</p>



<h3 class="wp-block-heading">Recursing our way to the base case</h3>



<p>OK, back to our &#8220;cryptic&#8221; line:</p>



<pre class="wp-block-code"><code>    &#91;head | for(x &lt;- uniq(tail), x != head, do: x)]</code></pre>



<p><code>head</code> is our first element and then we are using a comprehension to generate a list without duplicates.</p>



<p>We are saying, for each <code>x</code> in a deduplicated <code>tail</code>, add <code>x</code> to the list if it&#8217;s different from our first element <code>head</code>.</p>



<p>The part that gets people weirded out about is recursively calling <code>uniq(tail)</code>. We can get away with this because we have a base case that ensures we don&#8217;t recurse forever.  </p>



<p>At each call of <code>uniq(tail)</code> we are making the tail shorter by one element. </p>



<p>For example, executing <code>MyList.uniq([1, 2, 3, 3])</code> will make the following recursive calls:</p>



<ul class="wp-block-list"><li><code>MyList.uniq([1, 2, 3, 3])</code></li><li><code>MyList.uniq([2, 3, 3])</code></li><li><code>MyList.uniq([3, 3])</code></li><li><code>MyList.uniq([3])</code></li><li><code>MyList.uniq([])</code></li></ul>



<p>When we eventually get to the tail being <code>[]</code>, which is our base case,<code>[]</code> is returned and <code>MyList.uniq/1</code> is no longer called.</p>



<p>Recursion can be hard to grasp at first, but it&#8217;s a powerful tool and a staple of functional programming, so it&#8217;s well worth practicing.</p>



<p>As pointed out in the comment section, this implementation is quite illustrative but not very efficient. In production, you&#8217;d want to opt for the built-in functions or implement a tail-recursive version that leverages <code><a rel="noreferrer noopener" href="https://hexdocs.pm/elixir/MapSet.html" target="_blank">MapSet</a></code>. And although tail recursion is faster in this case, it&#8217;s worth noting that even that is <a href="http://erlang.org/doc/efficiency_guide/myths.html" target="_blank" rel="noreferrer noopener">not a silver bullet</a>.</p>
<p>The post <a href="https://programmingzen.com/remove-duplicates-from-list-elixir/">Removing Duplicates From a List in Elixir</a> appeared first on <a href="https://programmingzen.com">Programming Zen</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://programmingzen.com/remove-duplicates-from-list-elixir/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2486</post-id>	</item>
		<item>
		<title>Specify a Port when Booting a Phoenix Application</title>
		<link>https://programmingzen.com/specify-a-port-when-booting-a-phoenix-app/</link>
					<comments>https://programmingzen.com/specify-a-port-when-booting-a-phoenix-app/#comments</comments>
		
		<dc:creator><![CDATA[Antonio Cangiano]]></dc:creator>
		<pubDate>Mon, 04 May 2020 00:16:48 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[cowboy]]></category>
		<category><![CDATA[elixir]]></category>
		<category><![CDATA[elixir-cookbook]]></category>
		<category><![CDATA[phoenix]]></category>
		<category><![CDATA[port]]></category>
		<category><![CDATA[sever]]></category>
		<category><![CDATA[tips]]></category>
		<guid isPermaLink="false">https://programmingzen.com/?p=2474</guid>

					<description><![CDATA[<p>When developing a Phoenix application, you&#8217;ll boot the server with: mix phx.server. This will start Cowboy in development mode, which by default accepts connections on port 4000. But how do you specify a different port? In Phoenix, there is no -P or -p option. You&#8217;ll need to edit your config/dev.exs configuration file to change the host key as follows: System.get_env(&#34;PORT&#34;, &#34;4000&#34;) retrieves the value of the PORT environment variable if one has been set. If the environment doesn&#8217;t have the specified variable (i.e., PORT), it will default to 4000. You can then boot your Phoenix server by passing the variable </p>
<p>The post <a href="https://programmingzen.com/specify-a-port-when-booting-a-phoenix-app/">Specify a Port when Booting a Phoenix Application</a> appeared first on <a href="https://programmingzen.com">Programming Zen</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>When developing a Phoenix application, you&#8217;ll boot the server with: <code>mix phx.server</code>. This will start Cowboy in development mode, which by default accepts connections on port <code>4000</code>. But how do you specify a different port? In Phoenix, there is no <code>-P</code> or <code>-p</code> option.</p>



<p>You&#8217;ll need to edit your <code>config/dev.exs</code> configuration file to change the <code>host</code> key as follows:</p>



<pre class="wp-block-code"><code>http: &#91;port: System.get_env("PORT", "4000")],</code></pre>



<p><code>System.get_env("PORT", "4000")</code> retrieves the value of the <code>PORT</code> environment variable if one has been set. If the environment doesn&#8217;t have the specified variable (i.e., <code>PORT</code>), it will default to <code>4000</code>.</p>



<p>You can then boot your Phoenix server by passing the variable value to the command as follows:</p>



<pre class="wp-block-code"><code>$ PORT=5000 mix phx.server</code></pre>



<p>This will run the server on the port you specified, in this example <code>5000</code>.</p>



<p>The name of the environment variable is arbitrary. We used <code style="font-size: 16px;">PORT</code> but we could have opted for <code style="font-size: 16px;">PHX_PORT</code> or something else altogether. Just so long as your configuration file and environment use the same name.</p>



<p>You can, of course, set the environment variable outside of the <code>mix phx.server</code> command, for example in your shell profile.</p>
<p>The post <a href="https://programmingzen.com/specify-a-port-when-booting-a-phoenix-app/">Specify a Port when Booting a Phoenix Application</a> appeared first on <a href="https://programmingzen.com">Programming Zen</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://programmingzen.com/specify-a-port-when-booting-a-phoenix-app/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2474</post-id>	</item>
		<item>
		<title>Developing with Elixir/OTP Course Review</title>
		<link>https://programmingzen.com/developing-with-elixir-otp-course-review/</link>
					<comments>https://programmingzen.com/developing-with-elixir-otp-course-review/#comments</comments>
		
		<dc:creator><![CDATA[Antonio Cangiano]]></dc:creator>
		<pubDate>Thu, 30 Apr 2020 04:01:22 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Reviews]]></category>
		<category><![CDATA[elixir]]></category>
		<category><![CDATA[erlang]]></category>
		<category><![CDATA[online courses]]></category>
		<category><![CDATA[OTP]]></category>
		<category><![CDATA[pragmaticstudio]]></category>
		<category><![CDATA[review]]></category>
		<category><![CDATA[Ruby]]></category>
		<guid isPermaLink="false">https://programmingzen.com/?p=2457</guid>

					<description><![CDATA[<p>Ruby was the first programming language I truly fell in love with. Yes, I had used several others before (and have since), but Ruby was and still is something dear to me. I can appreciate the usefulness of Python, the simplicity of Go, and the mind-expanding nature of Haskell. Yet, anything that isn&#x2019;t Ruby felt like a usability downgrade. It&#x2019;s all highly subjective, &#xE7;a va sans dire, but Ruby was always my favorite. It&#x2019;s not every day that a language comes along and genuinely excites me to the point of putting Ruby aside (within the scope of what it&#x2019;s great </p>
<p>The post <a href="https://programmingzen.com/developing-with-elixir-otp-course-review/">Developing with Elixir/OTP Course Review</a> appeared first on <a href="https://programmingzen.com">Programming Zen</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Ruby was the first programming language I truly fell in love with. Yes, I had used several others before (and have since), but Ruby was and still is something dear to me.</p>



<p>I can appreciate the usefulness of Python, the simplicity of Go, and the mind-expanding nature of Haskell. Yet, anything that isn&#8217;t Ruby felt like a usability downgrade. It&#8217;s all highly subjective, ça va sans dire, but Ruby was always my favorite.</p>



<p>It&#8217;s not every day that a language comes along and genuinely excites me to the point of putting Ruby aside (within the scope of what it&#8217;s great at doing).</p>



<h2 class="wp-block-heading">I &lt;3 Elixir</h2>



<p>That language is Elixir. I&#8217;ve been using it on and off for a few years now. I first <a href="https://programmingzen.com/next-programming-language/">talked about it</a> back in 2016 and even managed to convince my team at IBM to adopt it to an extent. It&#8217;s working out well for us so far and I have a hunch we might double down on it soon.</p>



<p>Since I have a little more time, due to being stuck inside, I&#8217;ve been on a &#8220;study anything in sight related to Elixir and Phoenix&#8221; kick lately.</p>



<p>I am a big fan of Mike and Nicole Clark of The Pragmatic Studio and in the past have highly <a href="https://programmingzen.com/rails-books/">recommended their Ruby and Rails courses</a>. So I decided to start taking their Elixir courses as well. In this post, I&#8217;ll give you a fairly detailed review of their largest course on the subject, <a rel="noreferrer noopener" href="https://pragmaticstudio.com/elixir" target="_blank">Developing with Elixir/OTP</a>.</p>



<h2 class="wp-block-heading">Who is it for?</h2>



<figure class="wp-block-image size-full is-resized"><img data-recalc-dims="1" loading="lazy" decoding="async" src="https://i0.wp.com/programmingzen.com/wp-content/uploads/2020/04/developing-with-elixir-otp-review.png?resize=768%2C434&#038;ssl=1" alt="Developing with Elixir/OTP Course Review" class="wp-image-2460" width="768" height="434" srcset="https://i0.wp.com/programmingzen.com/wp-content/uploads/2020/04/developing-with-elixir-otp-review.png?w=1536&amp;ssl=1 1536w, https://i0.wp.com/programmingzen.com/wp-content/uploads/2020/04/developing-with-elixir-otp-review.png?resize=300%2C169&amp;ssl=1 300w, https://i0.wp.com/programmingzen.com/wp-content/uploads/2020/04/developing-with-elixir-otp-review.png?resize=1024%2C578&amp;ssl=1 1024w, https://i0.wp.com/programmingzen.com/wp-content/uploads/2020/04/developing-with-elixir-otp-review.png?resize=768%2C434&amp;ssl=1 768w" sizes="auto, (max-width: 768px) 100vw, 768px" /></figure>



<p>Developing with Elixir/OTP is aimed at programmers. It&#8217;s so well explained that beginners can give it a shot, however, they are not the target audience.</p>



<p>The course assumes you have zero knowledge of Elixir itself but it&#8217;s not going to explain basic programming concepts when they are not novel or unique to Elixir.</p>



<p>Experience with Ruby is not required nor assumed, but it&#8217;s beneficial. This isn&#8217;t so much due to the way the course is presented (though there are a couple of nods to Ruby programmers). Rather, it&#8217;s the similarity (on the surface) between the two languages.</p>



<h2 class="wp-block-heading">How much time do you need to invest?</h2>



<p>Developing with Elixir/OTP is a 6.5 hour course divided across 30 modules. There is no way for you to take this course in 6.5 hours and get anything worthwhile from it.</p>



<p>In fact, the secret sauce is that each module has a Notes section dedicated to expanding on the topic, providing tips and tricks, as well as exercises.&nbsp;</p>



<p>I would estimate that it took me around 20 hours or so to finish, despite being very familiar with the subject matter. Mind you, I do like to experiment quite a bit within IEx to veer off the beaten path.</p>



<p>Estimate 30 hours of your time, an hour per module, if you intend to fully absorb and experiment with the material presented.</p>



<p>Unlike their Rails course, you won&#8217;t develop two applications (one while watching the videos and one in the Notes section). In this course, there is only one application that is mostly developed in the videos and then enhanced in the Notes through exercises.</p>



<p>This will save you a lot of time at the small expense of having to pause and resume the video to type along.</p>



<p>Another time-saver is that the code for each module in the course is provided so that you&#8217;re never lost. Particularly useful to copy and paste the more tedious parts (e.g., sample data and template code).</p>



<h2 class="wp-block-heading">What will you build?</h2>



<p>The course starts off by developing a simple web server. Think, high-level transformations of requests into responses. It builds it from the ground up and then layers a simple RESTful API for a fictitious wildlife reserve on top.</p>



<p>They start off with the simplest thing, a function that transforms one specific request into one specific response, and then move up all the way to actually serving the API over HTTP.</p>



<p>The goal, as often stated in the course, is not to replace an established and much more robust web server like Cowboy or a framework like Phoenix. At all.</p>



<p>Instead, it serves two pedagogical purposes. First, it teaches you how to use the language to solve a fairly complex problem. Second, it gives you a deeper understanding of how the production-ready tools you are going to adopt actually work within.</p>



<p>This approach is endemic to their teaching method. For example, they&#8217;ll develop a simple web server and API from scratch and then show you how similar it is to the equivalent Phoenix version. By the time you hit module 17 on Phoenix, you don&#8217;t quite know Phoenix but it should feel oddly familiar. After all, you built a naïve/simplified version of the same controllers, router, templates, etc. from scratch. This is, of course, a deliberate choice.</p>



<p>The same is true when they implement a simple GenServer from scratch and then are able to seamlessly replace it with the real deal (with <code>use GenServer</code>). Yes, you developed the Fisher-Price version of the production-ready tools, but you now understand how they work under the hood. All before Mike and Nicole proceed to teach you how to use the battle-tested ones.</p>



<p>I&#8217;m a fan of this didactic approach and I think it will serve most people well.</p>



<h2 class="wp-block-heading">What will you learn?</h2>



<p>It might be surprising to some but this course does not provide the typical tour of data types and data structures available in the language.</p>



<p>Instead, it uses the language to build something from the beginning and, in the process, it quickly exposes you to a variety of concepts, including how to use common data types.</p>



<p>It doesn&#8217;t cover them thoroughly, however, so reading the <a rel="noreferrer noopener" href="https://elixir-lang.org/getting-started/introduction.html" target="_blank">Elixir tutorial</a> on the official site would be very beneficial prior to or after taking this course.</p>



<p>The course starts off with several modules that are heavily focused on pattern matching. This is a good choice because pattern matching is one of the most valuable and pervasive features of Elixir.</p>



<p>As you would expect, there is also quite a bit of emphasis on immutable data structures, the pipe operator, recursion, and the Enum module.</p>



<p>In the process you&#8217;ll also learn a lot about IEx, Mix, organizing your code in a logical and idiomatic manner, defining Structs as the safer alternatives to maps, and comprehensions. </p>



<p>Testing is covered adequately but not extensively in its own module. Not in a TDD manner from the very start of the course like they did in some of their previous courses. This has, again, didactical advantages even if you choose to adopt TDD in your actual work.</p>



<p>In the second half of the course, things get a little more serious courtesy of OTP, delving deeper into working with sockets, the actor model, Task, GenServer, and linking and monitoring processes.</p>



<h2 class="wp-block-heading">Other points worth making</h2>



<p>In more or less random order:</p>



<ul class="wp-block-list"><li>The course is up to date to Elixir 1.10.x, somewhat rare among Elixir courses. Some of the videos show Mike and Nicole using a previous version (i.e., 1.5), but the Notes use the latest version and the rare differences are noted.  For example, the video shows the old <code>mix new</code> project format which included a <code>config</code> folder. In their hands-on notes for the video, they have a comprehensive &#8220;I don&#8217;t see a config directory&#8221; section to address it. You&#8217;re basically never lost or confused due to version discrepancies.</li><li>The overall quality is excellent. It&#8217;s a really polished product in terms of audio, video, text, and visuals used to aid in explaining the more conceptual parts.</li><li>They answer the overwhelming majority of your &#8220;wait a second&#8221; questions and objections. Either later in the video or right in the notes for that particular module. They genuinely anticipate most questions, which is the hallmark of a great course.</li><li>Most modules have a single 5-15 minute video, but some modules include two videos. So the modules are&#8230; well, modular.</li><li>Although this course will equip you to start studying Phoenix, it doesn&#8217;t really cover the subject. There is a module, as I mentioned, which is just enough to whet your appetite for the framework.</li><li>Erlang interoperability is at least in part addressed in module 20, where sample code from the documentation of <code>gen_tcp</code> is converted from Erlang to Elixir code.</li><li>The course is full of small tips like enabling command history in IEx (with <code>export ERL_AFLAGS="-kernel shell_history enabled"</code>), speeding up unit tests by making them asynchronous (i.e., <code>use ExUnit.Case, async: true</code>), using <code>flush()</code> to clear a process&#8217; mailbox, etc.</li></ul>



<h2 class="wp-block-heading">Is it worth the price?</h2>



<p>At $89, <a href="https://pragmaticstudio.com/elixir">Developing with Elixir/OTP</a> is not your average Udemy course that&#8217;s routinely discounted to $12. That&#8217;s because it&#8217;s not your average course.</p>



<p>If I had to rate it, I&#8217;d give it a 4.5 out of 5. I highly recommend it to working programmers who are interested in picking up Elixir quickly.</p>



<p>I would argue that it&#8217;s a great, current resource that is well worth the price of admission if you favor learning from videos.</p>
<p>The post <a href="https://programmingzen.com/developing-with-elixir-otp-course-review/">Developing with Elixir/OTP Course Review</a> appeared first on <a href="https://programmingzen.com">Programming Zen</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://programmingzen.com/developing-with-elixir-otp-course-review/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2457</post-id>	</item>
		<item>
		<title>Sorting Results by Specific Values in SQL with CASE</title>
		<link>https://programmingzen.com/sorting-results-by-specific-values-in-sql-with-case/</link>
					<comments>https://programmingzen.com/sorting-results-by-specific-values-in-sql-with-case/#respond</comments>
		
		<dc:creator><![CDATA[Antonio Cangiano]]></dc:creator>
		<pubDate>Wed, 01 Apr 2020 01:50:06 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[SQL]]></category>
		<guid isPermaLink="false">https://programmingzen.com/?p=2411</guid>

					<description><![CDATA[<p>In this article, I show a handy example of how to use the SQL CASE statement. Recently I rewrote the backend for my service, Any New Books, due to an Amazon API change. Generally speaking, rewriting an entire codebase is a bad idea. However, the code was quite old and the API changes rather drastic, so I took the opportunity to rewrite the whole thing in Rails 6. This service allows you to subscribe (100% for free) to categories of your choosing and then receive a weekly email for each category with a selection of newly released books. In the </p>
<p>The post <a href="https://programmingzen.com/sorting-results-by-specific-values-in-sql-with-case/">Sorting Results by Specific Values in SQL with CASE</a> appeared first on <a href="https://programmingzen.com">Programming Zen</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="has-text-align-center"><em>In this article, I show a handy example of how to use the SQL CASE statement.</em></p>



<p>Recently I rewrote the backend for my service, <a rel="noreferrer noopener" aria-label="Any New Books (opens in a new tab)" href="https://anynewbooks.com" target="_blank">Any New Books</a>, due to an Amazon API change. Generally speaking, rewriting an entire codebase is a bad idea. However, the code was quite old and the API changes rather drastic, so I took the opportunity to rewrite the whole thing in Rails 6.</p>



<p>This service allows you to subscribe (100% for free) to categories of your choosing and then receive a weekly email for each category with a selection of newly released books. </p>



<p>In the backend, the algorithm uses a few heuristics to determine how to present new books for a given category, so that the best candidates surface to the top to be manually selected by a (human) editor.</p>



<h2 class="wp-block-heading">Sorting results by specific values with CASE</h2>



<p>One of the parameters to consider is, believe it or not, whether a book&#8217;s binding is hardcover, paperback, Kindle, or audiobook. So at some point, I needed to sort results by these specific values in SQL.</p>



<p>In the backend I rely on PostgreSQL, so I used the following simple case statement:</p>



<pre class="wp-block-code"><code class="prettyprinted">SELECT *
FROM   books
ORDER  BY CASE binding
            WHEN 'Hardcover' THEN 1
            WHEN 'Paperback' THEN 2
            WHEN 'Kindle Edition' THEN 3
            WHEN 'Audiobook' THEN 4
            ELSE 5
          END</code>
</pre>



<p>This will order books placing hardcover books first, then paperbacks, then Kindle Edition ones, then audiobooks. And if a book has a binding/format that was not included in the list (e.g., MP3 CD), it will be placed last.</p>



<p>SQL CASE statements like this are quite handy and will work in the majority of modern relational databases.</p>



<h2 class="wp-block-heading">Ordering by multiple fields</h2>



<p>This is cool, but can we do if we also want independently published books (whose publisher in the database is &#8220;Independently Published&#8221;) to appear first in the list? (Hey, let&#8217;s throw a bone to the indie crowd.)</p>



<p>That has nothing to do with binding used as the condition for the CASE statement; it&#8217;s another field altogether.&nbsp;</p>



<p>Here is what we cannot do:</p>



<pre class="wp-block-code"><code class="prettyprinted">SELECT *
FROM   books
ORDER  BY publisher,
          CASE binding
            WHEN 'Hardcover' THEN 1
            WHEN 'Paperback' THEN 2
            WHEN 'Kindle Edition' THEN 3
            WHEN 'Audiobook' THEN 4
            ELSE 5
          END
</code>
</pre>



<p>I mean, that will execute. But a book published by &#8220;Acme&#8221; will appear before independently published books which is not what we want. Likewise, if we use <code>ORDER BY publisher DESC, ...</code> books published by, say, &#8220;Wrox&#8221; will appear before independently published ones. (Wrox books tend to be great but still, it&#8217;s not what we want.)</p>



<p>You might be tempted to comma separate two CASE statements, one to sort by publisher and the existing one to sort by binding. Thankfully we don&#8217;t have to do that. There is a much simpler way using a single CASE statement:</p>



<pre class="wp-block-code"><code class="prettyprinted">SELECT *
FROM   books
ORDER  BY CASE
            WHEN publisher = 'Independently Published' THEN 1
            WHEN binding = 'Hardcover' THEN 2
            WHEN binding = 'Paperback' THEN 3
            WHEN binding = 'Kindle Edition' THEN 4
            WHEN binding = 'Audiobook' THEN 5
            ELSE 6
          END
</code>
</pre>



<h2 class="wp-block-heading">The LIKE operator in a CASE statement</h2>



<p>We can even inject a LIKE operator to pick up books whose publishers contain the string &#8220;Independent&#8221;:</p>



<pre class="wp-block-code"><code class="prettyprinted">SELECT *
FROM   books
ORDER  BY CASE
            WHEN publisher LIKE '%Independent%' THEN 1
            WHEN binding = 'Hardcover' THEN 2
            WHEN binding = 'Paperback' THEN 3
            WHEN binding = 'Kindle Edition' THEN 4
            WHEN binding = 'Audiobook' THEN 5
            ELSE 6
          END
</code>
</pre>



<p>Thanks to the <code>ILIKE</code> variant, we can make the LIKE operator case insensitive:</p>



<pre class="wp-block-code"><code class="prettyprinted">SELECT *
FROM   books
ORDER  BY CASE
            WHEN publisher ILIKE '%independent%' THEN 1
            WHEN binding = 'Hardcover' THEN 2
            WHEN binding = 'Paperback' THEN 3
            WHEN binding = 'Kindle Edition' THEN 4
            WHEN binding = 'Audiobook' THEN 5
            ELSE 6
          END
</code>
</pre>



<p>There you have it!</p>



<p>This is basic stuff, no two ways about it. Lately, though, I’ve been reflecting more on the fact that what&#8217;s basic to me might not be so basic to people who are just starting out. </p>



<p>As a result, I want to share more on this blog and hope that in doing so, I will help someone, somewhere. Make sure you subscribe below if you are interested in seeing further content like this.</p>



<h2 class="wp-block-heading">The Art of PostgreSQL is amazing</h2>



<p>While we are on the topic, I cannot stress my recommendation for <a href="https://netrich--theartofpostgresql.thrivecart.com/full-edition/?ref=sorting-results">The Art of PostgreSQL</a> highly enough. It houses fantastic content for those who already have a basic understanding of SQL and wish to take their knowledge of PostgreSQL (and SQL in general) to the next level.</p>
<p>The post <a href="https://programmingzen.com/sorting-results-by-specific-values-in-sql-with-case/">Sorting Results by Specific Values in SQL with CASE</a> appeared first on <a href="https://programmingzen.com">Programming Zen</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://programmingzen.com/sorting-results-by-specific-values-in-sql-with-case/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2411</post-id>	</item>
		<item>
		<title>String Length in Elixir</title>
		<link>https://programmingzen.com/string-length-in-elixir/</link>
					<comments>https://programmingzen.com/string-length-in-elixir/#comments</comments>
		
		<dc:creator><![CDATA[Antonio Cangiano]]></dc:creator>
		<pubDate>Mon, 14 Oct 2019 12:00:11 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[elixir]]></category>
		<category><![CDATA[elixir-cookbook]]></category>
		<category><![CDATA[standard library]]></category>
		<category><![CDATA[strings]]></category>
		<category><![CDATA[unicode]]></category>
		<guid isPermaLink="false">https://programmingzen.com/?p=2286</guid>

					<description><![CDATA[<p>In a previous post, I wrote about Hello World in Elixir. Using such a simple program allowed me to discuss a few concepts about the language. This post explores strings further, by discussing how to find the length of a string in Elixir. Simple enough, but there is more than meets the eye. Elixir String Length In Elixir, you can return the number of characters in a string with the String.length/1 function: String.length(&#34;Antonio&#34;) # 7 String.length(&#34;&#34;) # 0 String.length(&#34;r&#233;sum&#233;&#34;) # 6 Discussion In the case of a string like, &#34;Antonio&#34;, there isn&#8217;t much to discuss. String.length(&#34;Antonio&#34;) returns the number of </p>
<p>The post <a href="https://programmingzen.com/string-length-in-elixir/">String Length in Elixir</a> appeared first on <a href="https://programmingzen.com">Programming Zen</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>In a previous post, I wrote about <a href="https://programmingzen.com/elixir-hello-world/">Hello World in Elixir</a>. Using such a simple program allowed me to discuss a few concepts about the language. This post explores strings further, by discussing how to find the <strong>length of a string in Elixir</strong>.</p>



<p>Simple enough, but there is more than meets the eye.</p>



<h2 class="wp-block-heading">Elixir String Length</h2>



<p>In Elixir, you can return the number of characters in a string with the <code>String.length/1</code> function:</p>



<pre class="wp-block-code"><code class="prettyprinted">String.length("Antonio") # 7
String.length("")        # 0
String.length("résumé")  # 6</code></pre>



<h2 class="wp-block-heading">Discussion</h2>



<p>In the case of a string like, <code>"Antonio"</code>, there isn&#8217;t much to discuss. <code>String.length("Antonio")</code> returns the number of characters in the string.</p>



<p>The string clearly has 7 characters and since each character in this particular string can be represented with a single byte, its raw representation is 7 bytes as well.</p>



<p>Things become more interesting when a string contains special characters. </p>



<p>Consider the string, <code>"résumé"</code>. In this case, <code>String.length/1</code> returns 6. You can think of this as the number of &#8220;visible&#8221; or &#8220;user-perceived&#8221; characters in the string. However, let&#8217;s investigate its raw representation:</p>



<pre class="wp-block-code"><code class="prettyprinted">iex(2)&gt; i "résumé"
Term
  "résumé"
Data type
  BitString
Byte size
  8
Description
  This is a string: a UTF-8 encoded binary. It's printed surrounded by
  "double quotes" because all UTF-8 encoded code points in it are printable.
Raw representation
  &lt;&lt;114, 195, 169, 115, 117, 109, 195, 169&gt;&gt;
Reference modules
  String, :binary
Implemented protocols
  Collectable, IEx.Info, Inspect, List.Chars, String.Chars</code></pre>



<p>You&#8217;ll notice that the string&#8217;s actual data type is BitString. Specifically, this binary is made up of 8 bytes, even though there are only 6 user-perceived characters. This is because it takes 2 bytes to represent its accented é characters.</p>



<p>If you are interested in the number of bytes within a string, instead of its length, you can use the <code>Kernel.byte_size/1</code> function:</p>



<pre class="wp-block-code"><code class="prettyprinted">iex(3)&gt; string = "résumé"
"résumé"

iex(4)&gt; String.length(string)
6

iex(5)&gt; byte_size(string)
8</code></pre>



<p>From a performance standpoint, it&#8217;s worth noting that <code>Kernel.byte_size/1</code> is more efficient than <code>String.length/1</code>. Unlike the latter, which takes longer as the string grows, <code>Kernel.byte_size/1</code> will return in constant time.</p>



<p><a href="https://hexdocs.pm/elixir/String.html">Strings</a> in Elixir are UTF-8 encoded binaries. You can think of them as collections of code points. A code point is a Unicode character, whose underlying representation might require one or more bytes. For example, the é characters in the string <code>"résumé"</code> are code points whose representation requires two bytes each.</p>



<p>The Unicode standard also defines some special characters as the combination of other characters. In other words, even though they appear to the reader as a single character, they are in fact a combination of two or more code points. These are known as grapheme clusters.</p>



<p>For example, the e-acute letter can be represented as a single code point as we&#8217;ve done so far (this is also known as a precomposed character) or as a combination of two code points (the letter e and a combining acute accent). These look the same but they are technically two different characters as far as Elixir is concerned; so the two strings below end up representing two different binaries:</p>



<pre><code class="prettyprinted">iex(6)&gt; "é" == "e&#769;"
false</code></pre>



<p>When working with strings, you&#8217;ll often want to consider them in terms of the user-perceived characters, rather than their code points or the binary they actually represent.</p>



<p>To help us out, the Elixir <code>String</code> module provides us with <code>String.graphemes/1</code> which returns a list of characters, without splitting grapheme clusters into the underlying code points. If you need the codepoints, you can always use <code>String.codepoints/1</code>.</p>



<p>To see the distinction between code points and graphemes in action, consider the following string (using the grapheme cluster built from two code points):</p>



<pre class="wp-block-code"><code class="prettyprinted">iex(7)&gt; String.codepoints("cliche&#769;")
["c", "l", "i", "c", "h", "e", "&#769;"]

iex(8)&gt; String.graphemes("cliche&#769;")
["c", "l", "i", "c", "h", "e&#769;"]</code></pre>



<p>As you can see, <code>String.codepoints/1</code> shows us a list of code points in the string, and the special e-acute gets split into two code points. If you look closely, you&#8217;ll notice the accent as the last code point in the list.</p>



<p><code>String.graphemes/1</code> simply returns the list of graphemes and is the closest thing that we have to a function that provides a list of user-perceived characters.</p>



<p>Now, consider its length and byte size:</p>



<pre class="wp-block-code"><code class="prettyprinted">ie(9)&gt; String.length("cliche&#769;")
6

iex(10)&gt; byte_size("cliche&#769;")
8</code></pre>



<p><code>String.length/1</code> returns 6, the number of user-perceived characters in the string. <code>Kernel.byte_size/1</code> returns 8 because it takes 3 bytes to represent the special character/grapheme (1 for the letter e, and 2 for the combining acute accent).</p>



<p>We used the expression &#8220;visible&#8221; or &#8220;user-perceived&#8221; characters to give us an intuitive understanding.  Now that you know more about bytes, code points, and graphemes, we can be a little more precise and say that <code>String.length/1</code> returns the number of graphemes in a string.</p>



<p>Finally, if you wanted to know the number of codepoints, you could trivially compose the <code>Kernel.length/1</code> function and the <code>String.codepoints/1</code> function:</p>



<pre class="wp-block-code"><code class="prettyprinted">"cliche&#769;"
  |&gt; String.codepoints()
  |&gt; length()</code></pre>



<p>Note that if you are trying this in IEx, you&#8217;ll need to use the backslash character to continue on new lines:</p>



<pre class="wp-block-code"><code>iex(11)> "cliche&#769;" \
...(11)> |> String.codepoints() \
...(11)> |> length()
7</code></pre>



<p>So in summary, our string contains 6 graphemes, 7 code points, and 8 bytes.</p>
<p>The post <a href="https://programmingzen.com/string-length-in-elixir/">String Length in Elixir</a> appeared first on <a href="https://programmingzen.com">Programming Zen</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://programmingzen.com/string-length-in-elixir/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2286</post-id>	</item>
		<item>
		<title>Elixir Hello World</title>
		<link>https://programmingzen.com/elixir-hello-world/</link>
					<comments>https://programmingzen.com/elixir-hello-world/#respond</comments>
		
		<dc:creator><![CDATA[Antonio Cangiano]]></dc:creator>
		<pubDate>Fri, 11 Oct 2019 04:49:04 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[elixir]]></category>
		<category><![CDATA[elixir-cookbook]]></category>
		<category><![CDATA[erlang]]></category>
		<category><![CDATA[puts]]></category>
		<category><![CDATA[standard library]]></category>
		<category><![CDATA[strings]]></category>
		<guid isPermaLink="false">https://programmingzen.com/?p=2268</guid>

					<description><![CDATA[<p>It is customary to start programming language tutorials with Hello World programs. So today I&#x2019;m sharing with you a Hello World in Elixir, one of my favorite programming languages (along with Ruby and Python, of course). As you likely know, a Hello World is a very simple program that displays the phrase, Hello, World! Our Elixir Hello World might not be too exciting but it will allow us to discuss quite a few fundamental concepts. Hello World in Elixir As you might expect, this is very straightforward: How to run it The easiest way to run this line of code </p>
<p>The post <a href="https://programmingzen.com/elixir-hello-world/">Elixir Hello World</a> appeared first on <a href="https://programmingzen.com">Programming Zen</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>It is customary to start programming language tutorials with Hello World programs. So today I&#8217;m sharing with you a <strong>Hello World in Elixir</strong>, one of my favorite programming languages (along with Ruby and Python, of course).</p>



<p>As you likely know, a Hello World is a very simple program that displays the phrase, <code>Hello, World!</code></p>



<p>Our <strong>Elixir Hello World</strong> might not be too exciting but it will allow us to discuss quite a few fundamental concepts.</p>



<h2 class="wp-block-heading">Hello World in Elixir</h2>



<p>As you might expect, this is very straightforward:</p>



<pre class="wp-block-code"><code>IO.puts("Hello, World!")</code></pre>



<h2 class="wp-block-heading">How to run it</h2>



<p>The easiest way to run this line of code is to launch IEx (i.e., Interactive Elixir). This will also act as a sanity test to ensure that you have installed Elixir correctly on your machine.</p>



<pre class="wp-block-code"><code>$ iex
Erlang/OTP 22 [erts-10.4.4] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe] [dtrace]

Interactive Elixir (1.9.1) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> </code></pre>



<p>For the best experience on Windows, including tab-based autocompletion in IEx, it&#8217;s worth passing the <code>--werl</code> flag to IEx or permanently enabling it by setting the environment variable <code>IEX_WITH_WERL</code> to <code>true</code>.</p>



<pre class="wp-block-code"><code>C:\> iex --werl</code></pre>



<p>Once you type your Elixir Hello World and press enter, IEx will print out the message <code>Hello, World!</code> and then display the return value of the function, which is the atom <code>:ok</code><sup>1</sup> (indicating that the function executed successfully):</p>



<pre class="wp-block-code"><code>iex(2)> IO.puts("Hello, World!")
Hello, World!
:ok
iex(3)></code></pre>



<p>Alternatively, you could place our one-liner in a <code>hello.exs</code> file and execute it as a script:</p>



<pre class="wp-block-code"><code>$ elixir hello.exs
Hello, World!</code></pre>



<p>You could also create a whole (Mix) project for this, but arguably that is overkill for our humble Hello World. </p>



<h2 class="wp-block-heading">Discussion</h2>



<p><code>puts</code> is a function that prints a message and adds a newline character. <code>write</code> is the variant that does the same but doesn&#8217;t append a newline. They both belong to the <code>IO</code> module, a module that includes, as the name implies, various functions for handling input and output.</p>



<p>At any time, we can learn more about a function by using the <code>h</code> helper within IEx:</p>



<pre class="wp-block-code"><code>iex(3)> h IO.puts

                        def puts(device \\ :stdio, item)

  @spec puts(device(), chardata() | String.Chars.t()) :: :ok

Writes item to the given device, similar to write/2, but adds a newline at the
end.

By default, the device is the standard output. It returns :ok if it succeeds.

## Examples

    IO.puts("Hello World!")
    #=> Hello World!

    IO.puts(:stderr, "error")
    #=> error

iex(4)></code></pre>



<p>Unlike languages like Python and Ruby, in Elixir you need to use a qualified call that includes the module name in order to invoke this function.</p>



<p>If we don&#8217;t qualify the call, we get a compile error:</p>



<pre class="wp-block-code"><code>iex(4)> puts("Hello, World!")
** (CompileError) iex:1: undefined function puts/1</code></pre>



<p>If you wanted to omit the module name, you could import the module (i.e., <code>import IO</code>) beforehand, or more realistically, limit the import to the function(s) that you need:</p>



<pre class="wp-block-code"><code>import IO, only: [puts: 1]

puts("Hello, World!")</code></pre>



<p>That <code>puts: 1</code> indicates that we are specifically importing the version of the function that accepts one argument. You&#8217;ll see that function referred to as <code>IO.puts/1</code> and we say that it has an arity of one or it&#8217;s a one-arity function.</p>



<p>The arity of a function (i.e., the number of arguments it accepts) is important because in Elixir you can have functions with the same name but different arities.</p>



<p>In fact, there are technically two variants of the <code>puts</code> function, <code>IO.puts/1</code> which we just used, and <code>IO.puts/2</code> which also allows us to specify an IO device as its first argument. (I say <em>technically</em> because they are both declared within a single function definition.)</p>



<p>By default, the function prints to the standard output. This can be easily verified by looking at the Elixir source code:</p>



<pre class="wp-block-code"><code>def puts(device \\ :stdio, item) do
  :io.put_chars(map_dev(device), [to_chardata(item), ?\n])
end</code></pre>



<p>As you can see, the underlying implementation makes a call to the Erlang&#8217;s <code>IO.put_chars/2</code> function.</p>



<p>What&#8217;s worth noting here is that:</p>



<ul class="wp-block-list"><li>In Elixir, default parameters can be specified using <code>\\</code>.</li><li>The default IO device for the function is the atom <code>:stdio</code> which maps to <code>:standard_io</code> in Erlang. Basically, by default, it will print to your stdout unless you pass a different device to the function.</li><li>Another common value for the device is <code>:stderr</code> which is a shortcut for Erlang&#8217;s <code>:standard_error</code>.</li><li>When we call the function without a device (leveraging the default parameter) we are calling <code>IO.puts/1</code>. When we pass it a device as its first argument and a string as its second argument, we are calling <code>IO.puts/2</code>.</li></ul>



<p>In practice, you&#8217;ll most commonly use <code>IO.puts/2</code> when printing to the standard error, instead of the standard output:</p>



<pre class="wp-block-code"><code>iex(5)> IO.puts(:stderr, "Hello, Post-Apocalyptic World!")
Hello, Post-Apocalyptic World!
:ok</code></pre>



<p>For such messages, there are also <code>IO.warn/1</code> (used below) and <code>IO.warn/2</code> which output to the standard error and in addition, include a stacktrace (provided by the developer in the case of <code>IO.warn/2</code>).</p>



<pre class="wp-block-code"><code>iex(6)> IO.warn("Hello, Post-Apocalyptic World!")
warning: Hello, Post-Apocalyptic World!
  (stdlib) erl_eval.erl:680: :erl_eval.do_apply/6
  (elixir) src/elixir.erl:275: :elixir.eval_forms/4
  (iex) lib/iex/evaluator.ex:257: IEx.Evaluator.handle_eval/5
  (iex) lib/iex/evaluator.ex:237: IEx.Evaluator.do_eval/3
  (iex) lib/iex/evaluator.ex:215: IEx.Evaluator.eval/3

:ok</code></pre>



<p>In most cases, parentheses are optional in Elixir, so we could omit them.<sup>2</sup></p>



<pre class="wp-block-code"><code>IO.puts "Hello, World!"</code></pre>



<p>It&#8217;s worth noting that strings are double-quoted literals in Elixir. Unlike other languages, single-quoted literals are not an alternative way of representing strings.</p>



<p>In Elixir, single-quoted literals represent a related but ultimately different datatype (i.e., List), as we can verify by using the handy data type information helper <code>i</code> in IEx:</p>



<pre class="wp-block-code"><code>iex(7)> i "Hello, World!"
Term
  "Hello, World!"
Data type
  BitString
Byte size
  13
Description
  This is a string: a UTF-8 encoded binary. It's printed surrounded by
  "double quotes" because all UTF-8 encoded code points in it are printable.
Raw representation
  &lt;&lt;72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33>>
Reference modules
  String, :binary
Implemented protocols
  Collectable, IEx.Info, Inspect, List.Chars, String.Chars

iex(8)> i 'Hello, World!'
Term
  'Hello, World!'
Data type
  List
Description
  This is a list of integers that is printed as a sequence of characters
  delimited by single quotes because all the integers in it represent printable
  ASCII characters. Conventionally, a list of Unicode code points is known as a
  charlist and a list of ASCII characters is a subset of it.
Raw representation
  [72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33]
Reference modules
  List
Implemented protocols
  Collectable, Enumerable, IEx.Info, Inspect, List.Chars, String.Chars
iex(9)></code></pre>



<p>Strings are encoded in UTF-8, so you can use special characters and even emojis.</p>



<pre><code class="prettyprinted">iex(9)&gt; IO.puts("Fabrizio De André")
Fabrizio De André
:ok

iex(10)&gt; IO.puts("Hello, &#127758;!")
Hello, &#127758;!
:ok</code></pre>



<p>It&#8217;s also possible to print a given character by specifying its UTF-8 codepoint.</p>



<pre><code class="prettyprinted">iex(11)> > IO.puts("Hello, #{<<127758 :: utf8>>}!")
Hello, &#127758;!
:ok</code></pre>



<p>If you are familiar with Ruby, you&#8217;ll recognize the same string interpolation syntax in which the expression that needs to be evaluated is enclosed within <code>#{}</code>.</p>



<p>Windows users encountering issues related to special characters can improve their experience by changing the active console code page by executing <code>chcp 65001</code> in their Command Prompt, before executing IEx.</p>



<p>It doesn&#8217;t get any simpler than a Hello World program, but as you can see, if you dig a little deeper, you can find out quite a few things about a given programming language.</p>



<p>In the next Elixir-related post, I&#8217;ll publish a similar discussion for another seemingly trivial problem: the length of a string in Elixir. It will give us an opportunity to discuss strings more deeply. Subscribe, if you don&#8217;t already, to be notified of its publication.</p>



<h2 class="wp-block-heading">Footnotes</h2>



<ol class="wp-block-list"><li>Atoms are constants whose values are their own names. The value of <code>:ok</code> is <code>:ok</code>. If you are familiar with Ruby, atoms are equivalent to symbols.</li><li>A glaring exception to the parentheses being optional are non-qualified/local calls with zero-arity. In those cases, parentheses are required to distinguish simple variables (e.g., <code>user_list</code>) from actual function calls (e.g., <code>list_user()</code>). To avoid ambiguity, it&#8217;s also important to include parentheses with one-arity functions within pipelines (e.g., <code>"Hello, World!" |&gt; IO.puts()</code>). For stylistic recommendations of when to use parentheses and when to omit them, consider reading these two style guides (<a href="https://github.com/christopheradams/elixir_style_guide#parentheses">1</a>, <a href="https://github.com/lexmag/elixir-style-guide#parentheses">2</a>). At any rate, do not obsess over this. <code>mix format</code> or a properly configured editor will typically take care of applying idiomatic and consistent styling for you.</li></ol>
<p>The post <a href="https://programmingzen.com/elixir-hello-world/">Elixir Hello World</a> appeared first on <a href="https://programmingzen.com">Programming Zen</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://programmingzen.com/elixir-hello-world/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2268</post-id>	</item>
	</channel>
</rss>
