aboutsummaryrefslogtreecommitdiff
path: root/index.md
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2020-10-19 17:53:49 -0600
committerMelody Horn <melody@boringcactus.com>2020-10-19 17:53:49 -0600
commit8e9394ad85bc921e0658fd2758f5717540101627 (patch)
tree055159d50fdfa1b811fa26abcce4694c3a176654 /index.md
parent239fdd456e72a08465e8ef51bff12d5dbfac43dc (diff)
downloadspec-8e9394ad85bc921e0658fd2758f5717540101627.tar.gz
spec-8e9394ad85bc921e0658fd2758f5717540101627.zip
explicitly target C
Diffstat (limited to 'index.md')
-rw-r--r--index.md82
1 files changed, 72 insertions, 10 deletions
diff --git a/index.md b/index.md
index 72e2572..55d1646 100644
--- a/index.md
+++ b/index.md
@@ -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)