Its compactness and simplicity combined with its support for functions as first-class values inspired this CoffeeScript book, which was inspired by "The Little Lisper," "Little Scheme," and "Little MLer:"
https://raganwald.com/assets/books/coffeescript-ristretto.pd...
I really do like the piping though. I dearly wish that was in js/ts already.
The word "style" in "cofeescript style syntax" is doing heavy lifting there. Coffeescript's syntax is a terrifying sea of ambiguity. Perhaps one could tweak its syntax to make it less ambiguous, but I doubt that would preserve its intended lightweight charm.
To put it another way, coffeescript syntax is just ML syntax without modern tooling and without typing.
> Disallow no parens on single argument arrow function
With the large number of changes introduced, everyone bound to disagree with some of them, or how some changes are implemented. That's the downside of doing too much.
I disagree with a few things. I won't belabor it, but for one example:
> Implicit returns, even for multi-statement functions (avoid by specifying a void return type, adding a trailing ; or explicit return
This prevents me from doing command-f "return". And now the semicolon effects the function behavior? That's something easy to miss. It also makes functions with early-returns harder to skim. `return` is colored purple by my editor's syntax highlighting.
``` if (something) { getProperties() } ```
Does my function return if getProperties() returns? This seems hard to debug.
Implicit returns beat implicit voids, just my opinion. TS also squiggles at you if you have a mismatched return type. Funny how two wrongs can make a right (Coffee + Types).
The problem is that I feel that most sugar is for humans, and that simpler syntax rules esp. that are clear are better fine for AI.
Like the direction though.
- 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.
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.
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
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.
You can still add braces in Civet, they're just optional but proper indentation is enforced (best of both worlds?)
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.
Whitespace-sensitivity is a horrible decision. There’s a reason no language adopted it and Coffeescript didn’t take off—including when typescript was developed after the fact and could have.
The pipes are a welcome addition, though overall here’s a bit too much cleverness that makes it better for code golf than readability and maintainability.
Some of these simple examples would cause too much thinking during an incident.
Seriously, if any part of your product is software, you should know what’s in there, and if you don’t, it’s not your product anymore.
I love the direction of this, feels like pushing TS further towards Haskell on some ways. Great choices of proposals to include. But I was sad to see an Agents.md and Claude as a contributor.
I sometimes come across code pushed by people who don't write or read code. It is exactly what the description tells you it is. In my team, the "devs" who performed these stunts ended up being fired for incompetence after they introduced outages and failed to fix bugs.
I can't wait for this phase to end.
People are going to find that they're able to push the AI much further if they actually read the code in the early stages, and compress into reusable components instead of just shipping slop.
The problem isn't something that will get solved with models getting smarter, but with the human in the loop, making sure the prompt was communicated well, understanding the tradeoffs the code made, and what that actually means. If you don't anchor those concepts as you go, the AI will not be able to communicate things to you because it will not have a reference for what you as a person understand.
If you don't have human in the loop, then the cost of the software is basically inference, and can be paid by whatever source has money (governments, big corpos, whatever collectives), and the discussion is moot.
I'm just saying JS isn't the best of foundations for types to begin with so building an abstraction layer on top of types, on top of JS, is wild.
it was too inefficient (and overly complicated) to duplicate application state that the DOM needed between both sources and required so much glue code to reach the services I needed that it totally killed my interest in using wasm for web apps. LLMs don't even really change the picture for me; it doesn't have the performance characteristics I was seeking, so just getting it to work with tons of code in spite of the poor interfaces would have subverted half my reasoning to use it
The reason we have React, TS, and a crazy ecosystem is because client apps have become very large and complex. Adding more layers isn't addressing the complexity at its core: the Web layer was designed for blogs and websites like HN, not for interactive or complex client apps.
I guess it's more a rant about the Web, not so much this TS extension.
Just to nitpick, there is a whole list of reasons under “Changes from ES6” that invalidate the claim that this is a superset of typescript. In order to be a superset, you have to accept any valid typescript.