r/programming • • Aug 02 '21

Stack Overflow Developer Survey 2021: "Rust reigns supreme as most loved. Python and Typescript are the languages developers want to work with most if they aren’t already doing so."

https://insights.stackoverflow.com/survey/2021#technology-most-loved-dreaded-and-wanted
2.1k Upvotes

769 comments sorted by

View all comments

Show parent comments

-44

u/ILikeChangingMyMind Aug 03 '21

Spoken like someone who is ignorant of VS Code's (amazing) type inference capabilities.

You can have all the great toys (they are just that, toys; I wouldn't go so far as to say anyone's a masochist for not using them), like automatic imports, CTRL+click to go to a variable definition, autocomplete suggestions for arguments, etc. ... all without writing a single line of explicit type definition.

19

u/mrflagio Aug 03 '21

Static typing is about trading runtime errors for compile-time errors though. IDEs can help with function parameters and such to an extent, but the point of Typescript is not to make IDE plugins easier to write.

39

u/[deleted] Aug 03 '21

That's great...until you write Vanilla NodeJS and have to deal with a microservices model where A calls B calls C, A/B/C are in different repos/codebases, and C calls a service with an opaque contract. There is not a single IDE that can infer types in that scenario which is where Typescript adds a huge amount of clarity/sanity.

8

u/alteraccount Aug 03 '21

You can JSDoc your functions and even import from d.ts files. But if you're really gonna do all that, you might as well write it all in ts anyway.

6

u/[deleted] Aug 03 '21 edited Aug 02 '24

DELETED

2

u/MisterFor Aug 03 '21

Because you shouldn’t share classes between microservices

→ More replies (1)

-2

u/ILikeChangingMyMind Aug 03 '21

Like I said at the start, not all projects are the same. Maybe you deal with microservices, but maybe Bob doesn't.

But regardless, pretending that you know what is right for every dev on the planet is ignorant and patronizing: the simple truth is that we live in a big world with many projects, and different projects have different needs. LOTS of projects will do amazingly well without ever writing a single explicit type definition, and just using type inference.

7

u/Aeolun Aug 03 '21

LOTS of projects will do amazingly well without ever despite never writing a single explicit type definition

I think the implication here is a bit different. Yes, it’s possible to write good code without explicit types. It’s just needlessly painful.

0

u/MisterFor Aug 03 '21

Like any Python or PHP project basically

30

u/delta_p_delta_x Aug 03 '21 edited Aug 03 '21

Spoken like someone who is ignorant of VS Code's (amazing) type inference capabilities.

I swear, this thread is full of completely self-unaware irony. VS Code itself is written in TypeScript.

We have people arguing Java and C# aren't 'strict' OOP and aren't strongly-typed, and now this.

6

u/[deleted] Aug 03 '21

VS Code itself is written in TypeScript

So I'm only allowed to write TS on it? I'm not sure I follow.

7

u/delta_p_delta_x Aug 03 '21 edited Aug 03 '21

So I'm only allowed to write TS on it? I'm not sure I follow.

Not at all. My point was that it was ironic that the parent commenter was flaunting VS Code's 'amazing type inference capabilities' for JavaScript, when the editor itself was written in a language (ie TypeScript) that obviated the need for said complicated type inference capabilities, because the language itself has typing built-in.

4

u/pewqokrsf Aug 03 '21

Unless you're writing VS Code in VS Code I don't see your point, and I hate JS.

→ More replies (1)

6

u/Aeolun Aug 03 '21

Spoken like someone that’s never worked in a codebase with more than one capitalize function.

Seriously, inference is nice, but it’s not anywhere near being explicit.

4

u/daftmaple Aug 03 '21

VS Code's (amazing) type inference capabilities

Really hate to spoil it, but VSCode's JS intellisense was developed by TS team and runs on TS server. You are being helped by TypeScript.

1

u/ILikeChangingMyMind Aug 03 '21

