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
Beef
Jul 26, 2004
Or, you can create a thread for each core, pin them and give it a high priority and happily do coop multithreading yourself. Plenty of game devs necessarily do this, same for OpenMP, Intel TBB, etc.

Adbot
ADBOT LOVES YOU

Absurd Alhazred
Mar 27, 2010

by Athanatos

Space Gopher posted:

Yes, it's very dumb.

The problem he's trying to solve is that, when you're working with shared state in a preemptive multitasking environment, you have to be highly defensive about other threads modifying what you're working with. If you aren't defensive, and the scheduler stops you in the middle of the wrong non-atomic operation, then some other thread could come in and mess up what you're working on. Reasoning about how to be defensive is difficult, especially when performance is important. Like, if you come up with a cool algorithm for processing things in parallel that doesn't start with "first lock everybody else out of this section of code until I'm done with my thing", then you can probably get a doctorate or a publication in a decent journal out of it.

Cooperative multitasking on a single-processor system can solve this by explicitly making huge atomic operations that only yield control back to the scheduler at safe points, at the cost of allowing malicious or poorly written programs to take down the entire system. Nobody does this any more, because "just don't have malicious or buggy programs" isn't a workable constraint for a computer system.

But, let's say we bring it back, since losing one core out of many isn't as big a deal as losing the entire system. If you're working on a system with a bunch of cores, guess what? Other threads might still come in and modify things out from under you, even if everything is fully cooperative, because there might be an operation running on another core that modifies your shared state. You still have to be defensive - locking resources for your exclusive use (creating contention problems) or coming up with exotic solutions that can't be wrong even if they're interrupted. You gain nothing, and allow for the possibility of those same bad programs to eat up a full core. So, yeah, it's pretty dumb.

That's more or less what I was thinking, I just wanted to make sure it wasn't my "Jonathan Blow is an idiot" bias talking.

Steve French
Sep 8, 2003

In our lovely webapp hellscape future, maybe it will fully come back! You just need a core for each browser tab to be pinned to and boom

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
Under cooperative multitasking, the basic programming model assumes exclusive access to all accessible resources, so the vast majority of code has to be assumed to be unsafe to run with true concurrency, which means it’s very difficult to take advantage of having multiple cores outside of well-defined problems with lots of obvious parallelism (e.g. a library function to rotate an image). That kind of parallelism comes up a lot in the sorts of domains that use supercomputers, but consumer machines inevitably do a lot of heterogenous computation, and cooperative multitasking basically made it impossible to keep more than one core active for long. So it’s really the exact opposite of what Blow is suggesting: the growth of multi-core machines in the basic consumer market is exactly what killed cooperative multitasking.

Also I‘s not sure what he’s trying to say about core migration in preemptive multitasking but it sounds wrong. Probably he has some half-assed understanding of the problem and assumes it’s perfectly accurate like usual.

Beef
Jul 26, 2004
I actually read "cooperative multitasking" as "non-preemptive scheduling", because only the latter makes sense these days. (ignoring restrictive embedded systems etc)

dougdrums
Feb 25, 2005
CLIENT REQUESTED ELECTRONIC FUNDING RECEIPT (FUNDS NOW)
Clever use of x86's atomic instructions can get you pretty far. I think the downside is that they're serializing but I might actually be wrong about that and just thinking about the lock prefix.

I was looking at jai to see if he had implemented them but I can't even find anything about multithreading on there so that's probably what is causing his complaint.

E: I don't know a bunch about video juegos, but isn't it acceptable to interpolate a bit to make up for any 'suprises'? What would it take for there to be an unacceptable delay?

dougdrums fucked around with this message at 19:33 on Jan 8, 2020

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

Linear Zoetrope posted:

Oh, Python? That's easy, if numpy and scipy have taught me anything it's that the correct way to handle this is having a function that takes in a half-documented string badly acting as an enum to select the algorithm.
I don't understand why they do this since the enum module exists, so you'd have the benefit of knowing what options exist without looking at docs and it can be docstringed. I imagine it has something to do with decrepit Python 2 support like most other hosed up things in Python but idk for sure

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



dougdrums posted:

I was looking at jai to see if he had implemented them but I can't even find anything about multithreading on there so that's probably what is causing his complaint.

Hmm, people are saying my language needs thread primitives, but what if nobody needed threads because... multicore?! :pseudo:

QuarkJets
Sep 8, 2008

dougdrums posted:

I don't understand why they do this since the enum module exists, so you'd have the benefit of knowing what options exist without looking at docs and it can be docstringed. I imagine it has something to do with decrepit Python 2 support like most other hosed up things in Python but idk for sure

It's partly because those numpy functions were around much longer than the enum module and the advantages of using an enum aren't compelling enough to break backwards compatibility outside of a new major release.

But the reason it was done that way originally is because numpy was designed to look like Matlab and Matlab uses strings as enums a lot

QuarkJets fucked around with this message at 21:13 on Jan 8, 2020

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

