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
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.

TooMuchAbstraction posted:

i += 1 is only 3 more characters. It's time to move on.
Most code increments are by one, why shouldn't it have a shorthand?

Adbot
ADBOT LOVES YOU

AstuteCat
May 4, 2007

I remember in a previous job we had to use the Interlocked.Increment(ref i) function instead of i++ in order to side-step the issue when multiple threads were involved,

https://msdn.microsoft.com/en-us/library/dd78zt0c(v=vs.110).aspx

Exactly why the use of such a function was required in the implementation I was working on probably is a coding horror in and of itself.

AstuteCat fucked around with this message at 14:11 on Oct 24, 2017

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe

SupSuper posted:

Most code increments are by one, why shouldn't it have a shorthand?

Because most times you're incrementing by one, what you're really doing is iterating over a container, and that should have a shorthand.

In languages that have good iterator syntaxes, I hardly ever find myself incrementing things by 1.

Slash
Apr 7, 2011

TooMuchAbstraction posted:

Because most times you're incrementing by one, what you're really doing is iterating over a container, and that should have a shorthand.

In languages that have good iterator syntaxes, I hardly ever find myself incrementing things by 1.
iter++;

Eela6
May 25, 2007
Shredded Hen
next(subject)

Doc Hawkins
Jun 15, 2010

Dashing? But I'm not even moving!


Athas posted:

Software transactional memory (as seen in functional languages) also hasn't seen as wide usage as was hoped. I think what happened is that a bunch of people invented techniques to make parallel programming safe, but then realised that the real challenge is to also make it fast. You see this happening over and over again (although some research twists the story by indeed focusing on performance, albeit asymptotic cost on implausible machine models).

Once again proving that there are only two types of programming languages: unsafe and useless.

Happy Thread
Jul 10, 2005

by Fluffdaddy
Plaster Town Cop

TooMuchAbstraction posted:

Because most times you're incrementing by one, what you're really doing is iterating over a container, and that should have a shorthand.

In languages that have good iterator syntaxes, I hardly ever find myself incrementing things by 1.

You must just not be working on certain types of things though -- some projects require generating sequences of numbers and drawing math functions all the time

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe

Dumb Lowtax posted:

You must just not be working on certain types of things though -- some projects require generating sequences of numbers and drawing math functions all the time

Sure, but is that a global enough need to warrant having a special construct specifically to support it?

Doc Hawkins
Jun 15, 2010

Dashing? But I'm not even moving!


Dumb Lowtax posted:

You must just not be working on certain types of things though -- some projects require generating sequences of numbers and drawing math functions all the time

Sequences are a kind of iterable container. Sequence generators, a lazy kind.

darthbob88
Oct 13, 2011

YOSPOS
Cross-posting from Reddit:

iospace
Jan 19, 2038


darthbob88 posted:

Cross-posting from Reddit:


:wtc:

ChickenWing
Jul 22, 2010

:v:

darthbob88 posted:

Cross-posting from Reddit:


:allbuttons:

ChubbyThePhat
Dec 22, 2006

Who nico nico needs anyone else

darthbob88 posted:

Cross-posting from Reddit:


I don't know if I'm scared of this or intrigued.

Joda
Apr 24, 2010

When I'm off, I just like to really let go and have fun, y'know?

Fun Shoe
Part of me kind of wants to know what IDE has full color on unicode emojis. Before trying it out in WebStorm, I wanted to know what IDEs supported unicode emojis at all, but I guess it kinda makes sense to add native support for them in a web dev IDE.

Munkeymon
Aug 14, 2003

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



VSCode does, as does CodeWriter which probably doesn't count, but seems to come with Windows?

Sublime and Visual Studio don't. Seriously tempted to use that ghost :3:

Taffer
Oct 15, 2010


Joda posted:

Part of me kind of wants to know what IDE has full color on unicode emojis. Before trying it out in WebStorm, I wanted to know what IDEs supported unicode emojis at all, but I guess it kinda makes sense to add native support for them in a web dev IDE.

Intellij does (on Mac)

NihilCredo
Jun 6, 2011

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

darthbob88 posted:

Cross-posting from Reddit:


The real gem is in the comments:

'👨‍👩‍👦‍👦'.replace('👦‍', '👧‍') // 👨‍👩‍👧‍👦

