I was prepared to appreciate this as a curiosity and move on. Instead I'm nearly sold on it, to the point I might see myself using it. Some questions first, which would inform whether I could practically use this:
- Does it have LSP integration?
- Can a linter/formatter catch typescript/javascript which isn't valid Civet (needs minor changes to conform to the additional restrictions). Perhaps even an auto-formatter?
- I see semicolons are optional but not used in examples.. are there ASI pitfalls as with Javascript?
- Is this built from a fork of the Typescript compiler? Or is it compiling Civet -> Typescript -> Javascript (with the ts compiler involved in the second step)?
- Whitespace appears significant in Civet... are the rules of whitespace significance documented in one place anywhere?
- How does it play with existing ecosystem. I'm immediately wondering about runtime schema validation libs like Zod
And for me, the most compelling feature is the potential with switch. Any plans to support switch nesting and algebraic data types a la rust? This would be a killer feature IMO. I guess in the example, there is no type for `x` shown in the demonstration; Is `x` here presumed un-typed? If `x` was typed, would the switch present a compiler error if trying to match a subset of `x` disallowed by its typedef?
edit: Another question: what's the rationale behind disallowing whitespace between unary operands? IMO whitespace is useful for readability here.
- Yes there's decent LSP integration
- There are some in the community working on linters/formatters but it's an ongoing
- We've removed all the ASI pitfalls in the code emit stage
- Whitespace is significant, we try to keep it consistent and intuitive but there are probably some subtleties and edge cases. The interactive docs on https://civet.dev are fairly exhaustive.
- Compiles directly into cjs/esm via esbuild and other build plugins so has 100% integration with existing JS/TS ecosystem
There might be some existing issues about extending switch with more advanced pattern matching / data types. Currently the compiler itself is not very type aware to allow it to run each file independently. A fully type aware compiler opens up lots of opportunities with switch/overloading/etc. but can have challenges depending on what we need to know at compile time.
Rationale for disallowing whitespace between unary operands is to keep `a + -b` and friends more consistent. We may be able to add it in if you have some compelling examples.
Thanks for the feedback and hope you can give it a shot!
If you use LLMs they are surprisingly good at writing Civet considering the paucity of Civet data in the training corpus.
> Compiles directly into cjs/esm via esbuild and other build plugins so has 100% integration with existing JS/TS ecosystem
I'm assuming you must be compiling to TS in order for type issues to be flagged in an IDE by the TS language server? Or are you saying types in Civet are just hints that don't cause errors if violated? Docs say civet can compile to typescript, so I'd expect typescript checks to work.
> A fully type aware compiler opens up lots of opportunities with switch/overloading/etc. but can have challenges depending on what we need to know at compile time.
If the compiler's not type aware, couldn't it still leverage the fact that the typescript language server is? So perhaps Civet could compile an algebraic data type-hinted switch to Typescript code that follows a pattern approximating the DX of Rust's match (there are a few examples of this), and then you wouldn't have to change anything to civet's own type-awareness.
But you'd probably understand how difficult of a project this is better than I would. I'm just excited at the possibilities since Rust enums/matches are my favourite feature of the language in terms of ergonomics.
> Rationale for disallowing whitespace between unary operands is to keep `a + -b` and friends more consistent. We may be able to add it in if you have some compelling examples.
I don't actually have strong feelings about this; I was just curious
Whitespace-sensitivity has not been adopted by another new mainstream programming language, and I’d ask you to consider why that is. It is not simply a matter of personal preference.
Pipes are a great addition. Matching as well, except for the whitespace issue.
Some of these things seem more for code golfing; particularly `&` and the way method m-chaining can work without an explicit reference to the object.
When introducing syntactical sugar or metaprogramming, I’d ask myself, “it’s 2am and I’ve been paged. The issue lives across 10 20-line methods/functions in this language. How quickly and confidently can I identify it?”
Anything too clever is fun when you’re writing on a lovely spring morning and hell when you’re reading under pressure during an incident. I’d optimize for the latter.
Ycombinator is owned by genuinely evil people, but apart from that:
Pattern matching:
I dislike the pattern matching syntax a lot, but I respect that it would probably take way too many hours and take way too much research and such, to improve the syntax to something better.
For one thing, it is something of a symbol soup.
One's mileage may vary, and maybe others are fine with it, and maybe it is fine overall. It builds on syntax from existing works and proposals that has a lot of issues, so many of the issues are inherited from other languages and proposals.
Compatibility with JavaScript is an additional challenge for any language in this space.
Overall:
I suspect that Hacker News users here are sweet-talking you, just in case that is not clear, you probably are aware of it. Also, I suspect that the language does not have any chance. Though I could be mistaken. Neat effort regardless.
- Does it have LSP integration?
- Can a linter/formatter catch typescript/javascript which isn't valid Civet (needs minor changes to conform to the additional restrictions). Perhaps even an auto-formatter?
- I see semicolons are optional but not used in examples.. are there ASI pitfalls as with Javascript?
- Is this built from a fork of the Typescript compiler? Or is it compiling Civet -> Typescript -> Javascript (with the ts compiler involved in the second step)?
- Whitespace appears significant in Civet... are the rules of whitespace significance documented in one place anywhere?
- How does it play with existing ecosystem. I'm immediately wondering about runtime schema validation libs like Zod
And for me, the most compelling feature is the potential with switch. Any plans to support switch nesting and algebraic data types a la rust? This would be a killer feature IMO. I guess in the example, there is no type for `x` shown in the demonstration; Is `x` here presumed un-typed? If `x` was typed, would the switch present a compiler error if trying to match a subset of `x` disallowed by its typedef?
edit: Another question: what's the rationale behind disallowing whitespace between unary operands? IMO whitespace is useful for readability here.