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
fritz
Jul 26, 2003

Subjunctive posted:

Threads are terrible, if that helps.

This one is a perfect example.

Adbot
ADBOT LOVES YOU

Nude
Nov 16, 2014

I have no idea what I'm doing.

fritz posted:

This one is a perfect example.

:golfclap:

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
I spent an hour today tracking down memory leaks in Python code.

Python code:
def transform_tree(root):
    things = []

    def recurse(node):
        things.append(transform(node.data))
        for child in node.children:
            recurse(child)

     return things
Turns out this leaks — recurse holds onto things through a closure, and meaning it's a reference cycle. The cyclic GC in Python does not run very often.

I don't like Python very much.

Athas
Aug 6, 2007

fuck that joker
If you need parallelism in your glue scripting language, you are doing something wrong.

Pavlov
Oct 21, 2012

I've long been fascinated with how the alt-right develops elaborate and obscure dog whistles to try to communicate their meaning without having to say it out loud
Stepan Andreyevich Bandera being the most prominent example of that
Problem is enough people use python as a primary development language, not just as a scripting language.

Pavlov fucked around with this message at 07:41 on May 6, 2016

Xarn
Jun 26, 2015

TooMuchAbstraction posted:

The lack of block scoping and the lack of true multithreading are my biggest peeves with Python, and I'm honestly not certain which of the two is worse.

Definitely the weird scoping.

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

Munkeymon posted:

Cuntpunch said he started out of nowhere, which points to it not being that insipid habit.

Perhaps he read the reader letter in a recent CACM which advertised this as a good idea. it isn't when the compiler doesn't enforce it and the next merge scrambles your oh so carefully maintained comments

Zemyla
Aug 6, 2008

I'll take her off your hands. Pleasure doing business with you!
Threads are terrible, and the only thing worse is not having them and having to fake them. Back when I was doing DOS programming, there were lots of C libraries where cooperative multithreading was faked with setjmp/longjmp. Every one of them had their own unique... well, "quirks" was the most charitable word for it.

VikingofRock
Aug 24, 2008




Athas posted:

If you need parallelism in your glue scripting language, you are doing something wrong.

Tons of scientific libraries (in my case Astropy) more-or-less only exist in Python, or the alternatives are worse. Plus, sometimes you gotta use what your collaborators use.

ulmont
Sep 15, 2010

IF I EVER MISS VOTING IN AN ELECTION (EVEN AMERICAN IDOL) ,OR HAVE UNPAID PARKING TICKETS, PLEASE TAKE AWAY MY FRANCHISE

Zemyla posted:

Threads are terrible, and the only thing worse is not having them and having to fake them. Back when I was doing DOS programming, there were lots of C libraries where cooperative multithreading was faked with setjmp/longjmp. Every one of them had their own unique... well, "quirks" was the most charitable word for it.

I had to write one of those libraries in college. As best I can recall we would have aspired to only have "quirks."

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

Athas posted:

If you need parallelism in your glue scripting language, you are doing something wrong.

That isn't even remotely true. There are plenty of simple scripting tasks where you want to run multiple things at once. I've even turned shell scripts into makefiles because it was the lowest-effort way of parallelizing parts of them.

piratepilates
Mar 28, 2004

So I will learn to live with it. Because I can live with it. I can live with it.



Javascript has taken an interesting approach to threading by first not having any at all (a good move), and then having them only in the VM to handle queued async callbacks, and then "webworkers" which is just message-passing only threading, and now they're introducing more threading primitives but trying to make it so you cannot possibly gently caress this up and have to deal with real threading problems.

Athas
Aug 6, 2007

fuck that joker

VikingofRock posted:

Tons of scientific libraries (in my case Astropy) more-or-less only exist in Python, or the alternatives are worse. Plus, sometimes you gotta use what your collaborators use.

Plorkyeran posted:

That isn't even remotely true. There are plenty of simple scripting tasks where you want to run multiple things at once. I've even turned shell scripts into makefiles because it was the lowest-effort way of parallelizing parts of them.

I admit I was being a bit facetious, partly because Python is so very slow that I cannot see why one would want to parallelise it (writing performance-intensive parts in another language seems like a better approach).

