Q&A :: All About Java

java-logo

What is Java?

Java was first released in 1995 and is currently one of the most popular programming languages in the world, with an estimated 9 million developers using Java world wide to build software on everything from web applications to game consoles.  It’s a general-purpose, high-level programming language, which means it was designed to resemble human language as opposed to low-level programming languages, like Assembly, where programs are written in something closer to the 0’s and 1’s that machine’s read.

Who created Java?

James Gosling, Mike Sheridan, and Patrick Naughton at Sun Microsystems (now Oracle) began the Java development project in 1991.  Java was originally called Oak and the initial design and main concept for the languages use was to create interactive cable technology for home entertainment systems, but the technology was met with little interest from the large cable companies and never adopted.

The project was retooled and went through several different project names and incarnations until a few years later when engineers Patrick Naughton and Jonathan Payne used the programming language to build a web browser (HotJava) that could support moving objects and dynamic content.  Subsequently, Sun Microsystems released Java 1.0 to the public in 1995 and the language quickly took off as the language’s design was easily integrated into the needs of internet technology.

Sun Microsystems was eventually acquired by Oracle who re-licensed most of its Java technologies under the GNU General Public License in 2007.  Starting with Java 8 (2014) public support for Java is free, earlier versions are only supported on a commercial basis.

Why is Java so popular?

Because Java is initially compiled it’s considered a safe and secure language which makes it popular in industries where security is important. It was one of the first official object-oriented-programming (OOP) languages developed and it has extensive libraries which make Java a robust and flexible language to program in.

Most significantly though, Java was one of the first truly platform independent programming languages.  Programs originally written for one operating system (say Windows) can then be executed on another (say Linux). Being able to develop software that can easily run on multiple operating systems saves time and money, so Java became a popular choice for software engineers and companies.  This portability became particularly important after the internet took off as the need to run applications across multiple operating platforms became a high priority.

This portability is also described by the short-hand WROA,  short for write-once-run-anywhere. 

How did Java achieve platform independence?

Prior to Java most programming languages followed two different processes: Compiled and Interpretive.

A compiled language follows a compile-link-execute format. This means a programmer writes a program in a high-level-language, then a compiler converts the entire code into a low-level program called an object and finally, the object files get all linked together into executable files that the computer’s CPU can read and run.

Other languages like Lisp or Python use an interpretive process which means the high-level program gets converted to the low-level object line by line on the fly.

A good analogy, used by Dr Jeffrey S. Carroll is to compare the compiler process to someone translating an entire book and to think of the interpretive process as someone translating a conversation as it happens.

There are pros and cons to both compiled and interpretive language and there’s a ton of debate as to what type of language should be used and where but the interesting thing about Java is that it’s been designed to leverage the advantages of both processes.

Java’s doesn’t compile an object file, instead, it takes the high-level program written and compiles it into something called bytecode. The only thing the programmer has to worry about is creating a program that compiles and runs properly to bytecode, once that goal has been achieved the program is portable and will run on any platform that has a Java Virtual Machine installed.

What’s a Java Virtual Machine? (Stay with me, we’re almost finished)

Java engineers isolated issues that were specific to various platforms and developed different  Java interpreters that address these platform-specific issues.  When you write a Java program it get’s compiled to bytecode for the Java Virtual Machine, which then acts as a line by line interpreter. When the program comes to parts of the bytecode that might cause issues the Java interpreter links in appropriate code specific to the platform the program is running on and then keeps going.

So the way Java works it that it’s compiled first and then link-executed specifically to the platform it’s being run on. Leveraging the advantages of both processes.

If Java is a WROA language can I make an iPhone App with it?

Not easily. Objective-C and now Swift are the programming languages used to natively develop iPhone/iPad app development. However, there are some frameworks available that will let you develop iPhone apps with Java.

Where is Java used the most?

Andriod, a mobile OS developed by Google uses Java extensively to develop applications. Apache HaDoop, a popular big data software library is a framework that was developed with Java. Some games like MineCraft were/are developed using Java and stock market algorithms, scientific computing applications and banking programs often use Java as they’re industries that require precision and speed.

Are Java and JavaScript related?

I guess you can consider them very distantly related as their both object-orientated-programming languages but outside that and some syntax (they both have a penchant for semicolons and curly brackets) the two languages don’t have much in common.

JavaScript was developed by Brendan Eich for NetScape Communications in 1995. It’s a scripting language that needs to be interpreted within another program, JavaScript is put inside HTML and then interpreted by the browser.  Because of that, you can only run JavaScript on a browser or web app. Java is a stand alone programming language that runs anywhere there’s a Java Virtual Machine.

Another significant difference between the two is that JavaScript code is text that’s interpreted by the browser so it’s program can be run, altered and run again easily and its source code is easy to access and see. Java programs need to be compiled into bytecode before they can run and once they’ve been compiled the source code is unreadable to humans.

