Top Related Projects
A new type of shell
Maintainable configuration files
Better configuration for less
A new markup-based typesetting system that is powerful and easy to learn.
A strongly-typed language that compiles to JavaScript
Quick Overview
Nickel is a configuration language designed for building and deploying cloud infrastructure. It aims to provide a more expressive and type-safe alternative to JSON and YAML, while maintaining compatibility with existing systems. Nickel combines features of functional programming with a straightforward syntax to create a powerful tool for configuration management.
Pros
- Strong type system that helps catch errors early and improves code reliability
- Expressive language features, including functions, contracts, and imports
- Compatibility with JSON, allowing easy integration with existing systems
- Built-in support for merging configurations and handling overrides
Cons
- Relatively new project, which may lead to potential instability or lack of community resources
- Steeper learning curve compared to simpler formats like JSON or YAML
- Limited ecosystem and tooling support compared to more established configuration languages
- May require additional setup and integration steps in existing workflows
Code Examples
- Basic configuration with type annotations:
let config = {
server: {
host: "example.com",
port: 8080,
max_connections: 100,
},
debug: true,
version: "1.0.0",
}
# Type annotation for the config
let Config = {
server: {
host: Str,
port: Num,
max_connections: Num,
},
debug: Bool,
version: Str,
}
std.contract.from_type Config config
- Using functions to generate configuration:
let make_server_config = fun {host, port} => {
host = host,
port = port,
max_connections = if port > 1000 then 1000 else 100,
}
let config = {
server = make_server_config { host = "example.com", port = 8080 },
debug = true,
}
- Merging configurations with overrides:
let base_config = {
log_level = "info",
timeout = 30,
retries = 3,
}
let prod_overrides = {
log_level = "warn",
timeout = 60,
}
let prod_config = std.merge_recursive base_config prod_overrides
Getting Started
To get started with Nickel:
- Install Nickel following the instructions at https://github.com/nickel-lang/nickel#installation
- Create a new file with a
.ncl
extension (e.g.,config.ncl
) - Write your configuration using Nickel syntax
- Use the Nickel CLI to evaluate your configuration:
nickel eval config.ncl
For more advanced usage and integration with your projects, refer to the Nickel documentation and examples in the repository.
Competitor Comparisons
A new type of shell
Pros of Nushell
- More mature project with a larger community and ecosystem
- Designed as a full-featured shell replacement with built-in data manipulation capabilities
- Supports cross-platform usage on Windows, macOS, and Linux
Cons of Nushell
- Steeper learning curve due to its unique approach to shell interactions
- May be overkill for users who only need simple configuration management
Code Comparison
Nushell example:
ls | where size > 1kb | sort-by modified
Nickel example:
let config = {
port = 8080,
debug = std.env.DEBUG | default false
}
Key Differences
- Nushell is a complete shell environment, while Nickel is a configuration language
- Nushell focuses on data processing and pipeline operations, Nickel on type-safe configuration
- Nushell has a more extensive feature set, Nickel aims for simplicity in configuration management
Use Cases
- Nushell: Ideal for users looking to replace their traditional shell with a more powerful, data-oriented alternative
- Nickel: Best suited for projects requiring a robust, type-safe configuration language with functional programming features
Community and Development
- Nushell has a larger user base and more frequent updates
- Nickel is newer and still evolving, with a focus on configuration use cases
Maintainable configuration files
Pros of dhall-lang
- More mature and established project with a larger community
- Stronger focus on type safety and correctness
- Better documentation and learning resources
Cons of dhall-lang
- Less flexible and expressive compared to Nickel's contract system
- Steeper learning curve for users new to functional programming concepts
- Limited integration with existing ecosystems and tools
Code Comparison
Dhall example:
let Config = { port : Natural, debug : Bool }
let default = { port = 8080, debug = False }
in default // { debug = True }
Nickel example:
let Config = {
port : Num,
debug : Bool,
} in
{
port = 8080,
debug = false,
} | { debug = true }
Both languages aim to provide configuration management solutions, but Nickel offers a more flexible approach with its contract system and better integration with existing ecosystems. Dhall, on the other hand, provides stronger guarantees for type safety and correctness, making it suitable for projects where these aspects are critical. The choice between the two depends on the specific requirements of the project and the team's familiarity with functional programming concepts.
Better configuration for less
Pros of Nickel
- More active development with frequent updates and contributions
- Broader feature set, including advanced type checking and contract programming
- Extensive documentation and examples for easier onboarding
Cons of Nickel
- Steeper learning curve due to more complex language features
- Potentially slower execution time compared to the simpler Nickel.rs implementation
- Less focus on web-specific functionality
Code Comparison
Nickel:
let config = {
port = 8080,
debug = true,
database = {
url = "postgres://localhost/mydb"
}
}
Nickel.rs:
let mut server = Nickel::new();
server.get("/", middleware! { |_, response|
"Hello world!"
});
server.listen("127.0.0.1:6767").unwrap();
The Nickel code showcases its configuration-oriented syntax, while Nickel.rs demonstrates its web framework capabilities. Nickel focuses on declarative configuration, whereas Nickel.rs is more about building web applications in Rust.
A new markup-based typesetting system that is powerful and easy to learn.
Pros of Typst
- More focused on document typesetting and layout, making it potentially more user-friendly for specific document creation tasks
- Actively developed with frequent updates and a growing community
- Includes a web-based playground for easy experimentation and sharing
Cons of Typst
- Less flexible as a general-purpose configuration language compared to Nickel
- Limited to document creation and typesetting, whereas Nickel can be used for various configuration tasks
- Steeper learning curve for users not familiar with typesetting systems
Code Comparison
Typst example:
#set page(width: 10cm, height: 5cm)
#circle(radius: 2cm, fill: blue)
Nickel example:
let config = {
page = { width = "10cm", height = "5cm" },
shape = { type = "circle", radius = "2cm", fill = "blue" }
}
While both examples define similar structures, Typst's syntax is more specialized for document layout, whereas Nickel's syntax is more general-purpose and resembles a configuration format.
A strongly-typed language that compiles to JavaScript
Pros of PureScript
- More mature and established ecosystem with a larger community
- Extensive documentation and learning resources available
- Strong type system with advanced features like higher-kinded types
Cons of PureScript
- Steeper learning curve, especially for developers new to functional programming
- Slower compilation times compared to Nickel
- Less focus on configuration and data modeling use cases
Code Comparison
PureScript:
module Main where
import Prelude
import Effect (Effect)
import Effect.Console (log)
main :: Effect Unit
main = log "Hello, World!"
Nickel:
let main = fun () {
std.string.concat ["Hello, ", "World!"] | std.debug.dump
};
main ()
Summary
PureScript is a more established functional programming language with a strong type system and extensive ecosystem. It's well-suited for building complex applications but may have a steeper learning curve. Nickel, on the other hand, is a newer language focused on configuration and data modeling, offering a simpler syntax and faster compilation times. The choice between the two depends on the specific project requirements and the developer's familiarity with functional programming concepts.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
nickel.rs
nickel.rs is a simple and lightweight foundation for web applications written in Rust. Its API is inspired by the popular express framework for JavaScript.
Hello world
#[macro_use] extern crate nickel;
use nickel::{Nickel, HttpRouter};
fn main() {
let mut server = Nickel::new();
server.get("**", middleware!("Hello World"));
server.listen("127.0.0.1:6767");
}
Dependencies
You'll need to create a Cargo.toml that looks like this;
[package]
name = "my-nickel-app"
version = "0.0.1"
authors = ["yourname"]
[dependencies.nickel]
version = "*"
# If you are using the 'nightly' rust channel you can uncomment
# the line below to activate unstable features
# features = ["unstable"]
# Some examples require the `rustc_serialize` crate, which will
# require uncommenting the lines below
# [dependencies]
# rustc-serialize = "*"
You can then compile this using Cargo build and run it using Cargo run. After it's running you should visit http://localhost:6767 to see your hello world!
More examples
More examples can be found in the examples directory and the full documentation can be found here.
Contributing
nickel.rs is a community effort. We welcome new contributors with open arms. Please read the contributing guide here first.
If you're looking for inspiration, there's list of open issues right here on github.
If you need a helping hand reach out to @jolhoeft, @cburgdorf, @Ryman or @SimonPersson.
And hey, did you know you can also contribute by just starring the project here on github :)
Development Plan
Version | Branch | Description |
---|---|---|
0.11.x | maint-0.11.x | hyper-0.10.x (synchronous version), bug fixes only |
0.12.x | master | hyper-0.14.x (asynchronous version) |
0.13.x | new features, possibly will be 1.0 instead |
Top Related Projects
A new type of shell
Maintainable configuration files
Better configuration for less
A new markup-based typesetting system that is powerful and easy to learn.
A strongly-typed language that compiles to JavaScript
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot