Chapter 9. Scripting

In previous chapters, you saw how F# can be effective across programming paradigms. But F# is not only well suited for different styles of programming, it can also be effective for writing different types of programs as well. F# is not only useful for client applications but it can also be effective as a scripting language too.

Scripting is the general term used to describe programs that don’t have a UI and are focused on solving a particular task. In most scripting languages, the script consists entirely of code—as opposed to an executable program—that is then interpreted by a runtime engine.

Programming in this mode typically sacrifices execution speed for the convenience of being able to easily modify and deploy the program. Rather than creating a complex solution designed to work everywhere, you can simply move a script from machine to machine and modify it as necessary.

While F# may be best suited for client application programming, using it in a scripting context has one major advantage: you already know it. Rather than learning a separate language for your scripts, employing F# for your scripting needs lets you reuse your existing code and knowledge about F# programming. Also, F# code is never interpreted; it is always compiled first. So F# can be comparatively faster than pure scripting languages.

If you have a simple problem and don’t need a complicated interface, consider scripting the solution. In this chapter, you will learn about some constructs available ...

Get Programming F# now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.