Lesson 3. The REPL—changing how we develop
In this lesson, you’ll look at an alternative way to develop applications than what you’re probably used to in terms of both tools and process. You’ll first learn the pros and cons of techniques such as debugging and unit tests, and then see how to shorten your development cycle through alternatives that F# provides.
Think for a moment about your typical development process in terms of the way you write and then validate your code. After you’ve written some C# or VB .NET, how do you confirm that it works as you intended? What tools or process do you follow? I’m willing to bet it follows one of the following three patterns: application-based development, console test rigs, or automated unit tests.
You develop code for a while, thinking about the problem at hand. When you think it’s ready, you run the application and run the section of the application to stress the code you just wrote. If it behaves as expected, you move on to solving the next problem.
The problem with this approach, depicted in figure 3.1, is that it’s not particularly efficient. The section of code you’ve just written may take time to navigate through the application, or may not be feasible—for example, code that gets called only under circumstances out of your control, such as only when the network connection drops.