'👨‍👩‍👦‍👦'.replace('👦‍', '') // 👨‍👩‍👦

'🙅🏻'.replace('🏻', '🏿') // 🙅🏿

Bongo Bill
Jan 17, 2012

Can you link to the article, please?

boo_radley
Dec 30, 2005

Politeness costs nothing

NihilCredo posted:

Ah, the whomst'd've of programming.

Hello new thread title.

Things have been... OK lately, which in deploy suspicious of. The best thing that's happened is watching a dev team try to go from Angular 1 right to angular 4- it's been a hot cluster gently caress for them - half of the dependencies seen to mutate between dev machines. Everybody has different poo poo in their packages and pulling latest seems to churn versions.

Npm and the garbage heap of mini dependencies are a big horror for us right now.

JawnV6
Jul 4, 2004

So hot ...

rjmccall posted:

It's just lost a lot of interest. TM works alright if you basically don't have contention. If you do have contention, though, guaranteeing progress is hard even in practical cases — you basically need all other threads to gradually stop trying to begin transactions, even unrelated ones, because you can't easily know ahead of time whether a transaction is indeed unrelated — so either the overhead is much higher than advertised or you have really hard-to-predict and hard-to-analyze failure modes. That statement about progress is also true of things like compare-and-swap loops but much less likely in practice, in part because of the nature of things generally being attempted but also because progress is supposed to be the sort of thing you're aware of as a programmer using atomics, and nobody ever said atomics were a feature for novices, whereas people do make grandiose claims about how easy TM makes lock-free concurrency.
Oi, I've got a forums-inappropriate story about speeding up spin lock performance leading to Bad Results.

So it's fraught with the same problems as all concurrency, magnified by the attempt to democratize it and push it out to sub-atomic programmers? Swear I've heard that story before.

rjmccall posted:

Also, people have been pinning their performance hopes on hardware solutions, but hardware TM is inevitably going to have fixed transaction size limits, which means that a lot of things which would be merely bad ideas suddenly become impossible. For example, you can use TM to splice something out of a linked data structure (like a doubly-linked list) because you only need to touch some bounded number of nodes, but you generally can't use hardware TM to safely walk the entire data structure because the transaction would grow linearly with the size.
I guess it'd be hampered by lack of interest, but couldn't the HW just punt out to SW for things like that? Maintaining the bad-idea behavior instead of entirely blowing up. Like a page fault. HW does it's best, if it can't resolve it'll ask SW what to do. I've got X slots for my HW transaction window, when I hit the end of that I'll ask software for a pointer to a blob of memory to store more.

Athas posted:

Software transactional memory (as seen in functional languages) also hasn't seen as wide usage as was hoped. I think what happened is that a bunch of people invented techniques to make parallel programming safe, but then realised that the real challenge is to also make it fast. You see this happening over and over again (although some research twists the story by indeed focusing on performance, albeit asymptotic cost on implausible machine models).
That's the feeling I get about Rust? Sure it's safe, so would C be if you built at -O0, jammed an instruction barrier every other instruction, and generally made it slow as dirt.

VikingofRock
Aug 24, 2008




JawnV6 posted:

That's the feeling I get about Rust? Sure it's safe, so would C be if you built at -O0, jammed an instruction barrier every other instruction, and generally made it slow as dirt.

Optimized Rust's speed is pretty comparable to optimized C, though*. Most of the safety features have zero runtime overhead when compiled in release mode.

*There are some caveats here, like difficulty in getting LLVM to vectorize your code and the need to use unsafe blocks in some data structures. But for the most part I think the benchmarks show that this is true

taqueso
Mar 8, 2004


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

:pirate::hf::tinfoil:

VikingofRock posted:

But for the most part I think the benchmarks show that this is true
This is what I've seen, rust produces surprisingly good code for abstractions that feel like they would be heavy, coming from a mostly C background.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

JawnV6 posted:

Oi, I've got a forums-inappropriate story about speeding up spin lock performance leading to Bad Results.

I can definitely imagine that sort of thing exposing problems.

JawnV6 posted:

So it's fraught with the same problems as all concurrency, magnified by the attempt to democratize it and push it out to sub-atomic programmers? Swear I've heard that story before.

I would say that there's a difference in kind between the levels of optimism about contention required for normal atomics vs. TM. TM basically demands OS involvement from the start, which inherently limits its scalability and its performance.

