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.
 
  • Locked thread
Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

HoboMan posted:

having the fattest of fingers, i personally find the visual studio feature of copying the line you are on whenever you press ctrl+c extremely annoying when i meant to press ctrl+v and now i have lost what was in the clipboard
hmm... i'm not feeling it

HoboMan posted:

e: oh wait this is the internet, i mean: WHO THE gently caress DESIGNED THIS STUPID USELESS poo poo? gently caress, visual studio is an active dumpster fire and the .NET stack can suck my sack
there we go!

Adbot
ADBOT LOVES YOU

the talent deficit
Dec 20, 2003

self-deprecation is a very british trait, and problems can arise when the british attempt to do so with a foreign culture





NihilCredo posted:

c# doesn't have option types, so no (the only flatMap in c# is SelectMany which works for collections), although in this particular case you're parsing a value type so you could in principle define the same rules using nullable<T>

i write scala nearly every day and i still don't understand why List() ++ None is legal or good

gonadic io
Feb 16, 2011

>>=

the talent deficit posted:

i write scala nearly every day and i still don't understand why List() ++ None is legal or good

it is? christ

gonadic io
Feb 16, 2011

>>=

LeftistMuslimObama posted:

the one advantage i can think of is that its harder to carelessly use a null return value with the bool + out version.

ooooooopppptttiiiiioooonnnnnn tttyyyypppppepeeeeesss

comedyblissoption
Mar 15, 2006

gonadic io posted:

ooooooopppptttiiiiioooonnnnnn tttyyyypppppepeeeeesss

comedyblissoption
Mar 15, 2006

mainstream language intransigence on sum types has caused a lot of real world harm

hoare's 'billion dollar mistake' is probably an understatement

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

gonadic io posted:

ooooooopppptttiiiiioooonnnnnn tttyyyypppppepeeeeesss

epic thissery

comedyblissoption
Mar 15, 2006

back of the envelope calculation

googling shows there are ~10 million (10^7) working professional software developers right now

for each programmer, having to worry about null and having bugs created by null has probably caused at least $1,000 (10^3) of lost productivity over their career (I think this is a very conservative estimate)

this would make the economic damage at least around $10 billion.

NihilCredo
Jun 6, 2011

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

gonadic io posted:

so you're left with two methods that both fail to use the type system to encode invariants. i really want to like f# but having all of the legacy of c# libraries and all of the legacy of the ocaml language seems to be p annoying at times

for bool * Thing, if the parse failed and the bool is false is that thing null or an exception or is it unspecified?

if the parse fails the return Thing will be the default for that value type, fpr numerals that's 0

the reason it's not a string -> Thing option is because it's not a f# specific wrapper, rather the f# compiler automatically converts c#'s out parameters to additional (tupled) return values, which is awesome in general but i agree is suboptimal in this particular case