JavaScript is considered a simpler language to learn. It’s got far fewer commands and libraries and all you need to get started as a coder in JavaScript is a computer with a web browser and NotePad or TextEdit installed.

What are good online resources for learning Java?

Codecademy has a good intro course that will let you try out Java without needing to install the language or an IDE onto your computer and CodingBat has a large number of practice problems that also run in the browser.

Derek Banas has an excellent YouTube playlist of Java specific tutorials that I highly recommend. Coursera offers a 5-course specialization taught by Duke University if you’re looking for something more traditionally academic and EDx has MicroSoft verified courses on Java if you’re looking for something directly industry related.  Both Coursera and EDx have a rabbit hole of courses on Andriod, HaDoop and other interesting computer things that are taught using Java.

 

 

 

 

Advertisements

In The Long, Long Ago :: Kids and Teens React to Old Tech

My own child is too young to properly remind me that I’m approaching middle age so I turn to YouTube to fill the void. Here are some of my favourites from the amusing Kids/Teens React Series.

Bonus:

There is also an ‘Elders React’ series but it’s usually either too predictable (old white guys hate rap) or too unbelievable (former 1960s adolescents shocked by twerking) to be amusing. However, I did enjoy watching elderly people play Grand Theft Auto 5.

 

 

Play 5: Retro Console & Computer Games

While I know Google Play and the Apple Store are bursting with wonderful puzzle, maze and arcade style games for you to pull out during you train commute or while you drink your coffee at the cafe I still regularly seek out and play vintage games from the 1980s. The best vintage games like Frogger and Tetris helped show what video games were capable of but I mostly go retro when I want a taste of the ridiculous. There is a wonderfully naive quality to a lot of 1980s games that’s missing from contemporary games, an unfortunate side effect of video games becoming a multi-billion dollar industry.

AGS_BouncingBabies

1. Bouncing Babies

Let’s start with the game least likely to get rebooted, the three colour MS-DOS gem Bouncing Babies from 1984. In this game, you control two firemen who rescue babies thrown from a burning building by bouncing them on a stretcher into a waiting ambulance. In a game (il)logic common to the era the better you get at saving babies, the more babies get thrown out the window until your juggling quint, sept or hextuplets. Drop a baby, lose a life – at least that part makes sense. Even as a kid I wondered what kind of sicko would recklessly hurl multiple babies out a window like that but the game’s simple mechanics make it weirdly addictive.

AGS_Tapper

2. Tapper

I had forgotten about 1983’s Tapper until I saw it referenced in Wreck-it Ralph. In Tapper, you play a busy bartender who serves customers drinks, grabs empties and runs around collecting tips. The better a bartender you become the busier the bar gets and each time you level up (because ’80s game logic) the bar you work in gets worse, by level 3 your in a very dive-y Punk Bar.

I grew up playing the 3 colour IBM PC version that’s very similar to the online version I linked to. I recently learned that the original arcade version was sponsored by Budweiser but was quickly altered because of the ChildrenTM! I do remember the Mountain Dew logo from my youth and, frankly, beer is probably healthier, but that’s just my two cents. Apparently, the game has been repackaged as Root Beer Tapper because of the ChildrenTM! redux and versions of it are available for mobiles and modern consoles. I still like the old school version on DOS-Box, it’s actually harder because faster computers make the space bar more sensitive.

AGS_LocknChase

3. Lock ‘n’ Chase

I’m just going to come out and say it, Lock ‘n’ Chase is better than Pac-Man. It’s not as groundbreaking because it came out afterwards and it clearly owes Pac-Man its existence but I maintain that it’s more enjoyable to play than a robber collecting coins and avoiding capture than it is to play a yellow circle eating dots and avoiding ghosts. Apparently, the original game is available on Nintendo Wii as part of the Data East Arcade Classics compilation.

AGS_BurgerTime

4. BurgerTime

I use to play BurgerTime on the Intellivision. I would play this game until the Intellivision overheated and the graphics went all wonky and then, and only then, would I reluctantly go outside into the sunshine. This is the first game I remember getting really excited about and I still get weird urges to make a chef run frantically over giant hamburger ingredients, armed with only quick reflexes and pepper shaker.

The arcade version came out in 1982 and the Intellivision port was Mattel’s most popular console game for quite a while so I definitely wasn’t the only one who became a gamer because of BurgerTime. The games spawned a wealth of clones and official sequels and, like Tapper, an updated version is available for modern consoles but who needs 3D when you have DOS-Box amirite!

AGS_ThreeStooges

5. The Three Stooges

