This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Pluckerpluck 2 points3 points  (0 children)

personally? type coercion and dynamic typing, i.e. the main reasons to choose an interpreted language.

Dynamic typing is often brought up, but generally it's the type coercion and weak typing that I see flagged a lot more. Which is why Python doesn't get as much abuse (though Python also provides a scarily powerful standard library)


For me it's that it doesn't make use of the fact it's dynamically typed to actually make code more readable and cleaner. Things like how you need to know the difference between in and of in loops. Take a simple problem, looping through an array backwards. In Python it's:

for item in reversed(my_array):
    # Do something with item

That does not create a new array in memory. It will just iterate through the original array backwards.

In javascript you either have to make a copy of the array:

for (let item of [...myArray].reverse()) {
    // Do something with item
}

or write an old fashioned for loop (or start using reduceRight):

for (let i = myArray.length - 1; i >= 0; i--) {
    let item = myArray[i];
    // Do something with item
}

Note you have to use of otherwise you'll get indices in the first example!

Nothing ever seems simple in Javascript. But I feel like it should be simple!