News for hackers. Stuff that matters.
Re:Advice to my younger self: become allergic to the churn by rxhernandez on Thursday August 08, 2019 @10:58AM (#20645158)
I mean I haven't been a professional for multiple decades but I've written professionally in a very wide range of fields in C, Matlab, Java, Python, Verilog, Assembly, Fortran, and Javascript, and, there is no language that I've seen that has more hair pulling, braindead I just learned to program yesterday type programming nearly as much as I've seen in Javascript.

(I've worked intimately with decades old scientific programming codebases where the scientists didn't give a single damn about writing cleanly and even that was an order of magnitude more readable than the willy nilly, consistency be damned crap I've been seeing in Javascript)

(I feel like I could describe a small portion of hell for me and it would include Javascript)

Re:Advice to my younger self: become allergic to the churn by IggleSniggle on Thursday August 08, 2019 @12:03PM (#20645737)
It's all about who is writing it and why they are writing it, not the language. Well ok JavaScript has some legacy warts, but ECMAScript 2019 enables a variety of very well written code in a variety of styles, and TypeScript is icing.

As for me, I've only recently entered the JavaScript game, but the php I've seen has been much, much worse. I find the quality of JavaScript I typically encounter is on-par with typical Python code, and a fair bit better than the Frankenstein monsters of dev-ops code that often has a different convention for each line of bash (with attendant third-party applications) mixed in with inscrutable environment states as you shift in and out of various orchestration layers that have zero sense of application hierarchy or even running processes.

I've seen scientific codebases too, but the thing you're getting there is an authorship that is often small-team (1 or 2) and very slow to shift, with highly enculturated domain context. Of course JavaScript code is going to be a mess in organizations where you have devs coming from vastly different contexts and staying a max of 2 years with a team where all you care about is getting the pretty graphic on the screen.

Re:Advice to my younger self: become allergic to the churn by fao_ on Thursday August 08, 2019 @02:11PM (#20647000)
> It's all about who is writing it and why they are writing it, not the language.

But who is writing it and why they are writing it are inextricably linked with the language. Every language has a culture and a reason for existing, those are pressures that bear as much on the person writing the language and the code produced as much as the person writing the code does on the code and the language.

Whether or not say, modern Java encourages good code is neither here nor there, as not only is there resistance to learning new things there is resistance to using the new things properly. Java has a history of bloated, inefficient code for a reason, and when you use Java, the abstractions you use will alter the code that you write. It's impossible to get away from 'bad code' without rewriting things, and then you're not coding your new project you're rewriting someone else's. It's also 'good practice' to use x y z language idioms, but there are cases when such idioms make the code much harder to read and much less clean.

As an example from C: I like POSIX, but dirname and basename are two ridiculously shit functions. If I choose to use them, the rot starts infesting my code, and everything that deals with them has to account for that, which itself causes a bias towards more obtuse code.

Re:Advice to my younger self: become allergic to the churn by Xelbair on Friday August 09, 2019 @05:38AM (#20652736)
>It's all about who is writing it and why they are writing it, not the language. Well ok JavaScript has some legacy warts, but ECMAScript 2019 enables a variety of very well written code in a variety of styles, and TypeScript is icing.

Good languages kinda enforce some kind of basic rules, and prevent developers form making silly mistakes - because we all do them all the time. Those languages usually trade off the performance for safety though.

We should pick the safest language, that prevents errors and mistakes as long as we stay within allowed performance bounds.

JavaScript can be performant, but most of the times it isn't and it isn't safe at all. At least we have typed variants of JavaScript.

JavaScript by design was meant to fail gracefully - in the background - so the site works fine. Sadly nowadays sites are so JavaScript heavy that it isn't helping at all.

I generally prefer statically typed languages just because there is less ambiguity and function definition can help you greatly - you know what you put it, and what it returns.

With dynamic typed languages unless documentation is pristine(and in JavaScript ecosystem it is pretty varied from package to package) you are out of luck unless you look at the implementation.

bash and devOps code has their own special place in hell. bash has only one advantage - it works on any linux distro out of the box, and that's it. It is unreadable untyped mess.

Re:Advice to my younger self: become allergic to the churn by test6554 on Thursday August 08, 2019 @12:20PM (#20645888)
Seconded on php. I have used php, I can use php, I just choose not to any more if I can help it.
Re:Advice to my younger self: become allergic to the churn by iratewizard on Thursday August 08, 2019 @06:26PM (#20649507)
Smart choice. I opted to stop accepting php jobs several years ago and life has never been easier.
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.

Re:Advice to my younger self: become allergic to the churn by vinceguidry on Thursday August 08, 2019 @12:49PM (#20646147)
The only thing JavaScript was ever even barely good for was that which it was designed to do, be the programmable interface for a browser. Why anyone would want to do anything else with it simply boggles my mind.

It's like if someone took the BASIC my calculator offered back in the day and turned it into a general purpose programming language.

Re:Advice to my younger self: become allergic to the churn by heavenlyblue on Thursday August 08, 2019 @01:13PM (#20646371)
But JavaScript's got asynchronous!
Re:Advice to my younger self: become allergic to the churn by robocat on Thursday August 08, 2019 @04:14PM (#20648202)
A race to the "promised async hell".

I wonder how many devs are struggling to debug and fix bad code written using Promise and async features. With care you can use these features safely and productively, but it is also very easy to make subtle mistakes that cause intermittent faults or strange corner case errors.

Re:Advice to my younger self: become allergic to the churn by heavenlyblue on Thursday August 08, 2019 @07:42PM (#20650068)
The comment is a reference to a phrase “It’s got electrolytes!”.
Re:Advice to my younger self: become allergic to the churn by andrewprock on Thursday August 08, 2019 @02:14PM (#20647039)
So was Windows 95.
Re:Advice to my younger self: become allergic to the churn by ourlordcaffeine on Thursday August 08, 2019 @12:14PM (#20645850)
For me, R probably has a worse rate of churn than javascript in the case of breaking changes. Javascript is full of hyped frameworks, but R is the only language I've used where a minor update to a package caused an entire project to break (because the package author had changed its api)
Re:Advice to my younger self: become allergic to the churn by bsder on Thursday August 08, 2019 @05:44PM (#20649142)
> there is no language that I've seen that has more hair pulling, braindead I just learned to program yesterday type programming nearly as much as I've seen in Javascript.

I would argue that anything for phones is similarly braindead.

While the languages are okay, the API's, UI idioms, and general ecosystem seem to have a half-life of about 6 months. If you step away from programming phones for 18 months, it's like you're learning everything from scratch.

(Side note: All right, Groovy should be taken out and shot and the idiot who foisted it on the Android build system needs to be taken to the woodshed and beaten severely.)

Re:Advice to my younger self: become allergic to the churn by zmmmmm on Thursday August 08, 2019 @11:44PM (#20651177)
> Groovy should be taken out and shot and the idiot who foisted it on the Android build system

I think your beef there should really be with Gradle, or at least, how it is using Groovy. The way Groovy is implemented as a DSL for Gradle is, in my view, toxic. Almost everything is implicit behavior, crucial aspects rely on totally incidental "magical" features that just make things happen when you invoke some cryptic incantation that has an unobvious connection to its context.

Groovy itself is pretty good and IMHO much better than Java for most purposes.

Re:Advice to my younger self: become allergic to the churn by heavenlyblue on Thursday August 08, 2019 @07:45PM (#20650083)
Idk - there is definitely a difference between learning about React and a completely different way to do programming.

If you were any good 12 months ago - you will pick up any of the trends quite easily in a week or so (partially because you have also predicted the future).

Re:Advice to my younger self: become allergic to the churn by mighty_bander on Thursday August 08, 2019 @12:23PM (#20645920)
It's such a shame! JS could be a concise little language with a lot of power (in terms of being able to ignore types until they matter), but instead you end up transpiling unusable garbage with 10MB string manipulation libraries that release breaking changes as patch versions. Python is what JS is supposed to be, although I do feel like Bart Simpson in front of the blackboard every time I write `lambda x:`.
Re:Advice to my younger self: become allergic to the churn by bro25 on Thursday August 08, 2019 @04:20PM (#20648258)
Being a small language would be irrelevant to JS. The web could benefit from a sound type system built into browsers (aka typescript in the strict mode), but it's not like anybody complains about python lacking the type system, right? What web really needs is a way to write highly modular apps and let the browser download only relevant modules, with caching, prefetching and so on. None of the attempts have worked so far. If you look an any app today, it looks like the main module that has static deps on other modules that deoent on other modules and so on. When everything is linked together, we get this 50MB binary. Not a big deal for native apps or services, but it's a big deal for web apps that need to download all this mess and maybe actually use 20%. There is no way today to conveniently write a web app that would pull only necessary modules at runtime. It's not just that the language is missing some keywords, it's about the entire web world is designed around static linking: we'd need to redo existing non modules, existing frameworks, upgrade to http2 for batching multiple requests to download a bunch of small modules and so on. That's a lot of work that needs a lot of expensive devs and the returns of that work are non existent: there's no profit to be made there. That's why it'll stay this way: bloated web apps with thousands of unused deps.
Re:Advice to my younger self: become allergic to the churn by nesadi on Friday August 09, 2019 @07:33AM (#20653321)
> anybody complains about python lacking the type system.

Well, Python does have strong typing. It's just dynamic, not static, and I've seen enough criticism about it to say that it isn't as unimportant as you make it out to be. JavaScript gets a lot of criticism for having dynamic and weak typing. And I think both forms of criticism are valid, though not everybody agrees, which is fine too.

Re:Advice to my younger self: become allergic to the churn by bro25 on Saturday August 10, 2019 @03:53PM (#20664162)
What makes webapps bloated is the require-at-the-top pattern. Type system makes no difference here. What most devs don't realize is that if their precious app written in holy C plus plus or Java got compiled into a standalone binary that could run on any device inside a browser, it would be a 150 MB mess that wouldn't even boot. All these nice frameworks, libs and utils would need to be downloaded before the app can start. We'll see this soon with wasm, btw.