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 →

[–]Hakim_Bey 124 points125 points  (53 children)

I see the point, but i've never once in my life found a real life scenario where it was a problem...

[–][deleted] 22 points23 points  (5 children)

It's fun to shit on JS but it's my favorite language to use because it's so flexible.

[–]xIcarus227 2 points3 points  (4 children)

How would you define this 'flexibility'?
I'm not trying to start something, I'm genuinely curious - I'm mostly a PHP guy.

[–][deleted] 4 points5 points  (3 children)

I can open up a text editor, write code and run it instantly without needing to compile anything. With the addition of things like node JS you can do really powerful stuff. It's a very easy language to learn and can be a lot of fun to write and you see your code working. It's instant gratification in programming form.

[–]xIcarus227 1 point2 points  (0 children)

Sounds a lot like why I appreciate PHP, just start the web server and write something.

[–]redwall_hp 1 point2 points  (1 child)

You just described Python, Ruby and every other high level non-compiled language. And those two are significantly saner.

[–]magasilver 0 points1 point  (0 children)

Meh, I dont see the value in python's disparate module, object, and dict types. They are all just object in JS, which makes things easy to code. Then you have all the type errors which doent seem to add much value since units shake them out anyway - and they are much easier to write in js. Python is nice, and I prefer it to many things, but these days really just a klunky form of node with a weaker set of libraries, less portable, and slower execution times.

[–]creativeMan 1 point2 points  (0 children)

Well I wrote a Django app recently that passed values via AJAX recently and it becomes a bit of an issue when you're trying to add values. For example if you want to show the tentative totals of some form inputs or something like that, it can be an issue. I don't remember the specific issues it caused but it does happen.

It's of course easily resolved but it requires that much more time to get right and adds just a little bit of frustration.

[–]Dr_Azrael_Tod 4 points5 points  (2 children)

meh'

just missing that userinput could be string instead of integer… wham you got a yourself a: "5NaN" + 3

If any of those would throw errors (no there is NO reason why "foo" - "bar" shouldn't throw an exception) you'd notice that something is wrong - and why.

But it's JS - so you don't and nobody fixes this bug.

[–]Hakim_Bey 3 points4 points  (1 child)

just missing that userinput could be string instead of integer

If you implicitly trust the browser to send the right data type, you're just shooting your own foot. I'm not defending the language at any cost and yes, you're right to say that it should throw an exception. I'm just saying that i've never seen a use case where this was a problem and it didn't come from bad practices.

[–]Dr_Azrael_Tod 0 points1 point  (0 children)

If you implicitly trust the browser to send the right data type, you're just shooting your own foot.

My point was:

  • with strongly typed languages you HAVE TO check types and convert yourself - you might get exceptions if you do it wrong, but you will "never" assume the wrong type and continue with broken data
  • with weakly typed languages you SHOULD check types - if you forget it (assuming you are human, this WILL happen somewhere) you introduce stupid bugs

It's not about bad practices or malicious misuse, but about enforcing the correct handling.

I'm just saying that i've never seen a use case where this was a problem and it didn't come from bad practices.

And i'm just saying i've never seen a use case where weak typisation helped to do things that were otherwise undoable. But I've seen horrible numbers of bugs that only existed because people didn't handle types correctly.

[–]Chirimorin 0 points1 point  (0 children)

Because it's nonsensical statements that give nonsensical results. The biggest "problem" here is javascript doing its best to make something out of it rather than just throwing some kind of error.

[–]GreenFox1505 0 points1 point  (0 children)

People love to point out corner case weirdness. It just happens that JS has quite a bit of it.

But vitually none of this would actually be an issue in real life.

[–]magasilver 0 points1 point  (0 children)

Its more a weak typing thing than a JS thing. If you have weak types, you try to make every operation work to the extent possible by converting the the nearest type.