Home:ALL Converter>What is a computer programming language?

What is a computer programming language?

Ask Time:2009-08-25T09:59:10         Author:Gordon Potter

Json Formatter

At the risk of sounding naive, I ask this question in search of a deeper understanding of the concept of programming languages in general. I write this question for my own edification and the edification of others.

What is a useful definition of a computer programming language and what are its basic and necessary components? What are the key features that differentiate languages (functional, imperative, declarative, object oriented, scripting, etc...)?

One way to think about this question. Imagine you are looking at the hardware of a modern desktop or laptop computer. Assume, that the C language or any of its variants do not exist. How would you describe to others all the things needed to make the computer expressive and functional in terms of what we expect of personal computers today?

Tangentially related, what is it about computer languages that allow other languages to exist? For example take a scripting language like Javascript, Perl, or PHP. I assume part of the definition of these is that there is an interpreter most likely implemented in C or C++ at some level. Is it possible to write an interpreter for Javascript in Javascript? Is this a requirement for a complete language? Same for Perl, PHP, etc?

I would be satisfied with a list of concepts that can be looked up or researched further.

Author:Gordon Potter,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/1325686/what-is-a-computer-programming-language
Greg Hewgill :

While this doesn't directly answer your question, I am reminded of the Revenge of the Nerds essay by Paul Graham about the evolution of programming languages. It's certainly an interesting place to start your investigation.",
2009-08-25T02:08:52
starblue :

Not a definition, but I think there are essentially two strands of development in programming languages:\n\n\nThose working their way up from what the machine can do to something more expressive and less tied to the machine (Assembly, Fortran, C, C++, Java, ...)\nThose going down from some mathematical or theoretical computer science concept of computation to something implementable on a real machine (Lisp, Prolog, ML, Haskell, ...)\n\n\nOf course, in reality the picture is not as neat, and both strands influence each other by borrowing the best ideas.",
2009-08-25T07:01:09
deceze :

Slightly long rant ahead.\n\nA computer language is actually not all that different from a human language. Both are used to express ideas and concepts in commonly understood terms. Among different human languages there are syntactic differences, but you can express the same thing in every language (does that make human languages Turing complete? :)). Some languages are better suited for expressing certain things than others.\n\nFor example, although technically not completely correct, the Inuit language seems quite suited to describe various kinds of snow. Japanese in my experience is very suitable for expressing ones feelings and state of mind thanks to a large, concise vocabulary in that area. German is pretty good for being very precise thanks to largely unambiguous grammar.\n\nDifferent programming languages have different specialities as well, but they mostly differ in the level of detail required to express things. The big difference between human and programming languages is mostly that programming languages lack a lot of vocabulary and have very few \"grammatical\" rules. With libraries you can extend the vocabulary of a language though.\n\nFor example:\n\n\n Make me coffee.\n\n\nVery easy to understand for a human, but only because we know what each of the words mean.\n\n\n coffee : a drink made from the roasted and ground beanlike seeds of a tropical shrub\n drink : a liquid that can be swallowed\n swallow : cause or allow to pass down the throat\n ... and so on and so on\n\n\nWe know all these definitions by heart, but we had to learn them at some point.\n\nIn the same way, a computer can be \"taught\" to \"understand\" words as well.\n\nCoffee::make()->giveTo($me);\n\n\nThis could be a perfectly valid expression in a computer language. If the computer \"knows\" what Coffee, make() and giveTo() means and if $me is defined. It expresses the same idea as the English sentence, just with a different, more rigorous syntax.\n\nIn a different environment you'd have to say slightly different things to get the same outcome. In Japanese for example you'd probably say something like:\n\n\n コーヒーを作ってもらっても良いですか?\n Kōhī o tsukuttemoratte mo ii desu ka?\n\n\nWhich would roughly translate to:\n\nif ($Person->isAgreeable('Coffee::make()')) {\n return $Person->return(Coffee::make());\n}\n\n\nSame idea, same outcome, but the $me is implied and if you don't check for isAgreeable first you may get a runtime error. In computer terms that would be somewhat analogous to Ruby's implied behaviour of returning the result of the last expression (\"grammatical feature\") and checking for available memory first (environmental necessity).\n\nIf you're talking to a really slow person with little vocabulary, you probably have to explain things in a lot more detail:\n\n\n Go to the kitchen.\n Take a pot.\n Fill the pot with water.\n ...\n\n\nJust like Assembler. :o)\n\nAnyway, the point being, a programming language is actually a language just like a human language. Their syntax is different and specialized for the problem domain (logic/math) and the \"listener\" (computers), but they're just ways to transport ideas and concepts.\n\nEDIT:\nAnother point about \"optimization for the listener\" is that programming languages try to eliminate ambiguity. The \"make me coffee\" example could, technically, be understood as \"turn me into coffee\". A human can tell what's meant intuitively, a computer can't. Hence in programming languages everything usually has one and one meaning only. Where it doesn't you can run into problems, the \"+\" operator in Javascript being a common example.\n\n1 + 1 -> 2\n'1' + '1' -> '11'\n",
2009-08-25T05:05:58
S.Lott :

