Programming as a language

Programming as a language

Everyone must be acquainted with the term in English jargon programming language. Any language is a tool to communicate most probably within the biological species which makes the species naturally selected in evolution. There were many attempts to formalize mathematically a machine to make it say a species to effectively communicate with humans and vice versa. That led to the computerized digital world we live in. The most basic definition is Finite State Automata(FSA) which has a start state, set of symbols to navigate between other states and an end state of accepting member statement of the language. FSA is known to express regular language(heirarchy of languages by Chomsky: leave it for another article). FSA with conceptual stack is known to express context free languages. FSA with linear bounded Turing machine is known to express context sensitive languages. When trying to realize the theoretical framework with real program we get to know the basics that stick well in mind. See the following program in C,

Article content


In the above simple program if you think deeply how the computer runs this program to give us the output 30, you are in awe. This program is taken as input by another program that is compiler and then converting into binary, this program executes to print 30. If thinking still more how Chomsky hierarchical play works here, the basic FSA is used for identifier "i,j" matching the rules of variables naming, like not exactly keywords, not number in the beginning, no space in between. Also FSA takes care of numerical constants, string constants, character constants not to be messed up in syntax. Next comes FSA+Stack which actually handles most of the balanced parentheses "{},(),[]", in our case it is simply limited to the main function. Next in line is the FSA+Linear bounded TM, which is the compiler which has the power to correct all syntactical error. Without clearing the compiler check statistically typed language like C can never move to execution.

But thinking of compiler one cannot ignore Turing machine and the Halting problem. A Turing machine which when kept conceptually as a machine even with infinite memory cannot distinguish if it will halt for a particular input or not, unless by running over the problem itself. Consider the following function,

Article content

In the above function halts() is assumed to be a total function that returns True given a program as input that always halt and otherwise. But the above snippet, when the halts(g) is True g() loops forever and when halts(g) is False g() returns. This is in direct contradiction to the assumption leading there can be no total function halt() that can predict if a program can halt or not by itself. So compiler too never checks over its bound like looping forever code. It checks all the syntactic errors and unbalanced parentheses and leaves the complete logic to the programmer. It is a kind of grammar teacher who guides early budding human programmer. With chatGPT in play we are even wondering has AI passed Turing test.

To view or add a comment, sign in

More articles by Dr. Murukessan A P

  • Reinforcement Learning

    Reinforcement Learning (RL) is a paradigm of artificial intelligence that learns more similar to humans. The humans…

  • Edit Distance a Deeper Dive

    In the past article for Edit Distance algorithm between two strings, we have discussed the exact code using recursion…

  • Distant Strings

    Have you ever wondered how auto text suggestions and auto spelling corrections work the way they do in MS Word or in…

  • Regular to Recursive and LLM

    There is a hierarchy of languages by Chomsky. The first in hierarchy, regular language is the word builder, like…

  • Numerical Python

    Numerical Python library NumPy is a pioneer tool for python getting scaled in Artificial Intelligence. Numerical…

  • Dynamic Programming

    Computer software works like a stack of software. First comes the OS or Operating System, then all applications that…

Explore content categories