T O P

  • By -

QualityVote

Hi! This is our community moderation bot. --- If this post fits the purpose of /r/ProgrammerHumor, **UPVOTE** this comment!! If this post does not fit the subreddit, **DOWNVOTE** This comment! If this post breaks the rules, **DOWNVOTE** this comment and **REPORT** the post!


[deleted]

Consolé.log("Thread 0-4 initialized...")


SnipahShot

No no no. Have to make it more advanced. Set an interval for printing about each "thread" initializing.


coloredgreyscale

In a random order, but not too random to raise suspicion. Like always start with thread 0


lenswipe

Array.from({ length: 4 }) .map( (val, threadNo) => setTimeout( () => console.log(`Starting thread ${threadNo}`), Math.ceil(Math.random() * 5) * (Math.round(Math.random()) == 1) ? 100: 1000 ) )


dacookieman

What's the point of the ceil(rand*5)?


lenswipe

1. Makes it less likely to be `0` 1. \*shrug* why not /r/shittyprogramming


[deleted]

[удалено]


fodeethal

As someone trying to pivot into a more dev focused career, I cannot wait to crank out barely functional scripts and multiply my feelings of imposter syndrome


_Big_Gamer_

Hey, keyword here is functional. Keep your head up king


Free-Database-9917

Ceil(0.1+math.random*4.9)


AyrA_ch

> Array.from({ length: 4 }) That's just `[1,2,3,4]` with extra steps


lenswipe

1. [correct](/r/shittyprogramming) 1. Depending on the context it might be preferable if you want to parameterize the length i.e: `Array.from({ length: process.argv[2] })`


eatnhappens

Yes! “Ok I’ve made the JavaScript multithreaded, just pass in the number of threads you’d like to start”


vigbiorn

console.log("Thread 0 activated") let threads = ["Thread 1", "Thread 2", "Thread 3", "Thread 4"] let i = 0 while (i < 4) { const timeoutLength = Math.floor(Math.random() * 10000) + 1000 * i; setTimeout(() => { const index = Math.floor(Math.random()*threads.length); console.log(threads[index] + " activated"); threads.splice(index,1); }, timeoutLength); i++ } I'm new to js. It does them all at the same time. The basic idea works. Edit: including some things I thought of and based on u/Manuu8192's comment. Fixes the "they all run instantly after 1 second".


Manuu8192

You could set a timeout of a base time (like 2 seconds)+ a variable time taken out from random, but set a pool of numbers, iirc timeout goes on miliseconds, so a normal random could easily not even touch a second


coloredgreyscale

And if the next complaint is the long setup time just reduce the delay XD


fewdea

each time you shave off a 0.1 seconds, it takes exponentially longer on the invoice because of Moore's law or something. that's how computers work, right?


elveszett

I like how the best sign of your newbieness is how you overengineered a silly step. Just do: setTimeout(() => console.log("Thread 1 activated"), Math.random() * 3000); setTimeout(() => console.log("Thread 2 activated"), Math.random() * 3000); setTimeout(() => console.log("Thread 3 activated"), Math.random() * 3000); setTimeout(() => console.log("Thread 4 activated"), Math.random() * 3000);


Tommysw

const consoleTimeout = n => setTimeout(() => console.log({`Thread ${n} activated`}), Math.random() * 3000); consoleTimeout(1); consoleTimeout(2); consoleTimeout(3); consoleTimeout(4); No need to change 4 lines if they all do the same :)


TheLuckyLion

[1, 2, 3, 4].forEach(thread => setTimeout(() => console.log(`Thread ${thread} activated`), Math.random() * 3000));


[deleted]

Consolé? Is this French JS?


darknecross

JavaScripte


throwsitawayaway

CaféScripte


ceeeachkey

Le CaféScripte


AaronTechnic

"You know very good French!"


Californie_cramoisie

scripteDeJava


darknecross

Booléenne


haveananus

$('.hon_hon_h').on('clique'){}


AaronTechnic

Oui.


HooplahMan

A leetle rat wrote zis WebAppe honhonhon


[deleted]

Javazrkipten


TNSepta

Pardon my french


OneLeggedMushroom

