Hacker News new | ask | show | jobs
by always_good 3141 days ago
It's hard for me to take these comments seriously unless you feel this way consistently across most other dynamically-typed languages -- at least it'd be consistent.

I've used most dynamically-typed langs at this point and I've run out of reasons to use something aside from modern Javascript if I would have originally used Clojure or Ruby in the past.

Though it feels sheepish to reward your low-effort comment with a response.

2 comments

I still find a lot of reasons to use Ruby, though like you I spend a lot of time doing JavaScript in places I wouldn't have a couple years ago. (For a long time I've been anything-but-JavaScript, but I was also using JavaScript before it was cool--somewhere on a hard drive somewhere is a JavaScript implementation I wrote as a scripting layer for a game I was working on in like 2006...)

My experience with API design in JavaScript is that it still kind of sucks. It's not the worst, that wonderful spot goes to PHP, but it's distinctly harder to get something usable and maintainable done than Grape/Ruby. Probably worse than Flask/Python, too. The Swagger tools out there for JavaScript aren't very good and none of the lesser-used alternatives seem any better; maybe it's the stateful/metaprogramming-friendly nature of Ruby, but `grape-swagger` is really nice and nothing comes close in JS, at least not that I've found.

Data representation worries me, too. I have not yet found a decent `grape-entity`/`representative` library in JS (think a `grape-entity` or a `representative`). On top of that, SQL library support out there is pretty bad, Sequelize being the best I've found but much worse than Ruby's Sequel or even ROM. Sequelize is still frustrating and clunky.

I'm also uncomfortable dealing with money and financials in JavaScript, in part because of the lack of a BigDecimal/fixed class that I feel like I can trust (as I'm not really qualified to judge the implementations of the billion gems out there). A standard library I feel like I can trust is still out there, somewhere.

If all I have to do is plop out an endpoint, then JS (shouts, Express!) is as easy as it gets, and that's fine. But these days I need more, I want my tools to help me with it, and I don't really have time or inclination to build them, either.

If I'm missing any that are worth checking out, though, by all means, I'm very interested.

I don't like ORMs or abstractions like grape-swagger. I like working with the node-postgres client and knex when I need a query builder.

It sounds like if that's the sort of kit you want, then Ruby is for you compared to Clojure/Javascript.

What I do like about Javascript is that it's easy to write ad-hoc types via Typescript for my SQL functions to specify the shape of the data that comes from the database. I would never go back to something like Active Record that tried to make me canonicalize all of my data.

I have to wonder if these are more identity-level ecosystem differences.

I'm very confused as to why you don't care for "abstractions" like grape-swagger. Do you enjoy writing API client boilerplate?

As far as ORMs go, I'd certainly prefer not to use Active Record ones, but I also don't want to have to update my code when somebody else adds a field that I don't care about. My representations specify what I care about and how it should be presented to clients (for example, hashids rather than integer primary keys); I update them only when there's a new field that I care about. I can do this with functional mapping but the database boilerplate sucks more than Sequel does (it's a big part of why I've dropped ROM, though I much prefer it in theory). Computers exist to help me do less programming, not more, and what you describe is more programming for, to me, little benefit.

Money comes in integers. Any function that works with monetary values needs to eat integers and output integers.

This is not pedantry, it's a real-world constraint.

I thought your "real-world constraint" existed too. Then I had to keep track of thousandths of a cent.

When you have experienced the "no, a cent is no longer granular enough" problem, the conversion of DECIMAL(7,2) to DECIMAL(9,4) and the attendant code compatibility is something you'll appreciate.

That's what fixed precision types are: integers + a scale factor -- whether it's cents, mils or something else.

Javascript does badly need a native fixed precision type beyond "everything is a double" or some web assembly hack.

And I like Javascript, but this is a real problem.

Curious, for server side, why do you prefer JS over Clojure? (I assumed by your comment that you would still prefer modern JS already knowing Clojure. Maybe I misinterpret?)
Right, I would generally prefer JS over Clojure on the server side these days. Or, rather, I would default to JS and then possibly disqualify it based on my needs (like team composition).

I spent over three years using Clojure and eventually learned how unimportant technical superiority is for most of my projects. For example, the first time I met a co-founder and they simply weren't interested in using Clojure. Well, that was easy.

JS has major upsides like ubiquity and I'm-already-using-it-in-the-browser and its simple concurrency model that aren't so easy to paint over.

I'm not saying everybody should default to JS like I do. But I think a lot of these avoid-JS-at-all-costs posts need to update their intel. For example, JS has pretty great static analysis compared to anything I've used in the other dynamically-typed languages. It's also one of the few where gradual typing actually caught on.

For all its upsides, its warts aren't any worse than things like the overuse of metaprogramming in Ruby or the aversion to FP in Python or the tooling dependencies of Clojure.