Paradigms and theories of
programming. @ Articles ->
Programming Jul 20
2002 - 17:58 EST |
gregory_a_e writes: This article is mainly going to
be for beginning programmers, and those aspiring to go farther in to
the field of programming. This article will essentially be covering
the different paradigms or styles, you could say, of programming.
This text will not be overly technical as it is meant to be a
layman's article, as I said, for those who are new and inexperienced
in the field. I will be covering: Modular programming, functional
programming, logic programming, synchronous programming, assembler
and machine code, linear programming, non-linear programming,
object-oriented programming, sequential programming, and parallel
programming. There are other styles of programming, but I feel I am
either inexperienced to write about them, or I feel they are niche
styles, and not beginner information.
I should note
there is one type of programming I left out, and that would be
Quadratic Programming, a topic I am fairly familiar with but that is
so mathematically involved and outside of every-day programming that
there is no such thing as a layman’s explanation...
First
off, I’d like to begin with one of the popular theories in
programming, about what makes something a language, a protocol, etc.
In my own words I like to say that languages aren’t about
syntax, all syntax is equally easy, and that has nothing to do with
the complexity of the language. Languages are about code “elegance”
as some say, which can be defined as ease of organization, and the
ability to easily debug and upgrade due to a good code layout. The
other key factors in languages are the scope they apply to,
executable files, databases, web-based applications, etc. And
finally, it has to do with the implementation of the language, where
you use it, how you structure it, and how does it mesh with other
languages. The level of involvement of mathematics in a language
becomes a key factor once you get down to ASM, assembler, hex, and
machine code.
If you’re interested in how compilation and
binary, hex, assembler work, then please feel free to skip down to
that section of the article...
Contents. 1.
Modular Programming. 2. Functional Programming. 3. Logic
Programming. 4. Synchronous Programming. 5. Assembler and
Machine Code. 6. Linear Programming. 7. Non-linear
Programming. 8. Object-oriented Programming. 9. Sequential
Programming. 10. Parallel Programming.
1. Modular
Programming.
Modular programming is mostly an
organizational and executable style, for this reason it deals only
in these areas. A module is a sequential series of functions that
are all interconnected, this is key.
As with all
programming, module programming has to do with solving certain
programs that the program executes what it is meant to execute, and
modular programming is a style based on efficiency and grouping. As
I said, in one module you have all the sequential actions that the
given module applies to, and in the end, you have a lot
interconnected strings of processes, which in the end execute what
is meant to be executed by the given process.
In the end you
have what is commonly known as one large module, and it is composed
of many “sub-modules”. The idea is that all work together in a
sequential and properly synchronized order to execute a program in a
series of processes.
Modular programming is a growing field
because it is fairly simple, easy, and many people consider its
inherent code neatness and structure to be “elegant” and for this
reason very efficient for programs that are often upgraded, this
makes writing open-source programs in a module style and in module
languages, a very good idea.
The common motto, one might
say, for modular programming is that problems (processes) become
easier when broken down into smaller problem (sub-modules) and
eventually are all computed, and formulate one large, final, module,
which then executes the processes, and thereby the program.
No doubt this is true, we all know that when problems are
broken down they become easier to work out, and eventually they are
calculated to the very end, and the whole problem can be worked out.
This is the essence of modular programming, to make things
easier to compute, work out, and since different parts of the
program are in different modules, it makes it very easy to go
through and debug or upgrade just what needs to be, without spending
excessive time analyzing.
2. Functional Programming.
Functional programming is one of the oldest styles and
theories of programming, and a popular way of putting it is that
functional programming concentrates on evaluating certain
mathematical problems, or expressions, in context, rather than
certain specific commands, such as those found in builders, etc.
Functional programming is inherently mathematically
involved, and for this reason it was naturally the standard in the
earlier days of computers, though functional programming became less
and less popular with the advent of object-oriented programming, and
then modular programming, though functional programming does have
some upsides over the more popular styles.
One, it is
elegant because it is so mathematically involved, and since the
problems all have set answers, debugging really deals often with
double-checking certain expressions, for this reason, it becomes
easy for people with a good eye and mind for numbers to easily
program using functional programming.
There are a few unique
things about functional programming, one there are absolutely no
background results and functions, commonly known as assignments, so
if the function computes it will always, unerringly, compute
properly. This makes the program look complex, but because of a
strong basis built on mathematics, it is often much more accurate.
The idea of functional programming is that a great deal of
mathematical expressions are calculated, and thereby in proper
context and syntax the output is the action of the executed program,
the whole sum of processes in a program can be called an algorithm,
and for this reason, one can mathematically calculate the result,
and write what the algorithm must look like, comparing the two, and
allowing an easy comparison and debugging.
There is one
specific concept in functional programming known technically as
referential transparency, this basically states that all expressions
have a set result and output, and as I said above there are no
background results such as assignments, for this reason if the
expression is correct, the program will work in an exact fashion.
Functional programming has something about it that makes me
like it, and that’s the fact that it is not anomalous, there is a
set way it should function, and unless the programmer is in error,
this is how it would function, this gives a very pleasant sense of
security that your programs will definitely work.
At the
moment functional programming is set aside mostly for niche tasks,
mathematical programs and simulations, such as those used in
super-computers to test plane velocity and turbulence, or to analyze
mathematical patterns in real-life functions, etc. but many
programmers still use functional programming in their own programs,
because of the integrity of functionality that using it entails.
3. Logic Programming.
Logic programming has
to do with heavily mathematical algorithms that deal with
programming specific output from specific input, such as with
interactive AI programs. However, AI programming is really just a
certain area of expertise with the Logic paradigm.
There are
a few key things about logic programming to remember. One, as I said
that logic programming is almost purely mathematical algorithms,
processes, and computations. Secondly, there has to be some kind of
input that takes precedence over certain variables, and the output
is usually the desired result of the program (such as when
communicating with an IRC bot, or some kind of other AI program).
There are a great deal of downsides to logic programming.
Firstly they are so complex that human error is inevitable, and it
is extremely time-consuming, especially AI programming. Secondly,
due to the sheer complexity of the uses in which logic programming
is used it becomes an extremely difficult and tedious process to
debug. Thirdly, all programs are used only in their pre-determined
medium, for instance, an AI program cannot be used for heavy
mathematical calculations, because it wasn’t programmed for that.
This isn’t inherently a downside, but it requires a great deal of
programming just for each niche process.
Programmers do lots
of micro-management in logic programming, because every step needs
to be typed out and executed without a problem, or the whole process
can be ruined. This makes logic programming also an issue of proper
sequence, organization, and synchronization. This is extremely
important to keep in mind.
Recently the topic of AI
programming has been getting a lot of media attention, with the
advents of robots, and the popularity of chat/IRC bots, the AI
programming branch of logic programming is extremely important and
interesting to many people. And it takes a highly skilled individual
to be a competent AI programmer, although for some low-level bots,
many builders are available, which in my opinion cheapen the
process, making it seems much more simple and easy than it really
is.
AI programming is no doubt probably the most popular and
growing topic within logic programming, though it’s not really a
whole different style, it’s an area of expertise. For this reason I
gave it a deal of coverage. bec
4. Synchronous
Programming.
Synchronous programming is not in reality a
whole style of programming, or a paradigm or certain coverage of
languages. Synchronous programming is an important style of
programming, in which every process and function is timed
specifically so that when everything is computed and processed at
just the right time, the output is the execution of the program.
In some languages there is certain syntax that allows for
timing, but usually the way that such programming is organized, is
through the way it is compiled, and a new technology allows for
dynamic recompilation, as some call it, which allows an executable
file to compile over again every time it is used, and this allows
for a certain series of executions, as well as a level of
efficiency, since the compilation rarely takes overmuch time.
Synchronous programming is used in any number of programs,
but has been gaining increasing popularity in database programs,
allowing monitoring of current stats, each time updating the
database automatically, this of course requires a supplementary
program, but it is an ingenious idea that has been gaining speed and
popularity in the industry of database coding.
Synchronous
programming introduced an idea into the industry that I personally
believe is going to change the face of computers today, and that is
dynamic recompilation, and such specific mechanisms. The idea is
ingenious, and extremely practical upon close consideration.
Synchronous programming has little value in small, niche
programs, and for this reason, I don’t expect it to ever become an
important concept in that medium. This is unfortunate, but it is not
something that I expect will ever change.
5. Assembler
and Machine code.
Machine code is binary, and is the
lowest level language and code in computer and electronic systems.
It is the basis of all computing, and all high-level programs are
eventually compiled down to this fundamental code, and that is how
computing is done in the end. Machine code consists of strings of 0s
and 1s. The process goes like this, any source code is compiled, and
then dwindled down into binary so that the computer can understand
the instructions of the program, and execute it.
Machine
code is stored as executable files, not as source code, and for this
reason there is no way to de-compile programs once they are
compiled.
Computers, namely processors, are designed or
programmed to read only a certain amount of machine code at a time,
i.e. a certain amount in a specified order translates into the
proper set of instructions.
When debugging or analyzing
machine code, one “dumps” it. This is essentially printing out all
the binary machine code to see where the problem lies. However,
since machine code is so numerous, it is printed out in hexadecimal.
Hexadecimal is defined as a 16-number system, i.e. it is a system
containing 16 sequential numbers before adding another position, or
place, as some say, to the next number. Hexadecimal uses number 0-9
and A-F.
An assembler is a program that takes certain
written instructions in low-level assembly language, and converts
them so that the computer can use them in the proper way.
All PCs these days come with highly specific instructions in
assembly language, that when processed are used to perform basic
functions by the computer. Assembly language is used mostly for
programs designed to interface directly with the computer, due to
the fact that it’s a low-level language, and as closed as any
language gets to binary/machine code. Assembly programs are not
compiled, but “assembled”, makes sense really... this just means
that the instructions are sent to the computer in an understandable
fashion so that the functions are properly executed.
6.
Linear Programming.
Linear programming is a theory of
optimization and organization, where the program tries to find the
optimal way to execute a certain value, and the specific variables
in the right way, to execute the program. Linear programming is
about efficiency and structure, and applies on to certain types of
programs, it’s really a theory or concept of handling and executing
data.
Linear programming was considered purely theoretical
for a long time, but recently putting certain code organization and
designing compilers in the proper fashion has yielded much more
efficient results when executing and compiling the given code.
Linear programming is made up of a few steps. Firstly,
writing an algorithm specifically for finding optimal values and
properly formulate variable. Secondly, designing a structure for the
code, and also writing a compiler that will execute as written.
Linear programming is an obscure field, highly involved from
a mathematical standpoint, and I believe a powerful grounding in
linear programming allows any programmer to take advantage of the
given concepts to take advantage of the search for efficiency that
linear programming really is.
Linear programming is,
unfortunately, not something that is considered by all that many
programmers in some of the larger corporations today, and even some
niche or open-source programmers, which is an unfortunate thing.
However, I do believe that understanding linear programming concepts
is important, extremely efficient in the long run, and I believe
that it is a concept that will surely rise in popularity among
serious programmers.
7. Non-linear Programming.
Non-linear programming is a concept that I am very familiar
with, though I only partially support.
The concept of
non-linear programming is pretty simple, the idea is to minimize the
amount of code and syntax, as well as mathematical functions.
Although it may sound like it, non-linear programming is not
just for minimalists, and there are certain things about non-linear
programming that make it a nice concept both in theory and practice,
and others that do not.
Non-linear programming concepts do
their best to prove that creating mathematical formulations in
shorthand, or in as fewest steps as possible, allows for more
elegant code organization. From first glance, and in practice, this
is true, and it makes upgrading and de-bugging a much more painless
process. On the other had, by doing so, you sacrifice efficiency for
elegance. This isn’t something that I would like to subscribe to,
personally.
Allow me to elaborate on this. In non-linear
programming you make the code shorter, and the mathematical
functions shorter as well, by wrapping them up into one large, but
in the end, more compact problem, and by using shortened syntax and
minimal variables. Yes the code is more elegant, and sometimes it
makes it easier to debug, depending on the nature of the program.
However, this demands a specialized compiler, and also sacrifices
efficiency, because large mathematical calculations take tolls on
minimalist processors and hardware, which is partially what
non-linear software is meant for, and also, in the end usability in
analyzing the source is sometimes lacking as well.
In the
end, I’d choose the ideals and concepts covered in linear
programming over the ideals covered in non-linear programming by
far. But others have contrasting opinions.
8.
Object-oriented Programming.
Object-oriented programming
is the current standard for almost all commercial and a great deal
of niche and open-source projects today.
Object-oriented
programming was an evolution that started years ago, and quickly
gained speed and popularity and, in my opinion, for pretty good, and
worthy, reason.
Object-oriented programming, is quite
simply, as the name plainly states, organized around whole objects
in code rather than any mathematical functions, etc. What this
basically means is that in object-oriented the code is designed to
manipulate and/or use the objects that are written in the code, and
deals often in GUIs, and other graphical objects.
Objects
are much like modules, they are like packages with a lot of coded
information. C++ is probably the most common object-oriented
language, and all object-oriented languages deal with the code and
data, known commonly as functions and structures in C++.
They way they work together is simple, a function can be
assigned and operates within any number of structures,
consequentially any structure can be assigned to any number of
functions. It seems, and from a layman’s point, is very simple.
Relaying the actions from functions to data is done though
digital messages. The function sends a message of functional data to
the object during the compilation of the given program, and thus the
object behaves the way the message from the function says it should.
Information capsulation is the term used to describe the way
that the data from a function is sent only to the proper objects,
and then relayed between the objects, but is not accessible to the
other objects that it is not meant for.
Objects fit under
certain definitions, also known commonly as classes. These classes
define what kind of an object an object is, and what it likely does.
The executed code from a function is called a method, this
is what is being processed/executed by the object.
Arguments
are a concept in object-oriented programming, as well as other
mediums. Arguments are data sent during messages from functions to
objects, that give specifics as to how the data should be executed.
One thing that makes object-oriented programming so
efficient is the ability to flag an object as reusable, i.e. you
don’t have to write the code, the object will just be re-executed
when and where specified.
Object-oriented is an ever-growing
medium in programming today, and is relevant to any programming,
commercial, open-source, niche projects, in effect anything and just
about everything. And having a strong grounding in object-oriented
programming is what many consider the key to a lucrative and
successful career in programming today and probably for a very long
time to come.
9. Sequential Programming.
Sequential programming is an idea in organization and
compilation. It is a concept for code and data organization.
Sequential programming is designed for simple programs, on
single-processor machines, that are designed to execute one program
at a time.
Sequential programming is a fairly old concept in
programming, and the name describes it without further necessity.
The program is written and organized, the variables and syntax
specifically placed and organized so that every function in the
program is organized down the list, the way it is written in its
text form.
Sequential programming is quite a simple concept,
and for small projects, it’s a perfectly fine way to write programs.
It is easy enough to debug when writing small, simple, programs, and
for beginning programmers it is how most coding is done.
Sequential programming has huge downsides for large,
complex, programs. Firstly, it would take a long time to execute
every single function down the list, both during compilation, and
execution. In large programs, it also becomes extremely tedious to
just go down a list and have to look through every single function
to find the right function to debug.
Basically, sequential
programming is fine for beginning programmers, and for small
programs, but is ill-suited for large projects, and serious
programmers.
10. Parallel Programming.
Parallel programming is, at least fairly, a new concept.
The idea behind Parallel programming is to write and organize
the code so that certain parts are organized by certain processors
(i.e. you need at least two processors to take full advantage of
parallel programming).
Essentially, the program is coded and
designed in such a fashion that the program compilation and
execution is divided into different processors, allowing only a
small deal of the resources of each processor to be taken up. This
is especially useful in visual programming.
A common way to
split up the program when using two processors is by making on
processor do all the calculations, and the other doing all the
memory managing and accessing, as well as managing any I/O issues
that might arise.
The way this works is that data is
organized in specific ways and sections, and syntax is used to
assign certain sections to a given processor.
Parallel
programming is not extremely popular today outside of graphic
designers and visual programmers, but it’s always something to
consider if you have a beefy computer, and a processor to spare.
Well, that’s it. I hope you found the article enjoyable, and
informative.
- gregory_a_e
(c) New Order /
http://neworder.box.sk/ | |