Critically successful indie game developer Jonathan Blow, of The Witness fame: quits game development to create an ergonomic, high-performance, GC-free, JIT-free programming language specifically designed for game development, obliquely named after himself.

After five years of non-stop Twitch coding and countless tweet-storms, Jon sadly has yet to release so much as a compiler pre-alpha.



Commercially successful indie game developer Brian Fiete, of Bejeweled fame: quits game development to create an ergonomic, high-performance, GC-free, JIT-free programming language specifically designed for game development, obliquely named after himself.

After five years of quiet coding in absolute obscurity and having tweeted a grand total of seventeen times in ten years, Brian has made available six hours ago the very first public release of the language compiler, the core libraries, extensive documentation, cross-platform targeting (Windows, Mac, Linux, iOS, Android), command-line build tools, and a full cross-platform IDE (Windows, Mac, Linux) featuring autocompletion, refactoring tools, debugging, profiling, incremental compilation, hot code swapping including data layout, memory leak detection, and per-type or per-method optimization levels.



Critics have described the current status of Jonathan Blow as :owned:


e: from the man himself on HN:

Brian Fiete posted:

There's a lot of overlap ideologically [with JAI]. One major difference is that I'm an IDE fan and Jonathan dislikes IDEs. That can really percolate through a language.

BeefLang had an IDE on day one, and I think it'll show. One of my goals was to show how good a good IDE experience can actually be to someone who is used to working in C/C++.


e2: unrelated horror: current count of vegan HN posters who are seriously offended that a man with the initials B.F. has decided to name a programming language after literal cow murder: 5.

NihilCredo fucked around with this message at 21:55 on Jan 8, 2020

Volguus
Mar 3, 2009
Nobody knew programming languages could be so complicated.

Falcorum
Oct 21, 2010

I'm guessing this does fit in here.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
Adding new fields to existing types is solidly in the category of cool but bad ideas.

Beef
Jul 26, 2004
Obligatory Beef post about Beef.

Xarn
Jun 26, 2015
Doesn't C# also allow you to do that? Or is that for methods only?

redleader
Aug 18, 2005

Engage according to operational parameters

Xarn posted:

Doesn't C# also allow you to do that? Or is that for methods only?

methods only (at this stage). methods are e z since extension methods are just some light syntactic sugar over static methods in static classes

there's been interest from the language team about "extension everything" - properties/fields/operators/events/the whole nine yards, but nothing has eventuated yet because (1) it's hard (2) there are more useful things to work on and (3) it's hard

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆
Here's another fun bit from Beef.
code:
class Widget
{
    private int32 id;
    protected Rect pos;
    public uint32 color;
}

class Button : Widget
{
    /* This class can access 'pos' and 'color' but not 'id' */
}


static void Main()
{
    var button = new Button();
    /* We can only access 'button.color' */

    /* The [Friend] attribute allows us to access members which are normally hidden */
    int32 id = button.[Friend]id;
    /* Note that the 'friend' relationship is inverted from C++ here - the user is 
    promising to be friendly rather than the defining types declaring its friends */
}
There's a keyword to just ignore the private specifier and access any class's internal data.
Though I suppose C++ technically lets you do the same thing with evil pointer arithmetic shenanigans.

Xik
Mar 10, 2011

Dinosaur Gum
What's the point of even having different levels of accessibility when it's not guaranteed.

Looking forward to links in this thread years from now where library users just litter their code base with [friend]. Then complain when the internal implementation changes.

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

Xik posted:

What's the point of even having different levels of accessibility when it's not guaranteed.

Looking forward to links in this thread years from now where library users just litter their code base with [friend]. Then complain when the internal implementation changes.

Only good use I can think of offhand is tests

SupSuper
Apr 8, 2009

At the Heart of the city is an Alien horror, so vile and so powerful that not even death can claim it.

Xik posted:

What's the point of even having different levels of accessibility when it's not guaranteed.

Looking forward to links in this thread years from now where library users just litter their code base with [friend]. Then complain when the internal implementation changes.

Users already do that with reflection so at least this makes the kludge more obvious. Inevitably you run into a badly designed API you gotta work around.

I get the feel Beef isn't trying to be an "ideal language" but just soften all the nasty hacks and footguns C/C++ is used to. All stuff that was already possible but ugly. And coming with an IDE out of the box is super refreshing.

SupSuper fucked around with this message at 12:19 on Jan 9, 2020

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

Yeah I don't see that Friend keyword as a hack - access modifiers are a declaration of a contract, not a security system.

Requiring the use of an explicit "I know what I'm doing at my own peril" token is the appropriate level of enforcement, no different from using unsafe {}. And unlike going through a reflection call, it lets the compiler keep type-checking your code.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
There are plenty of times accessibility specifiers get in my way especially when I'm just writing some hacky debugging code. I like that as a solution

Athas
Aug 6, 2007

fuck that joker
Yeah, it's nice to be able to subvert protection mechanisms in way that are not undefined behaviour (as I think the usual pointer tricks in C++ would be).

Space Gopher
Jul 31, 2006