Growing up reruns The Three Stooges were standard Sunday morning viewing in my home and I remember my Father being really, really excited when we bought this game at a flea market. In hindsight, The Three Stooges is not a particularly memorable game but there are still a number of things about this obscure 1987 Amiga game that I enjoy. The graphics and sound quality were, for the era, top-notch and even now you can still appreciate how much work must have gone into designing it. The game consists of a series of mini-games (based on Stooges films) you play to earn money to save an orphanage from an evil man with a twirly moustache. If the overall premise strikes you as extremely hokey, that’s because it is. The Three Stooges filmography doesn’t exactly give creators a deep well of source material to work with but they do faithfully capture the humour and silliness of the troop so if custard pies and slap-stick are your thing give this game a go.

Three Visual Music Videos

Over the past few months, I’ve spent some time listening classical music (shout out CBC Radio 2’s Tempo & Shift) and thinking about pure abstraction. So, I guess it was inevitable that I’d find myself revisiting ‘visual music’.  I’ve started with the NFB archives and the world of Norman McLaren. From there I remembered Oskar Fischinger, and the magic algorithms of YouTube recommended a New Zealander, Len Lye, who seems like a bad ass.

Below are three introductory films, visit The Center for Visual Music (seriously, it’s a thing) for more about visual music artists and research papers.

Norman McLaren – Spheres

Oskar Fischinger – An Optical Poem

Len Lye – Kaleidoscope, A Colour Box, Colour Flight (excerpts only)

Bonus video:

After posting this I realized put up a broken link to the Len Lye video and YouTube recommended this Walter Ruttman work, Lichtspiel Opus I.

Ruttman was an Assistant Director to Leni Riefenstahl’s filming of Triumph of the Will and died on the front, working as a war photographer during WWII.

The Museum of Endangered Sounds

Screen Shot 2016-03-27 at 9.55.40 AM

Brendan Chilcutt has created an online archive of endangered sounds. If you’re trying to remember what Pac-Mac or a dial-up modem sounds like this is the place.  Ultimately Chilcutt wants to develop a markup language to reinterpret the sounds as a binary composition which has interesting possibilities for composers and sounds artists.

How To :: Take a Screenshot on a Mac

What is a Screenshot?

A screenshot is a way of taking a snapshot of your computer screen and saving it in a static image file for later use. Mac OS X comes with four built-in ways to take screenshots: keyboard shortcuts, the Grab and Preview applications and through the Terminal (not recommended for beginners). Macs automatically save the image as a .png on your desktop.

What are Screenshots Used For?

To quickly document something that only exists online. A Web Designer will often take screenshots of websites they’ve designed for their own portfolio. A journalist may take a screenshot of a controversial tweet or other online statements a politician or celebrity has made so a record exists if the author later deletes it.

To troubleshoot software problems. It’s often easier to take a screenshot and send the photo to a technician then trying to describe the problem in a written email or verbally over the phone.

In tutorials, screenshots are used to demonstrate correct settings or how to perform certain functions.

In software reviews, screenshots are used to show readers what the software looks like.

How To Take a Screenshot:

With Keyboard Shortcuts
Command-Shift-3: Takes a screenshot of the entire screen and saves it to the desktop.

Screen Shot 2016-03-05 at 11.14.17 PMCommand-Shift-3 :: A sample screenshot of my desktop.

Command-Shift-4, then select an area: Allows the user to select a specific area of the screen and save it to the desktop.

Screen Shot 2016-03-05 at 11.16.49 PMCommand-Shift-4 :: A sample screenshot of an area my desktop.

Command-Shift-4, then spacebar, then click a window: Take a screenshot of a window and save it as a file on the desktop

Screen Shot 2016-03-05 at 11.19.14 PMCommand-Shift-4, then spacebar, then click a window:: A sample of a screenshot of a window on my desktop.

With the Grab Application

Screen Shot 2016-03-05 at 11.28.34 PM

To use the Grab application click on the Macintosh HD icon on your computer, then click on Applications, then click on the Utilities folder then the program Grab. Click Capture on the menu bar at the top of your screen to see the four types of screenshots available in Grab:

Selection takes a screenshot of a specific area of your screen.
Window takes a screenshot of an open window on your screen.
Screen takes a screenshot of your entire screen.
Timed Screen takes a screenshot of your entire screen after a 10 second lapse.

With the Preview Application

Screen Shot 2016-03-05 at 11.31.50 PM

Grab can also be used with the Preview Application. Preview is the default program used to view images on a Mac. To open an image in Preview just locate the file and double click. Once the image opens on your desktop go to File and select Take A Screenshot from the drop down menu. There are three types of screenshots available in Preview:

Selection takes a screenshot of a specific area of your screen.
Window takes a screenshot of an open window on your screen.
Timed Screen takes a screenshot of your entire screen after a 10 second lapse.

Through the Terminal

The final built in way to take screen shots on a Mac is through the Mac terminal with the screenshot command. This method is usually used by developers writing larger scripts and is not recommended for beginners.

For example to take a screenshot of the entire screen, name file screen.jpg, and save it to the desktop you’d type the below command into the Terminal:
screencapture -S ~/Desktop/screen.jpg

A full list of commands for the screencapture utility is available at Mac Guides.