0
$\begingroup$

A younger friend of mine, a high school student I have been encouraging to take his Computer Studies class seriously, and possibly go for CS in tertiary education, brought this problem to me. He was given a term paper by his teacher in the course of which he had to discuss language constructs in programming.

Being a diligent student, he had done most of the assignment but wanted to impress his teacher in addition with a definition of the term language construct as used in programming. He showed me his jottings from books and on-line but complained he could not find definition he could quote or material simple enough to enable him create a very good definition of his own. In spite of this, he came up with and showed me his definition below:

"a language construct is a part of a program that does 
      some special work."

He wanted my opinion on whether the above definition will be satisfactory for his teacher. I was uneasy to say ok/not ok. I felt the definition was too fuzzy but I could not come up immediately with something more accurate YET WITH LANGUAGE SIMPLE ENOUGH to be at his vocabulary level! This is the dilemma. So I searched in the literature available to me, on-line too. I even read this thread on StackOverflow:

https://stackoverflow.com/questions/10057524/what-does-language-construct-mean and this one on Quora: https://www.quora.com/What-is-a-construct-in-programming

I got many explanations but no compact definition. I thought hard about it. I made no headway. I also found this definition from Wikipedia (which incidentally is the only one that came close to a compact definition of the term):

“A language construct is a syntactically allowable part of a program that may be formed from one or more lexical tokens in accordance with the rules of a programming language. The term Language Constructs is often used as a synonym for control structure, and should not be confused with a function.”

However, the definition was full of jargon and bombast ("syntactically allowable", "lexical ...") which were way over my friend’s head. Furthermore, the last sentence of the Wikipedia definition begged a question of what is and what is not a programming construct. Considering it, shall we say class, object, structures, hash tables and such are not programming constructs?

We tried to pick elements of the Wikipedia definition, translate it to simpler language and incorporate in my friend’s definition, and the result got verbose and so long, it lost the compactness of a definition. The target is to come up with a definition of the term programming construct” that is simple, within the vocabulary level of a high school student, precise enough to clearly delimit the scope of where construct starts and where it ends (so one can easily see what is a construct and what is not). I and my friend have discussed in the last three days on it and we seem to be getting into an intellectual quagmire: the more we try to step forward, the more intractable it gets.

I bring this here because we are teachers. As teachers, we are used to having to define basic concepts. I am hoping to get some precision and lucidity that AUGMENTS my friend’s definition and makes it more rounded. Lets help a serious young man who has done his due diligence and needs some scaffolding. Thanks people.