(imo it should be rewritten in f# style, in the same way that many System.String functions got functional wrappers)

so yeah while can't just Seq.choose to ignore the successful results, the idea is that you can still quickly pattern match on it

code:

// handle failures
Seq.map (fun x -> match Thing.tryParse x with | false, _ -> Error x | true, value -> Success value )

// ignore failures
Seq.choose (fun x -> match Thing.tryParse x with | false, _ -> None | true, value -> Some value )

// or equivalently
Seq.map Thing.tryParse
>> Seq.choose (function | false, _ -> None | true, value -> Some value)

// or equivalently and you're a fancy twat
Seq.map Thing.tryParse
>> Seq.filter fst
>> Seq.map snd

NihilCredo fucked around with this message at 13:21 on Jul 16, 2016

Soricidus
Oct 21, 2010
freedom-hating statist shill
oh hey it's nullchat

i'm working with a commercial library at the moment that deliberately goes out of its way to return nulls anywhere you might have expected it to return an empty collection. except sometimes it returns a null instead of a single-element collection when you can calculate what the element would have been yourself. and sometimes it surprises itself with nulls, so some methods throw null pointer exceptions unless you manually call other methods first and do the null checks for it.

none of this is documented, it's trial and error all the way! and we don't have source, naturally. intellij's built-in java decompiler is proving handy although the code is, of course, obfuscated.

gently caress everything.

comedyblissoption
Mar 15, 2006

one of my pet peeves is when someone does a check for if a collection is empty before doing some logic

but that logic just consists of processing or iterating a collection and it would've been a no-op for an empty list anyways

~Coxy
Dec 9, 2003

R.I.P. Inter-OS Sass - b.2000AD d.2003AD
code:
if (butts.Any())
{
	using(var reader = command.ExecuteReader($"select * from Butts where ButtId in ({string.Join(",", butts.Select(b => b.ButtId))})"))
	{
		...
	}
}
VVV yes I agree, I'm mostly being facetious anyway

~Coxy fucked around with this message at 13:08 on Jul 16, 2016

comedyblissoption
Mar 15, 2006

not using parameterized queries is in general a bad idea even if that particular use case might not be a sql injection attack

Soricidus
Oct 21, 2010
freedom-hating statist shill
new coworker insists on writing if (!(a == b)) instead of if (a != b), does this justify homicide?

e: I think I just found an instance of if (!(a == b)) { /* do nothing */ } else { code } :psyduck:

Soricidus fucked around with this message at 14:01 on Jul 16, 2016

Stringent
Dec 22, 2004


image text goes here

Soricidus posted:

new coworker insists on writing if (!(a == b)) instead of if (a != b), does this justify homicide?

e: I think I just found an instance of if (!(a == b)) { /* do nothing */ } else { code } :psyduck:

rather than algorithms and data structures, poo poo like this is what interviews should check for

gonadic io
Feb 16, 2011

>>=

Soricidus posted:

new coworker insists on writing if (!(a == b)) instead of if (a != b), does this justify homicide?

e: I think I just found an instance of if (!(a == b)) { /* do nothing */ } else { code } :psyduck:

no big deal, just fail the code review until he starts aligning to your place's coding custom.

gonadic io
Feb 16, 2011

>>=
for example, we just hired somebody who was pretty adamant in his interview that tests were bad and slowed down good programmers - his fundamentals and code was p great otherwise though.

it was made very clear to him that if he accepted the offer then he'd have to change his habits and align to our style. he accepted. we'll see how long it takes to get him into the habits.

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

Soricidus posted:

e: I think I just found an instance of if (!(a == b)) { /* do nothing */ } else { code } :psyduck:

that is a thing of beauty. buy him an account

Luigi Thirty
Apr 30, 2006

Emergency confection port.

today's project is back face culling

Thankfully this one is simple, all we need to do is figure out the sign of the dot product of the triangle's surface normal and a vector from the viewer to the one of the vertices of the triangle

Luigi Thirty fucked around with this message at 14:43 on Jul 16, 2016

Progressive JPEG
Feb 19, 2003

gonadic io posted:

ooooooopppptttiiiiioooonnnnnn tttyyyypppppepeeeeesss

... which are nullable :troll:

comedyblissoption
Mar 15, 2006

Progressive JPEG posted:

... which are nullable :troll:
i assume you are alluding to java which has this and more :eng99:
https://medium.com/@bgourlie/java-8-s-new-optional-type-is-worthless-448a00fa672d#.k7ww2oh0n
https://developer.atlassian.com/blog/2015/08/optional-broken/

to be fair, you can't really add in a sane option type after you've already designed your language with nullable references. your entire library ecosystem and applications return null everywhere and you'd have to wrap everything

VikingofRock
Aug 24, 2008




Are there languages where !(a == b) is not always equivalent to (a != b)? Or common libraries which overload the equality operators in that way? I'm trying to understand what would put someone in that habit.

GameCube
Nov 21, 2006

VikingofRock posted:

Are there languages where !(a == b) is not always equivalent to (a != b)? Or common libraries which overload the equality operators in that way? I'm trying to understand what would put someone in that habit.

wouldn't this go against the most basic of logical principles?

so, probably php

VikingofRock
Aug 24, 2008




GameCube posted:

wouldn't this go against the most basic of logical principles?

so, probably php

You'd think so, but you'd also think that == would be transitive and I'm pretty sure loads of languages have 1 == true, 2 == true, but 1 != 2.

Soricidus
Oct 21, 2010
freedom-hating statist shill

VikingofRock posted:

You'd think so, but you'd also think that == would be transitive and I'm pretty sure loads of languages have 1 == true, 2 == true, but 1 != 2.

loads of languages have 0 == false and 1 == true and treat anything else as true when evaluating a boolean expression, but most of them don't actually have 2 == true if you try to spell it out that way

VikingofRock
Aug 24, 2008




Soricidus posted:

loads of languages have 0 == false and 1 == true and treat anything else as true when evaluating a boolean expression, but most of them don't actually have 2 == true if you try to spell it out that way

Ooh actually yeah that was a bad example. I should have gone with something like JavaScript where 0 == '' and 0 == '0' but '' != '0'.

JawnV6
Jul 4, 2004

So hot ...

VikingofRock posted:

Are there languages where !(a == b) is not always equivalent to (a != b)? Or common libraries which overload the equality operators in that way? I'm trying to understand what would put someone in that habit.
depending on optimization settings those might emit different code? like choosing a branch flavor that inverts if equality checks are cheaper than differences done by equal/invert/branch true

qntm
Jun 17, 2009
I don't know of a single programming language where !(a == b) does not equal a != b

I want to say that nobody is that crazy

JewKiller 3000
Nov 28, 2006

by Lowtax
In sql if either a or b is null, then you have null != b which is false for all b, but !(null == b) would be !false i.e. true for all b :getin:

hobbesmaster
Jan 28, 2008

qntm posted:

I don't know of a single programming language where !(a == b) does not equal a != b

I want to say that nobody is that crazy

the answer is always php

Bloody
Mar 3, 2013

JewKiller 3000 posted:

In sql if either a or b is null, then you have null != b which is false for all b, but !(null == b) would be !false i.e. true for all b :getin:

so comparisons to null are always false? what

like it becomes some sorta NaN like bullshit?

Gus Hobbleton
Dec 30, 2003
Probation
Can't post for 3 years!
yeah sql does some weird poo poo with null

NihilCredo
Jun 6, 2011

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

Bloody posted:

so comparisons to null are always false? what

like it becomes some sorta NaN like bullshit?

the only predicate about a NULL column that is true is "X IS NULL", every other statement is false

the reason for this is so that WHERE and JOIN work as expected, if "NULL <> @unwantedvalue" were true then some queries would return a ton of useless rows because non-INNER JOINs use NULLs to represent missing matches (which is the actual horror)

NihilCredo fucked around with this message at 19:48 on Jul 16, 2016

VikingofRock
Aug 24, 2008




Bloody posted:

so comparisons to null are always false? what

like it becomes some sorta NaN like bullshit?

Even for NaN, NaN != NaN is true.

cinci zoo sniper
Mar 15, 2013




maybe it's like that not all infinities are equal type of thing

Luigi Thirty
Apr 30, 2006

Emergency confection port.

turns out basic back face culling takes about 15 seconds to implement once you look at the formula and the math is super simple lol

Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

I took database class in undergrad and the one of the main tips i remember our professor going on about was to watch out for sql nulls. if you don't pay attention you can start relying on some idiosyncratic or undefined behavior, and then you'll introduce a change that breaks everything in mysterious ways

NihilCredo
Jun 6, 2011

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

Lutha Mahtin posted:

I took database class in undergrad and the one of the main tips i remember our professor going on about was to watch out for sql nulls. if you don't pay attention you can start relying on some idiosyncratic or undefined behavior, and then you'll introduce a change that breaks everything in mysterious ways

one of the few legitimately good practices my boss had put in place was to forbid intentional NULLs in all database structures. always define and enforce default values for all columns

comedyblissoption
Mar 15, 2006

null in a database is okay and is like an option type. nullable types obviously can still be abused if you model the problem improperly, of course.

the problem with it in most programming language is that the programming language gives you no explicit choice and you are forced to possibly have null in your reference whether you like it or not

the equivalent problem in a database would be if a database made all your columns nullable and there was no way to prevent it

Adbot
ADBOT LOVES YOU

gonadic io
Feb 16, 2011

>>=
really suffering from paralysis here

the idea of my project was to do the data structures in rust and then use unity for the game engine. this is working okay, i've got rust plugins running in unity just fine.

the question is what do i do now? working in unity (and c#) is kinda balls, but i can't do much more in rust without rendering and having mouse interaction.

i guess i could start trying to start a f# project that calls the c# api so i can write the game logic in f#? but then maybe i'll switch to cryengine, but that doesn't have a mac editor and ahhhh

  • Locked thread