66

When you have behavior that you don't want to have to recompile the program in order to change. This is exactly why so many games use Lua as a scripting/modding language.


44

I did this, and I recommend that you don't. What I did was write all the business logic in Lua, and stored that Lua script in a database. When my application started up it would load and execute the script. That way I could update the business logic of my application without distributing a new binary. I invariably found that I always needed to update the ...


38

Let me attempt to find a dividing line between these three types of language. Of course, there will be numerous exceptions and counterexamples, since this is just my opinion. A markup language is used to control the presentation of data, like "represent these user names as a bullet list or as a table". A scripting language is used to mediate between ...


37

I really love Lua, but it does have some real limitations, and as others have mentioned they derive mostly from Lua's origins as a configuration file language and then later as an embedded scripting language. Because of the goal to keep Lua small, there exists only a very tiny standard library, that has only bare bones functionality. This has lead to an ...


37

Piping dynamic data into an interpreter of your implementation language is usually a bad idea, since it escalates the potential for data corruption into a potential for malicious application takeover. In other words, you are going out of your way to create a code injection vulnerability. Your problem can be better solved by a rules engine or maybe a domain-...


28

This technique can be used to implement core logic that is easily portable between different language environments. For example, I have a calculator simulator where all the internal calculator logic is implemented in 100% JavaScript. The user interface code is of course different for each platform: Web browser (JavaScript) iOS (Objective-C) Windows (C++ ...


23

Developer scripts go also into version control, because usually these scripts also depend on the items in version control, e.g. file paths. If these scripts are versioned they also should work for all developers to avoid that every developer writes his own set of scripts, which becomes a maintenance hell. In addition bugfixes or improvements of these ...


22

Yes! You definitely can do that with Node.js or Rhino. For example the coffeescript compiler is nothing but a node.js script. I will admit that it is not generally my first choice for desktop scripting but I see no reason why it would not work quite well for a number of tasks.


18

Very broadly there are two situations where you would apply this pattern: This is used internally to leverage some quality of the embedded language. This is used to provide external programmability. Internally Typically the embedded language is interpreted which allows changes to be made and tested quickly without a re-compile. The embedded language may ...


15

It's not just a bad idea. It's pretty much impossible. How do you implement IO with a language whose IO facilities depend entirely on the host operating system? How could you implement primitive scheduling without any useful interrupt primitives? How could you write a device driver in a language which cannot address a particular byte? Edit:-- Just to ...


15

bash has been around since 1989, and its syntax is largely compatible with that of the much older Bourne shell, which was released in 1977. Huge swaths of core functionality in many operating systems (most Linux distros, OS X, and indeed most POSIX-compatible operating systems), and many real-world systems (make systems, automated tests, initialization ...


15

What does it mean for a programming language to be interpreted and how are they compiled before execution in the terminal? Compilers and interpreters are very similar things, right up until the last step. For a compiler, the last step is to generate code in the output language and save it. For an interpreter, it's not trying to save your code; it's trying ...


14

A $ sign in variable name is a special case of "Sigil", Back in the early days of BASIC (1964 or so) $ was used to denote string variable names. My guess is, since it makes it easier on compilers to separate variable names from the rest of the grammar using some symbol, and since it was common to BASIC, its usage has progressed. However, this is not the ...


14

It depends on what code is in the include file. Did you try putting the #include for <stdio.h> inside main()? Depending on how the standard library is implemented on your system it may not even compile. Header files can contain not only function declarations, but function definitions. Standard C doesn't support nested functions. If your header file ...


14

A "script" is a set of instructions that do something the user could do themselves, only faster and with less possibility for error. Sure, I could delete all my old log files manually, but the script Bob wrote does it just fine. An "application" or "program", in contrast, is an automated or interactive bit of software that can be thought of as doing ...


13

It's particularly strong at handling a ton of file I/O and I would expect it to handle a ton of network communication well too. It seems particularly popular for socket-driven apps. The important thing to keep in mind is that if your needs aren't met by existing libraries (there are many) you may need to dive into some C which can be bound to JS commands. ...


12

Consts are good for just giving descriptive variable names to avoid the magic number problems, but they cause a similarly annoying problem of not being able to identify the value actually being used when the const is defined away from it's use. My suggestion, in all languages: define consts in as close a scope as possible to their actual usage. If used in ...


11

The fact that you are dealing with a custom scripting language is irrelevant. You are migrating a set of scripts from one language to another. There are 2 basic strategies: 1) Take an on large effort to convert all the scripts upfront (as a project) 2) As you need to make changes to particular scripts, rewrite them in the new language. After some time, ...


