Modern Systems Programming with Scala Native
Write Lean, High-Performance Code without the JVM
by: Richard Whaling
Published | 2020-01-22 |
---|---|
Internal code | rwscala |
Print status | In Print |
Pages | 260 |
User level | Intermediate |
Keywords | scala, functional programming, java, systems programming, native systems, JVM |
Related titles | Functional Programming in Scala |
ISBN | 9781680506228 |
Other ISBN |
Channel epub: 9781680507492 Channel PDF: 9781680507508 Kindle: 9781680507478 Safari: 9781680507485 Kindle: 9781680507478 |
BISACs | COM051280 COMPUTERS / Programming Languages / JavaCOM051210 COMPUTERS / Programming / Object OrientedCOM051210 COMPUTERS / Programming / Object Oriented |
Highlight
Access the power of bare-metal systems programming with Scala Native, an ahead-of-time Scala compiler. Without the baggage of legacy frameworks and virtual machines, Scala Native lets you re-imagine how your programs interact with your operating system. Compile Scala code down to native machine instructions; seamlessly invoke operating system APIs for low-level networking and IO; control pointers, arrays, and other memory management techniques for extreme performance; and enjoy instant start-up times. Skip the JVM and improve your code performance by getting close to the metal.
Description
Developers generally build systems on top of the work of those who came before, accumulating layer upon layer of abstraction. Scala Native provides a rare opportunity to remove layers. Without the JVM, Scala Native uses POSIX and ANSI C APIs to build concise, expressive programs that run unusually close to bare metal. Scala Native compiles Scala code down to native machine instructions instead of JVM bytecode. It starts up fast, without the sluggish warm-up phase that’s common for just-in-time compilers. Scala Native programs can seamlessly invoke operating system APIs for low-level networking and IO. And Scala Native lets you control pointers, arrays, and other memory layout types for extreme performance.
Write practical, bare-metal code with Scala Native, step by step. Understand the foundations of systems programming, including pointers, arrays, strings, and memory management. Use the UNIX socket API to write network client and server programs without the sort of frameworks higher-level languages rely on. Put all the pieces together to design and implement a modern, asynchronous microservice-style HTTP framework from scratch.
Take advantage of Scala Native’s clean, modern syntax to write lean, high-performance code without the JVM.
Contents and Extracts
- <b>Preface</b>
- Foundations of Systems Programming
- The Basics: Input and Output
- Working with Output
- Working with Input
- Case Study: Google NGrams
- What’s Next
- Arrays, Structs, and the Heap
- <b>The Stack and the Heap</b>
- Structs, Arrays, and Sorting
- Sorting an Array
- Aggregation at Scale
- What’s Next
- Writing a Simple HTTP Client
- Defining Terms
- Working with TCP
- Making a TCP Connection
- Testing Network Code with Netcat
- Introducing HTTP
- Implementing HTTP
- Testing Our Code
- What’s Next
- Managing Processes: A Deconstructed Shell
- Running a Program
- Introducing exec
- What Went Wrong?
- <b>Introducing Concurrency with fork() and wait</b>
- Supervising Multiple Processes
- Working with Pipes
- What’s Next
- Writing a Server the Old-Fashioned Way
- Understanding How a Server Works
- Building Our Server
- Creating a Minimum Viable Server
- Handling HTTP
- Performance Testing with Gatling
- What’s Next
- The Basics: Input and Output
- Modern Systems Programming
- Doing I/O Right, with Event Loops
- Blocking and Polling
- Introducing libuv
- Working with Asynchronous TCP Sockets
- Building an Asynchronous HTTP Server
- What’s Next
- Functions and Futures: Patterns for Distributed Services
- Designing an Asynchronous API
- Introducing Futures
- Implementing Futures
- Implementing an ExecutionContext
- Futures and Promises
- Introducing libcurl
- Asynchronous curl
- What’s Next
- Streaming with Pipes and Files
- Looking at Streams, Files, and Descriptors
- Streaming Pipe Input in libuv
- Streaming File Input in libuv
- Streaming File Output in libuv
- Stream Processors
- What’s Next
- Durability: An Embedded Key-Value Database with LMDB
- Introducing Embedded Storage
- Defining LMDB Concepts
- Working with the LMDB API
- Serialization and Deserialization with JSON
- Putting LMDB on the Web
- What’s Next
- Services: Encapsulation and Abstraction for Modern Designs
- Services and Distributed Systems
- Parsing, Revisited
- Moving from Server to Service
- Implementing an Idiomatic Service DSL
- Integrations and Ecosystems
- The Way Forward
- Doing I/O Right, with Event Loops