See \"Programming Considered as a Human Activity.\" EWD 117.\n http://www.cs.utexas.edu/~EWD/transcriptions/EWD01xx/EWD117.html\n\nAlso See http://www.csee.umbc.edu/331/current/notes/01/01introduction.pdf",
2009-08-25T02:16:39
Mark Stock :

Human expression which:\n\n\ndescribes mathematical functions\nmakes the computer turn switches on and off\n",
2009-08-25T02:22:06
Norman Ramsey :

This question is very broad. My favorite definition is that a programming language is a means of expressing computations\n\n\nPrecisely\nAt a high level\nIn ways we can reason about them\n\n\nBy computation I mean what Turing and Church meant: the Turing machine and the lambda calculus have equivalent expressive power (which is a theorem), and the Church-Turing hypothesis (which is a conjecture) says roughly that there's no more powerful notion of computation out there. In other words, the kinds of computations that can be expressed in any programming languages are at best the kinds that can be expressed using Turing machines or lambda-calculus programs—and some languages will be able to express only a subset of those calculations.\n\nThis definition of computation also encompasses your friendly neighborhood hardware, which is pretty easy to simulate using a Turing machine and even easier to simulate using the lambda calculus. \n\nExpressing computations precisely means the computer can't wiggle out of its obligations: if we have a particular computation in mind, we can use a programming language to force the computer to perform that computation. (Languages with \"implementation defined\" or \"undefined\" constructs make this task more difficult. Programmers using these languages are often willing to settle for—or may be unknowingly settling for—some computation that is only closely related to the computation they had in mind.)\n\nExpressing computation at a high level is what programming langauges are all about. An important reason that there are so many different programming languages out there is that there are so many different high-level ways of thinking about problems. Often, if you have an important new class of problems to solve, you may be best off creating a new programming language. For example, Larry Wall's writing suggests that solving a class of problems called \"systems administration\" was a motivation for him to create Perl.\n\n(Another reason there are so many different programming languages out there is that creating a new language is a lot of fun, and anyone can learn to do it.)\n\nFinally, many programmers want languages that make it easy to reason about programs. For example, today a student of mine implemented a new algorithm that made his program run over six times faster. He had to reason very carefully about the contents of C arrays to make sure that the new algorithm would do the same job the old one did. Luckily C has decent tools for reasoning about programs, for example:\n\n\nA change in a[i] cannot affect the value of a[i-1].\n\n\nMy student also applied a reasoning principle that isn't valid in C:\n\n\nThe sum of of a sequence unsigned integers will be at least as large as any integer in the sequence.\n\n\nThis isn't true in C because the sum might overflow. One reason some programmers prefer languages like Standard ML is that in SML, this reasoning principle is always valid. Of languages in wide use, probably Haskell has the strongest reasoning principles Richard Bird has developed equational reasoning about programs to a high art.\n\n\n\nI will not attempt to address all the tangential details that follow your opening question. But I hope you will get something out of an answer that aims to give a deeper understanding, as you asked, of a fundamental question about programming languages.",
2009-08-25T02:35:58
Anon E. Mous :

One thing a lot of \"IT\" types forget is that there are 2 types of computer programming languages:\n\n\nSoftware programming languages: C, Java, Perl, COBAL, etc.\nHardware programming languages: VHDL, Verilog, System Verilog, etc.\n",
2009-08-25T02:54:34
Eevee :

Interesting.\n\nI'd say the defining feature of a programming language is the ability to make decisions based on input. Effectively, if and goto. Everything else is lots and lots of syntactic sugar. This is the idea that spawned Brainfuck, which is actually remarkably fun to (try to) use.\n\nThere are places where the line blurs; for example, I doubt people would consider XSLT to really be a programming language, but it's Turing-complete. I've even solved a Project Euler problem with it. (Very, very slowly.)\n\nThree main properties of languages come to mind:\n\n\nHow is it run? Is it compiled to bare metal (C), compiled to mostly bare metal with some runtime lookup (C++), run on a JIT virtual machine (Java, .NET), bytecode-interpreted (Perl), or purely interpreted (uhh..)? This doesn't comment much on the language itself, but speaks to how portable the code may be, what sort of speed I might expect (and thus what broad classes of tasks would work well), and sometimes how flexible the language is.\nWhat paradigms does it support? Procedural? Functional? Is the standard library built with classes or functions? Is there reflection? Is there, ideally, support for pretty much whatever I want to do?\nHow can I represent my data? Are there arrays, and are they fixed-size or not? How easy is it to use strings? Are there structs or hashes built in? What's the type system like? Are there objects? Are they class-based or prototype-based? Is everything an object, or are there primitives? Can I inherit from built-in objects?\n\n\nI realize the last one is a very large collection of potential questions, but it's all related in my mind.\n\nI imagine rebuilding the programming language landscape entirely from scratch would work pretty much how it did the first time: iteratively. Start with assembly, the list of direct commands the processor understands, and wrap it with something a bit easier to use. Repeat until you're happy.\n\nYes, you can write a Javascript interpreter in Javascript, or a Python interpreter in Python (see: PyPy), or a Python interpreter in Javascript. Such languages are called self-hosting. Have a look at Perl 6; this has been a goal for its main implementation from the start.\n\nUltimately, everything just has to translate to machine code, not necessarily C. You can write D or Fortran or Haskell or Lisp if you want. C just happens to be an old standard. And if you write a compiler for language Foo that can ultimately spit out machine code, by whatever means, then you can rewrite that compiler in Foo and skip the middleman. Of course, if your language is purely interpreted, this will probably result in a stack overflow...",
2009-08-25T02:20:32
Aggelos Biboudis :

As a friend taught me about computer languages, a language is a world. A world of communication with that machine. It is world for implementing ideas, algorithms, functionality, as Alonzo and Alan described. It is the technical equivalent of the mathematical structures that the aforementioned scientists built. It is a language with epxressions and also limits. However, as Ludwig Wittgenstein said \"The limits of my language mean the limits of my world\", there are always limitations and that's how one chooses it's language that fits better his needs.\n\nIt is a generic answer... some thoughts actually and less an answer. ",
2010-01-17T14:04:58
John Feminella :

Like any language, programming languages are simply a communication tool for expressing and conveying ideas. In this case, we're translating our ideas of how software should work into a structured and methodical form that computers (as well as other humans who know the language, in most cases) can read and understand.\n\n\n What is a useful definition of a computer programming language and what are its basic and necessary components?\n\n\nI would say the defining characteristic of a programming language is as follows: things written in that language are intended to eventually be transformed into something that is executed. Thus, pseudocode, while perhaps having the structure and rigor of a programming language, is not actually a programming language. Likewise, UML can express many powerful ideas in an abstract manner just like a programming language can, but it falls short because people don't generally write UML to be executed.\n\n\n How would you describe to others all the things needed to make the computer expressive and functional in terms of what we expect of personal computers today?\n\n\nEven if the word \"programming language\" wasn't part of the shared vocabulary of the group I was talking to, I think it would be obvious to the others that we'd need a way to communicate with the computer. Just as no one expects a car to drive itself (yet!) without external instructions in the form of interaction with the steering wheel and pedals, no one could expect the hardware to function without being told what to do. As noted above, a programming language is the conduit through which we can make that communication happen.\n\n\n Tangentially related, what is it about computer languages that allow other languages to exist?\n\n\nAll useful programming languages have a property called Turing completeness. If one language in the Turing-complete set can do something, then any of them can; they are said to be computationally equivalent.\n\nHowever, just because they're equally \"powerful\" doesn't mean they're equally nice to work with for humans. This is why many people are willing to sacrifice the unparalleled micromanagement you get from writing assembly code in exchange for the expressiveness and power you get with higher-level languages, like Ruby, Python, or C#.\n\n\n Is it possible to write an interpreter for Javascript in Javascript? Is this a requirement for a complete language? Same for Perl, PHP, etc?\n\n\nSince there is a Javascript interpreter written in C, it follows that it must be possible to write a Javascript interpreter in Javascript, since both are Turing-complete. However, again, note that Turing-completeness says nothing about how hard it is to do something in one language versus another -- only whether it is possible to begin with. Your Javascript-interpreter-inside-Javascript might well be horrendously inefficient, consume absurd amounts of memory, require enormous processing power, and be a hideously ugly hack. But Turing-completeness guarantees it can be done!",
2009-08-25T02:09:30
yy