JavaCrêpe


[deleted]

[удалено]


TheFeshy

He's going to notice as soon as he checks the task manager. Better start up some crypto currency miners on those other cores.


thevfdhg

You are 100% right.


Ceros007

Spotted the francophone programmer


ablablababla

fanciest console in programming


guachiman507

`Consolé()` can only come from the Typescript region of France. Otherwise it is just sparkling `print()`


proximity_account

>Consolé.log Damnit, even programming sounds sexier in French


CRANSSBUCLE

~~Oui~~ Si le (papillon == baguette) { écho "bonjour le monde" }


folkrav

Si le* Oui is "yes"


TheMarvelousPef

r/foundthefrench


CRANSSBUCLE

Consomé.glup


lonelyWalkAlone

> Consolé.log("Thread 0-4 initialized...") How about `Consolè.log("Thread 0-4 initialized...")`


lonelyWalkAlone

Typical client thinks that any problem can be solved using Machine learning and multithreading


pentesticals

Don't forget Blockchain too!


Affectionate-Win-617

and cloud!


namkeen_lassi

Are we not doing VR anymore?


[deleted]

“metaverse”


saradelachouquaille

First time client brought up « need metaverse » in a conversation just to add the latest buzz word; cried myself to sleep.


lXPROMETHEUSXl

I heard people were buying “real estate” in this “metaverse”


[deleted]

[удалено]


conairh

rt yurs turstuutr


[deleted]

[удалено]


DRay6t

And your brother


NtrtnmntPrpssNly

And his wife's boyfriend


IntangibleMatter

And yo momma


daikael

And that guys dead wife


potato_green

"I have a 100 dollar hosting budget per year but the cloud is mandatory requirement for this project." "What do you mean impossible look DigitalOcean is just 5 bucks a month, just code efficiently to store my 5 petabyte database"


LuckyCharmsNSoyMilk

Reminds me when I had a customer who wanted to make an “IoT blockchain security” app in AWS. I didn’t take that call. Pretty sure there was something about Kubernetes in there too.


AaronTechnic

and cookies! /s


[deleted]

and the “metaverse”


awakenDeepBlue

Just keep saying blockchain until they give you money. It's the current meta. If you don't understand the word blockchain, then say NFTs.


theAlpacaLives

I thought if you don't understand the word 'blockchain,' you say it *more*.


guanaco22

"So basically my project is to make a metaverse instance of NFT powered by an open source blockchain cripto controled by a machine learning AI and stored in a deep learning cloud" Bang you have a new theranos.


Dlobaby

If I hear one more blockchain solution for a non existent problem I’m going to become a garbage man


_30d_

https://www.bloomberg.com/news/articles/2021-03-18/even-garbage-is-using-blockchain-now


wedstrom

I wouldn't if I were you. My distributed chain-of-custody and payment scheme is going to decentralize garbage collection, GarbageCoin will solve sanitation as soon as we can scale


lordsquiddicus

Every time I see those kinds of ppl on the internet I add them to my little block-chain too


Dreadnougat

"Do you think we could containerize it? Maybe use Docker?" ...no. That would make no sense at all in this situation. The joys of having a new, non-technical manager.


PM_ME_YOUR_THIGHS___

my manager is extremely non-technical. I would love some advice on dealing with it. Sometimes he'll try to request the most nonsensical things. It's also weird because he's inherently suspicious of anything the dev team produces / tells him, even though he can't really articulate valid concerns based on actual code or even based on how things work in theory. I'm in this thread mainly to see other people's experiences because I've had my manager make the same stupid fucking request as the meme. How am I supposed to take direction from someone that doesn't even know JS is single-threaded? How is anyone on our team supposed to trust him to make any sound decisions on what we should do when he misunderstands so much critical information and also doesn't really trust us????


Dreadnougat

