Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Sweeper
Nov 29, 2007
The Joe Buck of Posting
Dinosaur Gum

WHOIS John Galt posted:

i'm a really lovely programmer and i've never really explicitly used concurrency or multithreading in anything. what on earth would i use that poo poo for. like the goroutines+channels seem really cool but i can't figure out why i'd use them, especially when it seems like so much poo poo goes wrong in concurrent programming

im guessing you would use them if you need to do more than one thing at a time??

Adbot
ADBOT LOVES YOU

vapid cutlery
Apr 17, 2007

php:
<?
"it's george costanza" ?>
probably the most common example in application programming nowadays is making a request to a web service without locking up the entire application

rotor
Jun 11, 2001

classic case of pineapple derangement syndrome
I guess not freezing the entire ui while waiting for user input is a nice thing

vapid cutlery
Apr 17, 2007

php:
<?
"it's george costanza" ?>

rotor posted:

I guess not freezing the entire ui while waiting for user input is a nice thing

waht

Sweeper
Nov 29, 2007
The Joe Buck of Posting
Dinosaur Gum

rotor posted:

I guess not freezing the entire ui while waiting for user input is a nice thing

user... input??? who has that

AWWNAW
Dec 30, 2008

if you have to ask you'll never gnu

ants on my cum rag
Sep 2, 2011

"Oh God you got the spray gun, DO NOT LOSE IT, you seriously better not screw this up, I'm not kidding"
~~The Battle Hymn of the Contra Tiger Mother~~

tef posted:

your challenge is to stop posting

Can I start posting now?

Meiwaku
Jan 10, 2011

Fun for the whole family!
What should the other 3 cores on my laptop be doing if I've maxed the first core? Provide emotional support?

I peg all 24 cores on my workstation regularly...

vapid cutlery
Apr 17, 2007

php:
<?
"it's george costanza" ?>

Meiwaku posted:

What should the other 3 cores on my laptop be doing if I've maxed the first core? Provide emotional support?

I peg all 24 cores on my workstation regularly...

they should be turning themselves off to allow the processor to raise the clock speed on the one core that's doing work, which is what modern intel processors do

rotor
Jun 11, 2001

classic case of pineapple derangement syndrome

Meiwaku posted:

What should the other 3 cores on my laptop be doing if I've maxed the first core? Provide emotional support?

I peg all 24 cores on my workstation regularly...

seti @ home dude

Meiwaku
Jan 10, 2011

Fun for the whole family!
^^^ that, or code to use all N-cores so work can complete ~N times faster. Intel jumps through a lot of hoops since many developers seem incapable of adjusting to major shifts in hardware.

Hell, even cellphones have 2-4 cores now.

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope
How to write a multithreaded application:

1) Just make your application single-threaded
2) Copy this bat file as many times as you have processors, with different parameters in each file, duh:
DOS code:
yourapplication.exe inputfile1 outputfile1
yourapplication.exe inputfile2 outputfile2
yourapplication.exe inputfile3 outputfile3
yourapplication.exe inputfile4 outputfile4
3) Then copy and run this bat:
DOS code:
start batch1.bat
start batch2.bat
start batch3.bat
start batch4.bat
4) profit :xd:

X-BUM-RAIDER-X
May 7, 2008

Otto Skorzeny posted:

also ocaml is a pretty darn good language for writing a compiler in :toot:

gently caress yeah ocaml rules

X-BUM-RAIDER-X
May 7, 2008

Wheany posted:

How to write a multithreaded application:

1) Just make your application single-threaded
2) Copy this bat file as many times as you have processors, with different parameters in each file, duh:
DOS code:
yourapplication.exe inputfile1 outputfile1
yourapplication.exe inputfile2 outputfile2
yourapplication.exe inputfile3 outputfile3
yourapplication.exe inputfile4 outputfile4
3) Then copy and run this bat:
DOS code:
start batch1.bat
start batch2.bat
start batch3.bat
start batch4.bat
4) profit :xd:

how to stop Wheany posting:

1) stop posting
2) stop it
3) ???
4) ge tout

tef
May 30, 2004

-> some l-system crap ->

Wheany posted:

How to write a multithreaded application:

1) Just make your application single-threaded
2) Copy this bat file as many times as you have processors, with different parameters in each file, duh:
DOS code:
yourapplication.exe inputfile1 outputfile1
yourapplication.exe inputfile2 outputfile2
yourapplication.exe inputfile3 outputfile3
yourapplication.exe inputfile4 outputfile4
3) Then copy and run this bat:
DOS code:
start batch1.bat
start batch2.bat
start batch3.bat
start batch4.bat
4) profit :xd:

learn to xargs

Sapozhnik
Jan 2, 2005

Nap Ghost

vapid cutlery posted:

probably the most common example in application programming nowadays is making a request to a web service without locking up the entire application

mumble mumble node.js

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

Mr Dog posted:

mumble mumble node.js

mumble mumble gar1t on youtube

