Monday, November 6, 2023

Getting Started with Java


    This week, I started learning Java for my CPT307: Data Structures & Algorithms class. Java is well known for being an Object-Oriented Programming (OOP)  language and for running in the Java Virtual Machine. I've spent the past year and a half learning Python, so I've got a foundation with OOP, but the reading in this class is helping drive some of those concepts home. Oracle's (2015) lessons to teach OOP concepts are worth a read to familiarize yourself. A common way to begin thinking about OOP is to consider real objects around you. Every item around you has different properties or states associated with it - my dig is brown, is named Ruby, and is a mutt. The objects around you can also do things, exhibit behaviors, or have things done to it. Ruby can bark, be pet, or run around. Programming objects is just writing down those characteristics so that other programming objects can interact with them. 

Getting Ready to Code

    The great thing about learning Java in relation to a class is that the class provides starting resources; unfortunately, those resources are a bit dated, so I'm going to share the instructions that worked for me (in November of 2023). 

    First things first is getting the Java package downloaded and installed from Oracle. I'm using Windows 10, so next, I needed to set the path so Windows would know how to run Java programs. This Article from Nam Ha Minh was a lifesaver for me. I found his instructions clear with a good sprinkling of whys behind the steps. 

    Next, I needed an Integrated development environment (IDE). This is something that I had not taken seriously in my Python journey, just using whatever each tutorial recommended at the time. This ended up putting me at a disadvantage regarding managing Python environments and running scripts outside of the IDE until recently. With Java, I spoke to a trusted programmer friend, getting their input on an IDE. They recommended IntelliJ, which I was able to get with a free 1-year student license from JetBrains. Armed with my fancy IDE, I kept with Minh's and followed his instructions on "How to write, compile and run a hello world Java program for beginners" skipping to step 3 as steps 1 and 2 were just installing and setting the Windows' path. 

    One day into Java and I was already able to output into my command prompt: 

Sweet Sweet Java Output

    In preparation for using Java for more complicated things, I have read through the first half of the W3Schools Java Tutorial. I find it a good resource for basic functionality even it if lacks depth. With a little translation, much of what I learned in Python will serve me well with Java. The more I learn, the less this surprises me. As Shaffer (2013) points out:
"all modern programming languages can implement the same algorithms (stated more precisely, any function that is computable by one programming language is computable by any programming language with certain standard capabilities" (p.19).

How did I get here? 

    Far too long ago in high school, I took an HTML class. While t I do not remember any of the class itself, I have continued to use HTML throughout the years. Never to make a (successful) webpage, mind you, but I maintained little HTML pages on my local machine as text templates for years. Lately, I have used HTML in my professional work when deep-diving into online text editors with an HTML option. It seems like a trivial thing to me, but my managers are constantly impressed how my documentation is much better formatted than my peers. Little do they know it's just me abandoning the default editor's questionable GUI and manually changing font sizes and family myself. 

    But my most common usage of my HTML knowledge through the years is just a simple understanding that everything we see on the computer screen is the result of lines of code being interrupted by the computer. This code has structure and keywords that work together to make the programmer's vision a reality. While HTML is a markup language, not a programming language, I think it's a good place for beginners to start with learning the most basic concepts of coding. Most every personal computer is already going to have the tools to write and display the results. Within a few minutes, you can SEE the results of what you have created. I don't even recommend that new coders get very far into mastering HTML, unless they really want to, just seeing that connection between code and output, and hopefully getting a rush of pride, is my goal with this recommendation. 

    Last year, I finally got serious about doing actual computer programming. I got connected with a good tutorial for Python though Percipio. I messed it up a bit, but that happens. I love translating how I think into lines of code and watching the results unfold before me. I've been interested in Java for a while now - I would like to make some games and custom calculators, but have mostly focused on honing my ability to problem-solve with Python. Also, there's a lot of hype on the internet about the ease of writing Python making the jump a little intimidating. Well, CPT307 has made this decision for me. 

Here I come Java. 

Resources and Other Links

JetBrains, (n.d.). IntelliJ IDEA – the Leading Java and Kotlin IDE. JetBrains. https://www.jetbrains.com/idea/

Minh, N. H., (April 27, 2019). How to set JAVA_HOME environment variable on Windows 10. CodeJava. https://www.codejava.net/java-core/how-to-set-java-home-environment-variable-on-windows-10

Minh, N. H., (March 11, 2020). How to write, compile and run a hello world Java program for beginners. https://www.codejava.net/java-core/how-to-set-java-home-environment-variable-on-windows-10

Oracle, (n.d.). Java Downloads. Oracle https://www.oracle.com/java/technologies/downloads/

Oracle. (2015). Lesson: Object-oriented programming concepts http://docs.oracle.com/javase/tutorial/java/concepts/index.html

Shaffer, C. A. (2013). Data structures and algorithm analysis. (Edition 3.2). Retrieved from http://people.cs.vt.edu/~shaffer/Book/JAVA3elatest.pdf

W3Schools, (n.d.). Java Tutorial. W3Schools. https://www.w3schools.com/java/default.asp


No comments:

Post a Comment