Is it just me or it is harder to write readable code in javascript (especially in oop paradigm)
For further actions, you may consider blocking this person and/or reporting abuse
Is it just me or it is harder to write readable code in javascript (especially in oop paradigm)
For further actions, you may consider blocking this person and/or reporting abuse
James -
nobody-99 -
Truong Phung -
Charan Sajjanapu -
Top comments (4)
I think the main reason why it is so difficult about writing clean code is us, developer.
I often heard people saying that being lazy is not good, unless you are a developer. And most of the people out there have learned to adopt this moto without good reasons. There is nothing good at being lazy in our field of work. But instead of being lazy we should be smart.
Because lazy would mean writing a library that takes the least amount of work to be done. I see many libraries brag about being the fastest, about being the easiest to use. That's great really I don't mind that. But if that comes at the cost of the maintenance and the bugs that are created, leaving us a night of debugging because there has been a lack of runtime type checking in a chain of library calls, I would rather prefer a code that is 10x slower and that is reliable to use than that.
And most of the time this is what we saw:
Instead of this:
And that saddens me a lot. Because JavaScript itself has nothing wrong. No languages are perfect. Unfortunately, the path that JavaScript has taken (being an overly accessible and easy language for beginners to pick) has probably made it one of the most misused languages of all time.
Plus the fact that it tries to be both an object-oriented (but it is not since it is prototype-based) and a functional (but it is not, or at least not entirely) makes it even more difficult for newcomers to chose between the two to write good APIs. Also, the language itself does merely nothing to help us make the smallest amount of mistakes since it does not have type system baked into the language to do type checking, compared to TypeScript or Elm for instance.
So yeah, maybe JavaScript has gained its popularity because it is very easy to learn the basics of the language compared to TypeScript or Elm again, and it has contributed to the popularity of the Web ecosystem lately, but I think that now that its popularity is no more to justify, it should thrive for robustness and reliability.
But this is only my opinion, and I didn't have this opinion when I was a complete beginner since it was an opportunity for me that the language was so easy to learn and be productive with. Anyway, there is no very good answer to that question, we can only see that through the prism of our own experience and tell our own vision of what a language should be.
thank you for your response. i often look at the opensource project at Github, for projects which are written with php or python it it easier to read and it takes less time to understand what it is for. but when it comes javascript , i think javascript's oop approach is not what it should be, i mean in my opinion it lacks of oop principles. when i wrote code in a procedural style , other people read and understand it a lot easier but when i do it with oop paradigm, it is harder for them to read it. i think that another reason is manupilating dom with js. generally when i write a script without any DOM interactions is it much more easier to read and extend it
I agree with all of your points.
JavaScript prototype-based was one of the hardest points and I spent a long time understanding it coming from C & C++.
Recently, with the ECMAScript standard, they tried to make it look like a real OO language by adding some keywords like
class
orstatic
but it is just syntactic sugar over this prototype-based programming paradigm. And since they are two different concepts, this OO emulation in JavaScript is nowhere near complete compared to PHP or C++.In my opinion, it was a huge mistake. They should have gone to a more procedural path, or even functional, it would have been far easier to take, again still in my opinion.
It's funny how I can relate to your comment. I feel less lonely now. Haha!
No, I don't think...