{"id":4222,"date":"2017-03-14T12:36:39","date_gmt":"2017-03-14T16:36:39","guid":{"rendered":"https:\/\/photics.com\/?p=4222"},"modified":"2017-03-14T13:40:27","modified_gmt":"2017-03-14T17:40:27","slug":"five-typical-programming-mistakes-for-beginners","status":"publish","type":"post","link":"https:\/\/photics.com\/five-typical-programming-mistakes-for-beginners\/","title":{"rendered":"Five Typical Programming Mistakes For Beginners"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/photics.com\/wp-content\/uploads\/2017\/03\/keyboard-explosion.png\" alt=\"Keyboard Explosion\" width=\"150\"class=\"alignleft\" \/><a href=\"https:\/\/photics.com\/happy-pi-day-a-developers-perspective\/\">Happy Pi Day<\/a>! Since Snow Storm Stella has rendered\u00a0outdoor travel hazardous, I decided to use the extra time to help out new programmers. The reality is that programmers spend a lot of time in front of computer screens, regardless if it&#8217;s snowy or sunny outside. This article is to help beginners maximize their efforts, to focus on useful endeavors, rather than struggling with issues that so many programmers\u00a0battled\u00a0with in the past. Here are five typical mistakes that beginning programers make.<\/p>\n<p><!--more--><\/p>\n<h2>Choosing a Language \/ Getting Started<\/h2>\n<p>A typical question a beginners asks is, &#8220;What language should I learn first?&#8221; Just getting started can lead to a typical mistake. I see so many new developers getting caught up on why Python is the greatest thing since the discovery of fire or how PHP kicked your grandma&#8217;s puppy. Sure, there are lots of different programming languages. You don&#8217;t want to pick the wrong one. The problem is treating it like a sports team. Picking a popular language is helpful, as that increases the chances of that skill being useful. However, this isn&#8217;t just a popularity contest.<\/p>\n<p><a href=\"http:\/\/githut.info\">http:\/\/githut.info<\/a> is\u00a0&#8220;a small place to discover languages in GitHub&#8221;. It has a list of the most popular languages at\u00a0<a href=\"https:\/\/github.com\">GitHub<\/a> \u2013 an\u00a0online development platform. What\u00a0language is\u00a0at the top of that list? It&#8217;s JavaScript! Personally, that&#8217;s my favorite programming language. That&#8217;s because I&#8217;m a web developer and JavaScript was designed to be easy. However, it&#8217;s not the solution to every problem. Do you want to make iOS games? If so, then JavaScript is quite limiting. JavaScript doesn&#8217;t have the level of access to the iPhone \/ iPad hardware that Objective-C or Swift would have. Using JavaScript to create iOS games could be frustrating and game performance could suffer.<\/p>\n<p>That&#8217;s the point! Picking a language is not just about popularity. It&#8217;s about what you&#8217;re trying to do. I see a lot of hate towards PHP on <a href=\"https:\/\/reddit.com\/r\/webdev\">reddit.com\/r\/webdev<\/a> but I don&#8217;t care. They&#8217;re not paying my bills.<\/p>\n<p>The reality is that you&#8217;ll probably have to learn multiple programming languages. (Even just basic web development involves HTML, CSS and JavaScript.) The tech world is constantly changing. My first programming language\u00a0was <a href=\"https:\/\/en.wikipedia.org\/wiki\/BASIC\">BASIC<\/a>. While was that great fun on the Commodore 64 and TRS-80 Color Computer 2, it&#8217;s not very useful today.<\/p>\n<p>The\u00a0mistake is in not thinking logically. First, pick a language that has purpose. What are you trying to do? Who are you trying to be? Second, when learning programming for the first time, the language is less important than understanding\u00a0basic principles.\u00a0After you learn your first programming language, learning additional languages should be easier. While languages have differences, thinking logically is universal. You\u00a0should be able to\u00a0spot similarities and apply that knowledge. Pi is still 3.14159265\u00a0(etc.)\u00a0regardless of which programming language you pick.<\/p>\n<h2>Forgetting Punctuation (Syntax)<\/h2>\n<p>So yeah, I like JavaScript. That&#8217;s because it&#8217;s so easy and practical. Most modern computers have web browsers. That means a JavaScript project can be sent to billions of people worldwide. That&#8217;s tremendous power. JavaScript is even designed to be forgiving. It doesn&#8217;t freak out (usually) if you forget to add a semicolon at the end of a line.<\/p>\n<p>However, like most programming languages, it can be entirely unforgiving if you forget punctuation elsewhere. This is also know as <a href=\"https:\/\/en.wikipedia.org\/wiki\/Syntax_(programming_languages)\">Syntax<\/a>. A misplaced comma, a forgotten right-parenthesis, a single-quote instead of a double-quote, they all can cause your program\u00a0to crash when run.<\/p>\n<p>This is where a lot of beginners can get frustrated and give up. A single, tiny and seemingly insignificant mistake can derail your progress. How can you\u00a0prevent this? Syntax Highlighting is a great feature for a developer to have. Text editors can colorize the code,\u00a0emphasizing the syntax of that particular language.<\/p>\n<p><a href=\"https:\/\/atom.io\">Atom<\/a> is an open source (free download) and multi-platform (macOS, Windows, Linux) text editor. It&#8217;s a great way to get started with simple programming projects \u2013 especially web development.<\/p>\n<p><!--nextpage--><\/p>\n<h2>Single Equal Sign on Conditional<\/h2>\n<p>A big part of programming is storing values and then comparing them. If this, then do that. Here&#8217;s a very basic example in JavaScript&#8230;<\/p>\n<pre lang=\"javascript\" line=\"1\">var x = 3;\r\nvar y = 4;\r\nif (x = y) {\r\nconsole.log(\"They're equal.\");\r\n} else {\r\nconsole.log(\"They're not equal.\");\r\n}<\/pre>\n<p>What message should be displayed? Obviously, 3 is not equal to 4. If &#8220;x&#8221; equals &#8220;3&#8221;, and &#8220;y&#8221; equals &#8220;4&#8221;, then x \u2260 y. In this short program, is the &#8220;They&#8217;re not equal&#8221; message displayed to the console? No, if you try running it for yourself, the message &#8220;They&#8217;re equal&#8221; is displayed. Here&#8217;s the real mind-blowing part. It&#8217;s actually a true statement!<\/p>\n<p>In the conditional part of the program, the characters &#8220;x = y&#8221; are used. If you read that, the voice in your mind makes it sound correct. &#8220;If &#8216;x&#8217; equals &#8216;y&#8217; then&#8230;&#8221; However, that&#8217;s not what the computer is doing. It&#8217;s setting the value of &#8220;x&#8221; to the value of &#8220;y&#8221;.<\/p>\n<p>To fix this problem, simply use two equal signs. The correct code is &#8220;x == y&#8221;. It looks a little weird, but those are the rules.\u00a0This is not just a problem for beginners.\u00a0If you&#8217;re in a rush, or under the pressure, you could easily miss it. The way to avoid this problem is to have a solid understanding of Comparison Operators.<\/p>\n<p><a href=\"https:\/\/www.w3schools.com\/jsref\/jsref_operators.asp\">https:\/\/www.w3schools.com\/jsref\/jsref_operators.asp<\/a><\/p>\n<h2>Case Matters<\/h2>\n<p>Even just writing this article, I fell into a typical trap. Capitalization matters! A variable of &#8220;x&#8221; is not the same as &#8220;X&#8221;. To your mind, &#8220;x&#8221; and &#8220;X&#8221; are practically the same thing. To a computer, it doesn&#8217;t think. It just runs programs.<\/p>\n<h2>Arrays Start at Zero<\/h2>\n<p>Variables are one way to store values. But if you have a lot of values, an array makes it easier to organize. It&#8217;s like an Excel spreadsheet in your program. The problem is that Excel starts at row #1. An array, in programming land, typically starts at row #0.\u00a0This is another one of those things that messes with the voice in your head. &#8220;I want the first row&#8221;. OK, that&#8217;s array[0]. This can be very confusing, especially for beginners.<\/p>\n<p>A nice way\u00a0to solve this problem is to include table headers in your array. By putting column labels at the top, the rest of the array is shifted one row down. The numbers align. It&#8217;s makes more sense.<\/p>\n<p>If you&#8217;re using &#8220;<a href=\"http:\/\/shancarter.github.io\/mr-data-converter\/\">Mr. Data Converter<\/a>&#8221; to convert your data to web-friendly formats, such as\u00a0JSON and XML,\u00a0there&#8217;s a &#8220;First row is the header&#8221; option.<\/p>\n<h2>Conclusion<\/h2>\n<p>There are lots of ways to screw up in programming. The more you learn, the more involved\u00a0your projects become. This leads to more complicated problems to solve. If you think you&#8217;re having trouble battling with problems as a beginner, it doesn&#8217;t get better \u2013 it gets worse. What gets better is you. One of the\u00a0tricks of being a good programmer is identifying problems and then figuring out ways to solve them. If you&#8217;ve experienced any of the problems in this list, congratulations. You&#8217;re on your way to becoming a better programmer.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Happy Pi Day! Since Snow Storm Stella has rendered\u00a0outdoor travel hazardous, I decided to use the extra time to help out new programmers. The reality is that programmers spend a lot of time in front of computer screens, regardless if it&#8217;s snowy or sunny outside. This article is to help beginners maximize their efforts, to &hellip; <a href=\"https:\/\/photics.com\/five-typical-programming-mistakes-for-beginners\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Five Typical Programming Mistakes For Beginners&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[342],"tags":[389],"class_list":["post-4222","post","type-post","status-publish","format-standard","hentry","category-development","tag-javascript"],"_links":{"self":[{"href":"https:\/\/photics.com\/wp-json\/wp\/v2\/posts\/4222","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/photics.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/photics.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/photics.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/photics.com\/wp-json\/wp\/v2\/comments?post=4222"}],"version-history":[{"count":0,"href":"https:\/\/photics.com\/wp-json\/wp\/v2\/posts\/4222\/revisions"}],"wp:attachment":[{"href":"https:\/\/photics.com\/wp-json\/wp\/v2\/media?parent=4222"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/photics.com\/wp-json\/wp\/v2\/categories?post=4222"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/photics.com\/wp-json\/wp\/v2\/tags?post=4222"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}