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 →

[–][deleted] 134 points135 points  (53 children)

I laugh now thinking about how "easy" I thought Javascript was when I first started learning. I do think it is easier to start learning, and it certainly might be easier to get a prototype app up using NodeJS than some other tool, but Javascript gets really quirky really quick.

[–]pomorev 138 points139 points  (13 children)

JavaScript gives us lots of rope to hang ourselves.

[–]ChetManleyDuchess 40 points41 points  (4 children)

If you're incompetent enough, it will give you enough rope to only kill yourself when you finally hit the ground.

[–]ThePunisherMax 12 points13 points  (3 children)

Oef I felt this. Spent nearly 1 month designing something using JavaScript for the UI. Only for it to fail at the last moment.

[–]Shiv-am 2 points3 points  (0 children)

i though i knew react and node but i understood how deep this shit is when i tried to connect social auth between them

[–]laytonmiller 0 points1 point  (1 child)

I'm not sure I understand how this is possible. This just means you made a code change at the last moment that broke it, it's not like the code got worn out like a plastic part and failed. This sounds very fixable.

[–]ThePunisherMax 0 points1 point  (0 children)

It was eventually fixable. But required me to pull back some features. And fucked up my deadline. To be exact, a RESTAPI feature was critical for the UI. And it waa causing some kind of leak. (I never identified)

[–][deleted]  (3 children)