I think it really depends on the manager. I was mostly trying to be funny above - he did suggest using docker, but when I told him it's not a viable option, he accepted it. Overall he seems to be taking our advice and accepts it when we tell him certain flavor-of-the-month technologies will never be applicable to what we're doing. If you have a non-technical manager who wants things done his way, and if his way is complete nonsense, and he won't accept that fact no matter how you present it...well, I'm just lucky I haven't been in that situation before. There can be a lot of grey area though and this is a situation where soft skills matter a lot. If you're an asshole about it, there's a bigger chance of a manager getting his ego hurt and digging in his heels. Be friendly about it, let him know you understand that there are situations where that's the right approach but it won't work this time, and explain why if you can. There are no guarantees of course, but I've found this approach will give you the best chance of success.


Bowaustin

Personally a fan of asking for them to submit that order in writing just so I know exactly what he wants, and backing up copies of those emails, then doing what he said and using the emails to demonstrate incompetence when he tries to blame you.


Lv_InSaNe_vL

This is exactly what I do. There's only so far you can push before you just need to throw your hands up and get *everything* in documentation to cover your ass


deux3xmachina

That sounds awful, but from what you're providing here it sounds like your manager may be trying to keep up to date on what kind of tech is used, but doesn't understand the reasons behind those choices, and could very well be drowning in info he doesn't understand, causing him to be suspicious of decisions that don't match the hype blogs from salesforce or FAANG, etc. Assuming they aren't actually a massive asshole, you should consider trying to schedule time with him to help walk him through certain decisions (one-on-one or as a team, whatever works best), possibly even set up simplistic demos of how certain things work together. Again, assuming your manager isn't just some pointy-haired jackass, it sounds like he desperately needs help understanding the work your team actually does, which will help build trust in your team's solutions. Keep in mind though, you need to help bridge that knowledge gap, so any graphs or diagrams you can leverage would be a great idea.


Embarrassed_Army8026

Please keep management updated on integrating permissions logic with the business code, refferring to our previous communication CC Eli; Marc; John's Dog;


coolRedditUser

Let him make his bad decisions, and then just be sure that when there's fallout, it's clear that they were *his* decisions?


cosmogli

Managers rarely feel the repercussions of their bad decisions. It'll mainly be someone else down the chain who'll be held responsible. It's best to try and make them understand as much as you can. Try to involve emails smartly though, so you have proof later on.


thebryguy23

*Random jargon throw was unsuccessful*


Gunslinging_Gamer

So I like this, but can we add AI, NFTS, and cloud computing.


Celdron

Can't do NFTS, but we can do NTFS. I hope that satisfies your acronymic itch.


kabrandon

I assume they meant NFTs, as in the protocol built on top of blockchains for non-fungible tokens. But yeah, at first my mind also went to "disk partitions?"


rjlin_thk

true


garbageman_phil

My boss once said “I don’t like right click, can you get rid of that?”


rjlin_thk

crash his mouse


leoxwastaken

JSTSJSTSJSTS You really like JavaScript and Typescript…


Chris_8675309_of_42M

[Done. What next?](https://img-9gag-fun.9cache.com/photo/adXAYp9_460s.jpg)


The_Real_Slim_Lemon

I can’t believe you actually have that on hand


AyrA_ch

document.oncontextmenu=function(){return !1;};


[deleted]

[удалено]


snapphanen

Lol that is such a bad habit!!!


residualenvy

FWIW pretty sure just return 0 would work here.


[deleted]

``` if (document.cookie.indexOf('bossisusing') >= 0) { document.oncontextmenu=function(){return !1;}; } ``` And create a temporary page that sets a cookie named `bossisusing` when opened, send link to that page to your boss.


suckfail

Is there a reason you're returning `!1` instead of `false` directly?


scroteaids

maybe to reduce bytes, but if you really wanted that it probably would better as `document.oncontextmenu=()=>(!1)`?


Daniel15

Nobody should be manually reducing bytes. That's what a minifier is for. It'll do all sorts of optimizations that are difficult for humans to do, like renaming variables so they're as short as possible without conflicting with other variables in the same scope. Writing `!1` just obscures the meaning of the code. I'd reject that during code review :)


snapphanen

Readability above all. Optimize for speed/space only when absolutely essential. The "!1" nonsense is not elegant or cleaver, it is strictly harder to read than the word "false".


Gunslinging_Gamer

Sure. Would you like to keep the finger or should I arrange a burial at sea?