BLITHERING IDIOT AND HARDCORE DURIAN APOLOGIST. LET ME TELL YOU WHY THIS SHIT DON'T STINK EVEN THOUGH WE ALL KNOW IT DOES BECAUSE I'M SUPER CULTURED.

Xik posted:

What's the point of even having different levels of accessibility when it's not guaranteed.

Access modifiers that live at the "strong suggestion, not guaranteed" level work just fine in Java and C#.

Xik
Mar 10, 2011

Dinosaur Gum
Looks like I'm out numbered in that opinion so I concede.

Reflection is extremely powerful in C#, but it's basically number one on the hitlist for abused features in my experience.

Carbon dioxide
Oct 9, 2012

https://www.newscientist.com/article/2229238-a-lazy-fix-20-years-ago-means-the-y2k-bug-is-taking-down-computers-now/

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


https://twitter.com/MStrehovsky/status/1215331352352034818

It's pretty interesting but absolutely qualifies as a coding horror.

taqueso
Mar 8, 2004


:911:
:wookie: :thermidor: :wookie:
:dehumanize:

:pirate::hf::tinfoil:

That's some mighty powerful backwards compatibility.

Absurd Alhazred
Mar 27, 2010

by Athanatos
https://twitter.com/markberman/status/1215463797126836224

:stare:

comedyblissoption
Mar 15, 2006

Mode 7 posted:

Apparently, a guy on Reddit has patched a bug in the SFV netcode in 2 days that Capcom hasn't fixed in 4 years?

https://www.reddit.com/r/StreetFighter/comments/em24ck/release_sfv_netcode_fix/

The guy has apparently done some modding for GGXrd, DBZF and UNIST.
Early indications from that Reddit thread seems to be that it smooths out lag/rollback.

If this is an actual thing and not just the placebo effect in full force, fuckin' lol.
(I completely quit playing SFV b/c this netcode bug made it unplayable)

repiv
Aug 13, 2009

The developer of classic indie game VVVVVV just released its source code to celebrate its 10 year anniversary

https://github.com/TerryCavanagh/VVVVVV/blob/master/desktop_version/src/Game.cpp

tag yourself i'm the 4000 line switch statement that appears to contain most of the gameplay logic

actually no i'm the build instructions urging you to only using debug builds because optimizations break the game

The Fool
Oct 16, 2003


I'm the 70 lines of if statements for hard coded controls




game programming always produces the best horrors

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

I've never coded a game and don't have any interest in coding games, but when I see game code posted in Horrors I usually assume it's for the same reason there's a lot of lovely HTML/CSS/JS. Namely, some non-programmer had a dream and pushed and shoved at their keyboard to make their dream a reality.

Really, I kind of respect it.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

Thermopyle posted:

I've never coded a game and don't have any interest in coding games, but when I see game code posted in Horrors I usually assume it's for the same reason there's a lot of lovely HTML/CSS/JS. Namely, some non-programmer had a dream and pushed and shoved at their keyboard to make their dream a reality.

Really, I kind of respect it.

Sometimes a novice programmer with enough creativity and dedication nails it with a great game, regardless of how garbage the code is. Definitely respectable.

I suspect a lot of the the one-hit wonders lose momentum because they don't learn anything from the technical debt of their first success.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
Terry admits that his code was awful, because he wasn't a professional programmer, just an amateur gamedev. But some of it comes from the fact that Flash has you structure your project in a very different way, and that reads like a horror when directly translated to C++. Like the level data, the string-based level data was very common in Flash at the time, since that's what tooling was easiest to generate for.

Lots of the code I have no strong qualms with. It's just what gameplay code looks like.

Dicey Dungeons is supposedly a lot better made.

Sagacity
May 2, 2003
Hopefully my epitaph will be funnier than my custom title.
This clearly validates jblow's assertion that game programmers truly are the best programmers.

boo_radley
Dec 30, 2005

Politeness costs nothing

repiv posted:

The developer of classic indie game VVVVVV just released its source code to celebrate its 10 year anniversary

https://github.com/TerryCavanagh/VVVVVV/blob/master/desktop_version/src/Game.cpp

tag yourself i'm the 4000 line switch statement that appears to contain most of the gameplay logic

actually no i'm the build instructions urging you to only using debug builds because optimizations break the game
Extremely cursed GitHub repo

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

repiv posted:

The developer of classic indie game VVVVVV just released its source code to celebrate its 10 year anniversary

https://github.com/TerryCavanagh/VVVVVV/blob/master/desktop_version/src/Game.cpp

tag yourself i'm the 4000 line switch statement that appears to contain most of the gameplay logic

actually no i'm the build instructions urging you to only using debug builds because optimizations break the game

I'm the sense of utter frustration when playing the actual game too

xtal
Jan 9, 2011

by Fluffdaddy
As a former game developer let me tell you they're basically all like that

Adbot
ADBOT LOVES YOU

Volguus
Mar 3, 2009

xtal posted:

As a former game developer let me tell you they're basically all like that

Have you thought about better method naming? You know, to not expose implementation details?

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