Remix.run Logo
▲ Civet: TypeScript superset that favors more types and less typing(github.com)
49 points by nateb2022 a day ago | 36 comments
▲catlifeonmars 7 hours ago | parent | next [-]

I’ve always liked coffeescript style syntax.

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.

▲red_hare 5 hours ago | parent | next [-]

I couldn't believe it when I saw the "Comparison to CoffeeScript section". What a fun little language from the simpler times of front-end dev. I'm just happy to see someone carrying on the legacy.

▲a4isms 3 hours ago | parent [-]

A very fun language!

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...

▲winrid 6 hours ago | parent | prev | next [-]

You might like Nim, then, which compiles to JS and has a nice type system, and is more concise so less output tokens by LLMs.

▲Yahivin 4 hours ago | parent | prev | next [-]

There are ES compat compile flags that resolve syntax ambiguities in favor of TS.

▲agumonkey 4 hours ago | parent | prev | next [-]

coffeescript was neat, conciseness helped writing functional code rapidly. that said i often ended up with cryptic code

▲phil-martin 6 hours ago | parent | prev | next [-]

Maybe it should be called a super-duper-set

I really do like the piping though. I dearly wish that was in js/ts already.

▲kibwen 2 hours ago | parent | prev [-]

> I’ve always liked coffeescript style syntax.

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.

▲skrebbel 3 hours ago | parent | prev | next [-]

This page does a much better job presenting the language: https://civet.dev/

▲bluegatty 3 hours ago | parent | prev | next [-]

Love some of this.

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.

▲Yahivin 4 hours ago | parent | prev | next [-]

As the creator of this language I'm always looking for feedback, even/especially from HN :)

▲pcthrowaway 3 hours ago | parent | next [-]

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.

▲Yahivin 2 hours ago | parent [-]

- 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.

▲tyre 2 hours ago | parent | prev | next [-]

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.

▲Yahivin 2 hours ago | parent [-]

Fortunately there are different languages that optimize for different things. I put the things that I like in this language.

You can still add braces in Civet, they're just optional but proper indentation is enforced (best of both worlds?)

▲biasedstuff an hour ago | parent | prev [-]

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.

▲postepowanieadm 3 hours ago | parent | prev | next [-]

I have a coffee script / raku vibes.

▲bryzaguy 4 hours ago | parent | prev | next [-]

the examples in the documentation are soooo good. feels like burying the lead to not include them in the repo README. the Overview is too dense to effectively parse where the examples are really clear.

▲tyre 2 hours ago | parent | prev | next [-]

A multi-line list comprehension in a whitespace-sensitive language is someone who took all the wrong lessons from Python.

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.

▲montroser 4 hours ago | parent | prev | next [-]

The terseness reminds me a little bit of Perl, for better or worse.

▲nilsbunger 5 hours ago | parent | prev | next [-]

I love it but it feels like it missed its moment - we aren’t writing or reading code anymore.

▲adamddev1 2 hours ago | parent | next [-]

I am still writing and reading all my code.

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.

▲jjpeinet 5 hours ago | parent | prev | next [-]

Exactly now it’s even more important to read and write code. Once your brain got lazy and you lost control over your code base, it lost its value and it will be even harder to get it back.

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.

▲bryzaguy 4 hours ago | parent | prev | next [-]

Concise code that clearly captures intent also helps LLMs to be more effective and make less mistakes.

▲locknitpicker 5 hours ago | parent | prev | next [-]

> I love it but it feels like it missed its moment - we aren’t writing or reading code anymore.

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.

▲rafael-lua 5 hours ago | parent | prev | next [-]

We?

▲tgv 3 hours ago | parent [-]

Some people are so deep up the arses of the AI bros that they cannot imagine there are still those writing code.

▲preommr 4 hours ago | parent | prev | next [-]

> we aren’t writing or reading code anymore

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.

▲miksuko 4 hours ago | parent | next [-]

Don't you think models are going to get better and better at writing good code and designing good code architecture?

▲preommr 3 hours ago | parent [-]

No, to what you're really saying, because they've already crossed a threshold where they're good enough. Yes, they'll get better (much better), but the paradigm shift has happened already.

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.

▲shepherdjerred 3 hours ago | parent | prev [-]

I doubt we'll ever go back to reading/writing code. I do think that we need to continue organizing code/applications well, and LLMs/harnesses will continue to get better at this.

▲preommr 3 hours ago | parent [-]

yea, yea, the king is dead, long live the king.

▲deegles 5 hours ago | parent | prev [-]

all the more reason to make LLMs use the latest in strict types and formal methods. you can just set it and forget it

▲proc0 6 hours ago | parent | prev [-]

If strong types are needed it's probably better to remove layers from the abstraction layer and go back down to a systems language and then build for Web (with WASM). Web APIs have matured substantially so more can be built with less code removing need for so much type checking, which agian if needed it's probably better to remove the abstraction layers instead of adding more of them.

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.

▲motoroco 5 hours ago | parent [-]

wasm is just too hamstrung by its sandbox to be really useful everywhere I once imagined. years ago, I wanted to put my redux-like state machine in it so I could run the same version on mobile clients as well as web. but because there isn't a good solution for sharing memory between JS and WASM, and there's no way to let the WASM talk directly to IndexedDb, browser storage and the like, it was dead in the water

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

▲proc0 4 hours ago | parent [-]

Sure it's not a great solution but it's attempting to open up the Web APIs to any language which is the right approach. Ideally they would somehow be exposed directly bypassing JS, but browsers are security nightmares. The approach is not to use those APIs from WASM but instead use it as the backend to the frontend or the middle layer where most of the logic would live.

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.