JawnV6 posted:

I guess it'd be hampered by lack of interest, but couldn't the HW just punt out to SW for things like that? Maintaining the bad-idea behavior instead of entirely blowing up. Like a page fault. HW does it's best, if it can't resolve it'll ask SW what to do. I've got X slots for my HW transaction window, when I hit the end of that I'll ask software for a pointer to a blob of memory to store more.

That's a lot of extra complexity, though, since loads within the transaction sometimes need to be serviced from the transaction buffer (because they need to see an internally-consistent view of memory). And that complexity is specifically likely to lead to serious processor-soundness problems, since the processor doesn't really have a guarantee that nothing is concurrently modifying the "spilled" transaction buffer.

comedyblissoption
Mar 15, 2006

Rust's higher level abstractions are designed in the philosophy of C++'s "no overhead abstractions." Rust's aliasing guarantees could theoretically make idiomatic code faster than idiomatic C (ignoring aliasing specifiers in C) with a Sufficiently Smart Compiler.

Doc Hawkins posted:

Once again proving that there are only two types of programming languages: unsafe and useless.
Rust has an interesting approach to concurrency safety. No GC. No unsafe data races at compile time. The way data races are eliminated is by generally making unsafe aliasing of memory a compile time error. Aliased data with no concurrency synchronization (e.g. reference counted data) cannot be aliased across threads and will generate a compile time error. Aliased data with concurrency synchronization (e.g. atomically reference counted data) can be shared across threads.

This doesn't eliminate all concurrency problems of course, but in my experience a lot of programmers don't understand the basics of concurrency safety in accessing data across threads. Making these mistakes compile time errors may help a lot.

It remains to be seen if this model is ultimately useless, but it seems naively promising at first glance.

JawnV6
Jul 4, 2004

So hot ...

rjmccall posted:

I would say that there's a difference in kind between the levels of optimism about contention required for normal atomics vs. TM. TM basically demands OS involvement from the start, which inherently limits its scalability and its performance.
Ah, I see. Wouldn't things be great if we didn't need OSes in the first place?

rjmccall posted:

That's a lot of extra complexity, though, since loads within the transaction sometimes need to be serviced from the transaction buffer (because they need to see an internally-consistent view of memory). And that complexity is specifically likely to lead to serious processor-soundness problems, since the processor doesn't really have a guarantee that nothing is concurrently modifying the "spilled" transaction buffer.
I was imagining microcode handling each entry in the 'spill'. But it's still awful, each spill takes up some cache space and pushes out working set data, this microcode engine is doing heavy lifting on user-provided data, etc. etc.

I should check on the implementations, my picture has a few gaps.

comedyblissoption posted:

Sufficiently Smart Compiler.
...
It remains to be seen if this model is ultimately useless, but it seems naively promising at first glance.
:rolleyes:
How'd waiting on a SSC work out for VLIW anyway?

There's dozens of naively promising solutions in this space. We're not in need of those.

comedyblissoption posted:

Rust's higher level abstractions are designed in the philosophy of C++'s "no overhead abstractions." Rust's aliasing guarantees could theoretically make idiomatic code faster than idiomatic C (ignoring aliasing specifiers in C) with a Sufficiently Smart Compiler.

Rust has an interesting approach to concurrency safety. No GC. No unsafe data races at compile time. The way data races are eliminated is by generally making unsafe aliasing of memory a compile time error. Aliased data with no concurrency synchronization (e.g. reference counted data) cannot be aliased across threads and will generate a compile time error. Aliased data with concurrency synchronization (e.g. atomically reference counted data) can be shared across threads.

This doesn't eliminate all concurrency problems of course, but in my experience a lot of programmers don't understand the basics of concurrency safety in accessing data across threads. Making these mistakes compile time errors may help a lot.
If someone can't reason about the problem, do compiler warnings (or errors for that matter) really help them? No snark, I'm genuinely not sure.

It still just feels like handcuffs. Sometimes you can write a nice note to the complier explaining why you need both hands free, other times you just grab the unsafe key and hide all the handwaving in one corner.

KernelSlanders
May 27, 2013

Rogue operating systems on occasion spread lies and rumors about me.

Eela6 posted:

next(subject)

