Live data from Hacker News

Ask HN: Changing my mind about JavaScript

news.ycombinator.com

11–20 of 73 posts

Re: Ask HN: Changing my mind about JavaScript

#11
post #3

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 l…

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

Totally! This will give you lot of insights into low-level working of JS. Of course, some Node.js specifics too. Reading from STDIN, parsing strings into structured data etc.

Re: Ask HN: Changing my mind about JavaScript

#12
I did a lot of coding with C++ and ended up moving to 100% JavaScript for our game creation tool Construct (www.construct.net).

I'm now a huge fan of JavaScript - I think it's a really underrated language. People often still talk about it like it's 2010. The modern language features are amazing, the performance is incredible - including the GC performance - and it's memory safe and no need to worry about allocations. If you want static typing, use TypeScript, which is also very good and is basically a static type layer over JavaScript.

My advice is look at the modern language features which now have wide cross-browser support, and be sure to use them. It can significantly change your coding style for the better. By that I mean things like modules, private class fields, nullish coalescing, optional chaining, async/await, map/set - some of which are fairly old now but are still getting new improvements worth knowing about.

Re: Ask HN: Changing my mind about JavaScript

#14
I would recommend using Typescript and a strict linter if possible. TS is essentially modern Javascript plus static typing (so by learning TS, you also learn JS as a side effect), and strict linting rules will reject outdated Javascript features and nudge you towards the 'good parts'.

With those two things (a static type system layer, and strict linting) JS is actually a quite decent language nowawadays, especially in VSCode (e.g. see: https://code.visualstudio.com/docs/languages/typescript).

Re: Ask HN: Changing my mind about JavaScript

#15
I have been using JS for more than 20 years, and I do not like it. There are parts of it I find useful, but I avoid using it as much as I can in any project.

The biggest reason for this being that the execution of JS code it down to the browser rendering the page where it’s deployed. As such it’s practically impossible to get any code to run consistently. This is of course only relevant in my day to day work as a web dev.

That aside, JS has some funny behavior. If you wish toninderstand JS better you could read up on how null and undefined works.

You could also read up on how functions work, they are objects actually.

Re: Ask HN: Changing my mind about JavaScript

#16

I have been using JS for more than 20 years, and I do not like it. There are parts of it I find useful, but I avoid using it as much as I can in any project. The biggest reason for this being that the execution of JS code it down to the browser rendering the page where it’s deployed. As such it’s practically impossible to get any code to run consistently. This is of course only relevant in my day to day work as a web…

> the execution of JS code it down to the browser rendering the page where it’s deployed. As such it’s practically impossible to get any code to run consistently

Can you elaborate on this part? I would say one of the strengths of JS is that you can get it to run consistently just about anywhere.

Re: Ask HN: Changing my mind about JavaScript

#17
post #9

I mean why not use Typescript and have both? Projects don't have to become very large at all before static types are better & more productive than dynamic types. Especially for multi-person projects, or ones that last for a while so you forget stuff.

agree with this, at this point all my toy projects, even those of a few lines, are in typescript (with bun.js so I don't have the overhead of configuring node for ts)

Re: Ask HN: Changing my mind about JavaScript

#18
post #13

There's JavaScript The Good Parts by Douglas Crockford. I've read the book and watched a similar series on YouTube.

Second this recommendation. There's been a lot of changes to JS recently, but it's still worth reading The Good Parts because I think it's philosophically a good way to approach JavaScript. It can be a good language if you know which parts to avoid, and which quirks to look out for.

There's also https://github.com/getify/You-Dont-Know-JS as a good follow-up to The Good Parts.

Re: Ask HN: Changing my mind about JavaScript

#19
Static types are sanity when the people and years keep increasing. It isn't at all important in small one man projects since most of your defined types are in your head in any case.

There is nothing wrong with JavaScript as a language beyond it's, originally questionable, foundations that have since been iterated upon (much like PHP).

As a massive fan of static typed languages. There is no denying that dynamic typed languages are more fun to develop with in smaller project. It just they often hit a tipping point when they become a horror to deal with. I can still remember my first legacy Python code based where everything was thrice nested dictionaries.

Post reply on HN