Live data from Hacker News

Proposal: JavaScript Structs

github.com

201–210 of 371 posts

Re: Proposal: JavaScript Structs

#201
post #7

The general idea of types with a fixed layout seems great, but I'm a lot more dubious about the idea of unsafe blocks. The web is supposed to be a sandbox where we run untrusted code and with pretty good certainty expect that it can't crash the computer. Allowing untrusted code to specify "hey let me do stuff that can cause data races if not done correctly" is just asking for trouble, and also exploits. If shared str…

It's not unsafe as in "memory segmentation fault" unsafe. It's unsafe as in, if you don't follow the rules, the resulting value is ~rand(). For those familiar with C/C++ terminology, this is the tame "unspecified behavior" (not the nasal demon "undefined behavior.")

Nit: "unspecified behavior" isn't a thing, at least without some further qualifications. It's usually "unspecified result", or "unspecified result or trap" for certain operations. "unspecified behavior" without further qualifications is just "undefined behavior".

Having said that, an "unspecified result" can still come from anywhere, like a value left in a register from some previous computation or other "garbage" on the stack or heap. This still can be a security issue, even though the behavior is not completely undefined.

Re: Proposal: JavaScript Structs

#202

Earlier quoted context omitted.

Well, all the people that used JS 15 years ago followed Douglas Crockford advice very much to heart.

Crockford hates TypeScript and loves og JS. He thinks the push to turn JS into c# is misguided and a waste of the original small talk-y beauty of The Good Parts - src he said as much to me at a lunch I went to where he was also attending.

How long ago was this? TypeScript v1 and v2 definitely had a class-based stink to it since the typing system only handled those scenarios somewhat well.

Right around when I started using it (mid 2019) there was a bunch of V3 releases that each on it's own might've not seemed like much but they all improved small parts of the engine that made it easy to get typing on most of your code if using a functional style without adding maybe more than a few type declarations and some functions typings.

Re: Proposal: JavaScript Structs

#203

Earlier quoted context omitted.

Crockford hates TypeScript and loves og JS. He thinks the push to turn JS into c# is misguided and a waste of the original small talk-y beauty of The Good Parts - src he said as much to me at a lunch I went to where he was also attending.

Does TS make JS non-smalltalky? Static typing which is optional.. and you still get a REPL, online compiler and the ability to dynamically inspect objects in your global object...

v1 of TS had a heavy "OO"/class-based bias to it, v3 and v4 made it viable for real-world JS code but peoples perception stayed both due to those who looked early on seeing something they didn't like or the code produced by many who loved it early on.

Re: Proposal: JavaScript Structs

#204
post #160

Earlier quoted context omitted.

Yep and TS has all of that plus a gigantic layer of bullshit on top. The web development community has created the perfect environment for nobody to ever get any work done while still feeling like they're being productive because they're constantly learning minutiae.

Typescript is the best thing to happen to JavaScript since ES6

Types are great, but I prefer Not having to transpile everything. Stepping throught the TS Code with a Debugger ist non trivial.

Re: Proposal: JavaScript Structs

#205
post #27

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 think in this specific case it's JavaScript's requirement for backwards compatibility that bloats it... but there's a lot you can ignore. Like, you can declare a variable with var, let or const but there's absolutely no reason to use var any more. I feel similarly about the proposals to introduce records and tuples: https://github.com/tc39/proposal-record-tuple ... in most scenarios you'll probably be better off us…

> Like, you can declare a variable with var, let or const but there's absolutely no reason to use var any more.

I am going to continue to use var for everything, because I think let and const are stupid.

It is not cool or interesting to learn about new scoping rules introduced by let, and it is not cool or interesting that so many people — especially juniors, but not exclusively — are lulled into a false sense of security by believing const means the referenced value is immutable, which it isn't.

I am going to continue to write small JavaScript, like from The Good Parts.

Re: Proposal: JavaScript Structs

#206
post #80

Earlier quoted context omitted.

> but there's absolutely no reason to use var any more Naw, var has function scope and hoisting, both of which are useful.

My job isn't to be infatuated with your code. It's to get through your code and get stories done. People don't really get better at handling the complexity of large code bases. We are fundamentally the same organic matter that existed prior to the first computer coming into existence. So as code bases and library bases grow larger and larger, they need to be proportionately easier to read or even ignore. Your code ne…

> Your code needs to be dead boring 90% of the time

I also prefer boring code, but I think having the choice between var, let, and const is less boring than only having var.

Re: Proposal: JavaScript Structs

#207

I thought it said "Proposal: JavaScript Sucks" and was not surprised by the number of upvotes from HN

(Wipes away tears of laughter) I needed that! [1] [2] [1] just got some bad news [2] all in all, I love working in JS when I have to, but I’ve worked in it long enough to know of at least very many of the foot guns.

Why couldn’t you just write a paragraph instead of using some citing system for formulating your sentence?

Re: Proposal: JavaScript Structs

#208

JS devs - do everything but write in another language challenge level: Impossible.

What a bad take. If you're writing code that runs in a browser, there's no other choice. I'm not counting things like ClojureScript, as you still need to have deep knowledge of the low-level primitives, which exclusively bind to JS.

You can use other languages that compile to WebAssembly, but it's borderline as it's basically just a VM / self-contained executable that you can pipe to. It's completely isolated from the browser.

Re: Proposal: JavaScript Structs

#209

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…

Just as a quick side note this is actually one of the things I’ve come to appreciate most about some of the work you and the others have done with Dart where it very clearly has gotten much more powerful and has had to deal with some major changes in requirements over the years as well but on the whole I feel with only a few exceptions the complexity doesn’t feel like it’s gotten away from me or the community at large at all. It’s very obvious to just look at it and see that a tremendous amount of work has gone into the language design itself and just figured now would be a good time to offer my appreciation for that.

Re: Proposal: JavaScript Structs

#210

Earlier quoted context omitted.

(Wipes away tears of laughter) I needed that! [1] [2] [1] just got some bad news [2] all in all, I love working in JS when I have to, but I’ve worked in it long enough to know of at least very many of the foot guns.

Why couldn’t you just write a paragraph instead of using some citing system for formulating your sentence?

They're footnotes and are meant to be read as supplementary notes to the core message.
Post reply on HN