Live data from Hacker News

A Modern JavaScript Tutorial

javascript.info

121–130 of 299 posts

Re: A Modern JavaScript Tutorial

#121

Earlier quoted context omitted.

i and j are very understandle. I did browse the go code randomly and for example t, s, and b are terrible variable names in my opinion in this example : https://github.com/golang/go/blob/3ce865d7a0b88714cc433454ae... You can find a lot of code like this.

That strikes me as perfectly readable. t for template, b for bytes, and s for string. What else would you call them?

template, bytes, string.

Re: A Modern JavaScript Tutorial

#122

> According to your browser language headers, you know Chinese. Please help to translate the tutorial into your language! Thank you! I'm curious. How are my language preferences exposed through HTTP headers? I think this was a charming way to request volunteers for translation, but I was a bit taken aback.

This was probably set at the operating system level, i.e. you selected "zh_ZH"/Chinese at some point during setup. Upon installing a browser, it reads your OS language preference & then passes that through to websites via the accept-language header.

Re: A Modern JavaScript Tutorial

#123

Earlier quoted context omitted.

I never understood that. Is it really that hard to spell out full variable names? It’s so much more legible, there is autocomplete on virtually any editor (even the ones that aren’t IDEs), and you write code once but read it hundreds of times. Why even try to save 8 bytes at the expense of readability?

Short variable names make code more readable in some scenarios, not less. fooBarBazThings.each(t => t.DoThing()) for (int i = 0; i Some local code patterns are seen so often you understand it in one go. Something like fooBarBazThings.each(fooBarBazThing => fooBarBazThing.DoThing()) for (int thingIndex = 0; thingIndex Just clutters things up.

Modified obfuscator can make your code even more readable. It can simplify functions in addition to variables. Also, it improves job security, which is important in times of covid.

Re: A Modern JavaScript Tutorial

#124

Earlier quoted context omitted.

I never understood that. Is it really that hard to spell out full variable names? It’s so much more legible, there is autocomplete on virtually any editor (even the ones that aren’t IDEs), and you write code once but read it hundreds of times. Why even try to save 8 bytes at the expense of readability?

Short variable names make code more readable in some scenarios, not less. fooBarBazThings.each(t => t.DoThing()) for (int i = 0; i Some local code patterns are seen so often you understand it in one go. Something like fooBarBazThings.each(fooBarBazThing => fooBarBazThing.DoThing()) for (int thingIndex = 0; thingIndex Just clutters things up.

This is a bit of a false dichotomy, because the names don't have to be that long.

  fooBarBazThings.each(thing => thing.DoThing())
It's more useful when the receiver of the method doesn't tell you as much, eg:

  getRecentPurchases().values().forEach(price -> priceStats.accept(price));

Re: A Modern JavaScript Tutorial

#125

Earlier quoted context omitted.

I think many JS developers are also somewhat blind to the breadth of types of sites that are written, and so don't understand how valuable a type system can be on the web. Most websites are what I'd call "broad and shallow". For any individual action the corresponding code path is small. Most code in these sites is easy to write and easy to debug in vanilla JS. Typescript adds boilerplate and compiler times for type…

I'd guess I'd have to question why you need 10K lines of code for a single web page - perhaps you need to break up your SPA?

Because applications on the web are increasingly that -- full applications.

I create scientific models and simulations for use in schools. Whether it's simulating a hurricane, or continental drift, electronics, or molecular interactions, the simulations themselves need to run on the browser, and all the UI that provides the users with all the affordances to interact with the model needs to also be written in JS/TS.

I think your questions are just revealing a failure of imagination/experience for what kinds of applications run on the web these days.

Re: A Modern JavaScript Tutorial

#126
post #81

Earlier quoted context omitted.

Unlike other languages, typescript adds zero runtime overhead, and the APIs that one writes in TS are trivially consumable from JS. Consuming JS from TS is also made as easy as possible, including the option to set types aside entirely for some parts of your code using the "any" type, which means "don't type check this, just trust me that it works". TS really is different from other compile-to-js languages in this re…

It adds in developer overhead and for someone writing in JS that is often what you are trying to minimize.

Doesn't plain JS add developer overhead in the form of bugs and code the team doesn't understand a few weeks or months later?

Re: A Modern JavaScript Tutorial

#127

Earlier quoted context omitted.

i and j are very understandle. I did browse the go code randomly and for example t, s, and b are terrible variable names in my opinion in this example : https://github.com/golang/go/blob/3ce865d7a0b88714cc433454ae... You can find a lot of code like this.

That strikes me as perfectly readable. t for template, b for bytes, and s for string. What else would you call them?

template, file, text

Re: A Modern JavaScript Tutorial

#129

Is there a good tutorial that covers all the various frameworks that are in use? Modern Javascript has become very complicated due to the proliferation of these frameworks more so than the programming language.

Tbh if you know JavaScript well all these frameworks work like js. I build couple websites using vanilla js and when using any framework I can tell what it is doing behind the curtains because I have done it myself dozen or times in multiple lines of normal js
Post reply on HN