News for hackers. Stuff that matters.

rauschma

Re: on Sunday October 27, 2024 @03:13PM (#41964852)
Versioning has many downsides.

Let’s assume we create a new version of JavaScript that is not backward compatible and fixes all of its flaws. As a result, we’d encounter the following problems:

• JavaScript engines become bloated: they need to support both the old and the new version. The same is true for tools such as IDEs and build tools.

• Programmers need to know, and be continually conscious of, the differences between the versions.

• We can either migrate all of an existing code base to the new version (which can be a lot of work). Or we can mix versions and refactoring becomes harder because we can’t move code between versions without changing it.

• We somehow have to specify per piece of code – be it a file or code embedded in a web page – what version it is written in. Every conceivable solution has pros and cons. For example, _strict mode_ is a slightly cleaner version of ES5. One of the reasons why it wasn’t as popular as it should have been: it was a hassle to opt in via a directive at the beginning of a file or a function.

More information: https://exploringjs.com/js/book/ch_history.html#backward-com...

Re:Ask HN: Changing my mind about JavaScript on Monday August 05, 2024 @08:36AM (#41160753)
I have used many languages in my nearly 40 years as a programmer (Scheme, C++, Java, Python, Haskell, OCaml, Rust, etc.) and still enjoy JavaScript: It’s decent as a language and there is so much you can do with it.

Tips:

• If you like static typing, you’ll want to use TypeScript. It’s more work to set up, but it catches many bugs, especially subtle ones where JavaScript’s semantics are not intuitive.

• I learned a lot about JavaScript (and Node.js) by writing shell scripts in Node.js.

My books on JavaScript, TypeScript and Node.js shell scripting are free to read online and target people who already know how to program: https://exploringjs.com

Re:JavaScript Promises from the Ground Up on Friday July 19, 2024 @02:43PM (#41009703)
It depends on what you mean by syntactic sugar. I follow this definition: https://en.wikipedia.org/wiki/Syntactic_sugar

You can indeed translate an async function to an equivalent function that uses .then() but it’s a radical change, not syntactic sugar (as I use that term).

Re:Exploring JavaScript (ES2024 Edition) on Friday July 19, 2024 @08:17AM (#41005616)
Thanks for posting this! (I’m the book’s author.)

– The whole book is free to read online.

– This chapter gives an overview of what’s new in each ECMAScript version: https://exploringjs.com/js/book/ch_new-javascript-features.h...

I wrote my JavaScript book for people who already know how to program – maybe it works for you. Free to read online: https://exploringjs.com/impatient-js/
FWIW – with Mathias’ help, I turned this tweet thread into a blog post: https://2ality.com/2022/05/rfc-9239.html
Thanks for the kind words!

W.r.t. the “Dr.”: It’s interesting how much reactions differ. In Germany, people tend to think you are smart if you have a title. In the States, people tend to think you’re incapable of functioning in the real world.

I’m still experimenting. The title has worked well for me w.r.t. branding. Sometimes I mention it, sometimes I don’t.

For what it’s worth: That’s not what motivated this blog post. It was that I often encounter people who see the three dots being used in parameter definitions or destructuring and don’t understand what is going on (because they think it is spreading). The section on triple dots not being operators is more of a side note.
The Temporal cookbook has more information on time arithmetic: https://tc39.es/proposal-temporal/docs/cookbook.html#arithme...
Re:Deep JavaScript on Thursday June 10, 2021 @12:23PM (#27462476)
Thanks! I’m glad to hear that.
Re:Deep JavaScript on Thursday June 10, 2021 @11:40AM (#27461992)
[I’m the author of “Deep JavaScript”.]

Don’t forget that this book is for people who already know JavaScript well. It doesn’t try to explain the basics. This book does, though: https://exploringjs.com/impatient-js/

Re:Deep JavaScript on Thursday June 10, 2021 @11:36AM (#27461943)
From what I’ve read, TC39 acknowledges that this is important and is working on fixing JavaScript’s deficiencies in this area:

– BigInts (arbitrary precision integers) were a recent addition: https://exploringjs.com/impatient-js/ch_bigints.html

– A proposal for `Decimal` (base 10 floating point numbers with arbitrary precision) is currently at stage 1: https://github.com/tc39/proposal-decimal

Re:Deep JavaScript on Thursday June 10, 2021 @11:22AM (#27461773)
In JavaScript, classes are mostly just a slightly weird way of setting up prototype chains.

Diagrams help me understand how this works. At the following link, you can see the source code of a simple class and a diagram (section 29.2.2) that shows how all involved objects are connected: https://exploringjs.com/impatient-js/ch_proto-chains-classes...

Re:Deep JavaScript on Thursday June 10, 2021 @09:01AM (#27460185)
You can check out my book (it’s free to read online): https://exploringjs.com/tackling-ts/
IIRC, adding those operations was merely postponed, not rejected.

These are work-arounds: https://exploringjs.com/impatient-js/ch_maps.html#missing-ma...

AssemblyScript [1] is an example of a subset of JavaScript being compiled to fast WebAssembly. But it is very static code. If you want to run dynamic JavaScript fast, you need the more sophisticated strategies used by modern JavaScript engines.

[1] https://www.assemblyscript.org/

Here is a list: https://en.wikipedia.org/wiki/Prototype-based_programming#La...

JavaScript itself was inspired by Self in this case.

These two books are based on the 2ality blog and also free to read online:

– JavaScript for impatient programmers (covers most of ES1–ES2020, incl. many advanced topics): https://exploringjs.com/impatient-js/

– Deep JavaScript (covers advanced topics): https://exploringjs.com/deep-js/

Re:JavaScript for Impatient Programmers on Wednesday July 01, 2020 @11:27AM (#23702517)
Everything you’ve mentioned plays a role. It has also worked well marketing-wise: In Germany, people take you more seriously; in the US it doesn’t matter, but a title is still more memorable.
Re:JavaScript for Impatient Programmers on Wednesday July 01, 2020 @11:23AM (#23702453)
Ping me at dr_axel AT icloud.com and I’ll notify you. Two universities in Switzerland are using my book to teach JavaScript and seem happy with it, so far.
Re:JavaScript for Impatient Programmers on Wednesday July 01, 2020 @11:15AM (#23702336)
(Just in case the title is putting you off: You are describing the goals of this book.)
Re:JavaScript for Impatient Programmers on Wednesday July 01, 2020 @10:51AM (#23701980)
I agree! I’m in the process of editing the relevant chapter.
Re:JavaScript for Impatient Programmers on Wednesday July 01, 2020 @10:18AM (#23701578)
The title is tongue-in-cheek. The book itself is not superficial.
Re:JavaScript for Impatient Programmers on Wednesday July 01, 2020 @08:43AM (#23700708)
The book did indeed get longer than I had planned. However, there is a “quick mode” for reading it: https://exploringjs.com/impatient-js/ch_about-book.html#isnt...
Re:JavaScript for Impatient Programmers on Wednesday July 01, 2020 @08:05AM (#23700483)
> The first variable using `const` is called ”immutable”, which is misleading, since only the _assignment_ is immutable

That’s a first look at the syntax. The details are explained here: https://exploringjs.com/impatient-js/ch_variables-assignment...

But I should clarify that “immutable” here means “immutable binding”.

> Only single- and double-quoted strings are introduced at first

I had to start somewhere. Template literals and tagged templates are a more complex topic that benefits from strings already having been introduced.

> Arrow functions are introduced as just another syntax

Arrow functions are introduced in detail here: https://exploringjs.com/impatient-js/ch_callables.html

---

In general, I occasionally have to initially leave out some details so that the book can be read linearly. But those details are then filled in later in the book.

Re:JavaScript for Impatient Programmers on Tuesday June 30, 2020 @11:38AM (#23691119)
Thanks for the mention! The book is free to read online and was updated to ECMAScript 2020 last week.
I have written a few words about various strategies for migrating. Maybe it’s helpful: https://exploringjs.com/tackling-ts/ch_migrating-to-typescri...
Thanks for the mention!

The chapters:

– Asynchronous programming in JavaScript: https://exploringjs.com/impatient-js/ch_async-js.html

– Promises for asynchronous programming: https://exploringjs.com/impatient-js/ch_promises.html

– Async functions: https://exploringjs.com/impatient-js/ch_async-functions.html

– Asynchronous iteration: https://exploringjs.com/impatient-js/ch_async-iteration.html

Older »