ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
View Poll Results: Do you do any programming or scripting?
I have no idea what you're talking about.
1
1.47%
I get dizzy just looking at code.
3
4.41%
I've played around with both, but I don't do either regularly.
10
14.71%
I can write great scripts, but I leave programming to others.
10
14.71%
I do programming, but I'm not too good at scripting.
11
16.18%
I am a whiz at scripting, programming, and French toast.
11
16.18%
I refuse to recognize a difference between the two.
If you make an error in semantics in a compiled language, it may well execute for a while before it crashes and burns.
Similarly, some errors in syntax will prevent a script from even starting.
You have to admit, our four sentences can't completely define the difference between scripts and programs. Not much can be completely defined, while still being concise, in four sentences.
Kevin Barry
You have to admit, our four sentences can't completely define the difference between scripts and programs. Not much can be completely defined, while still being concise, in four sentences.
Kevin Barry
Your sentence implicitly claims there is a difference between "scripts" and "programs". I don't think there is. Someone could write a C interpreter... would C then become a scripting language?
Similarly, someone could write a compiler for (say) bash code. Would that change the nature of that code from a "script" to a "program"?
Further, your post to which I first replied was just plain wrong, even if for some reason you feel the need to separate some kinds of programming languages from other kinds.
A program is a sequence of instructions which tells the computer how to do something you want done. Whether the program is translated into machine language, some intermediate form (such as java .class files) or executed concurrently with translation such as bash programs(!)), it is still conceptually doing the same thing.
The poll would have made more sense to ask whether
- you don't program at all
- you prefer programming in languages like C/Java/C++, or
- you prefer programming in languages like shell, perl, ...
The poll would have made more sense to ask whether
- you don't program at all
- you prefer programming in languages like C/Java/C++, or
- you prefer programming in languages like shell, perl, ...
From the frontend (the ``source-code to parse-tree'' compiler), you can get at the backend (the PP interpreter) via a BEGIN subroutine. Likewise, to go the other way (get back to the compiler from the interpreter), you can use an eval("string") or a s/foo/bar/ee notation. By the way, despite appearances to the contrary, it turns out that an eval { BLOCK } and s/foo/bar/e are not actually hooks back to the compiler; it already handled them long ago and far away.)
Does that make sense? Think of every call to
$ perl somescript
as being
$ perl-compiler < somescript | perl-interpreter
At no point did our perl compiler as described above engage in the actual generation of C code, assembly language, nor machine code take place.
So there is no actual literal compilation taking place, but it is sorta semi-compiled. I will give you that Perl is one of those languages that really blurs the distinction, but the fact of the matter is that Perl scripts do not live in a platform specific bytecode or machine language (like C or Java).
<edit> I think this proves the point though - the difference between programming and scripting is very small, if it exists at all. </edit>
Last edited by MBybee; 12-16-2009 at 09:51 AM.
Reason: clarification
Believe or not, I'm learning linux assembly programming lately. I like to focus on the detail that only the assembly language can lead you to. I choose to use it in linux environment because i like the command line mode to compile and link. I found kate is a good editor in linux to write up codes.
Scripting is another thing i am planning to do in the feature.
I refuse to recognize a difference between the two.
I'll even go further. Switching on a lamp: not programming. Using a timer so the light goes on/off when I want it: programming. Another example: a humble cousin of mine claimed that all this programming was too difficult for him, all he did and could was write macros in Excel. I told him he was wrong, I told him that he was very much 'programming'.
It's about human - machine interaction and the way it happens, I guess the decisive factor is doing something not directly interactive. Anyway, food for philosophers. Any difference between 'programming' and 'scripting' is irrelevant IMO.
Tht's why I introduced the example of using punch-cards early in the thread. scripting is very much a form of programming, just as punching buttons in a certain order or throwing manual switches on an ancient computer or setting up the gears on a Babbit machine.
For those stuck on the difference between compiled and non-compiled languages, what about using the tcc compiler to run C programs as scripts? A 'program' is simply a logical sequence of instructions with a given purpose. It makes no difference what the interface between the person and the machine is, nor how it works. Programming -in it's very conception- is an abstraction.
Both do something useful - one is a shell script that I run from cron to verify a service is up, the other is a tiny C program I use to check if I'm on a 32 bit or 64 bit host (prior to doing a big automated install task).
Either could be done in a number of different languages.
How about this example?
Code:
HAI 1.2
BTW CAN HAS STDIO?
I HAS A VAR
VAR R 0
IM IN YR LOOP UPPIN YR VAR TIL BOTH SAEM VAR AN 10
VISIBLE SUM OF VAR AN 1
IM OUTTA YR LOOP
KTHXBYE
I have an interpreter that turns this into an executable file, and one that runs it like a script.
Last edited by MBybee; 12-18-2009 at 09:34 AM.
Reason: can't type before coffee /facepalm
Seems to me that scripting is a subset of programming, rather a whole different thing.
I agree too for the most part -- if even not precisely a "subset", it definitely isn't a "whole different thing":
The purpose of "programming" is to give a sequence of commands to a machine, for execution. Scripting fits this description, as does the punch-card example. Whether or not there's an interpreter (a shell, a card-reader..) between the commands and the machine, is not relevant.
That strongly reminds me of the code samples on Wikipedia's entry for COBOL.
In my opinion scripting is writing code that affects the behavior of another program, instead of running on the CPU.
Even in something like Python, it's the interpreter that does the actual work, so the python script affects the python interpreter's behavior.
Yes - LOLCode reminded me a bit of COBOL too
It's fun to write in.
That's an interesting way of looking at it - so you would say something like C, which has registers, direct ASM calls, and the ability to compile to machine code - programming? Or not, because it merely compiles to a lower set that is then itself interpreted again?
This description would of course exclude nearly anything that used the MFC, Java, Perl, COBOL, and, really, almost everything but Microcode? Thanks, but no thanks - I stopped using stuff like that when I left behind my Motorola 6800
I'll stick to the more portable higher level languages that are (mostly) cross platform - ANSI C, Perl, LOLCode, etc
Last edited by MBybee; 12-18-2009 at 10:49 AM.
Reason: quote was broken somehow
Seems to me that scripting is a subset of programming, rather a whole different thing.
The focus of the result determines the tool being used. For (a stupid) example, there's a reason the Linux kernel isn't written in PHP and your average website isn't written in C. The tools that we could conversationally call 'scripting languages' were designed with some specific goals in mind, like not having to worry about detailed memory management or being able to produce a working GUI with just a few lines. It's what makes something like Python a "high-level programming language", intended to collaborate with C code, not to replace the language C. Therefore calling one a "subset" of another doesn't do justice to either one. C might be able to allow you to do everything you can do with Python and more, each language has areas of use where using the other would be a waste of resources. Not subset or superset but partly overlapping.
What I mean is, as an alternative (there are other ways), you can look at it in terms of "generations" of computer languages. Increased capable hardware, development in ideas about software, increased demand for productivity all led to newer languages incorporating new abstractions but being built with ideas from previously developed languages.
Quote:
Originally Posted by MTK358
In my opinion scripting is writing code that affects the behavior of another program,
That makes some sense to me although I'm not sure if I want to look at it that way. Say I write a plug-in for another program, that would affect the program but I'd give it functionality that it didn't have before. Same with writing a wrapper around an existing program. Merely piping the output of one program into another would already create a new program with behavior the original programs separately didn't have. I don't mind to call all that 'scripting' but I fail to see the relevance in distinguishing it from 'programming'.
Quote:
Originally Posted by MTK358
Even in something like Python, it's the interpreter that does the actual work, so the python script affects the python interpreter's behavior.
I argue that the necessary run-time is not relevant because there'd be no functional difference between a Pong written in Python or one written in assembly (assuming that speed of execution or development wouldn't be a functional requirement here).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.