11

Windows has a component called Windows Scripting Host that allows you to automate administration and even mimic user activity to some extent through JScript. Update in 2017: OSX now allows you to automate desktop tasks with Javascript. What was previously possible through AppleScript is now possible through Javascript.


11

Your friends are being lazy and IMO unprofessional - the world will soon pass them by. Daily builds were meant for projects following Agile practices. It does not work for the waterfall model. I don't have a definitive reference handy, but daily builds were common at least as far back in the 90's, so they pre-date Agile, and the *Unified Process ...


11

A scripting language in a game engine is there to expose your game engine in a higher-level, interpreted manner. Take a game like Skyrim, for example. You'll notice that there are many quests and interactions that occur, and some of these have fairly impressive logic built into them, such as a guard reacting to you getting to close to an item during some ...


11

C programmers, on the whole, will expect the #include directives to be at the beginning of the file. Why risk confusing them without any significant benefit?


11

A markup language is a language which is used to represent structured data. For example, HTML enables to specify that some part of the document is a title or some other part is a list, by comparison to a flat text document. Markup languages are not considered as programming languages¹. The difference with programming languages is not always obvious. For ...


10

Your understanding is correct, if you're from the past. You're pretty much describe as it looked like in 1990s. Yes, many languages can be executed directly by a web server plugin. Right on for PHP, mod_php for Apache is still the most popular way to host it. However, high-traffic sites use more modern approach, using web server only as a proxy for FastCGI (...


10

In addition to @simon's answer. Not all in the software engineering is about programming, designing or modelling. There's a myriad of tasks we perform continuously during the working day. You already mentioned one -building the project outside the IDE- but there are many more. Experienced / proactive developers tend to automate these tasks. Some, even ...


9

Because Perl has a much more powerful feature set than PHP. Perl is a more general programming language, and has much more text operations capabilities than PHP, and probably than any other language out there, and better OS interaction. Perl has a powerful Regex native support, which means string manipulations at its best. Also, Perl has been around for ...


9

You could use an application to draw mockups instead of writing code. Like Balsamiq Mockups or equivalent. Using Mockups feels like drawing, but because it’s digital, you can tweak and rearrange easily. Teams can come up with a design and iterate over it in real-time in the course of a meeting.


9

Real world examples would include:- Most web browsers which will support embedded JavaScript. Microsoft Office Suite -- Excel Word etc. all support embedded VBA scripts. Many network routers include script APIs, in a variety of languages TCL, Perl , Lua. Many embedded devices are implemented using a very small set of core C functions which are glued ...


9

Basically the difference is just one of degree. A script tends to be a lot more formally defined, with a well-defined scripting language behind it, while a macro is usually something more simple and ad-hoc. Macros are frequently "recorded" by telling a program "watch everything that I do" and then performing the action, whereas scripts are generally ...


9

If you've ever used RESTful APIs, you've come across at least one where you have to make multiple API calls to get all the data you want. It just kinda comes with the territory. The benefits of a granular API are that you can get exactly what you need and nothing you don't. The cost is multiple calls, which can get bad if you need to build a deep object ...


Only top voted, non community-wiki answers of a minimum length are eligible