{"id":347,"date":"2011-02-08T09:02:22","date_gmt":"2011-02-08T16:02:22","guid":{"rendered":"http:\/\/blog.shadowkatmandu.net\/?p=347"},"modified":"2011-02-08T09:02:22","modified_gmt":"2011-02-08T16:02:22","slug":"an-introduction-to-computer-programming","status":"publish","type":"post","link":"http:\/\/blog.shadowkatmandu.net\/?p=347","title":{"rendered":"An Introduction to Computer Programming"},"content":{"rendered":"<p>Being a professional computer nerd is not, in some ways, unlike being a doctor.\u00a0 It&#8217;s one of those professions where people want you to do things for you once they find out it&#8217;s what you do.\u00a0 If you&#8217;re a doctor and somebody finds out on a personal level, they might tell you about an ache or a pain they&#8217;re experiencing.\u00a0 As a nerd, they want you to fix their computer.<\/p>\n<p>It goes beyond that, though.\u00a0 Nobody ever asks a doctor how to operate, but we computer nerds sometimes get asked how to program.\u00a0 We go through a lot of education&#8211;self-education or school-taught&#8211;to learn how to do what we do, but people want to skip all that and have us teach them (often in a very short time frame) all there is to know about writing computer programs.\u00a0 I guess most folks don&#8217;t realize the above-mentioned educational process required to learn how to write good software.\u00a0 It&#8217;s well-known, after all, that doctors invest a lot of time in education.\u00a0 Most, by my understanding, spend close to a decade in college learning their profession.<\/p>\n<p>With this in mind, I am going to present an introduction to programming.\u00a0 To start this discussion, I will answer a very basic question:\u00a0 What exactly <em>is<\/em> a computer program?\u00a0 Essentially, it&#8217;s a list of instructions a computer can interpret and act upon.\u00a0 In fact, for some computer programs, the thing running the software is called an <em>interpreter<\/em>.\u00a0 Computer languages which use an interpreter are often called <em>scripting<\/em> languages.\u00a0 For example, Javascript, with the word script right there in the name, is an interpreted programming language.\u00a0 The interpreter for it is built into internet browsers like Internet Explorer and Firefox.<\/p>\n<p>Javascript is an interesting example of a scripting language as it shows a little bit how languages evolve.\u00a0 The earliest versions of Javascript were purely scripts.\u00a0 Anytime you saw Javascript code, it was in its final form.\u00a0 Nowadays there are compilers for it, although these compilers don&#8217;t create what is called executable code.<\/p>\n<p>Let me take a step back and explain that.\u00a0 Regular computer languages are typically <em>compiled<\/em> into what&#8217;s called executable code.\u00a0 The code is written like scripting languages using keywords and variables and such (I&#8217;ll explain that later), but by itself nothing can be done with the code.\u00a0 Instead, a process is run which turns the code into something a computer more directly understands.\u00a0 That something is a file whose name ends in .exe or .dll, for example.\u00a0 The .exe files, called executables, are something Windows can natively handle.\u00a0 Actually, on a very low level, interpretation is still happening, but it&#8217;s Windows (or whatever operating system you&#8217;re using) does instead of some application Windows is running.\u00a0 An executable file has very little in it a human will recognize and be able to understand.<\/p>\n<p>So what use is a compiled Javascript program if it&#8217;s not executable like a .exe?\u00a0 This is actually a security concept somebody came up with a few years ago.\u00a0 As mentioned above, compiling code turns it into something humans cannot understand.\u00a0 So if somebody downloads a compiled javascript file, they cannot see what it&#8217;s doing just by looking at it.\u00a0 Uncompiled Javascript code is easily readable.\u00a0 As an added bonus, a compiler will find errors in the code.\u00a0 In fact, a compiler will not produce a compiled file if it finds errors in the coding.<\/p>\n<p>Okay, so now we know a little about what a program is.\u00a0 How does one write a program, then?\u00a0 Well, it&#8217;s a creative process, like writing a story.\u00a0 Perhaps that&#8217;s why I enjoy writing computer programs, or maybe why I like writing stories or both.\u00a0 I am a creative person and the process for writing a story or a program is, after a fashion, very similar.\u00a0 There is an opening to a story or program, things which take place in the middle, and finally a conclusion.\u00a0 Unlike a story, a computer program may jump around a little bit.\u00a0 This is because some pieces of code may get reused and are thus separated into <em>subroutines<\/em>.\u00a0 True, some stories will repeat parts already told sometimes, but you don&#8217;t see a book passage which says, for example, &#8220;Re-read pages 50 to 55 and come back here.&#8221;\u00a0 (Yes, I know about the do-it-yourself adventure stories which do this kind of thing, but <em>normal<\/em> stories don&#8217;t do that.)<\/p>\n<p>Beyond that&#8230;well, beyond that it gets a little more complicated.\u00a0 Modern computer languages often have a few things in common, but like written languages they still have many differences between them.\u00a0 So I will stop here today.\u00a0 Hopefully you have at least a little better understanding of programming and what it means to write software.\u00a0 If not, well&#8230;ask a nerd.\u00a0 See you tomorrow.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Being a professional computer nerd is not, in some ways, unlike being a doctor.\u00a0 It&#8217;s one of those professions where people want you to do things for you once they find out it&#8217;s what you do.\u00a0 If you&#8217;re a doctor and somebody finds out on a personal level, they might tell you about an ache [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4],"tags":[],"_links":{"self":[{"href":"http:\/\/blog.shadowkatmandu.net\/index.php?rest_route=\/wp\/v2\/posts\/347"}],"collection":[{"href":"http:\/\/blog.shadowkatmandu.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.shadowkatmandu.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.shadowkatmandu.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.shadowkatmandu.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=347"}],"version-history":[{"count":1,"href":"http:\/\/blog.shadowkatmandu.net\/index.php?rest_route=\/wp\/v2\/posts\/347\/revisions"}],"predecessor-version":[{"id":348,"href":"http:\/\/blog.shadowkatmandu.net\/index.php?rest_route=\/wp\/v2\/posts\/347\/revisions\/348"}],"wp:attachment":[{"href":"http:\/\/blog.shadowkatmandu.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=347"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.shadowkatmandu.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=347"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.shadowkatmandu.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=347"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}