DEV Community

Discussion on: Simple code is different from simplistic code: Elm vs JavaScript

Collapse
 
marciofrayze profile image
Marcio Frayze

Hey Roman, thanks for your comment.

This article is a translation from my original post (in brazilian portuguese, my native language) so maybe that's causing some noise in the translation.

But to better understand what I meant as being "simplistic", think about this definition (taken from wordnik.com/words/simplistic):

"Simplistic. Adjective. In a manner that simplifies a concept or issue so that its nuance and complexity are lost or important details are overlooked."

So the goal is not to say that we all should use Elm (as I tried to say in the conclusions, I still use JS/TS on some projects, and that's fine), but to always try to find the simplest solution that do not overlook the important details.

Your idea of using a wrapper around fetch to make it safer is exactly the kind of thought I was hoping to rise. And using the definition of "simplistic" above, your idea (if well implemented) could be a nice and simple (not simplistic) solution.

But it may be a little tricky to create a wrapper that also handles the situation of a return in an invalid format, for example. Or a return where a field is optional, and so on.

Languages like TypeScript take a step toward trying to help in these scenarios. Elm takes many other steps in this direction. But which language to choose is not the central idea of this post. JavaScript is a good technology, but we need to act even more proactively on these potential problems in this language.

Collapse
 
romeerez profile image
Roman K

Thanks for explaining, so you wanted to show that ELM takes care of data integrity so developer can keep calm and this is why it's "simple". And if it makes sense to always validate JSON data from server instead of trusting it - that's another question, for developer to decide, depends on situation

Thread Thread
 
marciofrayze profile image
Marcio Frayze

Yes, but not just data integrity. That was just the main example, but Elm takes care of all possible runtime exceptions. All those errors on the browser console? They never happen when you are using Elm. A little too extreme? Maybe. But Elm makes it so easy that I believe the benefits compensate the efforts.

But as you said, it's for the developer to decide, and I agree. But it's important we make an informed and well thought decision.