Show newer

@aschmitz @aescling @vaporeon_ I once used a JavaScript array as a queue, using the shift method to pluck elements from the start of the array. Of course, this means iterating over an entire "queue" should be slow, since every call to shift causes every element in the array to be reassigned and reduces the size of the array by 1. I benchmarked my algorithm and it was slower than I hoped, so I immediately worked on the queue as I thought it was a throttle for the algorithm.

I made an object that effectively had a JavaScript array as a private variable and created a method for "removing" the first element from the array. In reality, there was pointer being tracked by the object that simply shifted to the right by 1, simulating the behavior of a queue with an ordinary array. Obviously iterating over this structure should be O(n).

To my surprise, when I benchmarked the algorithm again, it was slower. Evidently, with my first approach, the JIT engine realized I was using an array as a queue and secretly optimized it for me. Without realizing, I tried to outsmart the JIT engine, and lost.

@vaporeon_ you know pokemon, Linux, C, and that america is bad you know the important things you're good

@vaporeon_ IF THE APPLICATION IS COMPLICATED. for simple little teeny things there are plenty of awesome Python libraries

@vaporeon_ it has nothing to do with Python and everything to do with the fact that all of the Python frameworks for desktop application development are not good yet

@vaporeon_ we built a desktop application with Python, which I can say from experience is an absolute nightmare and you shouldn't do it

@aescling @vaporeon_ I fucking loved the one lisp-like language I learned in college

@vaporeon_ I did actually get used to it but I felt the same way when I first starting using Python lol

@vaporeon_ it's a scripting language that looks like Java

what JavaScript sounds like it's supposed to be, is what Groovy actually is

@vaporeon_ nested python ternaries are things the devil itself would write

@vaporeon_ you'd be stunned by the performance that JIT engines can achieve these days, they can get stuff that is close-ish to Java sometimes

Most people who do it write the codebase in TypeScript, which is a language that looks a hell of a lot like JS but it strictly typed, and is compiled to JavaScript (I have extremely mixed feelings about TypeScript)

There is just a huge cost to running a server with JS though (either you use a JIT engine which has a significant memory cost or you don't and get a huge performance cost), which makes me hard-pressed to ever consider it for a web server

@vaporeon_ I love JavaScript so I have mixed feelings about it

Show older
📟🐱 GlitchCat

A small, community‐oriented Mastodon‐compatible Fediverse (GlitchSoc) instance managed as a joint venture between the cat and KIBI families.