Live data from Hacker News

Ask HN: Changing my mind about JavaScript

news.ycombinator.com

1–10 of 73 posts

Ask HN: Changing my mind about JavaScript

#1
I'm a longtime developer software developer with statically typed languages, in the last few weeks i started working on a couple javascript projects and i must say that i'm changing my mind about javascript, albeit i still think that for bigger project relying on statically typed languages is a better and safer path, i think that JS deserve a chance to be "really" learned, i'm not referring following the dozens of tutorial we find online that are pure crap (using dozens on stuping npm packages or using pre-cocked solutions without really understanding it's full potential).

Do you have any tip for learning js at it's fundamentals? internals, advanced patterns and everything that can relate to understand it in deep?

Re: Ask HN: Changing my mind about JavaScript

#2
If you have plenty of time, start a side project to build out a HTML canvas library (with no dependencies) ... just kidding! I've been building my canvas library for 11 years and there's still a shedload of JS understanding I've not yet poked.

More seriously, the MDN documentation is really useful[1]. Some of the advanced topics listed on that page may be a good place for an experienced engineer to start?

- Inheritance and the prototype chain - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Inhe...

- Memory management - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Memo...

- The event loop - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Even...

[1] - https://developer.mozilla.org/en-US/docs/Web/JavaScript

Re: Ask HN: Changing my mind about JavaScript

#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 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: Ask HN: Changing my mind about JavaScript

#4
JavaScript is flexible and simple in a good sense of the word.

There not much advanced to learn.

Thanks to single threaded design you basically just write whatever you intend to do and it works.

With a proper mix of oop and fp there is no place for “advanced patterns” and other over-engineering diseases in a lean js world.

The most terrible and ungly js code ive seen are from former .net and java developers.

I suggest you unlearn all the “patterns” and keep it as simple ad possible.

Re: Ask HN: Changing my mind about JavaScript

#5
I love JavaScript, been programming for more than 16 years now. Built websites, apps, banking portals, chat bots and customer experience software using Js, React, Redux and TypeScript. Also used Java and currently work on Go lang. Even after using every language I still prefer JS to be my everyday work love language. Its better now and improving too.

Re: Ask HN: Changing my mind about JavaScript

#6
> Do you have any tip for learning js at it's fundamentals?

Build something you think is fun. Take a static index.html page without any build tooling (just open the file with a browser), link a JS & CSS file to it, and make a cool thing with animations or interactivity. Maybe try to remake some cool interactive thing you saw somewhere

Re: Ask HN: Changing my mind about JavaScript

#7
I think the best way to understand/appreciate javascript as a language is to A) separate it from the DOM, and B) take a functional programming focus

Too many times, when people complain about javascript, what they are really complaining about is the hectic nature of web development. You have three trillion dollar companies (Google/Chrome, Microsoft/Edge, Apple/Safari) actively fighting over agreed upon standards for how the dom is rendered and manipulated. Try and learn any language in that environment, and you'll have a very frustrating time

Why functional programming? Javascript was one of the earlier mainstream languages to support passing around functions as first class citizens, and it's often an aspect of the language that gets downplayed. By and large, javascript sits at the sweet spot of allowing you to do cool functional programming concepts, without all the strictness and verbosity of a language like Haskell. Is that a good thing? It depends, obviously. But for the sake of "Change my mind", this is where I bet you'll start looking at it in a different light

I'm not saying it's the best/one-true language. It's just another cool tool to have on your tool belt

Re: Ask HN: Changing my mind about JavaScript

#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.

Re: Ask HN: Changing my mind about JavaScript

#10
There is a functional core in js, and as such it might be an idea to take a look at common OOP design patterns and how they translate to an FP approach.

This is Clojure based, but there is a lot of similarity to js once you get past the syntax: https://mishadoff.com/blog/clojure-design-patterns/

Post reply on HN