When to use a scripting language? [closed]
Asked Answered
G

10

28

When should one use a scripting language over a more verbose, compiled language like C++. C# or Java?

And to make the question a little more interesting, let's answer the questions like this:

You should use a scripting language when... BLANK...

When you need A use scripting language X.

When you need B use scripting language Y.

When you need C use scripting language Z.

Grandfatherly answered 29/12, 2008 at 10:1 Comment(5)
I don't get why people vote down questions like this, so I will upvote. Since a few days there seems to be a huge inflation in downvotes on everything - annoying.Tysontyumen
Well to be honest, I don't think of this as a substantial question, really. Never mind that it's open ended, subjective, and is about summed up with Paul's answer anyway.Kellogg
What question doesn't have some element of subjectiveness to it?Grandfatherly
Programming languages are tools. Tools have things that they are best-designed to do. That is purely objective.Grandfatherly
@AlexBaranosky: The word "best" is your culprit...Glenglencoe
U
34

You should use a scripting language when speed of development is more important than speed of execution.

Ulent answered 29/12, 2008 at 10:7 Comment(5)
How about the second part to the question dealing with specifics, like A, B, or C?Grandfatherly
I assumed your request was for answers to be in one of the suggested formats, not all of them. I thought I answered the question as asked: "When should one use a scripting language?" (Not "Which scripting language should you use.")Ulent
This about sums up any real reason I can think of to need a scripting language.Kellogg
This answer is way off base. 1) The reason to choose a scripting language is when you want a weakly typed programming language over a strongly typed programming language. 2) Language has nothing to do with performance, the compiler does. Scripting languages can be compiled into run time instructions.Citrate
Depends on the developer. For me it's faster to develop in my preferred compiled language as i don't dabble enough in scripting languages to be super fast... however updates are more difficult as they will take a full re-compile rather than just changing code.Infatuation
S
22

Adding a scripting language as a component of a larger compiled system is a common pattern: the compiled part of the system is optimized for speed of execution, but is harder to modify (because it must be compiled and reloaded), whereas the scripted part of the system is optimized for flexibility, it will run slower but can be quickly and easily modified by anyone with a text editor.

You would use this pattern if you wanted to make part of the functionality of your application easy to customize.

Sulphurbottom answered 29/12, 2008 at 11:3 Comment(0)
A
10

This is slightly a religious issue. I use a scripting language for ad-hoc tasks, such as:

  • looking for a specific item in a ten-thousand lines log
  • Generating a performance graph
  • Data reduction - transforming a text file into a needed format
  • Getting a specific subset of data from a database and packing it as a text file

All of these can also be done in a compiled language, but for me it is faster and easier to do them in a scripting language (I use ruby, but PERL and python are just fine).

Advocaat answered 29/12, 2008 at 10:25 Comment(0)
A
6

I tend to use scripting languages for rapid prototyping, experimentation, and data wrangling. For example if I have a bunch of text files that I need to preprocess and build into database fixtures as a one-off operation, I'll generally script that.

However, these days the line between 'scripting' and 'compiled' is becoming blurred, with languages like groovy and ruby. For the task mentioned above, I'll use ruby but then I'll also use it to build a production webapp with rails. I'll write desktop apps in java but groovy allows me to blend in scripts as well. Even when writing in C/C++, I found a useful pattern was to embed a domain specific scripting language (e.g. tcl, though I don't much like that language).

The actual choice of language is I think a religious choice, though there are some tradeoffs that are obvious (readability for example - perl is useful, but is too easy to write cryptic scripts in. In some ways it is a 'write-only' language :-). In the past I've used bash+awk+sed, some perl, ruby, etc etc...For one off tasks it is mainly a matter of what you and the rest of your team are comfortable with. I make a conscious choice to use ruby these days even if I'd be somewhat quicker doing the same thing in bash/awk/sed, but this is just to improve my ruby skills by doing as many tasks as possible in it.

Administrator answered 29/12, 2008 at 11:18 Comment(0)
R
6

Here's my hierarchy:

Try it using grep.

If you can't do it with grep, use sed.

If sed isn't powerful enough, use awk.

If awk isn't powerful enough (or starts to get really nasty-looking), use C, C++, or the other full-blown general purpose programming language of your choice.

Notice there's no "scripting language" in between awk and C. That's on purpose.

Renal answered 29/12, 2008 at 14:28 Comment(0)
T
2

I find scripting languages very useful obviously when there's a specific task that fits the language's strengths (i.e. string processing with perl, web development with ruby, or whatnot). In particular with web-development scripting languages have the property of showing you results of code changes faster.

There are some cases where you mix compiled languages with scripted languages - like in some games. It's useful to do that when you can express a smaller amount of behaviour faster, cleaner and simpler in a scripting language than in the compiled language. C++, for example, is a very expressive language - but it's development costs are higher than, say, lua.

Tysontyumen answered 29/12, 2008 at 10:35 Comment(0)
P
2

I dont't think theres a general rule when to use a scripting language. Scripting languages are easy so develop but sometimes they are hard do maintenance, especially when the script should run under different platforms (operating systems).

The pros of scripting languages are of course:

  • You can give the user (or customer) the possibility to change something in your script by himself.
  • It's easy to develop - the most scripting languages are not type-safe, what it makes much easier to develop in small applications, of course
  • But - it's platform independent...

Contras are:

  • It' s open source - everyone can see your code and can use your knowlege in their own competiting products...
  • It's slowly at runtime...
Pediform answered 29/12, 2008 at 14:22 Comment(0)
U
0

I use scripting language to mine data and feed them to database as a cron job. It's easier because i can easily set them using windows scheduler or crontab in unix and i find it easier to write due to some key features like regex in perl.

Plus the millions of modules that are made availble to me from CPAN...

Unfailing answered 29/12, 2008 at 10:50 Comment(0)
I
0

Use a scripting language when interactive operation is important, e.g. a command-line shell, or you are exporting functionality for other users to use in simple operations. (They shouldn't have to compile; scripting is enough)

Iny answered 29/12, 2008 at 14:10 Comment(0)
C
0

Scripting language if you plan on either writing once, or keeping it simple. A strongly typed language is much better once your project becomes larger. Think about it, how much time is spent on a large project with inititial development versus integration and maintenance. Would you rather have to maintain a large set of scripts or a strongly typed language enforcing that your types behave?

Citrate answered 15/4, 2010 at 21:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.