multigl
Nov 22, 2005

"Who's cool and has two thumbs? This guy!"

Meiwaku posted:

What should the other 3 cores on my laptop be doing if I've maxed the first core? Provide emotional support?

I peg all 24 cores on my workstation regularly...

I'll peg your 24 corse

Rufus Ping
Dec 27, 2006





I'm a Friend of Rodney Nano

WHOIS John Galt posted:

the goroutines+channels seem really cool but i can't figure out why i'd use them, especially when it seems like so much poo poo goes wrong in concurrent programming

concurrent programming introduces a whole load of new considerations and possible pitfalls but using a language with decent high level concurrency primitives ameliorates that somewhat

Rufus Ping
Dec 27, 2006





I'm a Friend of Rodney Nano
idk its like if you always want to ride a pushbike thats fine but if you want to drive a car you should def get one with at least 3 wheels and working brakes, car anal ogy

Tetramin
Apr 1, 2006

I'ma buck you up.

Dr. Honked
Jan 9, 2011

eat it you slaaaaaaag
if you don't know what concurrency etc. is good for, i don't really know what to say to you in words that you would understand, because you are clearly a homosexual retarded baby clown who was born in the circus

MononcQc
May 29, 2007

I'm due for a carepost on why node.js is a terrible idea.

Let's say I'm writing a server app decades ago. I start from scratch, on a computer with a single core. I first write my little socket acceptor dealing with TCP stuff. It opens a listen socket, waits to accept a connection, and then parses the request, dispatches it to some library function I have written, which goes fetch the data, builds the page that will result in it, then push it to the client. I then go back and accept another connection. This gives me an execution model a bit like that:

code:
accept -> parse -> dispatch -> read -> read more -> write -> push.
If two requests come at the same time under that model, one of these will have to wait until the other one is done before even being able to start:

code:
accept -> parse -> ... -> write -> push -> accept -> parse -> ... -> write -> push.
Realizing this, I wish I had parallelism to allow a flow more like this:

code:
accept -> parse -> dispatch -> read -> read more -> write -> push.
accept -> parse -> dispatch -> read -> read more -> write -> push.
But I can't -- I'm using a single processor and I am using a poo poo platform that doesn't support concurrency in any way (coroutines, threads [OS threads included], erlang-style processes [akka included], clojure-style actors, etc.) because I'm in the stone-age of computers and also no library for this exists. So what do I do? Well, I guess I'll break them up and track them by hand with callbacks -- it's the only way:

code:
(accept 1) -> (accept 2) -> (parse 1) -> (parse 2) -> (dispatch 1) -> ...
Which I guess is kind of okay, but annoying. poo poo can be locked up, I need to manually split everything in callbacks that will register themselves in order to know when things are done (something like resource.ready(callback)), I need to keep track of everything manually (is this parse for request 1, 2 or 73?).

Then at some point, computer evolution allows us to have things like threads and processes, and other proper concurrency mechanisms. By making things fork, go parallel, go async, or whatever after accepting, I'm able to serve two queries at once, without special care. If I have only my one processor with one core, then it will transform:

code:
accept -> parse -> dispatch -> read -> read more -> write -> push.
accept -> parse -> dispatch -> read -> read more -> write -> push.
automatically into:

code:
accept ->        parse ->          dispatch ->             read -> ...
        accept ->          parse ->             dispatch ->        ...
without me even needing to make a special effort, especially if there's a form of preemptive scheduling going on. I won't have to understand the callback based form of:

code:
(accept 1) -> (accept 2) -> (parse 1) -> (parse 2) -> (dispatch 1) -> ...
which will be declared as:

code:
accept (when accepted call parse callback)
parse (when parsed call dispatch callback)
dispatch (read once, when done, call dispatch2)
dispatch2 (read a second time, also when done reading, write)
read (when done call callback)
write (when done reading, push)
I'll only need to keep my code pretty much the same.

Then at some point, I may gain parallelism on top of it Awesome, poo poo will go great, except maybe my writes, which will need to block to be sane. What I'll be able to do with my concurrent code (not callback-based) is:

code:
accept -> parse -> dispatch -> read -> read more -> write -> push.
accept -> parse -> dispatch -> read -> read more ->        write -> push.
My code that was concurrent is now parallel by default, and I limit how much blocking I need to do (assuming the write is written to block correctly, either via transactions, safe queues, mutexes, locks or whatever). However, if I go back to my callback-based code and get parallel, what I get is still this:

code:
(accept 1) -> (accept 2) -> ... (write 1) -> (write 2) -> (push 1) -> (push 2)
And I want to get the speedup of my friends in the parallel and concurrent worlds. So I know what I'll do! I'll add non-blocking IO and will send poo poo to concurrent drivers in charge of doing poo poo right!

code:
(accept 1) -> ... ->          ->              -> (write 1) -> (write 2) ->
                     (read 1)    (read more 1)                             (push 1)
                     (read 2)    (read more 2)                             (push 2)
