diff options
Diffstat (limited to 'index.md')
-rw-r--r-- | index.md | 82 |
1 files changed, 72 insertions, 10 deletions
@@ -1,25 +1,87 @@ Crowbar: the good parts of C, with a little bit extra.
-This is entirely a work-in-progress, and should not be relied upon to be stable in any way.
+**This is entirely a work-in-progress, and should not be relied upon to be stable in any way.**
-# Context
+Crowbar is a language that compiles directly to [C99](https://en.wikipedia.org/wiki/C99), and aims to remove as many [footgun](https://en.wiktionary.org/wiki/footgun)s and as much needless complexity from C as possible while still being familiar to C developers.
-- [Rust is not a good C replacement](https://drewdevault.com/2019/03/25/Rust-is-not-a-good-C-replacement.html)
+Ideally, a typical C codebase should be straightforward to rewrite in Crowbar, and any atypical C constructions not supported by Crowbar can be left as C.
-# cactus's Blog Posts
+In principle, there's no reason it would be impossible to write a compiler directly for Crowbar, skipping the C step entirely, but that would take a lot of work.
-- [Crowbar: Defining a good C replacement](https://www.boringcactus.com/2020/09/28/crowbar-1-defining-a-c-replacement.html)
-- [Crowbar: Simplifying C's type names](https://www.boringcactus.com/2020/10/13/crowbar-2-simplifying-c-type-names.html)
+# Removals
+
+Some of the footguns and complexity in C come from misfeatures that can simply not be used.
+
+## Footguns
+
+### Almost Always The Wrong Thing
+
+- `goto`
+- Octal literals
+- Hexadecimal float literals
+- Wide characters
+- Digraphs
+- Prefix `++` and `--`
+- Chaining mixed left and right shifts (e.g. `x << 3 >> 2`)
+- Chaining relational/equality operators (e.g. `3 < x == 2`)
+- Mixed chains of bitwise or logical operators (e.g. `2 & x && 4 ^ y`)
+- The comma operator `,`
+- Strings that aren't UTF-8
+
+### Explicit Beats Implicit
+
+- `typedef`
+- Octal escape sequences
+- Using an assignment operator (`=`, `+=`, etc) or (postfix) `++` and `--` as components in a larger expression
+- The conditional operator `?:`
+- Preprocessor macros (but constants are fine)
+
+## Needless Complexity
+
+### Let The Compiler Decide
+
+- `inline`
+- `register`
+
+### Who Even Cares
+
+- `restrict`
+- `volatile`
+- `_Imaginary`
-# Additions to C
+# Adjustments
-For Crowbar to be "the good parts of C, with a little bit extra", we must first decide what C lacks.
-C has several widely known footguns, some of which are misfeatures that can simply be not supported, but some of which are insecure-by-default.
-As such, new features must be added to engage the safeties on these proverbial footguns.
+Some C features are footguns by default, so Crowbar ensures that they are only used correctly.
+
+- Unions blah blah blah
+
+C's syntax isn't perfect, but it's usually pretty good.
+However, sometimes it just sucks, and in those cases Crowbar makes changes.
+
+- Complicated types (function pointers, pointer-to-`const` vs `const`-pointer, etc)
+- `_Bool` is just `bool`, `_Complex` is just `complex` (why drag the preprocessor into it?)
+- Adding a `_` to numeric literals as a separator
+
+# Additions
+
+## Anti-Footguns
- C is generous with memory in ways that are unreliable by default.
Crowbar adds [memory safety guarantees](safety.md) to make correctness the default behavior.
+## Trivial Room For Improvement
+
+- Binary literals, prefixed with `0b`/`0B`
+
+# Context
+
+- [Rust is not a good C replacement](https://drewdevault.com/2019/03/25/Rust-is-not-a-good-C-replacement.html)
+
+# cactus's Blog Posts
+
+- [Crowbar: Defining a good C replacement](https://www.boringcactus.com/2020/09/28/crowbar-1-defining-a-c-replacement.html)
+- [Crowbar: Simplifying C's type names](https://www.boringcactus.com/2020/10/13/crowbar-2-simplifying-c-type-names.html)
+
# Syntax
[Read the Syntax chapter of the spec.](syntax.md)
|