دانلود کتاب Nim in Action
by Dominik Picheta
|
عنوان فارسی: نین در عمل |
دانلود کتاب
جزییات کتاب
Nim is a multi-paradigm language that offers powerful customization options with the ability to compile to everything from C to JavaScript. In Nim in Action you'll learn how Nim compares to other languages in style and performance, master its structure and syntax, and discover unique features.
Nim is a multi-paradigm programming language that offers powerful customization options with the ability to compile to everything from C to JavaScript. It can be used in any project and illustrates that you don't have to sacrifice performance for expressiveness! About the Book
Nim in Action is your guide to application development in Nim. You'll learn how Nim compares to other languages in style and performance, master its structure and syntax, and discover unique features. By carefully walking through a Twitter clone and other real-world examples, you'll see just how Nim can be used every day while also learning how to tackle concurrency, package finished applications, and interface with other languages. With the best practices and rich examples in this book, you'll be able to start using Nim today.
What's Inside Language features and implementationNimble package managerAsynchronous I/OInterfacing with C and JavaScriptMetaprogramming
About the Reader For developers comfortable with mainstream languages like Java, Python, C++ or C#. About the Author Dominik Picheta is one of the principal developers of Nim and author of the Nimble package manager.
contents
Part 1 The basics of Nim
1 Why Nim?
1.1 What is Nim?
1.1.1 Use cases
1.1.2 Core features
1.1.3 How does Nim work?
1.2 Nim’s benefits and shortcomings
1.2.1 Benefits
1.2.2 Areas where Nim still needs to improve
1.3 Summary
2 Getting started
2.1 Nim syntax
2.1.1 Keywords
2.1.2 Indentation
2.1.3 Comments
2.2 Nim basics
2.2.1 Basic types
2.2.2 Defining variables and other storage
2.2.3 Procedure definitions
2.3 Collection types
2.3.1 Arrays
2.3.2 Sequences
2.3.3 Sets
2.4 Control flow
2.5 Exception handling
2.6 User-defined types
2.6.1 Objects
2.6.2 Tuples
2.6.3 Enums
2.7 Summary
Part 2 Nim in practice
3 Writing a chat application
3.1 The architecture of a chat application
3.1.1 What will the finished application look like?
3.2 Starting the project
3.3 Retrieving input in the client component
3.3.1 Retrieving command-line parameters supplied by the user
3.3.2 Reading data from the standard input stream
3.3.3 Using spawn to avoid blocking input/output
3.4 Implementing the protocol
3.4.1 Modules
3.4.2 Parsing JSON
3.4.3 Generating JSON
3.5 Transferring data using sockets
3.5.1 What is a socket?
3.5.2 Asynchronous input/output
3.5.3 Transferring data asynchronously
3.6 Summary
4 A tour through the standard library
4.1 A closer look at modules
4.1.1 Namespacing
4.2 Overview of the standard library
4.2.1 Pure modules
4.2.2 Impure modules
4.2.3 Wrappers
4.2.4 Online documentation
4.3 The core modules
4.4 Data structures and algorithms
4.4.1 The tables module
4.4.2 The sets module
4.4.3 The algorithms
4.4.4 Other modules
4.5 Interfacing with the operating system
4.5.1 Working with the filesystem
4.5.2 Executing an external process
4.5.3 Other operating system services
4.6 Understanding and manipulating data
4.6.1 Parsing command-line arguments
4.7 Networking and the internet
4.8 Summary
5 Package management
5.1 The Nim package manager
5.2 Installing Nimble
5.3 The nimble command-line tool
5.4 What is a Nimble package?
5.5 Installing Nimble packages
5.5.1 Using the install command
5.5.2 How does the install command work?
5.6 Creating a Nimble package
5.6.1 Choosing a name
5.6.2 A Nimble package’s directory layout
5.6.3 Writing the .nimble file and sorting out dependencies
5.7 Publishing Nimble packages
5.8 Developing a Nimble package
5.8.1 Giving version numbers meaning
5.8.2 Storing different versions of a single package
5.9 Summary
6 Parallelism
6.1 Concurrency vs. parallelism
6.2 Using threads in Nim
6.2.1 The threads module and GC safety
6.2.2 Using thread pools
6.2.3 Exceptions in threads
6.3 Parsing data
6.3.1 Understanding the Wikipedia page-counts format
6.3.2 Parsing the Wikipedia page-counts format
6.3.3 Processing each line of a file efficiently
6.4 Parallelizing a parser
6.4.1 Measuring the execution time of sequential_counts
6.4.2 Parallelizing sequential_counts
6.4.3 Type definitions and the parse procedure
6.4.4 The parseChunk procedure
6.4.5 The parallel readPageCounts procedure
6.4.6 The execution time of parallel_counts
6.5 Dealing with race conditions
6.5.1 Using guards and locks to prevent race conditions
6.5.2 Using channels so threads can send and receive messages
6.6 Summary
7 Building a Twitter clone
7.1 Architecture of a web application
7.1.1 Routing in microframeworks
7.1.2 The architecture of Tweeter
7.2 Starting the project
7.3 Storing data in a database
7.3.1 Setting up the types
7.3.2 Setting up the database
7.3.3 Storing and retrieving data
7.3.4 Testing the database
7.4 Developing the web application’s view
7.4.1 Developing the user view
7.4.2 Developing the general view
7.5 Developing the controller
7.5.1 Implementing the /login route
7.5.2 Extending the / route
7.5.3 Implementing the /createMessage route
7.5.4 Implementing the user route
7.5.5 Adding the Follow button
7.5.6 Implementing the /follow route
7.6 Deploying the web application
7.6.1 Configuring Jester
7.6.2 Setting up a reverse proxy
7.7 Summary
Part 3 Advanced concepts
8 Interfacing with other languages
8.1 Nim’s foreign function interface
8.1.1 Static vs. dynamic linking
8.1.2 Wrapping C procedures
8.1.3 Type compatibility
8.1.4 Wrapping C types
8.2 Wrapping an external C library
8.2.1 Downloading the library
8.2.2 Creating a wrapper for the SDL library
8.2.3 Dynamic linking
8.2.4 Wrapping the types
8.2.5 Wrapping the procedures
8.2.6 Using the SDL wrapper
8.3 The JavaScript backend
8.3.1 Wrapping the canvas element
8.3.2 Using the Canvas wrapper
8.4 Summary
9 Metaprogramming
9.1 Generics
9.1.1 Generic procedures
9.1.2 Generics in type definitions
9.1.3 Constraining generics
9.1.4 Concepts
9.2 Templates
9.2.1 Passing a code block to a template
9.2.2 Parameter substitution in templates
9.2.3 Template hygiene
9.3 Macros
9.3.1 Compile-time function execution
9.3.2 Abstract syntax trees
9.3.3 Macro definition
9.3.4 Arguments in macros
9.4 Creating a configuration DSL
9.4.1 Starting the configurator project
9.4.2 Generating the object type
9.4.3 Generating the constructor procedure
9.4.4 Generating the load procedure
9.4.5 Testing the configurator
9.5 Summary
Appendix A Getting help
A.1 Real-time communication
A.2 Forum
A.3 Other communication methods
Appendix B Installing Nim
B.1 Installing the Nim compiler
B.1.1 Getting up-to-date installation info
B.1.2 Building from source
B.2 Installing the Aporia IDE
B.3 Testing your new development environment
B.4 Troubleshooting
B.4.1 Nim command not found
B.4.2 Nim and C compiler disagree on target architecture
B.4.3 Could not load DLL