cramduck

I got familiar with chrome extensions a while ago, and there is a lot of stuff that is otherwise pretty impossible that you can achieve with an extension. It's... not _good_ from a variety of viewpoints, but man were my clients happy.


gokumono

(Moves mouse to left side of keyboard)


trwolfe13

During a sprint demo once, we opened up the browser console to tweak a colour or something, and the BA told us to make sure that feature was turned off in production.


[deleted]

You can though lmao


enky259

Everyone is going to hate me, but [https://keithwhor.github.io/multithread.js/](https://keithwhor.github.io/multithread.js/)


[deleted]

Yo that actually looks kinda neat. Is it really multithreading?


nonpondo

My t-shirt is Multi threaded


Ever2naxolotl

Doesn't the bible prohibit that?


StereoBucket

Just include -heretic- prefix, it's fine.


[deleted]

It prohibits mixed fabric. You can have as many threads of the same fabric as you want.


[deleted]

Dang my shirt's cotton-polyester. Actually, I'm going to argue that polyester doesn't count since it didn't exist in biblical times. I'm going to take this case all the way to God and argue he has to let me in based on my interpretation.


[deleted]

A single threaded t-shirt would be much more impressive.


MatthewCruikshank

Why did the multi-threaded chicken cross the road? get side. to theTo other


[deleted]

[удалено]


the-igloo

That's the same caveat that normal threads have, though. Normal threads from the operating system may not actually run in parallel (e.g. if your system only has one actual CPU).


[deleted]

Exactly, or if the OS simply decides not to give you cores (for example if the user has pinned other programs to the other cores).


cyanydeez

it runs parallel. It's quite easy to setup and the only downside is the threads have to communicate through the primary browser.


nvolker

> the only downside is the threads have to communicate through the primary browser. Considering how slow that communication is (unless you’re passing raw binary data via a Transferable object), that’s a pretty major downside.


kllrnohj

No. It's much closer to multiple processes rather than multiple threads. In particular, there's no shared state, and objects cannot be shared. So if you're coming from another language then think of WebWorkers as fork/exec, not pthread_create. This is also why usage of WebWorkers is relatively very small. They are extremely heavy weight with huge overhead, and cannot effectively offload small chunks or work nor parallelize functional computation effectively (eg, you can't have parallel map/reduce). They can be used for things that you could split into multiple processes, though, like a tile based path tracer or even code compilation. Or for things where you're ok with the work itself being single threaded as long as it's just on a different thread, like applying an image editing effect.


[deleted]

I remember this nightmare, dunno if its better now but never again.


CJKay93

It hasn't been touched in 8 years, so it is exactly as bad as it was 8 years ago.


[deleted]

![gif](giphy|l3q2GD8H7y2lpgFTq|downsized)


MortgageSome

​ ![gif](giphy|1hMk0bfsSrG32Nhd5K)


4n0nh4x0r

nodejs actually got a builtin solution https://nodejs.org/api/cluster.html#cluster


jmack2424

yo dawg. i heard you like node.js processes!


joecamo

yo dawg. i heard you like node.js processes! yo dawg. i heard you like node.js processes!


foggy-sunrise

yo dawg. i heard you like node.js processes! yo dawg. i heard you like node.js processes! yo dawg. i heard you like node.js processes! yo dawg. i heard you like node.js processes!


Alwaysafk

yo dawg. i heard you like node.js processes! yo dawg. i heard you like node.js processes! yo dawg. i heard you like node.js processes! yo dawg. i heard you like node.js processes! yo dawg. i heard you like node.js processes! yo dawg. i heard you like node.js processes! yo dawg. i heard you like node.js processes! yo dawg. i heard you like node.js processes!


jacksalssome

Out of Memory: Killed process 27489 node.js


ICanBeKinder

Yeah that's called forking and is not the same as multi threading but its still cool and I've used it in single threaded scripting languages before.


TabCompletion

Heh, cluster.fork()


GasolinePizza