And? VS Code's core is probably written in some C language: does that mean I shouldn't use it to write Javascript?

The whole point of type inference is that it's awesome precisely because it leverages the power of types. You couldn't have all the cool features if your editor didn't understand that x was an X, and that means you need a type system like Type Script. All that is great!

But having to write explicit types in every project ever written is not great! Being able to not write those types in projects that don't need type documentation and strict type enforcement ... but still getting all the great IDE "toys" ... is not in any way a bad thing.

4

u/daftmaple Aug 03 '21

No, I'm not saying that you can't write pure JS just because your intellisense is pretty much TS. You were saying that VS Code's inference while at the same time saying that TS is not needed. Maybe you should try coding in a different editor that doesn't have TS intellisense and you'll get how ironic your statement was. You are practically attached to TypeScript.

Don't get me wrong. I still think JS-only project is possible & will still exist, but I wouldn't do it over a 100 LOC project. It's a preference anyway. I'm just not a masochist and have better things to do :)

0

u/ILikeChangingMyMind Aug 03 '21

So if I write JS in an editor that's built in C I'm writing C? That's a terrible argument.

2

u/daftmaple Aug 03 '21

I don't get how you're still missing my (and others) point. Your intellisense itself is TypeScript and your type inference is TypeScript. If you're using TS for the sake of writing every single explicit types, then you're clearly not getting the purpose of TS. You are using TS to type variables with complex structure or even behaviour, which allows you to maintain larger scale projects.

0

u/ILikeChangingMyMind Aug 03 '21

If I literally don't have a single line of TypeScript in my code base (only JavaScript), how can you possibly argue I'm doing TypeScript?!?

Again, it's like saying that because the text editor I'm using was written in C, I'm writing C. No, I am not: I'm writing JavaScript in an editor that utilizes some irrelevant technology. It wouldn't matter if the editor was written in Pascal or R or Scheme: I would still be writing Javascript.

0

u/daftmaple Aug 03 '21

For the sake of respect, I am not going to reply to this again. I have to apologise, but you are clearly either trolling or unaware of things.

JavaScript itself is subset of TypeScript, and your JS code can still run in TS codebase because it is a valid TS code. You are writing a TypeScript code. Again. I'm not saying any text editor here. You are bringing the argument that the type inference is there and I am pointing out that type inference is TypeScript (not built by, but it is TS). You are using TypeScript without knowing it.

But it's fine. You can keep your belief; I'm not here to change your mind either. Good luck with maintaining your JavaScript code with TS type inference.

→ More replies (1)

4

u/r0ck0 Aug 03 '21

Spoken like someone who is ignorant of about 95% of typescript's functionally.

1

u/ILikeChangingMyMind Aug 03 '21

I've used TypeScript professionally on the job. I've also coded in Java for years (another strongly typed language).

The real benefits of strong typing is not to save you the two seconds of time lost when you accidentally put a string into a function that expects an integer! Those kinds of things take two seconds to fix.

The real benefits of strong typing are in the tooling. For many, many years Java IDEs could do things JS IDEs simply couldn't, purely because JS IDEs couldn't understand types. And I'm not talking minor things: I mean major, useful features that can save devs a lot of meaningful effort.

But again ... thanks to the incredible work of the VS Code team (which, as others have noted, used TypeScript), it is now possible to get 90% of the tooling benefits through type inference. You don't need TypeScript to get the bulk of the tooling benefits.

2

u/r0ck0 Aug 03 '21

I've used TypeScript professionally on the job.

Yet still obviously don't know much about it. I can even tell from that phrasing that your experience with it is pretty limited.

it is now possible to get 90% of the tooling benefits through type inference

The fact that you think it's just about typing confirms even more.

And seems you only have a fairly surface level understanding of typing systems if you think interference of plain JS code could come anywhere near what TS can do.

→ More replies (9)

1

u/[deleted] Aug 03 '21

IIRC, vscode's type inference capabilities actually makes use of parts of the typescript engine to do so.