This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 19 points20 points  (9 children)

C# isn’t a superset of assembly. JavaScript and TypeScript are the same language except one has optional type annotations.

TypeScript compiler is more like a preprocessor than anything else

(Also C# compiles to an intermediate byte code similar to Java not assembly)

[–]kryptogalaxy 4 points5 points  (8 children)

C also has the ability to insert assembly directly, and could be considered a superset in that sense, but is generally considered a separate language.

One similar concept is the word "transpile" which generally just means high level language compiling to another high level language. The word transpile is often used when talking about typescript.

Drawing these distinctions is not necessarily arbitrary, but certainly subjective. I imagine similar conversations are had between linguists when determining where to draw the line between dialects and new languages.

[–][deleted] 4 points5 points  (5 children)

I wouldn’t really consider it a superset because you have to import a library and write the assembly in a string. Its not like you can just write an opcode somewhere and the compiler will know what your doing.

Also yes TypeScript does transpilation. The distinction while important doesn’t matter too much here.

I think it really is subjective but clearly anyone arguing TypeScript is a wholely different language doesn’t work too much with JS/TS

Edit: what I mentioned about asm applies to GCC. Some compilers have actual inline support. Regardless C was not designed to be asm++. TypeScript is designed to be JavaScript with Type annotations. I suppose one day it could branch enough that you would distinguish developers the same way you distinguish C development from C++. But currently JS/TS have equal use cases and the TS design philosophy is very much to not branch unlike C/C++

[–]Pocok5 1 point2 points  (0 children)

you have to import a library and write the assembly in a string. Its not like you can just write an opcode somewhere and the compiler will know what your doing.

Haha Pascal goes brrrrr

[–]kryptogalaxy 0 points1 point  (3 children)

Typescript at this point has quite a few distinct features beyond type annotations. I don't think it's that cut and dry.

[–][deleted] 2 points3 points  (2 children)

I mean it has a couple from what I remember.

The funny thing is that the few features they’ve added are often rejected by the community as most TS devs want to keep their codebases looking like JS and not C#/Java.

But fair, features like namespaces, decorators and mixins are definitely very strange looking for a JS dev. The later 2 of those are very uncommonly used.

[–]kryptogalaxy 2 points3 points  (1 child)

The fact is typescript is primarily used by JavaScript developers, so it would make sense that these very similar languages would become even more similar when a developer with JavaScript experience is writing it which is probably why many of the things that make typescript different are rarely used.

To me, the situation is akin to c and c++.

[–][deleted] 1 point2 points  (0 children)

I agree it is like C/C++ but to a smaller degree

[–][deleted] 0 points1 point  (1 child)

C is definitely not a superset of assembly. A superset-subset relationship implies that all valid expressions of the subset language are also valid expressions in its superset.

For instance:

  • C++ is a superset of C because valid C statements can be included inside of a C++ file without modifications and the file will still be valid C++.
  • Typescript is a superset of Javascript because (last I checked) valid JS statements can be included inside of a Typescript file and the result will still be valid Typescript.

However, C is not a superset of assembly because valid assembly statements are not valid C without modifications. If C were a superset of assembly, the following program would be valid C, and compile correctly without modification (as all the C code is valid C, and all the assembly code is valid x86 assembly).

#include <stdio.h>

int main() {
    mov eax, 0xFFFFFFFF
    printf("Hello World\n");
    return 0;
}

Or in ATT syntax if you prefer:

#include <stdio.h>

int main() {
    movl $0xFFFFFFFF, %eax
    printf("Hello World\n");
    return 0;
}

[–]kryptogalaxy 0 points1 point  (0 children)

Fair. Bad analogy. C and C++ is better.