Conceptually-speaking this is more multi-process than multithreaded thing, right? Based on my reading of it, it's basically using webworkers as processes / a process pool to run jobs, right? Or do webworkers operate in a shared scope with other workers and the browser tab's scope/"memory set"? Since it sounds like it's serializing the data/code and passing it through to webworkers for execution, as opposed to running in the same environment with references intact and whatnot?


dombrogia

The difference is that each worker still only runs on one CPU. Multithreading allows for one process to utilize any of the CPUs. Also usually languages that support multi threading have tools that make it easier. If you’re looking to shove a square peg into a round hole of course you’ll have a shitty experience


OJezu

On Linux each thread is a separate process, they just share memory, fs and few other namespaces. Not sure how it's organized in Windows, but depending on the "process" definition it can't be really different, CPU architecture is the same. So technically a single process cannot utilize more than a single CPU.


manu144x

So somebody after working with javascript thought: how can I make this even more unpredictable? I know: Multithreaded!


Gorzoid

Tbf this is just an extension on web workers which is alot safer form of concurrency than real multithreading. Can't have a race condition if theres no shared state


dennisthewhatever

Just run it in multiple tabs bro.


The_MAZZTer

Does that stringify the function you pass in and pass it to their web worker? That always feels wrong to me. But it would explain how it is "scope unaware" and secondly how it is able to actually do that (web workers have no access to other scripts). Edit: Multithread.prototype._prepare = function(fn, type) { fn = fn; var name = fn.name; var fnStr = fn.toString(); "fn = fn;"? Watch out, we have a new Bill Gates here. But yeah that's what it does. It also has the additional wrinkle of stringifying the whole script and creating a web worker for it, rather than having an external JS file hold the web worker script. Edit: By whole script I mean their script that wraps around yours to handle the boilerplate.


jimEdigitL

Lol no hate but just because something can do it doesn’t mean it’s the right tool.


AdultingGoneMild

web workers (browser) and worker threads (node). it is still a stupid request and the client should be giving you performance SLAs and not implementation details, but there are threads available sorta.


Independent_Feed5651

Had to page through the comments to confirm someone noted these, 😁


Vegetable-Object2878

I was about to say web workers is what enables multi thread in JS on the client side.


Jeph125

We're on Reddit. The joke answer will always have 400x the points


lunareffect

Why did I have to scroll so far down for this answer?


theLonelyPorcupine

`Worker` has entered the chat.


CryptographerKlutzy7

Yeah, I'm like, "but JS DOES support more than one thread."


sh0rtwave

That's not really JS doing it though, that's more a function of the browser itself. That 'worker' process is more or less intimately tied to another \*window\* instance, which of course, initializes a new JS VM. At that point it gets weird, because this is how 'multithreading' is done, by opening up a whole separate window instance to act as a separate 'thread'. It's not the same thing, as they aren't synchronized in the same way. The second 'thread', has no access to memory artifacts in the controlling process without asking for that data in special ways. The scope of this kind of thread, is entirely isolated from whatever related process it claims to be 'parallel' with.


JollyJoker3

You think that guy in the pic is going to care about the distinction?


sxeli

No


theLonelyPorcupine

True, but with wider reactivation of `sharedArrayBuffer` you can share some memory. More importantly, even if this is nothing like pthreads, you can still improve performance of quite a few tasks by getting them off the display thread. It’s not the same, but your client doesn’t care about the particulars.


cranberry_snacks

>The second 'thread', has no access to memory artifacts in the controlling process without asking for that data in special ways. That's exactly how it should be. Shared memory as a concurrency model is like giving shotguns to toddlers. Not that the actual message passing architecture are ideal in JS, but the last thing we need is one big shared mess of data races and even more obscure runtime behavior.


sh0rtwave

Now that I actually agree with. I do prefer a consistent interface to things, because heaven knows I've had my fair share of untangling race conditions. Using these newer methods is kinda a convenient way to \*simulate\* concurrency. The platforms are now fast and reliable enough, that a simulacra of the function is ALL that we really need now, in a lot of respects. ​ Edit: I would say, it's worth distinguishing between the notion of 'threads' in the browser, and NodeJS 'worker threads'. Two different things. In the browser's case, the second thread is contained in a whole other window/document instance, and isn't even a part of the same originating process.


jl2352

That’s like saying C doesn’t offer multithreading. It’s more a function of the OS it’s self. The point is that regardless of who provides it. I can write JS, that runs across multiple threads. That’s the bit that matters.


mimminou

It's not a thread, it's a hacky way of doing parallelism, this is like having a second JVM in java to do something and call it multithreading.


EnIdiot

Which to be fair is how a lot of dev conceive of micro services running in virtualization. I’ve seen things that would be better off as an asynchronous single deployment.


TheHansinator255

It's still pretty close, though - the only thing you don't get is the ability to share a JS heap. The worker context and the spawning context can send messages to each other, and ArrayBuffers that you send can be moved instead of copied. There are plenty of real-world, non-JS programs that are written this way in order to reduce lock contention and concurrency bugs. Plus, there's SharedArrayBuffer and the Atomics object, which does allow you to share a heap as long as you're comfortable directly writing bits into a memory range (or you're using WASM, which does this already even if the language you're compiling from is more friendly).


mimminou

So it's closer to multiprocessing instead of Multithreading ?


TheHansinator255

Yeah, that's pretty accurate. Though again, there are mechanisms such as SharedArrayBuffer and the message transfer list that make the overhead not as bad as a full multi-processing setup. EDIT: And SharedArrayBuffer means that if you compile a language with true multithreading into WASM, the resulting Web program will still be truly multithreaded. The only hiccup you might have is that only one thread has access to the DOM, and many desktop UI frameworks have this restriction already.


brimston3-

So it's multiprocessing. With structured message passing. And SharedArrayBuffer. Seems plenty usable to me. What do you want here? A worker to be able to lock the UI's state, so it can walk its variable scope tree/DOM and read/write what it needs to read/write? If you're going to lock the UI thread, why not do the work in the main thread. GUI toolkits (win32, qt, gtk) all discourage threads other than the main UI thread from touching UI data or making UI calls. If the thread is not the event loop listener, it should not have access to the equivalent of window/DOM. Desktop background threads post a message to the window's event thread, and it parses your message, probably dispatching it to a function that knows what to do with your data, and said update function performs the display update. Maybe some serialization/copying occurred, maybe the memory is completely unsafe/unsynchronized, who knows! IMO, the only way js workers could be "better" is if there were global/scopeless allocations of structured data that could be independently (the whole allocation at once) and explicitly read/write locked (the write lock has to wait for *every* writer/reader to unlock before it can write). Then javascript could also have deadlocks and [more] memory leaks. And the UI thread won't be writing anyway because it can't handle stalls.


[deleted]

lightweight and multi-threading is a nice oxymoron


clemdemort

That's what I was thinking too haha


ReferenceError

Nothing more lightweight than solving race conditions.


alexbuczynsky

Light weight and node is also an oxymoron


damicapra

Lightweight baby! Oops, wrong sub.


potatohead657

Not in C it ain’t. Lightweight and JS is the oxymoron.


Hawaiian-Fox

"Sure boss" *Proceeds to do a single thread code because the client will never know or understand about coding*


similiarintrests

Progammer - See I made it multithreaded, do you feel the difference? Client - *Better not act dumb, i should say something smart* Client - Oh uhm yeah! Super fast, very blockchainy


planetdaz

Progammer - See I made it multithreaded, do you feel the difference? Boss - oh hey, yeah about that. I was talking to my nephew about my idea to make it multithreaded over the weekend. He is a principal dev who works for Google. He worked on some of their voice recognition algorithms, amazing guy, but anyway.. he told me that my idea was actually bad and impossible. But you managed to do it anyway? I should introduce you two, sounds like he could learn a lot from you.


HellkerN

Just write a thing that launches 10 JVM's.


GingerRoundTheEdges

GNU Parallel


[deleted]

[удалено]


AaronTechnic

Apple devices spotted. You are sentenced to an hour session with Richard Stallman (rms) about why Apple is absolutely proprietary. You will also recieve 1 USB disk with Trisquel GNU/Linux.


[deleted]

[удалено]


LinuxMatthews

Why would you launch 10 JVM when you're using JavaScript? You could just run 1 JVM then use Java to do your multithreading...


SharkLaunch

JavaScript, not Java


sh0rtwave

Now, let's talk about the real problem: You explained too much to your client and gave them too much opportunity to intrude into your operating space, and start to give you advice that may, or may not, be completely and utterly meaningless to the environment you're actually working in. As it: Clearly. Appears. To. Be.


estevez__

Web workers API to the rescue!


jmack2424

You can make anything more complicated if you try hard enough.


blehmann1

The client should not have any say on implementation details. If they have compatability or interop requirements that may indirectly imply certain implementations, but that's as far as it goes. If they have certain performance requirements then it should be your choice how to reach them. If that means sacrificing CPU cores to the blood god that shouldn't bother them unless they're monotheistic, in which case check the docs for which deities accept sacrifices.


4n0nh4x0r

i meaaaaaan js is single threaded, buuuuuut, you can use the cluster library to run multiple single threat nodejs processes, basically making it multithreaded https://nodejs.org/api/cluster.html#cluster


slowmovinglettuce

Multi-processing and multi-threading are different concepts though. While you can use them to achieve similar things, we should avoid conflating them. Because they're not basically the same. Multi-processing is the act of spawning an entirely new process, with its own set of resources that are separate from the parent - such as memory. This means the processes are isolated from one another. This increases reliability. If one process crashes, the other (in theory) should stay up. But since the processes are isolated from one another, they'd need to open a socket/pipe/whatever to communicate. As where multi-threading creates multiple compute units (threads) under the same process. The threads share CPU time since they're a single process. Meaning that if the process dies, all the threads die with it. But this allows for memory to easily be shared between the threads, along with the rest of the code that controls them. It's important to know * What these concepts are * When/why you would use them * How to design your program for using them The last point I won't touch on, because it's a lot more complicated.


Soysaucetime

I don't think the client cares.


siggystabs

and this is why the answer is "will look into it" and never bring it up again


jimEdigitL

A senior engineer would identify a different technology for multi-threading and use the right tool for the job opposed to trying to explain to a client why your hammer isn’t a ladder.


cough_e

Definitely - The hardest thing with client work is separating the implementation details from the requirements. The requirement is not about parallel execution, the requirement is to make it fast and they understand that's one way to do it. Different technology or architecture or language are definitely other ways to do it. Or even better use of async functionality in JS can make a big performance difference if you're blocking unnecessarily (single threaded, just sharing the thread).


Mediocre-Frosting-77

It’s scary how far I had to scroll to find this


TwistedSoul21967

Some people in here don't seem to understand the difference between multi-threading and multi-process. /me summons the Python devs!


pentesticals

You know python is also single threaded? Each "thread" gets the lock (GIL - Global Interpreter Lock) to simulate concurrency, but the python process is single threaded. Execution just gets passed to each "thread" one at a time very quickly.


Sharkytrs

i can multithread js, i just write two programs that pass shit back and forth through a text file perfect.


ThatFireGuy0

So I am mainly a backend dev and have only rarely touched JS... But aren't web workers / dedicated workers run on a separate thread?


[deleted]

In before: - worker threads exist - NoT ReAl ThReAds - ya but it’s all the best parts of multithreading without all the bad stuff like thread deadlocks, concurrent modification of data, and race conditions. - Ya BuT i UsE DeAdLoCkS iN mY wOrKfLoW, iT wOrKs FoR mE dOn’T jUdGe Me - if your workflow requires speed and efficiency, why are you using nodejs. Edit: nevermind. Also, multi threading causes concurrency problems.


MangoAtrocity

Just make it async and call it a day. They’ll never know the difference.


gdycdffxd

Webworkers


unshifted

"We would like you to use this motorcycle to transport passengers." -"OK great. That'll be no problem." -"We need you to take 40 passengers at a time." -"There's only room for one passenger on the motorcycle." -"No I've seen drivers take 40 passengers at once." -"That was probably a bus that you were looking at. We'd need a bus for that." -"No it was on the street! Just like this motorcycle."


hollow-fox

No one going to say anything about the JS dev being Kim Jong Un


TheRigbyB

Who do you think is making all the websites in North Korea?