Matthew Gates http://notetoservices.com 9m 2,141 #learncode
The views of this article are the perspective of the author and may not be reflective of Confessions of the Professions.
Programming From Language Comparison
Honoring National Programmers Day
There are many different ways to learn new things, from simply listening to observing visually to remembering something. As your brain processes the information, you learn it, obtain it, and often times, upon repeating the process, you will learn it to the point where it becomes almost second nature to you. For some other things, such as programming, where logic (and possibly some math) is involved, it becomes a series of written statements in a lines that are inserted into pages, and when compiled and ran, those lines of codes tell the system what it needs to do. Line by Line, the computer software program, the computer itself, or a browser will read it, compile it, and perform the functions of what it was designed to do.
Since computers use logic in code, 99.99% of all applications that have errors are mostly from human error, with that last .01% being outdated hardware, in which the programming code is trying to call to a library to use something, but the code is outdated and no longer exists. For some programmers, there are times where you write code and you cannot figure out your issues, believing the computer or software is against you. For those of you who work with CSS or just about any language, there are plenty of times where the code is right there! Why the hell isn’t it working?!
After careful examination, also known as debugging, the programmer finds out that a variable is improperly named, or some code logic was written wrong, so the computer is doing its job: reading the line of code, reading the variable, or whatever lines it is reading, and performing its function, but if the variable is named wrong or the code is just wrong, than it has nothing else to do. I find myself writing many times, echo ‘test’; to make sure the line of code is being called, and to figure out what is happening before and after.
This becomes our common face often:
“I need this application to do this, so make it happen” is pretty much the job of a programmer, software developer, computer engineer, or whatever name you want to give. If code is written well, it almost needs no debugging, but it is rare. If it were not rare, I probably would not have a job right now, and many other programmers would be out of a job too, and I have held many jobs figuring out what went wrong with someone else’s code. I try to do the opposite, after a boss trained me to do so: Write it once so you don’t have to write it again later. That means understanding the logic, writing out the entire function, all before ever jumping into the program to actually write it. I find myself always having work, as I am the guy who is usually cleaning up after the last web designer or web developer, who overcharged, and usually left their clients in the dark. Wherever I go, I usually fix everything in my path, save my clients a ton of money, and get them to the point where the only thing they are having to pay me for is updating their websites or software every few months.
I was not born into it, as most of us are not, and ended up teaching myself at 12 years old. Later on, at 18, I quit programming cold turkey, going off to work a dead end job, only to realize I needed to further my education, and ended up with a degree in Psychology; only to return home, unable to find a job, desperate for money, and using that very skill I learned when I was 12, to get a job and make money doing it. After 3 months of training, basically of making useless programs, I was re-trained and ready to work. I was hired for several reasons:
- fix existing bugs in the program
- implement new features in the program
- create a friendlier UI (user-interface) for the program
I definitely accomplished a lot, but the program was so huge that bugs were always arising, sometimes out of no where, so I remained busy. I did not build the program, but when you hire programmer after programmer to do the job, and must go back to fix their issues, this can be a daunting task. During the year and a half at that job, I was learning as much as I could, but eventually I moved on to much better things. The year and a half at the job gave me the complete confidence to try and tackle anything within the programming world, but I developed a deep love for web development.
While I could tell you that at 12 years old, I was reading every programming book there was, I was not. Programming books cost a fortune and at the time, the Internet was not what it is today. You might be able to find a few articles on programming, but there was nothing and no where you could go, so I did what any kid would do at that age to learn: I thought about it and dreamed about it. Visual Basic 3.0 was my first programming language. I first played with the object-oriented system, dragging out objects on to a platform that aligned them. Then I wrote my first program, like we all do: “Hello World”. I then learned how to use the Random function and created an Eight-Ball program that allowed you to click a button and it would give you a response, out of about a hundred different responses. I would continue practicing, making programs interact with others, and eventually I would get into “AOL Programming”, where I was making some cool programs that interacted with America Online chats and other things within programs. Unfortunately, when I came of young adult age, my interest in programming dropped off completely, and it would be years before I even thought about it again.
When I re-trained myself much later in life for the job, you would assume I opened up every book there was to be read, or I went online and looked up everything I needed to, right? Only half correct. I already had the understanding of the logic of programming, and most books cover just about that. Information that can now easily be found online. Luckily for me as well, the software company was still using Visual Basic 6.0, which is not much different from Visual Basic 4.0 and 5.0. With a little logic, focus, and understanding, programmers can write anything. “I want it to do this. I need it to do that.” It is simply writing the logical code that does that.
For example, “I need it to send me an email once a day giving me an updated report from the database.” Logic dictates:
- Purpose: Make the boss happy AND keep my job
- Objective: Output data from database and send email, set delay for 24 hours
- Functionality:
- Connect to database, grab all data
- Once data is received, send it via email script
- Once the data is sent via email, set a timer for 24 hours and repeat
Very basic steps of logic that make some people hundreds of thousands of dollars every year. Although if you are anywhere outside the San Bay area, or not on the coasts, you will find that programmer pay is not always that much, unless you are very good at what you do and demand it from a willing company.
Programmers are investigators, researchers, and logical problem solvers. They must investigate situations that arise and figure out what problems are causing the issue. This can sometimes span across hundreds to thousands of lines, or even millions of lines of code and across many files or tables in a database, and even many databases. They then must research the issue. Sometimes they may search the Internet for the answer, as StackOverFlow (offcially known as the Stack Exchange Network), which has existed since 2008, is one of the largest and most dominant websites on the Internet for programmers, with an Alexa ranking of 43 (at the time of this writing). It is a huge database of mostly programming questions, over 10 million that have been asked and many have been solved by people who have had the same issues, or people who are helpful to try and figure out solutions in their spare time. Chances are, if a programmer is having issues and searches for a problem, this is the website they will most likely come across that will have the answer. Finally, after finding a solution, the programmer must implement it, and then run multiple tests to ensure it works as a permanent solution, not just within that one function, but make sure it works with the entire script or program.
Anyways, instead of reading books, I study code in order to learn it. I figure out the logic and syntax commands and write what it needs to do. When it comes to most code, no matter what language it is, if you know how the logic to one language works, you can pretty much learn them all. What if I could take two pieces of code and put them side-by-side in order to learn the basics of the language? Is this possible? Depends on how well you learn new languages. When it comes to spoken languages, it takes me years to master. When it comes to programming languages, it can take me just a few days to a few months to learn it. I had wondered, instead of taking two books, did this tool exist online that compared multiple languages?
If you are new to programming, chances are, this tool is not for you just yet. You need to have a basic understanding of at least one language in order to start learning another language. As that is my preferred method to learn a new language, by simply observing what it does, comparing the two languages, and learning the syntax. There is actually a tool that exists which makes it possible! Side-by-side comparison to learn code! Rosetta Code came up with a very good programming language comparison tool that helps programmers, like me, to study code side by side. It may not be the appropriate way to learn a language, but everyone has their own methods of learning. In this case, we take PHP and Python.
Text-Friendly Version
PHP | Python |
if ($contents = file_get_contents(‘input.txt’)) { if (!file_put_contents(‘output.txt’, $contents)) { echo(‘Could not write output file.’); } } else { echo(‘Could not open input file.’); } | import sys try: with open(‘input.txt’) as infile: with open(‘output.txt’, ‘w’) as outfile: for line in infile: outfile.write(line) except IOError: print >> sys.stderr, “Some I/O Error occurred” sys.exit(1) |
Both codes do the exact same thing but are two different languages. The code is for File Input / Output, or in other words, the code is showing how to read and write to a file, including an error message for any errors that may arise. Knowing the pattern of how code in another language is supposed to be written will usually give you everything you need to know. For example, in PHP, you write function myfunction() to define that it is a function. In Python, you write def myfunction() to define the function. Whereas PHP does not care how you indent or space your code, Python can be extremely strict on your indentation, and if something is off, even if the code is written correctly, Python will not run the function.
While the example above just shows file input/output code, it continues with many more functions to train you on what the correct syntax is. Once you get this down, you will likely be able to learn any language you desire. The free Rosetta Side-by-Side Snippet Comparison tool, a godsend, will teach you by comparing two languages at a time. The languages are:
- ActionScript
- ADA
- ASP
- C
- C++
- CoffeeScript
- ColdFusion
- Common Lisp
- D
- Delphi
- Elixir
- Elm
- ER Lang
- Forth
- Go
- Haskell
- Java
- Javascript
- Julia
- Lua
- Nim
- Objective-C
- OCAML
- Pascal
- PERL
- PHP
- Python
- Ruby
- Rust
- Scala
- Smalltalk
- TCL
While there are some languages that cannot be compared, such as C and C++, as they are likely too similar, and leaves you with the message: “these languages are probably fake”, which they are not, the Rosetta tool is very educational and will help you get started on learning the majority of languages side-by-side. If this is your method of learning, feel free to use it to your advantage. If not, I am sure you know your own best method of learning. If you already know at least one language, it is probably possible for you to learn them all at a much faster pace with this amazing programming tool.
(