4 ms·
Interesting, I've found the reverse is true for me with ES6. For example, ES6 already had local functions (and a very terse form of that too using lambdas)
by spion 10y ago
Interesting, I've found the reverse is true for me with ES6.
For example, ES6 already had local functions (and a very terse form of that too using lambdas)
class C {
method() {
let localFunction = x => x + 1
function anotherLocal(a) { return a + 1; }
}
}
... arrays are normally used to represent tuples (or freeform objects), and it includes destructuring too:
function f(x) { return [x, x*2] }
let [x, xdoubled] = f(5)
or
function f(y) { return {y, timesTwo: y*2} }
let {y, timesTwo} = f(10)
It almost seemed to me that many of the features listed here were "borrowed" from the liberal style allowed by ES6 and TypeScript (am probably wrong, and both are borrowing from elsewhere).
- ZeroClickOk 10y agoEach release c# get more and more "functional". Previous versions you can use anonymous methods or lambdas to "simulate" local functions, but now its first class citzen. The problem with JS is you need deal with a lot of hacky legacy things too, you want try new cool things on ES6/ES7, but you need take care about compatibility, 3rd party libraries integration, etc. IMHO, I hope something like "ES10", where they forget previous versions, create from scratch a new javascript, without worries about polifilling, compatibily, shimming, etc. Then start to evolve from there.
- dodyg 10y agoIt's not wise to start a over a language. Perl6.
- WaxProlix 10y ago> (am probably wrong, and both are borrowing from elsewhere). You're right there. Tuple unpacking has existed in even stronger form (pattern matching) in most functional or functional-ish languages for ages. Python's had unpacking since God knows when. F#, which is sort of related to ML and feeds features to C# somewhat regularly, does this sort of thing as first-class syntax. It's sort of a trend for people who learn JS first (or only) to look at features that it's had stapled to it and then point out how much other languages are taking from it.
- DougWebb 10y agoPython's had unpacking since it got it from Perl, back in the 90's. I'm really glad to see C# is catching up :)
- spion 10y agoYou're incorrect in assuming that I've only/first learnt JS. But its sort of a trend for people to look down on JS programmers, since its considered a "low-status" language ;) And I'm well aware that the direct inspiration for many of ES6's features is probably Python (and now C# with async/await, which in turn flowed there from F#) I'm assuming some cross-borrowing is happening here due to developments on the TypeScript team, and due to much higher similarities of the specifics with TypeScript. After all, F# has been around for quite a while, yet we're only seeing this development now - so if F# is the inspiration, why did it not happen much earlier?
- jackfoxy 10y agoIt didn't happen much earlier because the Microsoft languages team is very deliberate and careful about rolling out new features. They have to be. There are something like 1.5 billion machines running some sort of Windows, and (I don't know) on the order of 1/2 - 1 million developers who work with MS languages and tools. Lots of backward compatibility to think about. At this scale even five 9s quality ends up breaking things.
- WaxProlix 10y agoDisagree strongly. I don't think looking down on JS programmers is a trend really, it's been happening for a long time now. If anything, that era has been fading with the legitimacy that runtimes like Node and adoption by high-profile companies bring to the JS ecosystem. As for JS itself, ES6 is a great step in the right direction, and I like it a lot, though I prefer Typescript for pretty much anything when I can use it. Also - I didn't say that you learned it first or only, just that I see a lot of praise for 'JS features' being adopted by other languages from people who very obviously don't know any better - and this only in the last 3 or so years. So I think it's a trend.
- int_19h 10y agoThe borrowing kinda goes in circles. The terse syntax of ES6 lambdas is straight from C#, for example.