Programming Differences: Coding Preferences Do Not Dictate Value

This program should ask the user to guess for a word 7 times and exit when the word is guessed correctly. This program contains logic errors in that it does not run as intended. This program does not exit after the user correctly guesses the word. A functioning Python program would require additional code.

Software Developers utilize linters to automatically format their code according to a modifiable set of rules. Python is a difficult language to utilize a linter in because the linter cannot assume where multiple blocks of code end at the same time. This program is challenging to compare to other real programs in other languages because this program does not run and is not complete. The indentation is wrong after the while loop and quickly breaks this Python program. Indentation does not break a Java program because it contains a predictable syntax to indicate where a block of code begins and ends.

In programs of this size, I rarely notice a difference between languages in terms of program size. Program size can vary significantly in complex programs across languages. The Python library choice in this program is unique to Python. A similar program could be easily written in Java. Java would also import libraries like the Java util library that includes Arrays, Lists, Random (for the random number), and Scanner (user input). The program would look very similar to what you have here except it would be placed in a class and ran with a main method.

JavaScript, another scripting language, enables this program to be written either in a similar manner to the above program or written in classes similar to Java. JavaScript reveals these choices are a coding preference. Code architecture leads to an organized approach to coding; however, it requires more thought. Writing a program in classes can make it longer; however, writing classes becomes second nature, as if using a template or library. I wouldn’t view code architecture as an advantage or disadvantage. I would view it as a coding preference that any developer can adapt to.

As I gain more exposure to programming languages, I am learning that you should choose to code in a language you love. The advantages and disadvantages while helpful to know when leading teams are minor. A common practice dictates discussing developer worth based on the programming language or tool he uses; however, as you gain experience you quickly find that you can code in any language utilizing multiple approaches. Learning them all teaches you new perspectives and reveals your personal interests and style. The truth is if you successfully code a program, a year later you might code an equally acceptable program in a completely different way. While slightly different in implementation, similar programs are often equal in value.

If this hangman game was designed to run on the internet, JavaScript would allow this program to be written and ran directly in a browser. I consider this a programming advantage because it serves a specific purpose in a specific context. Like Java, Python does not have the capability to run this code directly in the browser despite it being a Scripting Language like JavaScript. This program illustrates Python as a coding preference and does not pose a significant advantage or disadvantage to other programming languages.

# Python

from random import choice

word = choice(["code", "club"])

guessed = []
wrong = []

tries = 7

while tries > 0:

out = ""
for letter in word:
      if letter in guessed:
           out = out + letter
      else:
           out = out + "_"

     if out == word:
          break

print("Guess the word:", out)
print(tries, "chances left")

guess = input()

if guess in guessed or guess in wrong:
      print("Already guessed", guess)
elif guess in word:
      print("Yay")
      guessed.append(guess)
else:
      print("Nope")
      tries = tries - 1
      wrong.append(guess)

print()

if tries:
      print("You guessed", word)
else:
      print("You didn't get", word)

Comments

Popular posts from this blog

SalonAboutBeauty: Less Integration for Consistent Styling Across Components

Why “Human Error” Is Usually a System Design Problem

Challenges in Prosecuting Deep Web and Darknet Crimes: The Case of Ross Ulbricht and the Silk Road