Quick comparison: C#, JavaScript, and TypeScript language features

Posted: (EET/GMT+2)

 

If you work with ASP.NET and modern frontends (React, Angular, etc.), you often end up using C#, JavaScript, and TypeScript side by side. Here's a quick comparison of some core language features.

This comparison is not about which language is "better" or more suitable. It's just a practical overview of similarities and differences you'll notice in day-to-day development. I'm exploring things like types, compliation, interface and OOP support and so on. Let's begin.

Typing model:

  • C#: statically typed, types are required at compile time.
  • JavaScript: dynamically typed, types are resolved at runtime.
  • TypeScript: statically typed on top of JavaScript, types are checked at compile time.

Compilation:

  • C#: always compiled to IL (Intermediate Language) before execution.
  • JavaScript: interpreted or JIT-compiled by the runtime (browser or Node.js).
  • TypeScript: transpiled to JavaScript before execution.

Interfaces:

  • C#: native interface support, enforced at compile time.
  • JavaScript: no concept for interfaces.
  • TypeScript: interface support, checked at compile time.

Object-oriented features:

  • C#: full OOP support (classes, inheritance, interfaces, access modifiers).
  • JavaScript: prototype-based, modern syntax supports classes but with fewer constraints.
  • TypeScript: class-based syntax with interfaces and access modifiers, compiled to JavaScript.

Type safety:

  • C#: strong compile-time type checking.
  • JavaScript: no compile-time type checking.
  • TypeScript: compile-time type checking, removed after transpilation.

Typical role in ASP.NET projects:

  • C#: backend services, APIs, business logic and server-side code.
  • JavaScript: browser-side scripting and runtime behavior.
  • TypeScript: structured front-end code, especially in larger applications.

In practice, C# and TypeScript feel closer to each other, while JavaScript gives more runtime flexibility. Knowing the differences helps when moving logic between the backend and the browser.

The interesting thing with C#, TypeScript and a little bit surprisingly, Delphi, is that they all share the same lead designer, Anders Hejlsberg. So no wonder they feel similar.

Happy hacking!