Live data from Hacker News

Ask HN: Help, I'm Drowning in JavaScript

news.ycombinator.com

51–56 of 56 posts

Re: Ask HN: Help, I'm Drowning in JavaScript

#51

Earlier quoted context omitted.

Thanks for the kind words. Slowly going into the water is my approach as well, but sometimes it just gets to me. My learning projects die on the hill, because of the frustration I have on the job with these techniques. Plus, overwhelming ecosystem. About my regex problem: This is a structual mess. JSON/XML with HTML code in the data fields. We process them and send them to multiple job boards. Our clients mainly use…

Thank you for the context! What you're doing is actually much harder than regular web dev. It's a specialized kind of data processing, often called a "extract, transform, load" (ETL) workflow. Most web devs don't need to do that, and that you're willing to tackle it at all just shows how willing to learn you are, despite the frustration. If you hate this situation, it's totally understandable lol. That kind of work h…

You are much appreciated. I didn't even know there is term for this part of my work.

Down the line, we do everything you cautiously described. We extract single fields with pointers (in lack of a better term, english is not my main language) to the XML/JSON fields we like to extract. Our software then lets us use JS snippets to manipulate the contents. Problem is, once you define a rule, it may get 80-90% over hundreds of datasets. But breakage is not an option most of the time. It's pareto principle work: 80% in 20% of the time, 20% work in 80% of the time. In the end, they are just snippets, then a giant gap, then the projects my colleague does.

I get where you are coming from, regarding "never to do that again". This not the only work I do. I also build HTML from customer demands, many of which are pdfs meant for print use, but not for the web. I like it, but I only scratch the surface of what might be. Thanks to the resources in this thread, I have a good insight of what to come. So, thanks again.

Re: Ask HN: Help, I'm Drowning in JavaScript

#52

Earlier quoted context omitted.

WTF, dude? I can’t even parse that enough to decide if it should get an up or down vote and I haven’t even tried regex.

WDYM WTF? He's clearly telling you that you can't parse HTML with regex. Don't even try.

s/He/She/

Re: Ask HN: Help, I'm Drowning in JavaScript

#53
post #34

Stop using regular expressions. Honestly, it sounds like you were having trouble with that, and blamed JavaScript. Regular expressions are the worst. Also if someone scraped web pages and then stored the HTML, that seems like a bad idea. You would want to actually extract the data at that point. Also regular expressions are the worst way to extract data from HTML. I think the real problem is the business model and te…

I would store the HTML as well for later purposes / hoarding

Re: Ask HN: Help, I'm Drowning in JavaScript

#54

Accept that your understanding of JavaScript is outdated. Appreciate you have at least some experience though. If you care to learn modern JavaScript, which you should, check out Eloquent JavaScript [0]. It’s a free web-based ebook providing an introduction to modern JavaScript. Also, stop with the negative narrative. You are overwhelmed, not helpless. Instead of telling yourself you don’t understand code and giving…

> Accept that there are black boxes that “just work”

This is pretty integral to my job and I’ve been in the industry for 11 years or so. You can’t know everything right away and it’s overwhelming to try to attempt to do so. Learning certain parts has its time. For now just focus on what is in front of you.

“Method X produces Y and that’s what I need” next step.

Re: Ask HN: Help, I'm Drowning in JavaScript

#55
> While I basically use if/else, he uses ternary operators. I write functions by hand, the uses arrow functions and symbols I can hardly understand.

What you are describing is commonly known as ES6 or ES2015 syntax. The language got some features at that time that solve gotchas related to using JS and arrow functions are a great example. These features make JavaScript easier to work with if you use them, and learning the most important ones doesn't take more than a day. https://www.boardinfinity.com/blog/top-10-features-of-es6/ After 20165, they only released like 2 features per year, and most of those haven't had the same adoption.

Arrow functions are a great example, as they don't have their own `this` and it makes the `this` keyword work how you think it should.

> ternary operators vs if/else

Sometimes new features make sense in a certain context. If/else makes sense if your code has actual branching, but if the assignment of a single variable is all you need to branch for, ternaries are great.

``` // classic JS let variable;

if (someCondition) { variable = 'foo'; } else { variable = 'bar'; }

// with ternary

const variable = someCondition ? 'foo' : 'bar'; ```

> We do not have the time to code review his projects.

That's crazy.

Ternaries are also a great example of a feature that can be abused. As conditions get more complex, ternaries become more opaque and are a worse choice. More concise code isn't necessarily better. This can be true for a lot of JS. Fancier code isn't better if the rest of the team can't understand it, and if you don't have a review system, you can't blame him for writing in his own accent and you not being able to understand. Developers on a team need oversight. I catch bugs my teammates write, and they do for me too. If you can't understand it when the PR is made, you're not going to understand it later.

So my answer to you is to try to start doing code review. Reading code is important, and a PR should be focused enough that you can track what a feature or bugfix is actually doing. If you can't, you should be speaking up.

> Also, he should not be my teacher.

Why not? What dev wants their teammates to struggle? I love helping more jr developers, and I've never had someone on any team bristle when I asked them to help me.

Re: Ask HN: Help, I'm Drowning in JavaScript

#56
PS. It's fine to stay old-school (until it finally isn't, but that's decades...)

https://news.ycombinator.com/item?id=31660869

Ask HN: Best alternative jobs for “outdated” skills with small websites/apps?

> you should be applying at small to medium-sized companies that are not tech companies. There's a ton of work in these companies and hiring is more focused on solving business problems

Post reply on HN