code:
.map

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
People that have been programming for longer than I have: does the confusion around Min/Max/Clamp ever shake off? Just spent close to 2 hours debugging something going weird because I wrote Min( width, 1 ) when trying to clamp to a minimum of 1.

Sinestro
Oct 31, 2010

The perfect day needs the perfect set of wheels.
How long have you been programming? I've been doing it for about... Jesus Christ, probably fifteen years at this point and I still have to walk through that poo poo under my breath every time.

steckles
Jan 14, 2006

darthbob88 posted:

Cross-posting from Reddit:

This got me thinking; I've been responsible for a major overhaul of the tooling for the obscure DSL we use at work. We took great care to ensure that our new compiler and run time played nice with unicode. I never tried it with anything fun though.

Compiles and runs just fine. Perhaps we've made a horrible mistake.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Sinestro posted:

How long have you been programming? I've been doing it for about... Jesus Christ, probably fifteen years at this point and I still have to walk through that poo poo under my breath every time.

I always do a double or triple take because getting it wrong suuuucks to track down.

See also: given one dimension and an aspect ratio, calculate the other dimension.

LongSack
Jan 17, 2003

Suspicious Dish posted:

People that have been programming for longer than I have: does the confusion around Min/Max/Clamp ever shake off? Just spent close to 2 hours debugging something going weird because I wrote Min( width, 1 ) when trying to clamp to a minimum of 1.

Am I misunderstanding clamp? I’ve been programming since around 1978 or so, and as I understand it min() returns the lower of the two values, max() the larger of the two, and clamp() returns min if value < min, max if value > max, else value. This seems fairly straightforward to me, but maybe you are talking about something different?

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

LongSack posted:

Am I misunderstanding clamp? I’ve been programming since around 1978 or so, and as I understand it min() returns the lower of the two values, max() the larger of the two, and clamp() returns min if value < min, max if value > max, else value. This seems fairly straightforward to me, but maybe you are talking about something different?

Suppose I have open-ended range, from 1 up to infinity. What function do I call to clamp a value into that range?

It's not the function that you mentally associate with the concept of "smallest value".

LongSack
Jan 17, 2003

Jabor posted:

Suppose I have open-ended range, from 1 up to infinity. What function do I call to clamp a value into that range?

It's not the function that you mentally associate with the concept of "smallest value".

max(value,1) ?

Edit: not sure where “smallest value” comes into this

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

LongSack posted:

max(value,1) ?

Edit: not sure where “smallest value” comes into this

You're specifying the smallest value of the range. You know, the minimum allowable value.

Yes, in a context like this where you're being explicitly asked about it, it's not too difficult to avoid. When you're focused on something else instead of the specifics of numeric manipulation, it's a really easy error to make.

The right answer is clamp(1, value, value).

LongSack
Jan 17, 2003

Jabor posted:

The right answer is clamp(1, value, value).

How is that different from max(1,value)? Assuming the definition of clamp is clamp(min,max,value)?

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

LongSack posted:

How is that different from max(1,value)? Assuming the definition of clamp is clamp(min,max,value)?

The difference is I'm a moron.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
I really want clamp(value, min=1) as a sort of default thing for every language. Too bad very few languages have named parameters.

LongSack
Jan 17, 2003

edit: redacted :cheers:

LongSack fucked around with this message at 05:36 on Oct 25, 2017

ShoulderDaemon
Oct 9, 2003
support goon fund
Taco Defender

LongSack posted:


Disagree. If you use clamp(1,value,value) the results will be different if clamp is defined as clamp(min,max,value) or clamp(max,min,value). This is quite obvious, so I am not sure what you are suggesting here.

In the spirit of the thread: Clearly clamp should just take three parameters in arbitrary order and always return the median. Then there can be no confusion.

Adbot
ADBOT LOVES YOU

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

LongSack posted:

Disagree. If you use clamp(1,value,value) the results will be different if clamp is defined as clamp(min,max,value) or clamp(max,min,value). This is quite obvious, so I am not sure what you are suggesting here.

Ignore the clamp(1, value, value) thing. Unless you want to take it as a challenge to explain why it doesn't work as intended.

Actually trying that might lead you towards the reasons for my assertion that order doesn't matter. what happens if max < min? is that even something you want to define?

e: ^ :mad: you're spoiling the puzzle

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