Ask HN: What do you enjoy about JavaScript?

21 points by xupybd ↗ HN
I don't find JavaScript fun to work with. I love Chromes debugging tools and realize it a hugely valuable language but I don't find it fun.

There are people that love JS and want to use it for everything. If you're one of them what makes it fun?

30 comments

[ 5.4 ms ] story [ 72.4 ms ] thread
I'm not a big fan, but it is interesting/exciting/terrible/wonderful that you can use document.write as an lvalue, if you wanted to have it do something else.
It’s a good balance. No compilation, but there are type checkers. Interpreted, but still pretty fast. Poor language design, but there are strict linters. Not pure functional but still takes inspiration from FP. In React land, declarative coding is the norm to the point where you can almost go too far with it. Straightforward to debug (no threading) and logging is straightforward.
Why does any programming language have to be fun?

It's just a tool get something done. For me JS fails silently far too often and is burdened by DOM + CSS + frameworks with their own quirks.

JS is useful for some situations and the worst possible choice in others. That's why we have lots of PLs to chose from. Just like hardware stores don't just sell hammers.

They don't have to be fun at all. I have friends who talk passionately about JavaScript, how it's a fun language.

I like to understand what draws different people to different things.

I have fun with F# because it's like a puzzle that just works once you get the pieces to fit.

I hate Perl while others love it. I find it fascinating to discuss what brings someone to get joy out of a tool.

Maybe you haven't tried ruby but fun matters.

Why would anyone want to write in a verbose language that can't get things done through natural human thinking?

Most languages are acceptable in that regard, so maybe you don't care.

It probably has to do with if you like prototypical inheritance and it's asynchronous nature (I'm sure many other things too -- probably different for each person).

I love these and find them very powerful, but it's probably a bit like extroverts vs introverts -- totally dependent on your character.

It can be used to solve legitimate computational problems, whether you enjoy coding it or not.

First class functions
That it basically runs everywhere. It is one of the few languages that can even be considered if you're aiming to target mobile devices.
I like the syntax and the base concept, having a Lips like programming language with a C/Java like syntax was a good idea I think.

Having an asynchronous model but a with single thread is also something I like about javascript. It provides good enough performances for most use cases without requiring to think about synchronizing between threads. The async/await model is much simpler to use compared to Golang or Rust for example, while it is a lot less powerful of course. You can also use more than one process but it's usually a good sign that you should use something else than JavaScript for the task.

I also like the tooling, you have a lot of great things on npm. A lot of terrible things too and you shouldn't install whatever you find on npm. In general the community is very nice and JavaScript doesn't have a lot of enterprise crap with overly complicated design patterns.

It's of course not perfect, but I think it's one of the best programming languages at this time.

I enjoy the needless suffering it creates for developers who depend on it.
(Old joke) The thing I most enjoy about javascript is closing the editor when I'm done.

Typescript seems like a genuine improvement but I am too lazy to learn it properly.

I like TypeScript a lot more than JavaScript. Types make a language significantly easier to understand/debug in general, and you can write very functional TypeScript code with lambdas, ADTs, pattern matching (although the last 2 are ad-hoc and not quite as good as real ADTs/patterns)
I like TypeScript exclusively rather than JS, if that counts.
Create a single HTML file and inside that you can create a UI app that can easy communicate with thousands of different apis. Run in a local server and use it immediately without packaging or compiling it.
Availability. Most anything else can be found implemented in other languages, but better and more concise. Nothing can beat having JS in all browsers, however.
Unlike most other programming languages it is super easy to write hello world and proceed from there.
I enjoy the obfuscated ways that any JavaScript code can be entirely rewritten with using just 8 different characters.

http://www.jsfuck.com/

I like the way it's asynchronous first and everything revolves around the event loop. It makes responsive GUI's very easy to create.

Always thinking asynchronously means your less likely to create synchronous render-blocking code which sucks for users.

Also the npm ecosystem and tooling is very easy to work with and easy to understand (everything is under node_modules not some globally installed binary)

It's great for small projects and websites, but anything that requires performance would probably be better in a compiled language.

> I like the way it's asynchronous first

This has been such a mistake, now it needs "await" all over the code.

Programs run synchronously and only needs to go async every once in a while but things get pretty verbose from it.

> This has been such a mistake, now it needs "await" all over the code.

Await is just a syntactic sugar, and quite a good one I think. You need to seperate async and sync functions somehow in order to prevent code from blocking the main thread.

> Programs run synchronously and only needs to go async every once in a while but things get pretty verbose from it.

Well I would argue that most things a program does (besides crunching raw data within memory) is asynchronous. Network requests, painting to screen, polling IO ports, fetching from the Filesystem, handling user interaction... these are all examples of asynchronous operations.

It's simpler to have a single-threaded event-loop rather than spinning up threads and keep track of them, preventing deadlocking etc...

A single-threaded event-loop also has the benefit of being incapable of dead-locking, as only one thread is accessing variables at any given point.

falsy, truthy, undefined and null...
I stricly use JS client-side. I like that it is flexible and not strict. It does not judge. You can get really creative with it. And I like to work with Event Listeners :-)
It provides an adequate compilation target for Clojurescript.. In seriousness, I don't like working in it much either. I think it could be an ergonomic language if one had the luxury of green-field projects with disciplined style to navigate around foot guns and tedium, but... Hell is other peoples' code.
Ubiquitous. Front-end, back-end, embedded and there's a node wrap for everything.
It's a nice language for code golf. Hazardous features like implicit type coercion and assigning to undefined variables can really help a chef portion out unreadable spaghetti onto very small plates.
I can run it in a browser. I can just open a browser on anyone's machine and we can start coding together.
I like I can build almost anything with it, from web applications to command line to desktop applications, to embedded scripts in almost any service.

I love it is asynchronous by default (and thus all its ecosystem is as well). As someone that had to deal a lot with thread pools, and semaphores and concurrency issues, this is invaluable to me.

I also like a lot the tooling. From VSCode support, to typescript, to eslint, prettier and despite people complain about large node_modules, I think NPM and the trade offs leading to that are very worth it.

I also really enjoy the availability of libraries... whatever you need, you'll find a popular package for it.

I like it because it's useful. It executes in a browser and manipulates the DOM. I don't think anything else can do that. Libraries like React allow me to reason about websites declaratively.
I think JS is a versatile and good enough language for many tasks. I use node for my backend services since there are sdk for everything now and why spend a few days of effort when it can be done in minutes? And the effort spent in a few minutes can also scale if necessary so again not a huge concern. Love it!

It’s a great place to start for many tasks. When things get slow or it’s not the right tool for the task, then it’s time to switch that piece to Go or Rust.