Retro computing with a touch of modern and the home for all things, retroCombs (aka Steven Combs).
Disclosure Statement: When you click on links to various merchants on this site and make a purchase, this can result in this site earning a commission. Affiliate programs and affiliations include, but are not limited to Amazon, the eBay Partner Network, and/or others.
DRAFT PAGE UPDATED: November, 11th, 2014
As an amateur coder, I often dabble in multiple languages such as Ruby, C, Arduino, Java, etc. Each language has a unique structure and specific syntax requirements (add a semi-colon at the end anyone?).
To help jog my memory, I thought it would be beneficial for me to create a page that demonstrates the same program in multiple languages. This will serve as a primer to each language as well as a comparison. I will stick to modern languages and am likely to add more in the future. The list below contains the first languages I will work through.
If you are looking for an app to try out various languages, might I suggest CodeRunner. It’s available in the Mac app store and is my go to app when I want to try out a snippet of code.
Many programmers create an outline of a program before they type a single line of code. This sometimes takes the form of either pseudo code or a flow chart. I will present both, but before doing so, I will also provide a description of the program in paragraph form.
Want to skip the background and go right to the languages? Click here.
As I began to write the program in various languages, there are assumptions made:
This program will prompt the user for a number of breaks, the amount of time between each break (in seconds) and a URL. If the number of breaks is equal to zero, the program will display a scathing message (“If you don’t need a break, why’d you ask?”) and exit. If the number of breaks is one or more, the program will execute. If the number of breaks is greater than 12, the program will display a scathing message (“You work too hard. Get a social life now!”) and exit.
At each break interval, the requested URL will open in the default browser as a reminder to take a break.
The inspiration for this program is from the first assignment found in the Udacity course, Introduction to the basics of programming using Python. It is a good example of how to use Python to create useful programs and implement into your daily workflow.
Pseudo code is a program outline that does not include any programming language specific code but is a plain english line-by-line description. Below is the pseudo code for the description above.
TIP: It is useful to copy the actual outline and paste it into the an integrated development environment (IDE) or program editor. After the outline is pasted, I convert each line to a comment. A good IDE, such as Atom or Sublime Text 3, will provide a tool to do this automatically. This process creates an outline for my work.
add comments:
load functions (if needed and based on language):
function to prompt user:
function for loop:
function to load web page:
run prompt user function run loop program function run load URL function
A flow chart is a graphical representation of programming code and is often used during the planning process. Below is the flow chart for the program described above.
Coming soon…
There are numerous programming languages available. To reiterate, the purpose of this page is to demonstrate the use of code to do something beneficial; prompt you to take a break during the day. You will not want to learn each languague, but this quick guide might assist you in determining which languge you want to learn.
Use the table below to quickly jump to a language example:
Coming soon…
Comments: Coming soon
Coming soon…
Comments: Coming soon
Coming soon…
Comments: Coming soon
Coming soon…
Comments: Coming soon
Coming soon…
Comments: Coming soon
Coming soon…
Comments: Coming soon
# Break Time
# Python
# Dr. Steven B. Combs
import webbrowser
import time
def prompt_user():
# allow variables outside of function
global breaks, interval, web_address
# request input
breaks = input('Enter number of breaks: ')
interval = input('Enter the interval in seconds: ')
web_address = input('Enter a URL (exlude http://): ')
def run_timer():
# insert timer code here
load_web()
return
def load_web():
webbrowser.open('http://'+web_address)
return
prompt_user()
run_timer()
Comments: Python is a great first language; however, it does have some quirks. Indenting is important and can easily cause errors. There are times when the syntax does not make sense and concepts are not readily apparent. There is a huge user community and outstanding web resources to answer questions. It comes standard as part of a Mac OS X install. It is a useful language for both web and computer applications.
Coming soon…
Comments: Coming soon
Coming soon…
Comments: Coming soon