That aside, isn't the GIL only an issue for running Python bytecode in parallel? As I have been led to understand, functions called through the FFI (that have not asked for the global lock), as well as subprocesses, can run in parallel just fine.

Series DD Funding
Nov 25, 2014

by exmarx

Zemyla posted:

Threads are terrible, and the only thing worse is not having them and having to fake them. Back when I was doing DOS programming, there were lots of C libraries where cooperative multithreading was faked with setjmp/longjmp. Every one of them had their own unique... well, "quirks" was the most charitable word for it.

User threads are actually really good when done correctly (i.e. goroutines). There's definitely no way to make the internals pretty, though

xzzy
Mar 5, 2009

Considering processors have tapered off on improving speed, parallelism is kind of mandatory if you want to process some poo poo quicker.

Too bad it's such a goddamn pain in the rear end.

Soricidus
Oct 21, 2010
freedom-hating statist shill

piratepilates posted:

Javascript has taken an interesting approach to threading by first not having any at all (a good move), and then having them only in the VM to handle queued async callbacks, and then "webworkers" which is just message-passing only threading, and now they're introducing more threading primitives but trying to make it so you cannot possibly gently caress this up and have to deal with real threading problems.

this is a reasonable approach in the case of a language with, uh, let's say "such a low barrier to entry".

dougdrums
Feb 25, 2005
CLIENT REQUESTED ELECTRONIC FUNDING RECEIPT (FUNDS NOW)
I maybe don't understand them, but I don't like the approaches to concurrency in C#. I think there's like three different ways you can make the same thread pool with the same scheduler, and the built in scheduler can be a bit wonky sometimes. I think what happens is that most implementations try to hand-wave or generalize a lot of stuff, but not all programs need to use concurrency in the same manner.

I've been working on an actor model library on and off for awhile, and I get so frustrated with the schedulers. On Windows, multithreading with .net works pretty well if I use my own userspace scheduler. Linux is a scheduling disaster. If I let it run long enough, Mono segfaults in a way that I can't take the time to understand, and CFS will stall my long-running threads unevenly and at weird times, even if I peg them to a core. I've tried mucking with it but I usually end up making it worse :saddowns:, when all I want is my few background threads to get equal shares. (Of course it technically doesn't matter if they get equal shares, as far as the logic goes, it would be nice though. It keeps one thread's message queue from overflowing into the others...)

While what I'm trying to do directly involve scheduling, I think the point I'm trying to make is that schedulers should start with a simple set of models and allow you to tune and combine them as you please, or perhaps offer several different models. I think that's the point of C#'s threading syntax, but it all becomes a good ol' threadpool iirc. It would be nice if they tried to make scheduling a little less 'magical'.

I haven't looked at Go, but I'm scared of new things ... after doing a little reading, does the 'go' keyword actually create a new thread or process every time? I didn't know this is what go was about, I thought it was just another new killer c++. The way it's set up reminds me of pi calculus.

As far as python goes, I learned python by making an IRC server, along with realizing that python isn't terribly good for it. Python == the REPL as far as I'm concerned, which it conceptually excels at.

And there's this, "The Linux Scheduler: a Decade of Wasted Cores":
http://www.ece.ubc.ca/~sasha/papers/eurosys16-final29.pdf

dougdrums fucked around with this message at 19:36 on May 6, 2016

Lonely Wolf
Jan 20, 2003

Will hawk false idols for heaps and heaps of dough.
Go is m:n threaded.

The go keyword creates a new "goroutine": a lightweight somewhat green thread-like, somewhat coroutine-like thing, which exists only in the OS process. It's similar to Erlang processes, though more primitive.

The Go runtime multiplexes and schedules goroutines onto multiple OS threads.

It's not a panacea to the terrors of concurrency and parallelism by any means. But it's nicer to deal with in practice than many approaches, though not as nice as others.

Like many things in Go it sits at this weird middle ground between high- and low-level. Not for everyone, but I like it.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

dougdrums posted:

And there's this, "The Linux Scheduler: a Decade of Wasted Cores":
http://www.ece.ubc.ca/~sasha/papers/eurosys16-final29.pdf

Love this paper.

dougdrums
Feb 25, 2005
CLIENT REQUESTED ELECTRONIC FUNDING RECEIPT (FUNDS NOW)

Subjunctive posted:

Love this paper.

I like that they only cite Torvalds to make him look like an rear end.

Also, when I was in the navy I used to read case studies on ship collisions and other nautical accidents to pass the time. It reminds me so much of a literal shipwreck, too many cooks over a long period of time and all.

dougdrums fucked around with this message at 20:14 on May 6, 2016

fritz
Jul 26, 2003

Lonely Wolf posted:

Go is m:n threaded.

The go keyword creates a new "goroutine": a lightweight somewhat green thread-like, somewhat coroutine-like thing, which exists only in the OS process. It's similar to Erlang processes, though more primitive.

The Go runtime multiplexes and schedules goroutines onto multiple OS threads.

It's not a panacea to the terrors of concurrency and parallelism by any means. But it's nicer to deal with in practice than many approaches, though not as nice as others.

Like many things in Go it sits at this weird middle ground between high- and low-level. Not for everyone, but I like it.

I thought I read something that said until recently the default number of threads used by the go runtime was "1", does anybody know what I'm thinking of?

hyphz
Aug 5, 2003

Number 1 Nerd Tear Farmer 2022.

Keep it up, champ.

Also you're a skeleton warrior now. Kree.
Unlockable Ben
Grinding through some Java code written by a cow orker and find this at the end of every function.

If ("" != null) return X;
Throw new Exception("Missing return statement in function");

I have no idea why.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

hyphz posted:

Grinding through some Java code written by a cow orker and find this at the end of every function.

If ("" != null) return X;
Throw new Exception("Missing return statement in function");

I have no idea why.

Without the condition there would be an error for dead code, so that explains one part. I can't get all the way to understanding the rest.

Series DD Funding
Nov 25, 2014

by exmarx

fritz posted:

I thought I read something that said until recently the default number of threads used by the go runtime was "1", does anybody know what I'm thinking of?

You're thinking of GOMAXPROCS, which controls the number of simultaneously executing goroutines and used to default to 1. The runtime still used multiple kernel threads because a goroutine inside a syscall or C code doesn't count as executing

Lonely Wolf
Jan 20, 2003

Will hawk false idols for heaps and heaps of dough.

fritz posted:

I thought I read something that said until recently the default number of threads used by the go runtime was "1", does anybody know what I'm thinking of?

They changed the default from 1 to runtime.NumCPU() a year or two back, after a lot of work to improve the scheduler.

It's always been a tunable, though. Before the change, a lot of programs just started off with runtime.GOMAXPROCS(runtime.NumCPU()).

piratepilates
Mar 28, 2004

So I will learn to live with it. Because I can live with it. I can live with it.



Soricidus posted:

this is a reasonable approach in the case of a language with, uh, let's say "such a low barrier to entry".

It also makes a lot of sense for a language that was made in 1995 very quickly and hasn't required a good deal of multithreading until now.

Still not sure why they went with "webworkers" for the name though.

Sedro
Dec 31, 2008

hyphz posted:

Grinding through some Java code written by a cow orker and find this at the end of every function.

If ("" != null) return X;
Throw new Exception("Missing return statement in function");

I have no idea why.

The compiler already checks for missing return statements, so we're converting compile time errors into runtime errors? As a bonus, we can infer that every function throws Exception

necrotic
Aug 2, 2005
I owe my brother big time for this!

piratepilates posted:

Still not sure why they went with "webworkers" for the name though.

Can you use them outside of a browser? BrowserWorker doesn't quite have the same ring to it.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
There's webworker libraries for node.js, but actually using them sounds like a terrible idea.

piratepilates
Mar 28, 2004

So I will learn to live with it. Because I can live with it. I can live with it.



Doesn't look like nodejs has native webworker support (for whatever loving reason) but there are add-ons or what not to add them, also there's stuff like node-fibres and other add-ons for other threaded support.

