|
102 | 102 | <subsection xml:id="installing-java"> |
103 | 103 | <title>Installing Java</title> |
104 | 104 | <p><idx>JDK</idx><idx>Java development kit</idx><idx>Oracle</idx><idx>OpenJDK</idx> |
105 | | - Before you can use any Java IDE or compile Java programs, you need to install the <term>Java development kit</term> (<term>JDK</term>) on your computer. The JDK includes the Java compiler, the runtime environment, and essential tools for Java development. You can either download the latest version of the JDK from Oracle's website (<url href="https://www.oracle.com/java/technologies/downloads/" visual="https://www.oracle.com/java/technologies/downloads/">https://www.oracle.com/java/technologies/downloads/</url>) or use OpenJDK, which is a free and open-source implementation available at <url href="https://openjdk.org/" visual="https://openjdk.org/">https://openjdk.org/</url>. Most IDEs will help you configure the JDK once it's installed, but you'll need to have it on your system first. To verify your installation works, open a command prompt or terminal and type <c>java -version</c> - you should see version information displayed. |
| 105 | + Before you can use any Java IDE or compile Java programs, you need to install the <term>Java development kit</term> (<term>JDK</term>) on your computer. The JDK includes the Java compiler, the Java runtime environment, and many essential tools for Java development. You can either download the latest version of the JDK from Oracle's website (<url href="https://www.oracle.com/java/technologies/downloads/" visual="https://www.oracle.com/java/technologies/downloads/">https://www.oracle.com/java/technologies/downloads/</url>) or use OpenJDK, which is a free and open-source implementation available at <url href="https://openjdk.org/" visual="https://openjdk.org/">https://openjdk.org/</url>. Most IDEs will help you configure the JDK once it's installed, but you'll need to have it on your system first. To verify your installation works, you can open a command prompt or terminal and type <c>java -version</c> - you should see version information displayed. |
106 | 106 | </p> |
107 | 107 | </subsection> |
108 | 108 |
|
|
303 | 303 | <section xml:id="why-another-programming-language"> |
304 | 304 | <title>Why Another Programming Language?</title> |
305 | 305 |
|
306 | | - <p> |
| 306 | + <p><idx>dynamic language</idx><idx>static languages</idx> |
| 307 | + <idx>Python</idx> <idx>Java</idx> |
307 | 308 | Python is a nice language for beginning programming for several reasons. |
308 | 309 | First the syntax is sparse, and clear. |
309 | 310 | Second, the underlying model of how objects and variables work is very consistent. |
310 | 311 | Third, you can write powerful and interesting programs without a lot of work. |
311 | | - However, Python is representative of one kind of language, called a dynamic language. |
312 | | - You might think of Python as being fairly informal. |
313 | | - There are other languages, like Java and C++ that are more formal. |
| 312 | + However, Python is representative of one kind of language, called a <term>dynamic language</term>. In dynamic languages like Python, the type of a variable (whether it's a number, string, list, etc.) is determined while the program is running, not when you write the code. |
| 313 | + </p> |
| 314 | + |
| 315 | + <p>In <term>static languages</term>, all variable types need to be declared upfront. |
| 316 | + You might think of Python as being fairly informal about data types. |
| 317 | + Java and C++ are more formal about types. |
314 | 318 | </p> |
315 | 319 |
|
316 | | - <p> |
| 320 | + <p><idx>performance</idx> |
317 | 321 | These languages have some advantages of their own. |
318 | | - First, is speed: Java and C++ code will generally give better performance than Python code. (See <xref ref="note-python-performance"/>.) |
319 | | - Second is their maintainability. |
| 322 | + First, is speed: Java and C++ code will generally give better <term>performance</term> than Python code. (See <xref ref="note-python-performance"/>.) |
| 323 | + Second is their <term>maintainability</term> over time. Maintainability is the ease with which a program can be modified to correct faults, improve performance, or adapt to a changed environment. |
320 | 324 | A lot of what makes Python easy to use is that you must remember certain things. |
321 | | - For example if you set variable <c>x</c> to reference a turtle, and forget later that <c>x</c> is a turtle but try to invoke a string method on it, you will get an error. |
| 325 | + For example, if you set Python variable <c>x</c> to reference a turtle, and forget later that <c>x</c> is a turtle but try to invoke a string method on it, you will get an error. |
322 | 326 | Java and C++ protect you by forcing you to be upfront and formal about the kind of object each variable is going to refer to. |
323 | 327 | </p> |
324 | 328 |
|
325 | | - <p> |
326 | | - In one sense Python is representative of a whole class of languages, sometimes referred to as “scripting languages.” Other languages in the same category as Python are Ruby and Perl. |
327 | | - Java is representative of what I will call industrial strength languages. |
328 | | - Industrial strength languages are good for projects with several people working on the project where being formal and careful about what you do may impact lots of other people. |
329 | | - Languages in this category include Rust, C++, C#, and Ada. |
| 329 | + <p><idx>scripting language</idx> <idx>industrial strength languages</idx> |
| 330 | + In one sense Python is representative of a whole class of languages, sometimes referred to as <term>scripting languages</term>. Other languages in the same category as Python are JavaScript, Ruby, and Perl. |
| 331 | + Java is representative of what we might call <term>industrial strength languages</term>. |
| 332 | + Industrial strength languages are good for large projects with multiple programmers, where being formal and careful about code structure is important because changes made by one person can impact many others. |
| 333 | + Other industrial strength languages include Rust, C++, C#, and Ada. |
330 | 334 | </p> |
331 | 335 |
|
332 | 336 | <p> |
|
343 | 347 |
|
344 | 348 | <p> |
345 | 349 |
|
346 | | - Although Python code is generally slower than Java and C++ code, in practice Python programs can achieve equivalent performance. |
| 350 | + Although Python code is generally slower than Java and C++ code, in practice Python programs can achieve equivalent performance. Performance can be defined as how efficiently software can accomplish its tasks. |
347 | 351 | This can be done by compiling Python code to C code (see: <url href="https://cython.org" visual="https://cython.org">Cython</url>) or by calling high-performance libraries from Python (e.g., <url href="https://numpy.org" visual="https://numpy.org">NumPy</url>, <url href="https://scikit-learn.org/stable/" visual="https://scikit-learn.org/stable/">scikit-learn</url>, etc.). |
348 | 352 | So native language performance is just one criteria to consider when deciding which language to use for a program. |
349 | 353 | </p> |
350 | 354 | </note> |
351 | 355 |
|
352 | 356 | </section> |
353 | 357 |
|
354 | | - <section xml:id="sec-why-java-why-not-c-or-c"> |
| 358 | + <section xml:id="sec-why-java-why-not-c-or-cpp"> |
355 | 359 | <title>Why Learn Java? Why not C or C++?</title> |
356 | 360 |
|
357 | 361 | <p> |
|
361 | 365 | <p> |
362 | 366 | <ul> |
363 | 367 | <li> |
364 | | - <p> |
365 | | - Java includes a larger standard library than C or C++, which means that sophisticated programs can be created in Java without including external dependencies. |
| 368 | + <p><idx>standard library</idx> |
| 369 | + Java includes a larger <term>standard library</term> than C or C++, which means that sophisticated programs can be created in Java without including external dependencies. |
366 | 370 | The Java Standard Edition contains thousands of built-in classes that support tasks like file input/output, networking, data structures, and graphical interfaces. |
367 | | - We could not begin to scratch the surface of these classes even if we devoted all of class time! However, we will cover many useful and powerful features of the Java standard library this semester. |
| 371 | + We could not begin to scratch the surface of these classes even if we devoted many more chapters! However, we will cover many useful and powerful features of the Java standard library. |
368 | 372 | </p> |
369 | 373 | </li> |
370 | 374 |
|
371 | 375 | <li> |
372 | | - <p> |
373 | | - Java incorporates automatic garbage collection of memory, whereas C and C++ programs typically include some degree of manual memory management. |
| 376 | + <p><idx>garbage collection</idx> |
| 377 | + Java incorporates automatic <term>garbage collection</term> of memory, which is an automatic memory management process that identifies and removes unused objects from memory, helping to free up space and improve program efficiency. |
| 378 | + C and C++ programs typically include some degree of manual memory management. |
374 | 379 | This makes programming in those languages more challenging. |
375 | 380 | </p> |
376 | 381 | </li> |
|
0 commit comments