Menu
Sign In Search Podcasts Libraries Charts People & Topics Add Podcast API Blog Pricing

Anders Hejlsberg

๐Ÿ‘ค Speaker
701 total appearances

Appearances Over Time

Podcast Appearances

The Pragmatic Engineer
TypeScript, C# and Turbo Pascal with Anders Hejlsberg

Now, arguably, an alternative way of doing this is to use threads in the OS.

The Pragmatic Engineer
TypeScript, C# and Turbo Pascal with Anders Hejlsberg

But the problem with threads is that they come with preemptiveness.

The Pragmatic Engineer
TypeScript, C# and Turbo Pascal with Anders Hejlsberg

And the OS has the ability to preempt you at any point in time.

The Pragmatic Engineer
TypeScript, C# and Turbo Pascal with Anders Hejlsberg

And that's not necessarily what you want.

The Pragmatic Engineer
TypeScript, C# and Turbo Pascal with Anders Hejlsberg

And

The Pragmatic Engineer
TypeScript, C# and Turbo Pascal with Anders Hejlsberg

And, and your UI, now you have to be multi-threaded in your UI and all sorts of other problems come along with it.

The Pragmatic Engineer
TypeScript, C# and Turbo Pascal with Anders Hejlsberg

Plus threads are heavyweight.

The Pragmatic Engineer
TypeScript, C# and Turbo Pascal with Anders Hejlsberg

And typically not well suited for lightweight tasks like, like you can do with async functions.

The Pragmatic Engineer
TypeScript, C# and Turbo Pascal with Anders Hejlsberg

So there are pros and cons.

The Pragmatic Engineer
TypeScript, C# and Turbo Pascal with Anders Hejlsberg

You know, like async await introduces this notion of function coloring, which is unfortunate, where you have two kinds of functions, async functions and regular functions.

The Pragmatic Engineer
TypeScript, C# and Turbo Pascal with Anders Hejlsberg

And all the red functions can call the blue functions, but the blue functions can't call the red functions.

The Pragmatic Engineer
TypeScript, C# and Turbo Pascal with Anders Hejlsberg

And so that means once you want, you know, a red function, now everything above it has to be red.

The Pragmatic Engineer
TypeScript, C# and Turbo Pascal with Anders Hejlsberg

And so if you want from a sync function to call something async, well, then you've got to turn this function into an async function and its caller has to be et cetera, et cetera, right?

The Pragmatic Engineer
TypeScript, C# and Turbo Pascal with Anders Hejlsberg

So that's unfortunate, and that's why some environments like Go, for example, has Go routines and green threads, which are really language-emulated, lightweight threads that kind of do what I'm talking about, but at a much lower cost.

The Pragmatic Engineer
TypeScript, C# and Turbo Pascal with Anders Hejlsberg

But you avoid the function coloring.

The Pragmatic Engineer
TypeScript, C# and Turbo Pascal with Anders Hejlsberg

So there is a bunch of different things.

The Pragmatic Engineer
TypeScript, C# and Turbo Pascal with Anders Hejlsberg

But, you know, but for an environment that already exists like JavaScript or like C Sharp and the Windows event loop and whatever, this was the right solution.

The Pragmatic Engineer
TypeScript, C# and Turbo Pascal with Anders Hejlsberg

I think it was sort of a confluence of a number of things that happened in the early 2000s, right?

The Pragmatic Engineer
TypeScript, C# and Turbo Pascal with Anders Hejlsberg

First of all, the JavaScript platform, execution platform,

The Pragmatic Engineer
TypeScript, C# and Turbo Pascal with Anders Hejlsberg

matured a lot.