necrotic
Aug 2, 2005
I owe my brother big time for this!

piratepilates posted:

Doesn't look like nodejs has native webworker support (for whatever loving reason) but there are add-ons or what not to add them, also there's stuff like node-fibres and other add-ons for other threaded support.

Yeah, WebWorkers were designed for the browser. Someone implemented the API using threads for... reasons?

Carbon dioxide
Oct 9, 2012

code:
Alexs-Macbook:~ alex$ woodoo
It's a weird tree.
Alexs-Macbook:~ alex$ sudo woodoo
Password:
     _              __
    / `\  (~._    ./  )
    \__/ __`-_\__/ ./
   _ \ \/  \   \ |_   __
 (   )  \__/ -^    \ /  \
  \_/ "  \  | o  o  |.. /  __
       \. --' ====  /  || /  \
         \   .  .  |---__.\__/
         /  :     /   |   |
         /   :   /     \_/
      --/ ::    (
     (  |     (  (____
   .--  .. ----**.____)
   \___/
Alexs-Macbook:~ alex$
I chuckled, okay?
The little script to make this work

Just Andi Now
Nov 8, 2009


Carbon dioxide posted:

[code]Alexs-Macbook:~ alex$ woodoo
It's a weird tree.
Alexs-Macbook:~ alex$ sudo woodoo

Least this could've done was spell the Pokemon name correctly. Unless a joke just went way over my head.

karms
Jan 22, 2006

by Nyc_Tattoo
Yam Slacker

andipossess posted:

Least this could've done was spell the Pokemon name correctly. Unless a joke just went way over my head.

It's a good joke.

Malcolm XML
Aug 8, 2009

I always knew it would end like this.

Suspicious Dish posted:

I spent an hour today tracking down memory leaks in Python code.

Python code:
def transform_tree(root):
    things = []

    def recurse(node):
        things.append(transform(node.data))
        for child in node.children:
            recurse(child)

     return things
Turns out this leaks — recurse holds onto things through a closure, and meaning it's a reference cycle. The cyclic GC in Python does not run very often.

I don't like Python very much.

im pretty sure that if it were possible to ban recursion completely in python, guido would have done it

Obsurveyor
Jan 10, 2003

andipossess posted:

Least this could've done was spell the Pokemon name correctly. Unless a joke just went way over my head.

Remove space and read again.

Carbon dioxide
Oct 9, 2012

It's actually sudowoodo without the second o but I couldn't be bothered the remove it figuring nobody would care.

Zemyla
Aug 6, 2008

I'll take her off your hands. Pleasure doing business with you!

Carbon dioxide posted:

It's actually sudowoodo without the second o but I couldn't be bothered the remove it figuring nobody would care.

You assumed that a bunch of goons wouldn't be pedants about minor spelling errors? Big mistake.

beuges
Jul 4, 2005
fluffy bunny butterfly broomstick
code:
            try {
        ........
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException dbEx) {
                Exception raise = dbEx;
                foreach (var validationErrors in dbEx.EntityValidationErrors) {
                    foreach (var validationError in validationErrors.ValidationErrors) {
                        string message = string.Format("{0}:{1}",
                            validationErrors.Entry.Entity.ToString(),
                            validationError.ErrorMessage);
                        // raise a new exception nesting  
                        // the current instance as InnerException  
                        raise = new InvalidOperationException(message, raise);
                    }
                }
                return;
            }
He came so close...

Adbot
ADBOT LOVES YOU

Cuntpunch
Oct 3, 2003

A monkey in a long line of kings
This isn't even the same person as the last horror. But, like the other one, also has 5+ years of experience and is considered to fill a mid-senior seat!
code:
//Variables obfuscated and simplified
var check = myData.Name == "Foo" || myData.Name == "Bar" ? true : false;
Corollary: I asked about this pattern of using a ternary and after 10 minutes of trying to explain I was confused by the apparent redundancy, the final word was "If you say it will work, then I guess you can try that" as though I was missing out on some fundamental truth of how code works.

Programmers: Huge, fragile egos.

Cuntpunch fucked around with this message at 17:24 on May 10, 2016

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