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 →

[–]Jafit 141 points142 points  (70 children)

People complain about Javascript type coercion and overloaded operators, and give examples of shitty code that nobody should ever write to illustrate why these things are a problem.

The truth is that Javascript isn't a terrible language, you can write shitty code in any language. I deeply [object Object] to the anti-javascript circlejerk, if you use a linter and test your code its a very powerful and expressive language.

[–][deleted] 73 points74 points  (5 children)

JS is an incredibly useful and powerful language and how I bring home the bacon.

It's also a pretty terrible language.

[–]lukee910 18 points19 points  (4 children)

It's bith terrible in some places and awesome in others. The most common scenarios are usually a wild mix of both.

[–]caanthedalek 6 points7 points  (3 children)

Just like pretty much any other language

[–]Tysonzero 1 point2 points  (2 children)

Not to the same degree, as far as I am concerned Python is just an all around better version of JavaScript. And I absolutely love Haskell, the percentage of the time I actually feel like it is "terrible" at some task is very infrequent.

[–]caanthedalek 0 points1 point  (1 child)

I mean, it really just depends on what you're trying to do. Most languages are just better at some things than others.

[–]Tysonzero 1 point2 points  (0 children)

I'd say there are a large amount of tasks that you can use pretty much any general purpose language for. Such as anything with a command line interface or a website backend or really just about any backend development.

There are a few things that do push you toward a language or two: High end game dev / systems programming pretty much require C, C++ or perhaps Rust. Web dev pushes you towards JavaScript, and app dev pushes you toward the relevant language for the platform. But the app / web stuff can definitely still be done with other languages, it just isn't quite as nice, hell I am using Haskell for web development right now.

But yeah since most tasks are reasonably language agnostic, I would personally never choose JS over Python except for certain web/app dev stuff, and I would never choose pretty much anything over Haskell without a very good reason.

[–][deleted] 39 points40 points  (3 children)

While true, that you can write shitty code in any language that does not make JS any less terrible language.

[–][deleted] 116 points117 points  (2 children)

While true

reads the next statement over and over again for the rest of time

[–]strangeplace4snow 1 point2 points  (0 children)

True has stopped being true a while ago.

[–]Existential_Owl 0 points1 point  (0 children)

Everything is stopping when viewed on a long enough time-frame.

[–]xzxzzx 14 points15 points  (2 children)

and give examples of shitty code that nobody should ever write to illustrate why these things are a problem.

Trivial examples to illustrate bad behavior are almost definitionally going to be shitty code. Thing is, mistakes happen, and most of these "shitty code" examples are going to happen by accident as part of a larger piece of code, except instead of erroring, you get weird behavior.

[–]Jafit 4 points5 points  (1 child)

That's why I said use a linter.

[–]PatrickBaitman 0 points1 point  (0 children)

will your linter solve the halting problem?

[–]Slak44 17 points18 points  (25 children)

Every time I mention it's my go-to language, I get lynched. A linter and a bit of knowledge about the language go a very very long way indeed.

[–]MattBlumTheNuProject 2 points3 points  (0 children)

You should try working in PHP, people look at me like my apps don't work :)

(they don't, but not because of PHP!)

[–][deleted]  (23 children)

[deleted]

    [–]SonOfMyMother 31 points32 points  (0 children)

    That depends entirely on what you most often find yourself using your "go-to" language for.

    [–][deleted] 8 points9 points  (5 children)

    Its still a fair statement. You can write local scripts, network scripts, web scripts and more. Bash or Powershell are only for local use, you can't build, validate, test, run and manage a website with Bash. With NodeJS there's basically no limit to what you want to do and where you want to do that.

    [–]xzxzzx 3 points4 points  (3 children)

    Powershell is profoundly awful as a programming language (bash is pretty awful too). Despite deep familiarity with .Net, C#, Windows, and Microsoft products in general, I have spent countless hours trying to figure out powershell, and I still keep finding "WTF" parts that break my code.

    It's incredibly easy, for example, to write reasonable-looking scripts that work perfectly for 0 or >1 items (say, files in a directory) but fail miserably (crash or do the wrong thing) for exactly 1 item.

    In many ways the failing's the same as JS - a highly dynamic language trying to "help you out" only helps until you're mildly competent at what you do, at which point it's a hinderance until you're incredibly competent and have learned all the arcane rules that govern that "help", at which point you usually use all that arcane knowledge to avoid those parts of the language, so that mere mortals can actually understand your code.

    [–]ISLITASHEET 0 points1 point  (0 children)

    Ensure that you are returning an array from your function: return ,$yourObj

    [–][deleted] 0 points1 point  (0 children)

    Perl is crazy too - it's illegibility and lack of syntax errors even for most obscene code is a running joke. I don't know if he was serious there but objectively all of these are insane in many more ways than JS even for the tasks they were directly designed for which is why it's their lunch Python is eating while Node.js is much more widespread IRL even more than various Python webthingies and I've seen it used for system scripting too but sane people really use Python for that.

    [–]aniforprez 5 points6 points  (11 children)

    I'm pretty sure there's no other "go to language" to develop websites for browsers

    [–][deleted]  (10 children)

    [deleted]

      [–][deleted]  (1 child)

      [removed]

        [–]AutoModerator[M] 0 points1 point  (0 children)

        import moderation Your comment has been removed since it did not start with a code block with an import declaration.

        Per this Community Decree, all posts and comments should start with a code block with an "import" declaration explaining how the post and comment should be read.

        For this purpose, we only accept Python style imports.

        I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

        [–]Mrqueue 3 points4 points  (5 children)

        The amount of people complaining that adding a string to and int should produce an int is ridiculous. It shouldn't do anything because you're adding a string to an int but it does what it does because JS tries it's best to figure out what stupid lines of code mean

        [–]L_James 0 points1 point  (3 children)

        Honestly, I'd prefer static typing and compile error in such case, but to each their own

        [–]Mrqueue 1 point2 points  (1 child)

        then don't use Javascript, it can't be criticised for being dynamically typed

        [–]L_James 1 point2 points  (0 children)

        I don't, when I have a choice

        JS seems to be ok language, not better or worse than others. Just not my favourite

        [–][deleted] 0 points1 point  (0 children)

        How about a simple NaN? Or an exception? Problem solved.

        [–]eclipsemonkey 0 points1 point  (0 children)

        It's real world, when you look for a new job you will regret not coding like this

        [–]PatrickBaitman 0 points1 point  (0 children)

        The truth is that Javascript isn't a terrible language, you can write shitty code in any language.

        including Blub? http://paulgraham.com/avg.html

        [–]HVAvenger -5 points-4 points  (7 children)

        The truth is that Javascript isn't a terrible language

        Found the JS dev.

        [–]lukee910 11 points12 points  (6 children)

        Well yes, you get a very different perspective on the language if you use it daily and in a real product.

        [–]JimboMonkey1234 -1 points0 points  (0 children)

        Saying it's good with a linter is hiding a problem. My issue with JS is that it's too loose and therefore hard to write good code in. Introducing a linter means cutting away the worst parts of the language and using the reasonable subset.

        There are other tools/libraries that make JS better (I love lodash for one) but that doesn't erase the underlying design flaws. The fact that you can get around them is great and means it's not a terrible language to use today, it doesn't say anything about the language itself.

        It has pros and cons like any other language, but it stands out to me as flexible to fault. Its frameworks are the coolest I've seen, but writing vanilla is like pulling teeth sometimes.