Hacker News new | ask | show | jobs
by eksemplar 2857 days ago
We had a lot of trouble doing things without typesafety and declarations, so we tried a few things. Elm was one of the better ones, and we migrated a few minor systems to it. A few others to typescript and we even made a few pocs with Xamarin and Wasm.

Then one of my older employees randomly watched “JavaScript the better parts”, and recommended it to me and we’ve been doing classless JavaScript ever since.

Elm is great, certainly one of the better alternatives, but now it really feels like a step backwards.

1 comments

What is classless JavaScript? I don't understand how you had trouble doing things without typesafety but found that going from JavaScript to Elm is a step backwards? Maybe I'm missing something here?
https://web.archive.org/web/20151029152324/http://ericleads....

https://weblogs.asp.net/bleroy/crockford’s-2014-object-creat...

Once you start doing this, most other languages become obsolete. Because you avoid most of the problems of JS that things like elm try to fix, while maintaining the freedom and also writing a lot less code because you don’t have to write a “recipe” for half the things you write.

The disadvantage of JS is that it’s actually going in the wrong direction. Class is an attempt to copy C-style languages, and that really what you don’t want to do, because as soon as you use inheritance, the “this” keyword or “new” you’re basically doing JAVA/C#/whatever with all the downfalls of JS.

Many people (myself included) have never meaningfully used the OOP elements of JS you are referring to. The approaches listed above are common JS patterns and ones that I and I think most JS devs have used extensively.

However, they don't really solve any of the problems that Elm sets out to try and tackle. Do you have any examples?

Also these patterns certainly do not make any other languages obsolete, and as far as I'm concerned it doesn't solve _any_ of the problems with JS that people complain about.

JS vs Elm simply cannot be reduced to "classes".

Classes is only a tiny part of what's broken in JS.

TS (coupled to "JS, the good parts") saves the day though, but I have no idea how avoiding classes also somehow made you abandon the usage of a type system (whether Elm's or TS's) It all seems so unrelated.

Your comparison doesn't make any sense. You would use a language like Elm/Purescript/Reason etc for the type safety, that's completely orthogonal to whether something has classes or not.
Except you don’t need typesafety when you do this because you’re never expecting a specific type, and at the same time, you don’t have to waste time writing the recipe for what you’re going to do.
You're always expecting a specific type, whether the type or schema is made explicit by the language or not.
That's not classless. It's just class using factory instead of constructor for object instantiation.
> What is classless JavaScript?

Sounds like old school javascript. Either just functional programming or prototype inheritance.

I had to find out: this is Douglas Crockford on it: https://youtu.be/DxnYQRuLX7Q?t=2734