They nearly gave JavaScript types
ฝัง
- เผยแพร่เมื่อ 20 ม.ค. 2025
- ES4 was the version of JavaScript that never got released. It shipped with a HUGE variety of features - too many even to list in this description.
But it was too big, and discussions around it got too fraught - so it was abandoned in favour of a smaller release, which became ES5.
Article: evertpot.com/e...
Another great article: auth0.com/blog...
Become a TypeScript Wizard with my free beginners TypeScript Course:
www.totaltypes...
Follow Matt on Twitter
/ mattpocockuk
Join the Discord:
mattpocock.com...
Discovering ES4 is like discovering an ancient civilization had electricity and smart phones 2000 years ago.
Yeah, feels like everything we have today was introduced almost 24 years ago.
I was shocked when saw ESX
Oh then Let me tell you about the precision of cutting granite, one of THE hardest known materials on the planet.
Today, we struggle with our diamond tipped tungsten carbide, laser cut hardened steel saws.
But Yolo, the people before the Egyptians... No problems. Making ice-cream scoop like impressions in granite... No sweat.
Us today? Naww. How you even?
Reminds me of that black and white photo of a woman on a mobile phone. People were meme-ing about her being a time traveller, but it turns out she was legitimately just using a prototype mobile phone decades before they were viable for general use. Feels weird knowing what was under our noses the entire time.
It's really impressive how ES4 was going to be ahead of its time
What's funny is that PHP ended up having almost all these features, but not javascript.
Seems very inspired by Java
@@TehRoflizer Everything copies Java in the end
@@Hamstertron They didn’t
@@illker. Bro it's ok, nothing to be ashamed of. PHP did it too.
ActionScript 3 was a pretty faithful, if not 100% perfect implementation of ES4. ActionScript powered huge amounts of the multimedia web until Flash was killed off in the early 2010s. As an ex-Flash dev its kinda funny/sad/awesome how we've come back full circle to so many of these language features with TS - I mean, I'm glad we finally have but it was pretty rough to be making way without them for a fair few years.
AS3.0 was great, but the tooling was awful. Writing scripts in Flash IDE was horrible, Flex IDE left a lot to be desired and FDT - I couldn't find a crack for ;) Kids these days have it too easy with their free VSCodes, hot reloads and frameworks for everything. Something something uphill both ways!
thanks for making my chidhood you guys. really miss those glorious flash days
@@wayslow Ehh, in the final dark few years we had Flash Builder, which was based on the Eclipse IDE platform. That thing was pretty neat. Proper step debugging, perfect intellisense, static analysis, type checking, lots of nice things we only really got back with by the time VS Code got underway.
That explains a lot, I once said to a Flash developer "oh ActionScript is just the same as JS" and he went all "incredible hulk" on me... I see why now. But, then again, in those days, I still thought jQuery was ah-mazing...............
I really enjoyed AS3 as well. So sad that it never caught on outside Flash.
We could have had integers in JS 24 years ago? Infuriating :P
Omg - why have they never shipped, the world would be a better place. Any I'm so happy that we finally realise that types are awesome. Still filling a bit sad not to have type checking during runtime.
There is zod now.
The ES4 notation mostly already existed in Java Servlets, and Java Servlets didn't make the world better. (Of course, Java in the browser had a ton of problems, so maybe that's an unfair comparison.)
Damn, they were so close to making this language so much better, and yet something stopped them
I really really wonder what &^%^$# ((
that something was literally microsoft lmao
@@biskitpagla f@#$g microsoft "made typescript" but killed built-in ts?! ((
Nah. We all know that scriptards hate static typing; just look at every other scripting language. If anything, my bet is that Microsoft was the main one trying to add static typing to JavaScript, but the other scriptards sabotaged it.
It was Adobe pushing their AS3 language they just bought as the next standard (so they could... license flash technology to browsers or something? Unclear)
My impression was that nobody else on the committee liked the specific design, and couldn't get Adobe to budge, but it's been a long time since I've read about it.
Damn, it even had the `private` keyword, instead of the botched implementation that they did now with # in front.
ES4 almost made JavaScript Java script
As someone who heavily used both Javascript 3 and actionscript 3 for (desktop!) application development, I'm not at all surprised that AS3 was dropped when it was proposed as ES4.
As3 might have been handy for flash games, but for serious application and library development it was a complete mess, absolutely nothing like as nice as typescript.
There's more in ES4 than AS3, but not by much and it's not clear that much if any effort was put into thinking about if all these features were at all feasible, let alone together (like, how did the overloading work with union types?)
Basically, it's easy for a language to look cool in syntax examples, extremely hard for it to actually be a good language. The ECMA committee have done incredible work turning the mess that es3 was in around, and it's gone from near the bottom of my list to near the top, and I've got quite a long list of languages.
Bump. After watching this video I'm glad ES4 got shot down. Strongly typed languages were a huge pain in the butt for decades. We needed to go through this untyped/duck typing phase to collectively understand that we deserve more from our typing systems. For about the first decade of my career I only used strongly typed languages and there is no comparison between the state of those typing systems and the near utopian TypeScript experience we have now.
Correction: promises were introduced in ES6, but async/await wasn't introduced until ES7!
Yeah promises without async/await was one of my least favorite things about js in that time period. It essentially forced you to structure you code with endless callbacks
I literally checked if it was April fools today
I work with E4X in Mirth with Rhino currently.
It doesn't have all the features and XML work is pretty jank to work with
But it definitely beats es3 and XSLT
I seem to remember Adobe had something to do with this too and ended up kind of melding it into ActionScript3 ? And there was a hope that this would then become ES4 again ?
I gave up waiting and ended up using Haxe to output to ES3 😞
Yes! Macromedia was involved (though I think not on the committee) and based A3 on the ES4 spec. But when ES4 collapsed they were hung out to dry a bit.
I wish Javascript had these features today!
Maybe one day we could have something akin to a 'use strict' that would enforce runtime type checking?
Adding file directives to enforce a certain (*possible breaking) runtime behaviour isn't that great of an idea imo, it is kind of inconsistent. If you accidentally leave it out once it will be a complete nightmare and would lead to possible fatal silent errors. What would be great tho is something like tsconfig for Javascript, where you can toggle runtime checks for an entire program (including it's dependencies - of course) 🥹
we can only hope
More modes have been explicitly rejected by the committee in general, and they're quite aligned on not adding a runtime checked type system (both for several very well founded technical reasons).
It's been tried, several times, even, and the consensus from people that would know is it's technically a bad idea too, as it both significantly slows startup time to perform all the checks, and doesn't improve runtime performance better than, or even as much as, dynamically inferred runtime types.
So, while it's not completely impossible, you should expect it not to happen.
@@SimonBuchanNz You get the awards for best buzz kill and best profile image...
There wolf... there castle.
JavaScript *has* runtime type checking. It is one of the key advantages of a compiler that it checks the code BEFORE you run it.
So we lost 25 years in terms of technological progress. Huge bummer!
And to this day we still don't have a type system included natively in the browser.
Imagine all the unnecessary suffering inflicted upon programmers all those years.
Untold amount of hours lost in productivity. And billions upon billions of $ that did not materialize because of it.
People who shut down ES4 should be put on trial.
I don't think it was 'shut down' - I think it was:
1. Various companies couldn't agree which features they wanted to implement
2. The web was more 'walled gardens' then (Netscape, IE) so shipping a new general version of the language didn't feel like a priority
3. Browsers balked at needing to support these new proposals
So I don't think a radical shift would even have been possible back then.
@@mattpocockuk yes it was shut down or killed, because it didn't continue and in fact it's the exact period where nothing happened for years in the JS progress, the browser env was harder to change than flash because it was edited by a single company and was simpler and had versionning. maybe when they realized that flash will get it first they chose to kill it to avoid competition.
you are wrong on one detail : it was shipped as Action Script 3, I used it for almost a decade, I had to find a lot of patience when working with javascript at the time, and I switched only 4 years ago when some of the mandatory stuff began being supported widely in runtime environments. During the same time javascript progress slowed to a crawl . The ES4 is more than just jsx, it comes with special syntax and an API, you can use it to parse and match fragments of XML/HTML. It made using XML nice and powerful, better than JSON which come with no API/feature (apart from parsing, serializing) from syntax and it allows to use the same skills and knowledge to work on the document and the configuration/data files.
The package looks a big redundant but makes sense, it's a subjective choice really, there was no "default" but I don't consider this critical.
Most of what it brings would have turbo charged the community, and there would have been ways of handling retro compatibility. This fuck up was the reason why I stayed far away from JS for most of my career. Now with TS I'm back in 2004 when I was using AS2 which is really not as good as AS3, so I still consider JS not as advanced as AS3 was. AS3 is only missing some recent syntactic sugar and the async/await promise, it would be quicker to go from there and apply the recent upgrades. Some TS advanced typing feature makes powerful things possible, which were not in AS3, sometimes the usable patterns were limited by the language features. Today to make a good HTML component framework possible using ES4 and E4X powers, it would require many recent JS improvements to make it practical, but the potential was clearly there.
Loved this episode... a trip down memory lane! Thanks, Matt!
You made me remember another awesome anecdote that might complement this story. Who actually implemented ES4? ActionScript 3, the language that powered the more recent versions of Flash (as long as it survived). I actually liked a lot ActionScript 3 as a language (even though it felt very Java-ish!). And what about E4X? Adobe Flex implemented that and I think it was a great idea at the time (not too different from what component-based frameworks using JSX are today). Such a shame all this work got lost once the flash platform died out... But on the other end is great to have the web is powered by an open platform rather than a proprietary runtime :P
As a former haskeller, (number, string) looks like it's a tuple. I'm happy we got unions with | instead
Wow those overloads were actually super cool
plot twist: Those who were involved in ES4 got together and worked on TypeScript :D
These are features found in most "good" programming languages so hilarious this was never implemented and instead was sort of patched years later with TS
We need it back!
ES6 did not introduce async/await, it was introduced in ES8
They were so smart back in the days...I feel like now everything stopped or slowed down really hard, like people are afraid to innovate, like WHY JS is not evolving at a greater speed 😞
Can we have a time machine please?
Javascript almost got Java :D
The JS community is sometimes very funny, they make a hype, and when you look at it, it is just something that exists in C or Java for 10, 20 years. I think it is all more about young programmers learning JS as their first language without knowing the whole programming languages ecosystem.
I thankfully started with Java sucked up every bit of syntax and structure and departured to rust to embrace a huge amount of new syntax and structure. Every time I write or even see Javascript I feel sad for the devs working with it.
Well even if it exists in C or Java, It is still a bomb in javascript. Because javascript can do things easier than C or Java, meaning with more power relative to C, javascript will be a lot better => Hype.
I think people hype up has a point though, more power means more responsibility, but with javascript your responsibility is much smaller than C or java.
In an alternate universe JavaScript takes it's name from Java because it's basically the same thing.
I got goosebumps and at the same time tears in my eyes by seeing this!
So now we just need to resurrect this proposal and no more TS. Love it!
A bit of topic but do you have any video discussing in what scenario you actually use function overload? I feel that almost always genetics do the job in a more elegant way.
Polymorphism. An overloaded function/method can implement entirely different behavior depending on the passed arguments.
Can you please do a tutorial on how to properly use zod-fetch? :D
Sure! What issues are you running into?
Reminds me of when they went to ActionScript 2 and further onto ActionScript 3..
I bet they were loving what was happening there, and then bailed halfway through
Yeah, ActionScript 3 was based on the spec that was put together for ES4 - so when ES4 failed it left ActionScript 3 out to dry.
@@mattpocockuk I remember those days.... Though, I also remembering trying to use XML back in AS3.. and almost crying..
@@mattpocockuk as old AS3.0 dev - I was super pleasantly surprised how much at home I felt when I did my first big TS project... and how disappointed I became when I realized it's not runtime. Anyway - It's a nice idea for a video to compare AS3 to TS.
@@wayslow you mean you didn't have the pleasure of using AS2 with someObj._y = 123; because underscores meant the property was extended... Because... People cared??? It was horrible.
@@ColinRichardson AS2 was a step in the typing direction but was not very well designed and it was limited like TS is because it compiles down to un-typed AS1.
Looking at ES4 gives me the feel that it was just a wannabe JAVA, got dismissed cause there was already JAVA.
1:56 Colin approves of the length of that Generic
ActionScript 3.0 smell in the AIR 😁
None of this surprising as static languages existed since 75 and proven to be far better than dynamic languages when building big projects spanning across members.
I think in about 20 years we will def have this
😆
In some universe of these multiverses (if theory is true), this proposal might have been accepted and there is no typescript
Why didn't it ship tough? Maybe jit engines would become slow?
Oh boy, what the Internet could've been!
Why hasn't this version of js been approved?
Wow that runtime type checking looks a lot like PHP.
And the ES4 never being released is sort of reminiscent of PHP 6. I think that was supposed to replace the built in strings with Unicode strings, but it was never shipped. Replaced I think with 5.6 and then 7.
We could have all this good stuff back then, what a shame 🥺
async await came out in ES7
My bad! Thought it was ES6.
@@mattpocockuk all good! Great content Wizard
Why didn't they release ES4?
js wasnt considered worth investing in back in those days so tons of big names rallied against the advancements.
Did I read "Tail call"? Really, they were really into bringing TCO to JS? What a missed opportunity. And proper numeric types.
Glad it never happend. I like how typescript is now only a superset of JS and not a standart. I know new developers struggle on this chaos, but in real examples this choise is giving more flexibility to where do level down.
if i have a ts question i want to fire at you.. how would i do that?
mattpocock.com/faqs
Ignoring the type system, a considerable number of features from ES4 were added to ES6 but with a different syntax.
Eg, the `private` keyword is replaced by private members (properties or methods starting with '#')
Classes (And methods) are defined in a shorter way that in ES4, ES Modules (Which IMO is better than the ones in ES4, it kinda resembles Java's API)
Getters and setters defined with their respective keywords which are also much shorter,
And ESX with JSX. (Although its not the same as having native support in the language)
IMO, the newer API's introduced in ES6 and beyond are better.
But the reason ES4 is so missed is because of its Type system.
There is currently a proposal for Types as comments in JavaScript, but since the JS engine will just ignore it like a comment, it won't be as good as the ES4 that actually used it..
Types in comments has been around for a long time. It's called JSDoc.
@@maelstrom-qw1jl I'm not talking about JSDoc annotations. The 'types as comments' proposal aims to bring typescript-like annotations to javascript natively.
Like in JSDoc, you would do something like:
/** @type {number} */
let x;
But the proposal aims to add typescript-like annotations, like:
let x: number;
You can search for it, it's in stage 2 I think.
@@Dev-Siri Oh OK I got confused by the name. Treating type annotations as inline comments. Strange choice of words by TC39.
This is crazy!
Not really sure if ES4 qualifies as *"forward thinking."* Many of those features look almost identical to OO features in other languages right at the time that OO was peaking in mindshare and popularity. ES4 looks like an attempt to turn JavaScript into Java.
javascript now has types (typeof exists)
I love this
This video was pretty informative and ...cozy?
💚💚💚
We could have had flying cars and time machines if ES4 had been the standard. Instead we’re here writing typescript, treated as outcasts by the javascript plebs
Not just types but `int` and `double` as separate from `number`!!!!!!!
ES4 Become more java i love to see this overload and runtime checkers
ES4 walked so PHP 6 could run.
(Just in the "version lost to time and skipped" sense)
I read somewhere that the first version of Javascript didn't even support multi dimensional arrays lol
It still doesn't? Arrays of arrays, aka "jagged arrays" as each item array can be of different length, are quite different.
I mean this would've made JS into Java... Well anything would've been better than what JS is now. It might have even become a decent server-side language. Oh well we got Go for that so we're good.
Weirdly enough Microsoft (the creator of Typescript) would oppose ES4.
Such a shame ES4 was never a thing.
Makes me a bit sad
JavaScript just needs to adopt type script features and do them in runtime. It would make JavaScript so much better
Do we wizards just code ? what about our witches ?
Wait.. It was more like Java.
This is where Microsoft inspired when they created Typescript.
It probably happened in an alternate universe where JS doesn't suck.
it was cool and all until E4X caught me completely off guard
basically, Microsoft stole features of es4 for Typescript
as good as it sounds, it will only kill javascript if it did. The next non-typed "easy to learn" script lang will take over just like js did, you all will be writing type-vb-script today, prob also made by MS
legit just bootleg java, oh wait
Let's see how much of conspiracy this video will generate
The guys whom made typescript definitely got most of the clues from es4.
If ES4 happened I would probably be a web developer instead of a systems developer.
I like strict type systems that make things crystal clear. I think dynamic typing is and has always been a big mistake and should have never been created.
In some moment for JS it was so unbearable to be a toy language, then it start mutate into C++
@@maelstrom57 it’s just not fashionable anymore. Other than that it’s a fine language, why not use it
@@maelstrom57 Not sure about how it goin in other countries, i can say only for Russia - A lot vacancy in embedded development & IoT. Only issue is pretty high knowledge requirement and long term experience ( About 3-5 years )
@@maelstrom57 The shit people write on the internet...
Who ever is Wondering why this version of JavaScript was not released because If they had released this one, it could have broken 99% of the existing websites.
That's not the reason.
If only ES4 survived, we could be rid of this language for a language
Hmm, hope by going back in time you didn't interfere with the time-line - you might have just inadvertently caused billions of errors never to be born
First
Unpopular opinion: JS was fine without TypeScript. Types are unnecessary if you use proper naming conventions and sensible software design.
Js was fine up until node and then other frameworks rolled around
I think it's a minority position, but I wouldn't say unpopular. Personally, I think it largely depends on the size of the project, the quality and complexity of the untyped language, the quality and complexity of the type system, and your knowledge of how to handle issues with either not using or using a type system.
I think a lot of the push back against type systems from the 90s-00s was due to the majority of available type systems being clumsy and not very valuable and the by then more feasible untyped languages becoming much more powerful, but by now we have quite good type systems, and it's definitely worth getting familiar with them if the other factors (size of project, etc) line up.
@@SimonBuchanNz I'm a tech lead for a large company at the moment, and I have to outline future developments, strategies, architecture, etc. I'll always choose TypeScript for situations like the one I am in.
But you're right, it's not all black and white; some people and some projects and some teams are perfectly fine without TypeScript.
I'm one of those people, I started as a front-end developer in 2000 and I've done vanilla JavaScript far longer than TypeScript has even been around.
I learned it "the right way", but I also see that people who have "only" been around for, say, 5 to 8 years (many people!) have probably never worked with just vanilla JavaScript. For them, it's almost impossible to work without TS.
And I acknowledge that fully.
It just came as a surprise to me that when I worked for one of the bigger FAANG companies, my entire team decided against using TypeScript for 5 of our projects.
Significant projects, mind you, but the average age of the people was above 35. Most of us were autodidact, too. So most of us simply didn't need TS.
I'l admit that I didn't like TS up until 3 years ago, though. Before that (before 2019 I would say) it was not intuitive at all, too many things were missing, too many gotchas...
Today, TS is fine. And I hope they realize they need to not make it unfine. When TypeScript turns into Java, I'll stop being a hands-on manager and I'll just develop for fun in my own time.
It was fine if you are a solo developer on a smaller project. With growing project complexity and having more people on the project, TypeScript is just a super powerful tool. You also cannot always count that you will have mid-senior people working on a project. You know, juniors exist as well and they are a majority of the market probably.
Yes TS has a learning curve and it can annoy you from time to time, but all of its downsides are worth it when you realize what you get out of it. I've been using TypeScript for 3-4 years now and going back to a JS project these days feels awful. I'm not even coming from a strongly typed background either since JS was the first language I learned so I don't have bias towards typed languages, but TS feels great to use, especially in a team.
If you have great success just writing vanilla JavaScript, then go for it, but I think as time goes on you'll be left behind. If you are against TS just for some personal reasons (Microsoft bad or something), you should re-evaluate your position and actually try TypeScript in a real project. Who knows, you might like it.
@@rand0mtv660 Read my other reply :) I do like TS, but I don't need it. For me, TS adds nothing of value. It feels like constantly walking on the streets and pointing at things and saying what it is. "That's a car! That's a bird! That is air! That is a street! That is a building! That is glass! That is a bus!"
And then generics come into play and suddenly: "That B is sometimes a C but it can also serve as a T!"
People might wonder what these single-lettered things are, and they are super confused. But the TypeScript lover throws them around everywhere.
I've worked with TS nearly full-time for 7 years now, over a 22+ year long career, including several FAANG companies. And I get why many people love it and need it.
But for me, myself, and I? It's overly verbose and strictly unnecessary all of the time.
Coding and naming conventions plus progressively applied JSDoc offered all I need and I never needed more.
But I would also never start a project without TS anymore. Because I need to keep learning new TS things every release :) And I need to stay relevant in the market.