Live data from Hacker News

Ask HN: Changing my mind about JavaScript

news.ycombinator.com

21–30 of 73 posts

Re: Ask HN: Changing my mind about JavaScript

#22
My (unpopular?) take is that JavaScript should suffice.

Once I feel the need for TypeScript, I've done something wrong. For example, built my whole frontend with JavaScript or built my backend in JavaScript.

JavaScript's use case for me is sprinkling it where needed in browser. Anything extra and it feels wrong tool for the job.

Frankly, I believe whole existence of TypeScript is a mistake – we should've never used JavaScript at a scale where static typing becomes necessary.

Having said all that, I'd love to be able to write gradually typed JavaScript (i.e. TypeScript) in the browser. Gradual typing is still greatly beneficial, even in my sprinkles.

Re: Ask HN: Changing my mind about JavaScript

#23

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

I would also recommend Typescript. Anything important you need to know about Javascript, you will end up picking up along the way.

My main complaint: the default compiler settings are pretty loose, presumably in the interests of erring on the side of letting Javascript code through by default. I'd recommend going through the available project settings carefully and switching on more of the checks. eslint is also a good idea I think - and a similar comment applies. (I activated pretty much everything, and dialled it back as I found myself getting annoyed by things that felt like poor value for moneey.)

Re: Ask HN: Changing my mind about JavaScript

#25
I have a long history developing stuff in strongly typed languages, C, C++, C#, Go, Rust, Java and Kotlin but have always done the "quick and dirty" in Perl, Ruby or more recently Python or Kotlin.

I still much prefer strongly typed languages for anything that needs to be maintained, and i've always hated JS with a passion.

What finally convinced me that JavaScript might have it's merits was working on an application written in TypeScript. In my opinion (and not everybody elses) TypeScript fixes a lot of "flaws" not only JavaScript but any duck typed language.

I've long used type hints in Python, but they rely on the editor/tooling to find stuff that doesn't match, where TypeScript finds it compile time. Sure, it's all javaScript in the end, but considering that JavaScript can compare Apple and Orages and decide they're all tomatoes, having compile time type checking is a god sent.

Re: Ask HN: Changing my mind about JavaScript

#26

My (unpopular?) take is that JavaScript should suffice. Once I feel the need for TypeScript, I've done something wrong. For example, built my whole frontend with JavaScript or built my backend in JavaScript. JavaScript's use case for me is sprinkling it where needed in browser. Anything extra and it feels wrong tool for the job. Frankly, I believe whole existence of TypeScript is a mistake – we should've never used J…

How would you not build the whole frontend in JS though? Use another compile-to-JS language?

Re: Ask HN: Changing my mind about JavaScript

#28
I strongly suggest TypeScript, which is (as you probably already know) JavaScript with static typing: in other words exactly what you want.

TypeScript adoption over plain JS is HUGE in the recent years, I wouldn't be surprised if it becomes the native default in browsers some time in the future.

Re: Ask HN: Changing my mind about JavaScript

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

For writing shell scripts in Node, there’s a helper library called zx created by Google.

I find it a lifesaver for the common occasion when I’m tempted to write a bash script but also know it’s going to need some slightly more advanced features (as in parsing a JSON, or just arrays that are not totally bonkers in syntax).

Re: Ask HN: Changing my mind about JavaScript

#30
I love writing javascript. It behaves like a lisp which really likes hashtables and runs on some of the best compiler tech anyone has shipped. Typescript is an interesting layer I haven't used enough.

Most stuff written in javascript makes me nauseous. The entire NPM ecosystem is a parody of software development. But you can ignore essentially all of the libraries and still get work done.

Post reply on HN