News for hackers. Stuff that matters.
Re:Advice to my younger self: become allergic to the churn by tomgp on Thursday August 08, 2019 @11:52AM (#20645636)
I have a similar set of experiences but have a feeling that it's at least partly down to the sheer number of people writing Javascript and the very public nature of much of that code that so much of it is a mess. I don't think there's anything inherent in JS that make is produce messy code other than the fact that it's easy for amateurs to get results (thanks to the fact it runs in a browser and there's lots of easily available code samples).
Re:Advice to my younger self: become allergic to the churn by tenaciousDaniel on Thursday August 08, 2019 @12:02PM (#20645729)
I'm a JS dev and I love it, but JavaScript is to programming languages what the electric guitar is to musical instruments.

It's the thing that attracts a lot of new beginners who may or may not be interested in the more serious theory that makes programming what it is.

Re:Advice to my younger self: become allergic to the churn by _bxg1 on Thursday August 08, 2019 @01:41PM (#20646685)
Agreed. I've gotten to where I don't like it as much for really large projects - TypeScript helps a bunch but is inherently limited by aspects of JS itself - but there is absolutely no language I'd rather sketch something out in.

The core data types actually strike a really excellent balance between representing the major distinct paradigms (named collections, unnamed collections, strings, numbers, booleans) while giving you maximum flexibility within them. Its standard library - array functions in particular - has become very mature. FP and OOP concepts are both quite well-supported, and doing async stuff (client or server or otherwise) with promises just smashes every other language I've used in terms of ergonomics.

Much of the above could be said about Python too, but regardless.

Re:Advice to my younger self: become allergic to the churn by tenaciousDaniel on Thursday August 08, 2019 @01:51PM (#20646781)
Yeah definitely, it's amazing for scratching together ideas. Though at a certain scale, it starts to feel pretty fragile. I don't have much experience with other languages but the explicit interface/implementation paradigm that Objective C used was so amazing to me (as someone who started out in JS). I find myself missing it every now and then, especially for large projects.
Re:Advice to my younger self: become allergic to the churn by rxhernandez on Thursday August 08, 2019 @12:05PM (#20645756)
Have you worked in other languages for substantial amounts of time?
Re:Advice to my younger self: become allergic to the churn by filoleg on Friday August 09, 2019 @01:59PM (#20656805)
Yep. Python for many years, Java+TurboPascal+C# for a couple of years, C+Matlab for a bit under a year, and a few other ones that I wouldn't list simply due to how little work I've done in those.

TypeScript and Python (with typehints) are the current favorites. Golang seems to be getting up there for me too, but I don't have enough experience with it to actually be able to say that.

Re:Advice to my younger self: become allergic to the churn by celim307 on Thursday August 08, 2019 @01:17PM (#20646417)
I used kotlin, golang, and ruby for multiple. not a huge sample of languages but i still like es6 javascript the best
Re:Advice to my younger self: become allergic to the churn by tenaciousDaniel on Thursday August 08, 2019 @12:22PM (#20645913)
I did Objective C for about 1-2 years, and a bit of java over the years. But no, not really.
Re:Advice to my younger self: become allergic to the churn by rxhernandez on Thursday August 08, 2019 @01:13PM (#20646380)
Fair enough. Thank you for taking the time to a question that, in retrospect, sounds antagonistic (apologies for that).
Re:Advice to my younger self: become allergic to the churn by tenaciousDaniel on Thursday August 08, 2019 @01:34PM (#20646600)
Nah, I didn't take it that way
Re:Advice to my younger self: become allergic to the churn by marshray on Thursday August 08, 2019 @01:51PM (#20646793)
Also, it's used with high levels of added distortion.
Re:Advice to my younger self: become allergic to the churn by LargeWu on Thursday August 08, 2019 @03:21PM (#20647675)
I agree that there's nothing inherent that makes it produce messy code, but it also doesn't really promote good code either.

There's half a dozen different syntaxes for importing/exporting functions, creating functions, creating objects, etc., and it's all fair game. Then there's the asynchronous nature, so sometimes it's async/await, and sometimes it's promises, and sometimes it's callbacks, sometimes all happening in the same function.

And then on top of that there's all the front-end web frameworks which are like, totally un-opinionated, man, except for the parts where they're implicitly super opinionated.

Re:Advice to my younger self: become allergic to the churn by imesh on Thursday August 08, 2019 @02:19PM (#20647097)
I have made a few Wordpress sites for customers that required me writing Javascript and PHP code as I learned them for quick features and fixes. In other words, I had to write Javascript and PHP code before I even considered myself a programmer, I basically copy-pasted and edited until it worked.

I imagine that accounts for a lot of bad Javascript and PHP code. By the time I wrote any C++ or Python professionally I had a CS degree and a decade of programing experience.

Re:Advice to my younger self: become allergic to the churn by MiroF on Thursday August 08, 2019 @12:07PM (#20645775)
what killed Javascript for me (and I think many others) is that there is no idiomatic way of writing Javascript. There is no "javascript"-y way of doing things (unless you count callback hell).

I'm not saying that a language should only offer one approach to a problem, but there should be general guardrails and guidelines. A shared vocabulary. None of that exists in modern JS

Re:Advice to my younger self: become allergic to the churn by _bxg1 on Thursday August 08, 2019 @01:35PM (#20646611)
The same criticism (which is a valid one) is doubly true of Lisp, but Lisp doesn't take half the flak that JavaScript does.
Re:Advice to my younger self: become allergic to the churn by marshray on Thursday August 08, 2019 @01:54PM (#20646825)
"There are only two kinds of languages: the ones people complain about and the ones nobody uses."

- Bjarne Stroustrup

Re:Advice to my younger self: become allergic to the churn by vkou on Thursday August 08, 2019 @01:54PM (#20646817)
That's because there's three or four orders of magnitude more JS code out in the wild, then there is Lisp code.
Re:Advice to my younger self: become allergic to the churn by bobthepanda on Thursday August 08, 2019 @04:45PM (#20648528)
The problem is that the original paradigms were pretty terrible but JS has to keep (as much as reasonably possible) backwards compatibility to not break the web. If you forked JS and made changes to clean it up that weren't backwards compatible, you'd have a hard time convincing browsers to take it, making the whole exercise sort of moot.

The fact that we have things like the Wayback Machine is a testament to how this approach, while terrible for developers starting out or working in a legacy codebase, has enabled us to preserve what is now a significant portion of contemporary cultural history. AFAIK there is no similar archive of programs for, say, Java or C.

Re:Advice to my younger self: become allergic to the churn by mceachen on Thursday August 08, 2019 @01:41PM (#20646680)
"Standard" [1] and "Airbnb" [2] seem to capture some amount of sensible guidelines. Adding Prettier [3] gets you something akin to gofmt, and adopting standard eslint rules [4] can help too.

[1] https://standardjs.com/ [2] https://github.com/airbnb/javascript [3] https://prettier.io/ [4] https://eslint.org/

Re:Advice to my younger self: become allergic to the churn by MiroF on Thursday August 08, 2019 @02:26PM (#20647166)
You're talking about style, I'm talking about idioms. Those aren't the same thing!
Re:Advice to my younger self: become allergic to the churn by mceachen on Thursday August 08, 2019 @07:05PM (#20649807)
I think idioms and style have some level of overlap.

Semicolons could be considered idiomatic or stylistic, for example. Requiring strict equality operators feels more of an idiomatic way to avoid bugs, rather than simply whitespace. Eslint certainly has a number of rules that are more idiomatic than stylistic.

If you're touching on the lack of consistency in, say, open source javascript, I agree, code is all over the place. Also, I think you're looking at a language that has had dramatically more evolution (especially in recent time) than most other popularly used languages. Old code without promises and suffering from callback hell feels archaic.

However, I think if you look at, say, TypeScript repos (which is cheating, I know, it's not javascript), there is more homogeneity, at least from what I've seen.

Re:Advice to my younger self: become allergic to the churn by heavenlyblue on Thursday August 08, 2019 @07:40PM (#20650057)
>> language that has had dramatically more evolution

Of course it evolved. It’s easy to evolve if it was literally nothing in the first place.