Live data from Hacker News

Proposal: JavaScript Structs

github.com

131–140 of 371 posts

Re: Proposal: JavaScript Structs

#132
post #128

Earlier quoted context omitted.

I can think of a few when hoisting is nice, stylistically: if (...) var x = ... else x = ... ///// try { var x = ...} catch (error) { x = ... } ///// for (...) { var x: NodeJS.Dict = {} x[key] = ... } return x

All of those feel like anti patterns to me. Much more difficult to read.

That's subjective, Idk about "MUCH more difficult".

All it does is moving the declaration to the correct visual scope, instead of a dangling up-front declaration.

Admittedly, I understand most coders are aready trained to read the latter.

Re: Proposal: JavaScript Structs

#134

I am not sure how to really refine this thought I have had, but I have this fear that every language eventually gets so bloated and complicated that it has a huge barrier to entry. The ones that stand out the most to me are C# and Typescript. Microsoft has a large team dedicated towards improving these languages constantly and instead of exclusively focusing on making them easier to use or more performant, they are c…

I've been meaning to write a longer essay on this for years, but I believe the reason for this observation is different cohorts. Imagine you are a C# programmer just as C# 1.0 is released. C# is a fairly simple language at that time (and similar to other languages you already know), so you can get caught up on it fairly easily and quickly. A few years later, C# 2.0 comes out. It's got a handful of features, but not t…

This is spot on, well written, and perfectly reflective of my recent experience doing some recreational language hopping.

Incoherence through gradual accretion of complexity is the probably fate of most non-trivial systems, beyond just programming languages. Individual programs, certainly. Buildings too. (People?)

Also, I am a big fan of your books, Bob! Thank you! :)

Re: Proposal: JavaScript Structs

#135

I am not sure how to really refine this thought I have had, but I have this fear that every language eventually gets so bloated and complicated that it has a huge barrier to entry. The ones that stand out the most to me are C# and Typescript. Microsoft has a large team dedicated towards improving these languages constantly and instead of exclusively focusing on making them easier to use or more performant, they are c…

It doesn't help how arcane the TS documentation is. Important docs live as frozen-in-amber changelog entries; huge tracts of pages "deprecated" yet still #1 on Google. Google "typescript interfaces." #1 is a page that has been deprecated for years. How did this happen?

Can tell you right now a lot of important information about mapped types live in Github issues on the TS repo

Re: Proposal: JavaScript Structs

#137

I don't understand the need for the ever-growing list of "enhancements" to JS. Take Class for example. Class is entirely unnecessary and, essentially, tries to turn JS into a class-oriented language from its core which is object-oriented. I never create classes. I always create factory functions which, when appropriate, can accept other objects for composition. And I don't use prototypes, because they are unnecessary…

>And I don't use prototypes, because they are unnecessary as well. Thus sparing me the inconvenience, and potential issues, of using 'this'.

Eh, prototypes share, instead of create, method references. I guess you can use delegate objects too though unless you're just doing pure functions.

Re: Proposal: JavaScript Structs

#139

I am not sure how to really refine this thought I have had, but I have this fear that every language eventually gets so bloated and complicated that it has a huge barrier to entry. The ones that stand out the most to me are C# and Typescript. Microsoft has a large team dedicated towards improving these languages constantly and instead of exclusively focusing on making them easier to use or more performant, they are c…

Javascript is not simple AT ALL. It has 3 ways to declare functions, multiple variations on arrow functions syntax, a weird prototyping inheritance system, objects you can create out of "new" on functions, object literals that can act an pseudo-classes, classes, decorators, for-i loop + maps + filter + for-in loop (with hasOwn) + forEach, async / await + promises and an invisible but always-on event loop, objects pro…

That is still pretty simple as far as mainstream languages go.

Re: Proposal: JavaScript Structs

#140
post #137

I don't understand the need for the ever-growing list of "enhancements" to JS. Take Class for example. Class is entirely unnecessary and, essentially, tries to turn JS into a class-oriented language from its core which is object-oriented. I never create classes. I always create factory functions which, when appropriate, can accept other objects for composition. And I don't use prototypes, because they are unnecessary…

>And I don't use prototypes, because they are unnecessary as well. Thus sparing me the inconvenience, and potential issues, of using 'this'. Eh, prototypes share, instead of create, method references. I guess you can use delegate objects too though unless you're just doing pure functions.

Sure, but imo unless one is creating very many objects each with their own set of functions it's not really a significant issue.

Sometimes programmers spend way too much time optimizing code which doesn't really need it.

In my experience how data is structured is almost always the most important factor when it comes to performance.

Good data structure + simple code === performance.

Post reply on HN