See? I got the parallelism going! I only did so at the cost of a shittier way to read and write code, still as sensitive to failures or blocks from independent requests, and relying heavily on the implementation of individual drivers not to gently caress my poo poo up! It's still worse on every level, but hey, I get to keep using my callback-based code (not that it's impossible to do in concurrent/parallel systems anyway). Hooray.

While the modern world of programming on servers has moved to concurrent and parallel methods a long while ago (mostly because they are objectively better), Javascript users with node.js came crashing through the door and said "we have a great new model! it's callbacks with non-blocking IO! it's loving great!".

Everyone who is not node.js knows what they propose is worse than what exists. It's like someone inventing PHP again, but for server-side platforms.

Node still has a decent community, interesting libraries, documentation, etc. In some cases better than many other communities and libraries. Parallel and concurrent code still is tricky to write without high-level constructs to keep you from having deadlocks, memory corruption, etc. and requires a lot of discipline otherwise.

This changes nothing to the fact that the underlying model of node.js is still outdated garbage. It's the worst of both world.

MononcQc fucked around with this message at 14:11 on Oct 12, 2012

Shaggar
Apr 26, 2006
i still dont understand what benefit ur getting out of node.js there. you get to use a bad language? is that the benefit?

0xB16B00B5
Aug 24, 2006

by Y Kant Ozma Post
it helps if you keep shouting "non blocking" and "web scale" while ignoring everyone else

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

MononcQc posted:

I'm due for a carepost on why node.js is a terrible idea.

Nice!

MononcQc
May 29, 2007

Shaggar posted:

i still dont understand what benefit ur getting out of node.js there. you get to use a bad language? is that the benefit?

you know how to use a knife, so you bring a knife to a modern war fought with guns, tanks, and missiles while shouting "at least I can use the same tools when I eat and when I fight! I save so much time!" before somehow managing to shoot yourself in the foot anyway.

Tiny Bug Child
Sep 11, 2004

Avoid Symmetry, Allow Complexity, Introduce Terror

Meiwaku posted:

^^^ that, or code to use all N-cores so work can complete ~N times faster. Intel jumps through a lot of hoops since many developers seem incapable of adjusting to major shifts in hardware.

Hell, even cellphones have 2-4 cores now.

it's dumb that developers should have to write weird code just because the only way intel can make better processors is to jam more tiny mini-processors into them

Shaggar
Apr 26, 2006

MononcQc posted:

you know how to use a knife, so you bring a knife to a modern war fought with guns, tanks, and missiles while shouting "at least I can use the same tools when I eat and when I fight! I save so much time!" before somehow managing to shoot yourself in the foot anyway.

in this scenario java is a carrier

Tiny Bug Child
Sep 11, 2004

Avoid Symmetry, Allow Complexity, Introduce Terror

Shaggar posted:

in this scenario java is a carrier

huge, slow, and clunky

Zombywuf
Mar 29, 2008

MononcQc posted:

you know how to use a knife, so you bring a knife to a modern war fought with guns, tanks, and missiles while shouting "at least I can use the same tools when I eat and when I fight! I save so much time!" before somehow managing to shoot yourself in the foot anyway.

Also the knife is blunt.

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

Shaggar posted:

in this scenario java is a carrier

an armored personnel carrier. tinfoil for armor, no gun to speak of, shoehorned into a billion tasks it isn't good at because hey common chassis saves money

Shaggar
Apr 26, 2006

Otto Skorzeny posted:

an armored personnel carrier. tinfoil for armor, no gun to speak of, shoehorned into a billion tasks it isn't good at because hey common chassis saves money


thats python. people like to think its a replacement for java when its an unfinished piece of poo poo for retards.

java is the ultimate in utility and can project its power anywhere it likes.

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

Shaggar posted:

in this scenario java is a carrier
of influenza

Shaggar
Apr 26, 2006
the wide variety of weaponry onboard a carrier is the equivilent of java frameworks and libraries. we've got what you need for any situation.

Shaggar
Apr 26, 2006
and everyone likes to think its a dead or archaic tool, but in reality its still the best and nothing can come close.

0xB16B00B5
Aug 24, 2006

by Y Kant Ozma Post
its a battleship analogy

Sapozhnik
Jan 2, 2005

Nap Ghost
in the midst of all this there are the php programmers

the huge teetering tricicles armed with lances and stacked with clowns

Shaggar
Apr 26, 2006
php are makeshift rafts people use to flee the 3rd world. they know its risky, but it only needs to work once and then they can move on to better things. no one would try to reuse the raft.

Adbot
ADBOT LOVES YOU

rotor
Jun 11, 2001

classic case of pineapple derangement syndrome

MononcQc posted:

you know how to use a knife, so you bring a knife to a modern war fought with guns, tanks, and missiles while shouting "at least I can use the same tools when I eat and when I fight! I save so much time!" before somehow managing to shoot yourself in the foot anyway.

hahahahaha

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply