Subscribe Contact

Home  »  Chapter 2 : Programming Basics
Basic Programming Concepts

Introduction

In the humanities, we explore language, culture, and human experience. Computer programming is often perceived as a discipline for Science Technology Engineering & Math (STEM) disciplines. However, learning and using programming in the humanities remarkably complements the creative, investigative spirit of humanist disciplines such as Communications, English, History, Linguistics, Philosophy, World Languages & Culture, Writing, and Rhetoric. This synergy unlocks new perspectives, especially in digital humanities, data analysis in linguistic research, archival information retrieval, and interactive media. Understanding the basic concepts of programming hence becomes essential. This chapter unfolds these foundational elements, offering you the tools to begin this exciting interdisciplinary journey.

Terminology

Given the description of Python above, the following is provided to help fill in possible gaps in knowledge about these terms.

General-Purpose: A general-purpose programming language is designed to be used for writing software in a wide variety of application domains. This means it's not restricted to a specific kind of software, like how HTML is specific to web page data. Instead, developers can use it to create anything from desktop and web applications to games and mobile apps.

High-Level: High-level programming languages are designed to be easy to read and understand, abstracting away complex details of the computer's hardware. They allow programmers to write code using natural language elements and abstracted command terms, closer to human language. These languages handle several lower-level operations like memory management, making them more user-friendly but less efficient than low-level languages.

Domains: In the context of programming, "domains" refer to the specific fields or industries where certain technologies or practices are applied. A domain encompasses a set of problems and solutions, tailored to particular business or technical needs, such as 'healthcare,' 'finance,' or 'machine learning.' The term aids in describing the specialization areas of certain technologies, practices, or languages within these fields.

Paradigms: Paradigms in programming define the conceptual framework and methodology of structuring and organizing code, which impacts how tasks are handled. They provide a set of standards and patterns for programming logic, such as 'Object-Oriented,' 'Procedural,' or 'Functional' paradigms. Each paradigm offers different ways of thinking about how data and code are interconnected based on various principles and philosophies.

Procedural: Procedural programming is a paradigm based on the concept of procedure calls, where programs are structured as a collection of procedures, also known as routines or functions, which are sequences of computational steps. These procedures operate on data, perform computations, and can be reused throughout the program, emphasizing a linear and top-down approach. This paradigm is known for its simplicity, but it can become inefficient in larger, more complex software projects.

Scripting: Scripting languages are designed for integrating and communicating with other programming languages or components, often used for automating processes. These languages are typically easier to learn and faster to write, making them suitable for tasks like batch processing, text processing, or everyday programming tasks. They are often interpreted, meaning they're executed line-by-line, generally offering more flexibility but at the cost of performance.

Imperative: The imperative programming paradigm expresses the logic of a computation as a sequence of statements that change the program state. It focuses on describing how a program operates, consisting of commands for the computer to perform specified actions with variables and structures. This approach can be intuitive, mirroring the step-by-step logic humans often use to approach problems, but it can become complex and hard to maintain with larger programs.

Functional: Functional programming is a paradigm where programs are constructed by composing and applying functions, treating computation as the evaluation of mathematical functions and avoiding state changes and mutable data. It emphasizes the application of functions, allowing for constructs like higher-order functions, lazy evaluation, and tail recursion, thereby facilitating highly modular and predictable code. This approach can lead to more efficient, easily testable, and scalable code but may require a shift in mindset from traditional programming methods.

bject-Oriented: Object-oriented programming (OOP) is a paradigm based on the concept of "objects," which are data structures encapsulating data fields and methods together. It emphasizes principles such as encapsulation, inheritance, and polymorphism, allowing for data and behaviors to be represented as one cohesive unit. This paradigm simplifies the software development and maintenance by providing a framework for code organization and reuse, but can introduce complexity that is unnecessary in simple programs.

Dynamic: In the context of programming, "dynamic" often refers to languages or systems wherein operations that could take place at compile-time can happen at runtime. This could involve features like dynamic type checking, allowing types to be inferred while the program is running, and dynamic method binding. While offering more flexibility and requiring less boilerplate code, it can introduce runtime errors and performance overhead.

Interpreted Language: An interpreted language is a type of programming language for which most of its implementations execute instructions directly, without previously compiling a program into machine-language instructions. The interpreter executes the program directly, translating each statement into a sequence of one or more subroutines, and then into another language (often machine code). This allows for increased flexibility and ease of debugging, but it often results in slower performance compared to compiled languages.

Compiled Language: A compiled language is a programming language whose implementations are typically compilers (translators that generate machine code from source code), and not interpreters. In this process, the compilation happens before runtime, which means the source code is translated into machine code, and this binary executable is what runs on the processor. Compiled languages tend to provide faster execution times and more efficient resource usage than interpreted languages, but they lack the flexibility and ease of modification that interpreted languages enjoy.



1. Algorithms and Logic

Before diving into codes and syntax, one must understand algorithms—a set of step-by-step instructions to perform a task. In cooking, a recipe is an algorithm; in literature, a narrative structure can be algorithmic. Algorithms in programming are similar, directing the computer to process information and make decisions, solving problems efficiently and effectively.

Logic forms the backbone of these decisions. Computers operate on binary logic (true/false or yes/no), known as 'Boolean logic.' This form of reasoning mirrors critical thinking in humanities: identifying conditions, considering outcomes, and making informed conclusions.

2. Syntax and Semantics

Learning a programming language, like studying a foreign tongue, involves rules and grammar—syntax. Each language (e.g., Python, Java, JavaScript) has unique syntax dictating how commands are structured, influencing how we instruct the computer.

Semantics refers to the meaning behind these commands. Just as analyzing the semantics in literature involves understanding themes and motifs beyond the text, in programming, you interpret the function and effect of code lines—what tasks they accomplish and what outputs they produce.

3. Variables and Data Types

Variables in programming are akin to nouns in language—placeholders for values that can change. They store data that your program will manipulate. For instance, a variable could represent a count of ancient artifacts, storing numbers, or hold a block of text from an old manuscript.

This data comes in various 'types'—integers, floating-point numbers, characters, strings, and Booleans, to name a few. Recognizing how to work with these types is paramount, as it would be in understanding genres or forms in humanities research.

4. Control Structures

Control structures manage the flow of a program's execution, comparable to plot devices in a story. They include:

Conditional Statements ('if' statements): These are the forks in the road, where your program decides between options based on certain conditions. Loops ('for' and 'while' loops): These repeat a segment of code multiple times, like a chorus in a song or recurrent themes in literature. They're handy for tasks like analyzing datasets or automating repetitive tasks.

5. Functions and Modularity

Functions are self-contained modules of code that accomplish specific tasks, just as paragraphs or chapters in a text can be standalone but contribute to the larger narrative. By 'calling' a function, you execute the task, then return to the main flow of your program. This modularity makes your code more organized, reusable, and easier to conceptualize, paralleling the structuring of arguments in a scholarly discourse.

6. Debugging and Problem Solving

Debugging is the art of problem-solving—finding and correcting mistakes in your code. In humanities, much like in thorough critical analysis or editorial processes, debugging requires patience and a keen eye for detail. It involves retracing steps, verifying assumptions, and sometimes, seeking different perspectives or approaches.

Conclusion

Embracing programming in humanities doesn't mean abandoning the passion for human culture, language, and societal developments. Rather, it’s about augmenting that passion with new tools. As you delve into programming, you'll find it a natural extension of the investigative and interpretive skills honed through your humanities studies. In the following chapters, we will build on these concepts, venturing further into the rich, interdisciplinary landscape where technology meets human inquiry.


«  Previous : Preliminaries
Next : Overview of Python  »




© 2023 John Gordon
Cascade Street Publishing, LLC