What's the C language equivalent of TypeScript for JavaScript?

I recently came across TypeScript and I’m trying to understand it better. I know it’s related to JavaScript, but I’m wondering if there’s a similar relationship between C and another language.

I’ve been thinking about this and have a few ideas:

  1. Perhaps there isn’t a perfect match since TypeScript is transpiled to JavaScript, but I don’t know of any mainstream language that does the same with C.

  2. Could Java be a reasonable comparison? It tends to be stricter than C++ while sharing some C-similar syntax.

  3. What about Scala or Haskell? They’re recognized for their strong type systems, which seems to be a key aspect of TypeScript.

I’m simply looking for any analogy that might make the concept clearer. Even if it’s not perfect, I’d really appreciate your insights!

Has anyone had experience with both C and TypeScript? What comparisons can you draw?

i’d say C++ is probably the closest equivalent to TypeScript for C. it adds object-oriented features, stronger type checking, and other enhancements while maintaining backwards compatibility with C. but it’s not a perfect analogy since C++ is a separate language, not just a superset like TypeScript is to JavaScript.

Having worked extensively with both C and TypeScript, I can say there isn’t a perfect one-to-one equivalent. However, I’d argue that D comes pretty close to being the ‘TypeScript for C’. It was designed as a re-engineering of C++, maintaining C-like syntax while adding modern features like garbage collection, RAII, and contract programming.

D offers strong static typing, metaprogramming capabilities, and compile-time function execution, which are somewhat analogous to TypeScript’s advanced type system and decorators. It also compiles to native code, providing performance similar to C.

One key difference is that D is a full-fledged language, not just a superset like TypeScript. But in terms of enhancing and modernizing a base language while keeping familiar syntax, D does for C what TypeScript does for JavaScript.

While there’s no exact equivalent, I’d argue that Objective-C comes close to being the TypeScript for C. It’s a superset of C that adds object-oriented programming features and dynamic runtime capabilities. Objective-C maintains full compatibility with C, allowing you to use C code within Objective-C programs. It introduces stricter typing and additional syntax for defining classes and methods, similar to how TypeScript extends JavaScript. However, unlike TypeScript, Objective-C is compiled directly to machine code rather than transpiled. It’s worth noting that Objective-C has largely been superseded by Swift in Apple’s ecosystem, but the comparison still holds in terms of language evolution and enhancement.