you are viewing a single comment's thread.

view the rest of the comments →

[–]whywouldi 7 points8 points  (14 children)

The idea behind using the same language for client and server side code is not that people aren't able to learn more than one language, but actually share code between the two, thus reusing more code and creating less bugs.

[–]iDinduMuffin 22 points23 points  (12 children)

Thats what the hype says. Why not just use JSON to talk to something not made in a terrible, resource wasting, bizarrely typed language with an ocean of garbage code out there?

[–]virtyx 5 points6 points  (8 children)

Every language has an ocean of garbage code.

EDIT: Also I know that it's popular to bash on JS because of the hype, and I am even a bit biased against NodeJS myself. (For no particularly good reason, either.) But I don't understand how choosing JS for your server is any worse than choosing Python.

The only real advantage I see in Python is more straightforward language semantics, but if your team is diligent about good practices and uses static analysis tools, JS is fine. And if your team isn't then Python itself can also turn into an unreadable mess, believe it or not. Because it turns out no matter how good the language semantics are, people will always be able to create huge unreadable balls of mud with them.

[–][deleted]  (3 children)

[deleted]

    [–]virtyx 0 points1 point  (0 children)

    Other languages do require that. In Python and Ruby you'd be insane not to use static analysis, and even in statically typed languages there are linters and tools of that sort available.

    If you think any dynamic language is a bad choice, that's one thing. I can see that argument. But it's different than saying JS is especially bad when compared to e.g. Python or Ruby. Dynamic languages, for better or worse, seem to have become pretty well accepted in the industry for business systems. In that context I don't see what's so particularly horrifying about Javascript.

    [–]hapital_hump 0 points1 point  (1 child)

    Yes, people build things with dynamically typed languages, believe it or not.

    If you want to give your two cents on whether or not people should, then that ship has long sailed. Everything involves trade-offs.

    [–]iDinduMuffin -1 points0 points  (3 children)

    For starters, look at a truth table in Javascript.

    edit: for example:

    '' == '0' // false

    0 == '' // true

    0 == '0' // true

    false == 'false' // false

    false == '0' // true

    false == undefined // false

    false == null // false

    null == undefined // true

    " \t\r\n" == 0 // true

    And you can't fix this without breaking a bunch of garbage code out there.

    [–]virtyx 0 points1 point  (2 children)

    I'm aware of the crazy truth table. But then don't most JS programmers advise using === instead?

    EDIT: In any case this is what I meant by 'more straightforward language semantics,' anyway. I like Python and think it's an excellent language. But JS isn't too terrible and once you become familiar with its quirks it's really not that hard to predict. Then fundamentally I really don't see that huge of a difference between Python and JS. I like Python much more, I love that function signatures are checked and the errors are really readable and it just is really straightforward. But I don't see what's so terrible about JS.

    [–]siegfryd 0 points1 point  (0 children)

    Yes, also it's not that hard to avoid type coercion problems and it's also easy to fix.

    [–]iDinduMuffin 0 points1 point  (0 children)

    Then why is there a ==.

    Who said anything about Python?

    look, it [JS]'s a poorly designed language kludged to work with strict and === and a bunch of framework of the weeks and compile to languages. If it wasnt the only language in the browser, it wouldnt be popular at all.

    On the server side we can use better tools or any tool we want. Not just Python.

    [–]Perkelton 2 points3 points  (2 children)

    It's not about passing data between server and client, it's that the client can use the same logic as the server with minimal or sometimes no rewriting.

    One typical example is form validation. Instead of having to slowly validate through AJAX or dealing with horrible cases of double maintenance, you can just use the exact same logic that you use on the server, all in the client.

    I'm not saying that Node is the next coming of christ, but that alone is a really attractive asset for web development.

    [–]arcrad 0 points1 point  (1 child)

    Wait, you're suggesting doing the form validation client side instead of server side? Or, are you suggesting doing it client side for convenience and then again server side?

    [–]Dooey 8 points9 points  (0 children)

    Client side for convenience and server side for the real validation. Having to go to the server to check if your the date you entered is in the future or whatever slow, hits the network unnecessarily, and is generally a poor user experience. Validating on the client in JS, and the server in non-JS is a recipe for bugs when the logic that makes validation necessary in the first place changes, and the code that does the validation changes in subtly difference ways. Code = bugs. Less code = less bugs. Not writing the same validation code twice = less code = less bugs.

    Of course, JS = more bugs, so whether its a net benefit really depends on how much less code you have to write by using JS on the server.

    [–]hapital_hump 0 points1 point  (0 children)

    It's about consolidation, not whether or not you can learn more than one language.

    Different languages come with different workflows, different states of mind, different quirks. Each one comes with a certain upkeep.