Submitted by twovests in just_post

Using JavaScript and it's like, huh, this just feels like a good programming language and could fit in the same spots as Python.

I've only ever seen it used in websites, webapps, and in Gnome shell extensions.

But like, it's a whole ass programming language! It's really similar to Python since it's interpreted and dynamically typed, but also it ties in tightly to webdev.

Bonus points that it runs in the browser, so on practically any modern machine with a keyboard, you can fuck around in the dev tools with a nice JS repl.

Does anybody here use JavaScript for anything other than websites and webapps? If so, what do you do with it?

5

Comments

You must log in or register to comment.

emma wrote (edited )

Haven't tried it yet, but apparently you can write DOS programs in JS. I honestly had a hard time wrapping my head around this when I first heard about it, because "JS interpreter" and "16-bit OS" don't mix in my brain.

As for why JS isn't more popular, Python has been around a hell of a lot longer, and JS has only caught up to other languages in the past few years.

4

twovests OP wrote

Right? I can't articulate what weird mental blocks I had about JavaScript but it's over 20 years old but I feel you entirely on that "hm JS on DOS? wack".

1

emma wrote

Arguably node.js and its standard library is what made JS practical as a general purpose language, and that's only been around for about a decade.

3

voxpoplar wrote

I think there's multiple factors to this. Part of it is Javascript itself. It has confusing and weird behaviour from being a language that for long time didn't so much have a standard as a bunch of different implementations in various browsers that converged on each other while collecting various unintended or undocumented behaviours that became standards simple because if they were changed it would break people's websites. There's also a bunch of reductant ways of doing similar things in it that are kind of confusing.

Here's a talk showing some weird unexpected behaviour. There's reasons for all of this stuff, but they're unintuitive and confusing at first glance.

Then there's the fact that web browsers are generally designed to be really forgiving. Webpages don't generally crash no matter what nonsense you put in the Javascript. The browser will allow the tab to do whatever you want with various values. This means it's very easy for people to make mistakes and not realise they've made them. Or to copy around code without really understanding what it's doing and just tweaking it semi-randomly until it does approximately what they want.

So while Javascript doesn't exactly make it hard to write good code, it makes it extremely easy to write incredibly awful code. Code that's impossible to understand, has lots of side effects or basically only works by accident.

So there is a lot of very very bad Javascript in the world. And for a long time there were not very good tools for working with it other thank text editors and then running it in a browser. Which made debugging Javascript absolute hell. There are better tools now but crying while not being able to understand why the webpage is doing what it was doing is a lot of people's experience with Javascript. And there's still a lot of Javascript that's not written with newer tools or written badly with those tools.

And even with all the better tools that exist now the language itself still lacks a lot of things. It's not really dynamically typed so much as there's a system for building objects that resembles a typing system. There's no inheritance. There's no interfaces. It's very limited and frameworks need very hacky systems in order to work. Using things like React to me feels very weird and like you're fighting the language a lot to make it work.

Then there's also just general dislike for the state of the modern web and what has been built with Javascript. I run NoScript in my browser because the vast majority of websites are much more pleasant to use when you don't let them run Javascript. Because the Javascript they run is mostly just for spying on you and making using the website slower and worse when all you want is to read a fucking article.

And finally there's a lot of criticism of the modern Javascript development ecosystem as it were. I don't have much skin in this game and don't have much opinions on it but the left-pad incident in particular spawned a million blog posts of people questioning how much web developers relied on jenga towers of hundreds of dependencies that could be doing god knows what.

4

voxpoplar wrote

Also if you're used to Python and go into your browser console and type print(thing) to try and get its value it brings up the print document dialogue in the browser which I find very funny.

3

twovests OP wrote

Oh I love these "weird JS behavior" talks and they're probably the reason I felt "Hmmm" in the first place about JS. (And the dependency issues you mentioned)

So while Javascript doesn't exactly make it hard to write good code, it makes it extremely easy to write incredibly awful code

This is an impactful takeaway

2

musou wrote

javascript is an OK language to use for some things, but it has a lot of annoying aspects that make it difficult or just unsuitable for many kinds of programming. for example, there is still no real integer type in JS, which means arithmetic is potentially subject to floating point rounding errors, so it's very easy to shoot yourself in the foot if you're having to operate on, e.g. amounts of money, or other applications where precision is absolutely critical.

it's also the case that most (but not all) js libraries and frameworks are written without much regard for mutable state - which makes sense given that the original context for the language is inside the browser, where the Document Object Model basically treats the entire content of a web page as a giant global variable that can be accessed and mutated from anywhere in your program. this can make large js applications, even those not running in a browser, very difficult to debug when something goes wrong.

it also lacks good language-level primitives for concurrency compared to some other languages, which is something that is becoming increasingly important as CPU clock speeds aren't really going to be getting much faster anymore, and program authors need to spend more time making sure they're making good use of all the CPU cores available. i spend most of my programming time writing code that targets the erlang VM, and the lack of a first-class primitive datatype to represent processes/threads is the feature i miss most of all when working in JS.

3

twovests OP wrote

Ooh I have nothing to add but I appreciate this perspective, esp. as someone who hasn't done anything real with concurrency

2

bea wrote

there is still no real integer type

the language always had proper signed and unsigned 32bit int support, though tbf it was boxed in 64bit floats, now we have BigInts

lacks good language-level primitives for concurrency

I guess "good" is the key word there but just in case I'll mention that we have: Workers in the browser and Worker Threads in Node.

2

[deleted] wrote (edited )

−2

bea wrote

why do you always have to be so mean about everything :/

2

no_defun_allowed wrote (edited )

I had a quote by Erik Naggum but then I remembered it's Alan Kay's 80th birthday, so I should celebrate by flaming using something he said.

[JavaScript] is another example of filling a tiny, short-term need, and then being a real problem in the longer term. Basically, a lot of the problems that computing has had in the last 25 years comes from systems where the designers were trying to fix some short-term thing and didn’t think about whether the idea would scale if it were adopted. There should be a half-life on software so old software just melts away over 10 or 15 years.

2