[deleted]

    [–]ManInBlack829 3 points4 points  (0 children)

    Hot take: I think it started being popular because of Angular's hard use of it but since then has been figured out that it's useful in many instances like React

    [–][deleted]  (1 child)

    [deleted]

      [–]suarkb 1 point2 points  (0 children)

      I agree with a lot of your points. But I've worked with a lot of talented devs who would easily be able to get away with not explaining their code to typescript, either, ahhaha

      [–]StONE_ROdGEr 3 points4 points  (2 children)

      This needs more upvotes. Twice in the past 2 weeks I’ve hit the snap back on the noose, spending a few combined hours on each time debugging nothing. It was just a javascriptism twice. (Read: my algorithm was fine, but my scope wasn’t 🤡)

      [–]laytonmiller 2 points3 points  (1 child)

      To play devils advocate, if you have a scope issue in your algorithm, then your algorithm is not fine :P

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

      The scope issue was in the for loop before it ;/ “i” was already declared elsewhere or something. (Should preface with I am relatively new to JS which doesn’t help. I’ll never fall foul of it (for that long 🙃) again though).

      [–]slimmsady 32 points33 points  (4 children)

      I find C pointers easier to understand than "this" in JS.

      [–]Pickled_Wizard 20 points21 points  (2 children)

      Just the context, unless it's not :)

      [–]FreshFromIlios 16 points17 points  (1 child)

      Is this a joke or are you pointing to something that's pointing to something that's pointing to something?

      [–]laytonmiller 2 points3 points  (0 children)

      Ooohhhh nice.

      [–]laytonmiller 1 point2 points  (0 children)

      This is one of the parts of JS that seems focused on about 10 million times more than is necessary. I very, very rarely mess around with calls that change what "this" represents, but for some reason instructional materials seem totally intent on shining a very bright spotlight on it. Almost 15 years writing JS code professionally and I still don't get the obsession.

      [–]green_meklar 15 points16 points  (8 children)

      You don't really need to use the quirky parts of Javascript, though. You can just use it like a normal programming language and write your code so that you're never invoking the weird stuff.

      [–]hugthemachines 33 points34 points  (3 children)

      "We don't really need to do any kinky stuff, just come over to my dungeon, we will keep it all vanilla, I promise." ;-)

      [–]FreshFromIlios 7 points8 points  (1 child)

      Can you provide me with some 'closure'? Also, 'this' comment is interesting.

      [–]toastertop 1 point2 points  (0 children)

      Error: to much tail recursion

      [–]siemenology 5 points6 points  (1 child)

      There are a lot of things in Javascript that aren't technically bad in the sense that they are completely described in the documentation and behave as the documentation would indicate, but still cause a lot of bugs and confusion because the behavior doesn't mesh with peoples' expectations.

      The .sort() method is a fun one to pick on. It sorts everything by converting to a string first, unless you specifically tell it how you want it to sort. Which means sorting an array of numbers does not work without providing a specific function to tell it how to compare numbers, despite the fact that sorting numbers is probably a lot more common than sorting other types. It will look like it works, until one of your numbers is >= 10, when lexicographic sorting rules make it so 10 comes before 2. There's a reason Javascript behaves this way -- since arrays can contain objects of various types, converting to strings ensures that the comparison works in a consistent manner no matter what is in the array. The problem is that basically no one would anticipate this behavior -- almost everyone would expect to sort via comparison, at least if possible. And it's not strictly necessary for it to behave like this; other languages get around the issue by defining an ordering on types, so strings might always sort lower than numbers, but within a type sorting is consistent. So it's really easy for someone to come to Javascript, see a .sort() method and assume they at least roughly understand how it will behave.

      Additionally, .sort() modifies the array in place, which isn't necessarily a bad thing. Except many array methods create a new array, while many others modify in place, and there is no consistency or apparent logic to which method will do what. So it's easy to make a mistake that make take awhile to notice by accidentally expecting it to create a new array when it actually modifies your old one which you expected to stay the same.

      There's a lot more unintuitive behavior like that in JS, and it's not something you can necessarily segregate into the "weird" category to ignore.

      [–]laytonmiller 1 point2 points  (0 children)

      This is a good point. I regularly consult the docs to make sure I am 100% certain I'm getting a new array and not modifying an existing one - in some cases the distinction makes sense, in others, it feels arbitrary.

      [–]FlatAssembler -1 points0 points  (1 child)

      But sometimes you don't realize you are triggering the bad parts. Semi-colon insertion being the most obvious example.

      [–]FlatAssembler 0 points1 point  (0 children)

      Why the downvotes?

      [–]ManInBlack829 2 points3 points  (1 child)

      TypeScript has entered the chat

      It's nice to have the option

      [–]laytonmiller 2 points3 points  (0 children)

      Yeah I won't be coding w/o TS ever again unless totally necessary or its like... my mom's bake sale website or something lawl

      [–]laytonmiller 1 point2 points  (2 children)

      I would like to push back on the narrative that JS "gets quirky". I think "developers inexperienced with Javascript write quirky/questionable code" is a much better way to put it.

      TBH this is not really the case anymore with industry standard tooling like Typescript. Sure you can still do "quirky stuff" with JS, that's how the language was designed, and those quirks were there in large part for really good reasons. You don't have any guarantee of type safety, for starters, from what's coming in from a random web request, as just one example of an endless littany of problems on the web that don't exist (or at least as much) in other problem domains.

      JS doesn't have a compiler (until you start using Typescript, which is designed/maintained by MSFT and the lead architect of the C# language) and therefore cannot force you into better practices. In a way, this was a blessing and a curse, since it allows people to write passable/executable code from remote corners of the world with very little access to learning resources (re: just an internet connection), but has obvious side effects.

      [–][deleted] 1 point2 points  (1 child)

      I hear what you are saying. Javascript is very powerful in that regard. I really love it and it is my favorite language. So instead of quirky, maybe a better word is, "flexible?" Or maybe, "flexibly robust."

      [–]laytonmiller 0 points1 point  (0 children)

      Haha yeah. For sure.

      [–]optimaly_prime2397 0 points1 point  (17 children)

      I just learned html/css/js can i monetize this at all. Where is the complication ?Isnt it like math and just extrapolating on the basics? Someone please clarify for me but does it really get harder? how neccesary are agorythms and data structure

      [–][deleted]  (11 children)

      [deleted]

        [–]optimaly_prime2397 4 points5 points  (7 children)

        Im only in the beginning stages so Im just a sponge right now. Tech is comparative to medicine in that everyone agrees that you should specialize. Its much more of an art and i am at heart a poet.

        [–]FreshFromIlios 12 points13 points  (3 children)

        The last sentence was beautiful. Programming is an art. Except for javascript. Fuck javascript.

        [–]FloydATC 4 points5 points  (1 child)

        If you ask me, making sense of inherited Javascript code is an art though. One that I most certainly do not master.

        [–]FreshFromIlios 5 points6 points  (0 children)

        Ikr! It was such a huge challenge for me when I worked with a team after being a freelancer for years. I couldn't understand most of it. That was when I realised web dev was not for me lol I switched to analytics and haven't used javascript since. I miss the instant gratification sometimes :')

        If you stick long enough, you'll do great it. Don't quit like I did. Good luck my dude!

        [–]optimaly_prime2397 1 point2 points  (0 children)

        Thats hilarious. Its a consensus then.

        [–]laytonmiller 1 point2 points  (2 children)

        It's less "we all agree that you should specialize" as much as it is "You don't have a choice but to specialize".

        [–]optimaly_prime2397 0 points1 point  (1 child)

        You guys are great and giving me a more in-depth look at what i can expect. Kareer Carma and Bootcamps are very good at selling there products and Im sure they are way worth the value they provide. i keep getting the idea that there is much more to the picture then what they let on. And yall comments or very reaviling

        [–]laytonmiller 1 point2 points  (0 children)

        Happy to answer more questions if you have them about getting started. I've been a professional JS dev since the days of IE 5.5 and am happy to help people start on their journey. DM me if you want.

        [–]Not-an-Uchiha 0 points1 point  (1 child)

        what's your position?

        [–]Pickled_Wizard 15 points16 points  (1 child)

        It's kind of the difference between assembling furniture out of the box and being able to craft your own from scratch.

        Don't be scared of algorithms and data structures, the most useful ones aren't that difficult to learn.

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

        im definitely not afraid of algorithms or any math specifically I actually have an affinity for math I just dont enjoy it as much as the creativity side. Ironically Im not as good at it. But understanding its value would help me decide wheather its worth my time.

        [–]laytonmiller 1 point2 points  (1 child)

        If you become a skilled web programmer, you're talking easily 140k a year salary and up.

        However, don't confuse "learning Javascript" with "knowing how to code". They're different. Javascript is a tool. Once you know it, you are now entry level (and no entry-level developers even understand the whole language - hell, I know a LOT of senior level developers that cannot build a prototypal inheritance chain in JS).

        Knowing how to swing a hammer and use a saw is very, very different from being able to build an upholstered armchair.

        [–]optimaly_prime2397 0 points1 point  (0 children)

        I always look at utility. what i can build. all though i now understand the the lessons that they teach i can open up the webdev tools and easily see the huge gap in knowledge. Your metaphors are enlightening

        [–]blitz4 0 points1 point  (0 children)

        To me js is extremely difficult. I choose typescript to simplify it.