Hacker News new | ask | show | jobs
by DonHopkins 2287 days ago
I think what Andrew Hejlsberg himself, the designer of C# and TypeScript, said speaks to the claims orange8 is making about TypeScript being a "VERY opinionated linter" and that "you loose a lot of its power and flexability by shoe-horning it into strongly typed languange patterns".

Andrew Hejlsberg's point is that TypeScript is a "multi-paradigm" language: it's not just strongly typed, but also structurally typed, interface based, plus everything else JavaScript itself is: dynamically typed, duck typed, functional, imperative, event driven, class based, prototype based, object oriented, etc.

Even the term "object oriented" has a broad spectrum of independent meanings: JavaScript has many but not all of the a la carte menu of features or properties of "object orientation" that Jonathan Rees listed in response to Paul Graham's essay "Why Arc isn't Especially Object-Oriented".

http://paulgraham.com/reesoo.html

http://mumble.net/~jar/articles/oo.html

http://paulgraham.com/noop.html

Andrew Hejlsberg said:

>I think it's wrong to talk about "Oh, I only like object oriented programming languages, or I only like imperative programming, or functional programming".

It's a mistake to think that TypeScript restricts you to just one way of programming, and you have to give up the ways you used to program JavaScript. TypeScript ADDS to the number of ways you can program JavaScript. It's a superset of the multiple programming paradigms that JavaScript supports.

You don't "loose a lot of its power and flexability by shoe-horning it into strongly typed languange patterns" -- quite the opposite, you don't "lose" anything: you actually gain more "flexibility" and more "language" patterns.

1 comments

>> you don't "lose" anything: you actually gain more "flexibility" and more "language" patterns.

You do not need TS to use OOP language patterns in JS. Remember TS is compiled down to JS, so all that flexibility comes from JS. The same flexibility that makes the concept of TS and the 100 other "compile to JS" languages possible. Some of that flexibility is lost because you let the TS compiler make some decisions for you as it generates the JS output.

You're factually wrong: zero flexibility is lost. Not even any "flexability". (But I'm glad we're both using the same word now -- I was worried you had some completely different definition of "loose languange flexability" that you were arguing, because you don't seen to be making any sense, and your facts about TypeScript are wrong. Programmers who scoff at IDEs and compilers like you do should be more careful about your own spelling and punctuation and grammar and logic and facts and definitions and semantic arguments.)

The TypeScript compiler will BY DEFINITION compile any JavaScript code to equivalent JavaScript code that does exactly the same thing. So no flexibility is lost, which is obvious if you know TypeScript, or have bothered to read the second sentence of the first paragraph of the TypeScript wikipedia page. TypeScript is a "strict syntactical superset" of JavaScript. So it's impossible for the TypeScript compiler to decrease the flexibility of TypeScript, because all JavaScript is valid TypeScript. Understand?

https://en.wikipedia.org/wiki/TypeScript

>TypeScript is an open-source programming language developed and maintained by Microsoft. It is a strict syntactical superset of JavaScript, and adds optional static typing to the language.

Just the opposite of your claim, and consistent with what Wikipedia and Andrew Hejlsberg say, the TypeScript compiler "ADDS optional static typing to the language", which INCREASES the number of programming paradigms.

Yet you wrote:

>Remember TS is compiled down to JS, so all that flexibility comes from JS.

C++ is compiled down to machine language, but machine language is not object oriented, while C++ is. Do you claim that the flexibility of C++ comes from machine language's innate object oriented-ness, not the C++ compiler? That's simply wrong.

Somehow the C++ compiler is adding object oriented programming to machine language, just as the TypeScript compiler is adding generic programming and structured typing and static typing and other features to JavaScript, even though JavaScript doesn't have those features itself. They came from the compiler, not the target language. JavaScript simply isn't capable of checking types before running a program, and you know that.

You're really not getting the point, or just purposefully trying to avoid it. Read what Andrew Hejlsberg himself said about multi-paradigm languages, which I've quoted to you twice but you haven't acknowledged. Do you really so blatantly disagree with the guy who wrote TypeScript, about his own language?

If you so strongly disagree with Andrew Hejlsberg and the TypeScript manual, then why don't you go edit the Wikipedia articles about TypeScript and JavaScript, and remove the parts about TypeScript being a "strict syntactical superset of JavaScript" that "adds optional static typing to the language", and also remove the part about Javascript being a "multi-paradigm language", and see how long those edits lasts?

https://en.wikipedia.org/wiki/JavaScript

>JavaScript (/ˈdʒɑːvəˌskrɪpt/),[6] often abbreviated as JS, is a programming language that conforms to the ECMAScript specification.[7] JavaScript is high-level, often just-in-time compiled, and multi-paradigm. It has curly-bracket syntax, dynamic typing, prototype-based object-orientation, and first-class functions.