Programming Crystal
Create High-Performance, Safe, Concurrent Apps
by: Ivo Balbaert and Simon St. Laurent
Published | 2019-02-01 |
---|---|
Internal code | crystal |
Print status | In Print |
Pages | 244 |
User level | Intermediate |
Keywords | Ruby, DSL, fast, concurrent, Python, PHP, Go, Rust, Swift, Java, C# |
Related titles | Programming Ruby 1.9 and 2.0, Dave Thomas, 2013, ISBN: 978-1-93778-549-9 |
ISBN | 9781680502862 |
Other ISBN |
Channel epub: 9781680506648 Channel PDF: 9781680506655 Kindle: 9781680506624 Safari: 9781680506631 Kindle: 9781680506624 |
BISACs | COM051410 COMPUTERS / Programming Languages / RubyCOM051010 COMPUTERS / Programming Languages / GeneralCOM051010 COMPUTERS / Programming Languages / General |
Highlight
Crystal is for Ruby programmers who want more performance or for developers who enjoy working in a high-level scripting environment. Crystal combines native execution speed and concurrency with Ruby-like syntax, so you will feel right at home. This book, the first available on Crystal, shows you how to write applications that have the beauty and elegance of a modern language, combined with the power of types and modern concurrency tooling. Now you can write beautiful code that runs faster, scales better, and is a breeze to deploy.
Description
Crystal is elegant to read and easy to program like Ruby, allowing full object-oriented development. Its compiler is powerful enough to nearly always infer the type of your variables. So you get the benefits of a statically typed language: more robust code, safety, and execution speed while still reaching high productivity in development. Null pointer exceptions as in JavaScript, Java, or C#, are a thing of the past: Crystal annihilates them, just like Rust.
Explore the building blocks and design of the language and how you can use the Crystal tool-chain to build and manage powerful applications. Harness the power of the macro system, as well as how to work with fibers and channels, making concurrency as easy as possible. Learn how to use the Kemal web framework and access databases and how to tap the potential of existing Crystal libraries. Find the spot that Crystal fills in today’s software world with real-world examples.
With Crystal, you can combine the best of both worlds: the high-level coding of dynamic languages and the safety and blazing performance of a natively compiled language.
Contents and Extracts
- <b>Preface</b>
- Getting Started
- Diving into Crystal
- A Programming Language for Humans and Computers
- Slick As Ruby, But Way Faster
- Almost As Fast As C
- Speeding Up the Web
- Talking to Databases
- More Safety Through Types
- No to the Billion-Dollar Mistake
- Batteries Included
- Putting Crystal to Good Use
- A Company’s Story Crystallized: Red Panthers
- Wrapping Up
- Crystal Foundations <b>excerpt</b>
- Using Basic Variables and Types
- Variable Operations
- Structuring Data with Container Types
- Controlling the Flow
- Using Methods
- Organizing Code in Classes and Modules
- Executing Code Concurrently Through Fibers
- A Company’s Story Crystallized: Dev Demand
- Wrapping Up
- Diving into Crystal
- Building Blocks
- Typing Variables and Controlling the Flow
- Converting Data Between Types
- Getting Input
- Putting It Together—Converting Currencies 1
- Exception Handling for Faulty Input
- Chaining Methods
- Getting Input from Command-Line Arguments
- Using String Methods
- Using Symbols as Identifiers
- Using Enums
- Using Regular Expressions
- Putting It Together—Converting Currencies 2
- Beyond Hashes and Arrays: More Composite Types
- Nilable Types
- Controlling the Flow and Types
- A Company’s Story Crystallized: Linkfeed
- Wrapping Up
- Organizing Code in Methods and Procs
- Passing Arguments
- Returning Values
- Working with Yield, Procs, and Blocks
- Overloading and Multiple Dispatch
- Using a Shorter Syntax for Exception Handling
- Using Recursive Methods
- A Company’s Story Crystallized: Duo Design
- Wrapping Up
- Using Classes and Structs <b>excerpt</b>
- Converting a Ruby Class to Crystal
- Structuring a Class
- Applying Inheritance
- Controlling Visibility
- Working with Structs
- Viewing the Type Hierarchy
- Some Nice Tricks
- A Company’s Story Crystallized: LI-COR Biosciences
- Wrapping Up
- Working with Modules
- Combining Files with Require
- Using Modules as Namespaces
- Letting Modules Extend Themselves
- Mixing in Modules
- How the Compiler Finds Methods
- Applying Built-In Modules
- A Company’s Story Crystallized: Diploid
- Wrapping Up
- Managing Projects
- Creating a Shard
- Formatting Code
- Documenting a Project
- Writing Tests with Spec
- Using External Libraries
- Benchmarking Your Code
- Deploying a Crystal App
- A Company’s Story Crystallized: Diploid—Part 2
- Wrapping Up
- Typing Variables and Controlling the Flow
- Advanced Crystal
- Advanced Features
- DRY Your Code with Macros
- Low-Level Programming and C Bindings
- Creating Concurrent Code
- Accessing Databases
- A Company’s Story Crystallized: NeuraLegion
- Wrapping Up
- Using Web Frameworks and Shards
- Build Web Applications with the Kemal and Amber Frameworks
- A Brief Tour of the Shard Ecosystem
- A Company’s Story Crystallized: Kemal in Production
- Wrapping Up and Afterword
- Advanced Features
- Appendices
- Setting Up a Crystal Environment
- Working with Crystal Online
- Installing Crystal on Your Machine
- Compiling Code
- Using Editors and IDEs
- Working with Crystal Playground
- Using Crystal Documentation
- Wrapping Up
- Porting Ruby Code to Crystal
- Ruby Extensions in Crystal
- Your Turn Answers
- Chapter 2: Crystal Foundations
- Chapter 3: Typing Variables and Controlling the Flow
- Chapter 4: Organizing Code in Methods and Procs
- Chapter 5: Using Classes and Structs
- Chapter 6: Working with Modules
- Chapter 7: Managing Projects
- Chapter 8: Advanced Features
- Chapter 9: Web Frameworks and the Shard Ecosystem
- Appendix 1: Setting Up a Crystal Environment
- Setting Up a Crystal Environment