Just a lucid, compact and rounded definition at the vocabulary level of a high school student please. (I will ensure you are acknowledged in my friend's paper if your definition is not an extension of his, and is used by him).

$\endgroup$
1
  • 1
    $\begingroup$ I suspect you'll do better working by analogy than by definition, though I admit I am having trouble thinking of one of those, too. $\endgroup$
    – Ben I.
    Nov 3, 2019 at 12:34

2 Answers 2

1
$\begingroup$

A "programming construct" is a sequence of zero or more words and symbols that is legal for the language and also complete.

The above mostly works, but not all programming systems are built from words and symbols. One can program graphically, for example. Therefore "sequence" isn't quite right. But it works for the majority of common languages.

There are two issues.

The first is that what is "legal" varies a lot. So, in the definition you found, words like lexical are important, since the lexical structure of a language determines which words and symbols can be used, but is agnostic about how they are used. Likewise syntactically allowable is how we talk about how those (lexical) symbols can be put together to form a legal construct.

So, by saying "legal for the language", I'm hiding a lot of detail.

The second issue is that almost all languages are recursive in some sense. So a "programming construct" can contain other programming constructs recursively.

In some languages (Pascal) the empty string is actually a construct and can represent a statement.

Common examples of programming constructs are:

  1. variables

  2. functions and procedures

  3. expressions

  4. assignments

  5. classes

  6. values

  7. commands

  8. programs

etc etc etc

But note that these are not necessarily distinct categories. For example, values can be expressions. And functions can be values (some languages).

Also note the my definition says that the sequence needs to be complete. Some sequences of symbols might be "part of a construct" but not a construct. Leaving off the terminating period in a Pascal program leaves you with only part of a program, not the complete construct.

But note that objects are not (normally) programming constructs since they are a feature of the running program, not the text of the program itself. They aren't part of the language and don't exist until the program runs. (There are exceptions to this - some languages have a different idea of object than do Java and Python.) And I said "text" which brings us back to the "sequence" issue, which isn't universal. But this is why the word "language" was important in the definition. Programming Constructs are part of the language in which we express programs, not part of what the program does when it executes.

Things are messy. It's complicated.

$\endgroup$
2
  • $\begingroup$ Yea, i've grappled with it and appreciate the messiness. The word is nuanced between the languages and in the way it is used by authors that its tricky doing a satisfactorily rounded, simple definition. But iam beginning to see the light from your definition. My key take aways from your definition is, it is: sequence of words/symbols, complete, legal, not about what the program does but how it is built up. Much insightful. $\endgroup$ Nov 3, 2019 at 7:36
  • $\begingroup$ This kind of confusion does not arise if you start with a definition like: "A computer is a metal thing with moving (electrical) parts inside that can be set up to perform desired actions." Since a computer is not a thinking being, nothing is lost in this simplification. Then you just say: "Lazy people find increasingly complex ways to set the thing up to do repetitive actions. (see: Computer Language)." It is when we try to start the explanation somewhere else that all the problems arise. Computers are machines, it is the human mind and its complexity that makes them seem otherwise. $\endgroup$
    – Scott Rowe
    Nov 9, 2019 at 21:34
2
$\begingroup$

Rephrasing

a language construct is a part of a program that does some special work

This is indeed too vague. First of all, every program is built specifically to do a particular job. "Special" is subjective, often synonymous with "custom tailored" and thus any program can be called a "special work". By logical extension, any part of a program is therefore part of that program's special job.

The quickest (but not perfect) fix here would be

a language construct is a part of a language that does some special work

It's still too vague, but it hits the nail more on the head. Constructs are very specifically not something you've written yourself, i.e. they are not part of your program but were already part of the language/compiler.

More specifically, I would define a language construct as a predefined operation of the language, i.e. it is not something that developers must build for themselves.

Learners don't yet grasp the big picture

...by semantical definition of what a learner is.

I could not come up immediately with something more accurate YET WITH LANGUAGE SIMPLE ENOUGH to be at his vocabulary level!

In software development, where everything is so abstract, you only understand a given name (= dictionary entry, vocabulary) when you understand the underlying concept. If your friend does not have a particular word in their vocabulary, they do not understand the underlying concept.

In a way, their inability to define what a language construct is specifically proves that they either don't know what a language construct is, or they don't understand some key concepts that language constructs (and their definition) inherently rely upon.

The purpose of providing this definition to the teacher is not to give the teacher some wisdom that they already have. The purpose is for your friend to show that he knows it.

The proper solution for this is for your friend to either dig deeper into the concepts that he's trying to tackle, or to not overreach at the moment.

Overly complex definitions

“A language construct is a syntactically allowable part of a program that may be formed from one or more lexical tokens in accordance with the rules of a programming language. The term Language Constructs is often used as a synonym for control structure, and should not be confused with a function.”

This sounds like a quote from the Architect in The Matrix, who is often ridiculed for using near-nonsensical liguistic complexities merely as an affectation.

I could delve into abstract analogies as to why the Architects innate desire to abstract and define is very similar to what you're trying to do, but I'm instead going to focus more on the specifics of software engineering.

Languages vs frameworks

Considering it, shall we say class, object, structures, hash tables and such are not programming constructs?

A language is different from its framework, and this is a very important distinction (that your friend may not understand yet).

Take the example of C# and the .Net Framework. IEnumerable<T> is part of the .Net framework, it is not part of the C# language. However, interfaces and generic type parameters are part of C#.

In the end, an application is just layers upon layers code, where any layer tends to rely on the predefined concepts in the layer beneath it. As a basic model:

  • The language provides language constructs and a syntactical definition
  • A framework extends functionality by creating additional predefined concepts which rely on the language constructs
  • An application relies on its framework (and language) and can rely on all predefined concepts at its disposal in order to achieve its goal in the best way possible.

To you as an application developer, the lines between language features and framework features can be muddied (because it doesn't really matter to you where it comes from). But for framework designers and language designers, these distinctions are incredibly important.

At a base level, a language is globally pervasive whereas a framework can be avoided selectively. For example, I am able to write my own IEnumerable<T> as long as I avoid namespace conflicts with my framework's IEnumerable<T>. Good practice suggests I don't do this, but I am technically able to do so.

However, I am never able to use for or switch anywhere in my code for anything other than referring to my language's constructs. Good/bad practice doesn't even come into it, it's just outright prohibited to repurpose these constructs as their definitions are globally persisted through all of the code (written in that particular language).

Education through definition

The target is to come up with a definition of the term programming construct” that is simple, within the vocabulary level of a high school student

When you drill down into software development, things become more complex, not less. The diligence you are putting effort into is what is leading you to the increasing complexity.

Ask a beginner programmer what a "hello world" application does. Now ask them on the intricacies of how these characters are displayed on the screen. They are patently unable to do the latter because you're asking them something they do not yet grasp, yet they already display top-level knowledge by being able to understand the purpose of a "hello world" application.

I am hoping to get some precision and lucidity that AUGMENTS my friend’s definition and makes it more rounded. Lets help a serious young man who has done his due diligence and needs some scaffolding. Thanks people.

Your question is based on the underlying principle that one learns by observing strict definitions and derives understanding from them. I want to challenge that frame of mind, especially in the field of software engineering.

The vast majority of good developers I've worked with are all "hands on" developers. They learn by doing, and their vocabulary naturally grows with their skill. If you put these developers in a classroom and get them to learn definitions of things they do not yet understand, or have not yet encountered in practice, they are going to either actively reject or genuinely forget the intricacies you've poured into these definitions.

I'm not saying that it's impossible to learn the theory before the practice, but for abstract fields such as software development it's so very fickle to understand a theoretical definition without misinterpretations if you don't have practical experience to rely on. It's not impossible, but it is highly improbable.

Just a lucid, compact and rounded definition at the vocabulary level of a high school student not explanations please.

Abstract concepts don't work without practical examples. You cannot teach a child what addition is without at some point having used physical objects to show addition in reality.
You can teach a child to blindly accept and parrot the symbology of 1 + 1 = 2, but they won't understand what it represents in the real world. Furthermore, if they only recognize the symbology and not the meaning, then they will be unable to answer 2 + 2 or 1 + 1 + 1 as they cannot apply the general concept of addition as they have not yet understood it.

Compared to children, adults are significantly less capable of deriving understanding from parroted information. Compared to adults, software developers are even less capable of doing so; and those that do blindly accept and parrot things often end up stagnating in their job by repeating what they know instead of perpetually reevaluating their approach.

Abstractions stem from practical applications, not the other way around

Your friend's definition of a language construct should not be the start of their understanding on what a language construct is. Their ability to define a language construct is the resulting proof that they have understood what a language construct is.

Don't pour your effort into definition. Pour your effort into practical experimentation. The definition will naturally come from your practical experience.

$\endgroup$
2
  • $\begingroup$ The definition is not a must. It was just "sugar" he wanted to add to his assignment, and seeing the diligence and zeal, he went about it, I felt we could help lend a hand. & we have: with your rephrase of his definition, and explanations immediately following it + @Buffy's earlier one he is good to go. I shall let him read this thread and do a draft definition he can ultimately use. Thanks people $\endgroup$ Nov 5, 2019 at 15:19
  • 1
    $\begingroup$ Gosh, here I was, thinking I was a teacher just so I could get paid for my students to present me with new insights day after day! Maybe I have a different definition of teacher and student. $\endgroup$
    – Scott Rowe
    Nov 9, 2019 at 21:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.