small medium large xlarge

Web Development with ReasonML: Type-Safe, Functional Programming for JavaScript Developers

by

Cover image for Web Development with ReasonML

Web Development with ReasonML

Type-Safe, Functional Programming for JavaScript Developers

by

ReasonML is a new, type-safe, functional language that compiles to efficient, readable JavaScript. ReasonML interoperates with existing JavaScript libraries and works especially well with React, one of the most popular front-end frameworks. Learn how to take advantage of the power of a functional language while keeping the flexibility of the whole JavaScript ecosystem. Move beyond theory and get things done faster and more reliably with ReasonML today.

Customer Reviews

By the time of the book’s conclusion, the reader will not only have become familiar with a new language’s syntax and semantics in isolation, but will have learned how to integrate it with other familiar tools and frameworks like React and webpack to build a modest web application. In other words, the reader will walk away armed not only with a paradigmatic shift in their thinking towards a functional style of programming, but also with the skills required to put it to practical use in their daily work.

- Arno Bastenhof

Solution Architect, Rabobank

An authoritative and comprehensive introduction to ReasonML. I definitely learned a lot and look forward to finding excuses to use it in a new application.

- Peter Hampton

Senior Software Developer, Citi

Finally, a complete path for learning how to be a functional programmer for the web with ReasonML and React. The author incrementally builds upon what you’ve created in the previous chapters. When you complete the book, you’ll have all the elements needed to start to work with ReasonML by yourself.

- Massimiliano Bertinetti

Full-Stack Developer, Softwave Soluzioni e Tecnologie

This is a great book for people who want to learn ReasonML properly.

- Riza Fahmi

Developer Evangelist, Co-Founder, HACKTIV8

Even though ReasonML is still young, there are already plenty of success stories of organizations adopting it to become more productive. J. David Eisenberg has put together the best starter manual on ReasonML. Anyone who wants access to build more robust web applications using ReasonML’s powerful toolchain should definitely give this a read.

- Lewis Chung

CTO, ShopWith

See All Reviews

Choose Your Format(s)

  • $24.95 In Stock
  • Ebooks are DRM free.

  • Ebook delivery options.

About this Title

Skill-meter-4-6
Pages: 208
Published: 2019-04-01
Release: P2.0 (2019-10-23)
ISBN: 978-1-68050-633-4

ReasonML is a new syntax for OCaml, a battle-tested programming language used in industry for over 20 years. Designed to be familiar to JavaScript programmers, ReasonML code compiles to highly readable JavaScript. With ReasonML, you get OCaml’s powerful functional programming features: a strong static type system with an excellent type inference engine, pattern matching, and features for functional programming with immutable variables. ReasonML also allows flexibility with opt-in side effects, mutation, and object-oriented programming. ReasonML hits the sweet spot between the pure theoretical world and the laissez-faire approach of JavaScript.

Start using ReasonML’s powerful type system as you learn the essentials of the language: variables and arithmetic operations. Gain expressive power as you write functions with named parameters and currying. Define your own data types, and integrate all these capabilities into a simple web page. Take advantage of ReasonML’s functional data structures with map and reduce functions. Discover new ways to write algorithms with ReasonML’s recursion support. Interoperate with existing JavaScript libraries with bindings, and write reactive web applications using ReasonML in tandem with React. Reinforce concepts with examples that range from short, tightly focused functions to complete programs, and practice your new skills with exercises in each chapter.

With ReasonML, harness the awesome power of a functional language while retaining the best features of JavaScript to produce concise, fast, type-safe programs.

What You Need

You’ll need to have node.js (version 10.0 or above) and npm (version 5.6 or above). Once you install the bs-platform package and fire up a text editor, you’re ready to go. There are plugins for many popular editors that will make editing easier.

Contents & Extracts

  • Introduction
    • What Makes ReasonML Special?
    • What Should You Know?
    • What’s in This Book?
    • Acknowledgments
    • Online Resources
  • Make Your First ReasonML Project
    • Running Your First Program
    • Using Variables and Doing Arithmetic in ReasonML
    • Working with Types
    • Doing Conditional Computation
    • Working with Strings
    • It’s Your Turn
    • Summing Up
  • Writing Functions
    • Defining Functions
    • Using Labeled Parameters
    • Providing Default Values for Labeled Parameters
    • Shortening Code with refmt
    • Specifying Parameter Types
    • Writing Functions without Parameters or Return Values
    • Currying: Handling One Argument at a Time
    • Currying and Labeled Parameters
    • It’s Your Turn
    • Summing Up
  • Creating Your Own Data Types
    • Renaming a Data Type
    • Creating Variant Data Types excerpt
    • Using Variant Data Types
    • Creating Variant Data Types with Parameters
    • It’s Your Turn
    • Using the option Type
    • Working with option Values
    • Working with Belt.Option
    • Using Pipe First
    • It’s Your Turn
    • Getting Another Perspective
    • Summing Up
  • Interacting with Web Pages
    • Creating an Example Web Page
    • Setting Up the Project
    • Accessing the DOM
    • Building the Web Bundle
    • Completing the Calculation
    • Getting a Value
    • It’s Your Turn
    • Reviewing DOM Functions
    • Summing Up
  • Using Collections
    • Accessing Functions in Other Files
    • Grouping Heterogeneous Data with Tuples
    • Using Lists
    • Manipulating Lists with Belt.List
    • Using map, keep, and reduce with Lists
    • Interlude: Displaying Lists
    • Using Arrays
    • Using map, keep, and reduce with Arrays
    • Putting Arrays to Work
    • It’s Your Turn
    • Summing Up
  • Repeating with Recursion
    • Defining Recursion
    • Analyzing a Recursive Algorithm
    • Writing Recursive Functions
    • Interlude: Measuring Performance
    • Understanding Tail Recursion
    • Practicing More Recursion
    • Using Recursion with Lists
    • It’s Your Turn
    • Summing Up
  • Structuring Data with Records and Modules excerpt
    • Specifying Records
    • Accessing and Updating Records
    • Creating Modules
    • Creating Interface Files for Modules
    • Putting Modules to Work
    • It’s Your Turn
    • Summing Up
  • Connecting to JavaScript
    • Adding Raw JavaScript
    • Binding to Existing Functions
    • Interoperating with Data Types
    • Interoperating with Objects
    • It’s Your Turn
    • Working with JSON
    • Setting Up the Server
    • Implementing the Client
    • It’s Your Turn
    • Summing Up
  • Making Applications with Reason/React
    • Viewing React from 20,000 Meters
    • Starting a ReasonReact Project
    • Investigating the Sample Project
    • Creating a More Complex Stateless Component
    • It’s Your Turn
    • Using Stateful Components
    • Putting Components Together
    • It’s Your Turn
    • Adding Side Effects with Storage
    • It’s Your Turn
    • Summing Up
  • Understanding the ReasonML Ecosystem
    • In the Beginning was OCaml
    • Enter ReasonML
    • A Non-Unified Ecosystem
    • Summing Up
  • Miscellaneous Topics
    • Switching to fun
    • Using open
    • Using Belt.Map.update
    • Dangerous Interop
    • Hiding Type Information

Author

J. David Eisenberg is a programmer and instructor at Evergreen Valley College in San Jose, California. He is co-author of several books on programming technology (SVG, Elixir, Erlang, and ClojureScript). David’s interest in foreign languages has led him to write online tutorials for Korean, Modern Greek, and Russian. He is also a cat person.