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
Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Ithaqua posted:

It's not necessarily intuitive, but it's well-defined behavior.
http://stacktoheap.com/blog/2013/06/15/things-that-trip-newbies-in-powershell-pipeline-output/

You can pipe the output of ReturnFalse into out-null so that it doesn't put the extra $false into the pipeline.

A lot of the things PHP does are "well-defined behavior" too, that doesn't make them any less of a horror.

This is unjustifiable behavior. Anyone who has ever written code in any language but Powershell is going to be surprised by this.

And if you're lucky you'll be surprised by it when writing some one-off script. If you're me, today, you'll find out about it because your deployment system written entirely in PS (which is, itself, a horror) decided to take a code path that no one expected, taking down several production servers.

I wasn't the one that wrote the offending code, but if four devs staring at the code (two of whom write PS daily) can't figure out what's happening for hours then I don't know if you can really blame the person who did.

Adbot
ADBOT LOVES YOU

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
Returning false from my script is success you say? Throw an exception you say?

code:
if (-not $poolOk)
{
    throw $unicode_tableflip_emoticon
}
Edited because the forums are apparently also a horror.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Dr. Stab posted:

Are you sure you want to cancel?
Cancel | Continue


If the order of the buttons were flipped this would be fine, since you should also follow the convention that the operation being confirmed will happen when pressing the rightmost button.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
*huff, puff* Is this where the indentation and braces style debate is happening? I'm not late, am I?

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

ExcessBLarg! posted:

holy poo poo I don't care.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Biowarfare posted:

php:
<?
function isEven(int $i): bool {
        $check = ($i / 2);
        if (stripos((string)$check, '.') === false) {
                return true;
        } else { return false; }
}
?>

lol if this works, because it means php returns a float result from integer division

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

WHERE MY HAT IS AT posted:

PHP doesn't have integer division. When would you ever need that?

Why isn't there a :php: yet?

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

zergstain posted:

I love how that will overflow if n is odd.

My favorite part is just what the gently caress is it even doing?

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
My mental image is something like a dude on a skateboard, going "Oh my god, I think I finally got this, you gu-" and then faceplanting right into some stairs.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Harik posted:

I'm well aware. It's only c++11 in that they're abusing the new features 11 brought. Are there good examples of operator "", or is it just there to be a lurking horror?

Well, a trivial example would be your own bespoke artisanal string class. Saves on the macros.

The builder pattern isn't too bad to use, but it's a huge pain in the rear end to implement.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

loinburger posted:

eliminate the unlikely chance that he'd generate two identical UUIDs out of a hundred million ids

Heat death of the universe.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

quote:

*** Bug 260998 has been marked as a duplicate of this bug. ***
Seen from the domain http://volichat.com
Page where seen: http://volichat.com/adult-chat-rooms
Marked for reference. Resolved as fixed @bugzilla.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Internet Janitor posted:

Why on earth would this be considered desirable behavior?

~omakase~

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

No Safe Word posted:

So, someone took a moderately objective and somewhat constructive view of the old classic bastion of coding horrors: TempleOS

http://www.codersnotes.com/notes/a-constructive-look-at-templeos

I don't remember who called TempleOS "outsider art" but that seems like the most apt description of it, and when I saw it called that I immediately understood why my friend was so interested in the music I created before I knew anything about making music.

The dude created an entire OS from scratch by himself with tons of interesting features. He may be crazy but he is also a genius.

Dessert Rose fucked around with this message at 19:54 on Jun 9, 2015

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
C# is a great language and ASP.net MVC is a ... good framework.

fleshweasel posted:

If you just want to get started with something quick, node.js is alright but I'm skeptical of it for anything big or important.

I think node.js might be one of the only frameworks you could have picked that is actually worse than Rails.

Probably your first concern when picking a framework is picking a language.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Drastic Actions posted:

Bug, assigned to me.



People have no sense of humor, I swear.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
I enjoy "expected result: unexpected xxx should not.." Thanks for the detail!

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
In 1995 or so, everyone freaked out about this crazy problem where a bunch of idiots decided to save space by storing the year in two digits instead of four, and the world was going to end in 2000.

2000 rolled around and nothing happened. Because people realized there was a problem and worked hard to fix it.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
Ntfs has always supported symlinks

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Plorkyeran posted:

It's only supported symlinks since XP/2003, and it wasn't until Vista that you could create them in user mode (in XP you needed to install a helper driver).

oh huh. i could have sworn they were in nt4. welp

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Plorkyeran posted:

There were always junction points, but having a single directory appear at multiple paths won't help you with the problem at hand.

Oh, that's what I was thinking of. Glad to know I'm just wrong and not insane.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Snapchat A Titty posted:

Maybe you're both!!!!

Yes that is a possibility I am considering.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
I've never seen the term "all hell breaks loose" in official, public documentation before.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

IT BEGINS posted:

Half of my coworkers still don't understand how to use rebase in mercurial. As a result, our repository log often looks like this:



I think it looks pretty :3:

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Hammerite posted:

One could imagine a sort of "generalised switch" statement that takes two arguments, a comparison function and an operand.

So basically condp.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Milotic posted:

I'm possibly missing some subtlety above, but null is useful in imperative based programming languages where you don't know what the value of a variable to be assigned will be yet, and it doesn't have a sensible default value.
Not initializing the variable is a perfectly acceptable option here. Your compiler should be able to work out if the variable is definitively initialized before use in all execution paths.

quote:

It also fulfills the useful requirement of failing hard and fast when one arises unexpectedly - it means you've got a logic error or a failure to respect the interface of a method call. I think most .NET programmers wouldn't mind as much if the null reference exception just listed the variable name somehow (or if the runtime was able to infer the type the object was meant to be).
Wouldn't it be better if the compiler could catch that you weren't respecting the interface of a method call?

quote:

e: I guess you're encoding that it can return a unit in the signature of the method, which could be useful - but isn't unit in danger of becoming a bucket type like null then? i.e. It's undefined, or the method does something under the covers.

If it's encoded in the signature of the method and I have to unwrap it explicitly (like returning a Maybe or an Either) then it's obvious from the caller side that I have to handle both cases.

When null is allowed by default it is terrible because every method that returns an object could be returning null. Maybe this one returns null on error! Maybe it throws an exception! We just don't know.

Eric Lippert has said that he wishes .NET had non-nullable references by default. But now it's too late.

Null is not a good idea. The "problems" it "solves" either don't really exist or have much better solutions.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Milotic posted:

Yes, but it would likely not cover every edge case and possibly bloat compile times.

As to the latter: compile times are like the last thing I care about, compared to getting a crash report from production because of a nullref. I'll happily blow an hour a day on automated tools that tell me when I could be loving up.

Isn't the entire point of a managed language to help you not blow your foot off? That's what we're spending all those runtime resources on, right? If you don't want compiler warnings for every possible mistake in your code, why not just write native code?

As to the former: The point is not to cover every edge case, necessarily, but to make it very difficult to make this kind of mistake. It may be possible to "trick" the compiler one way or the other (usually managed compilers err on the side of, well, errors, if they can't figure things out) but that is a sign that you are doing something wrong too.

If a machine can't figure out your code's intent, you should probably restructure it.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
It's a pretty good comparison, because programmers expend tons of effort to ensure that the enormous mistake from the past doesn't actually cause that much damage.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

No Safe Word posted:

http://www.diogonunes.com/blog/custom-build-configurations-visualstudio/

How not to use build configurations with Visual Studio :doh:

I mean, yeah that's how you set them up. But it's not what they're for.

code:
#if   RELEASE_CLIENT_ABC
    bool _isDebug = false;
    Organization _currentOrg = new ClientABC();
#elif RELEASE_CLIENT_XYZ
    bool _isDebug = false;
    Organization _currentOrg = new ClientXYZ();
#elif RELEASE
    bool _isDebug = false;
    Organization _currentOrg = new DevTest();
#else
    bool _isDebug = true;
    Organization _currentOrg = new DevTest();
#endif
:sigh:

I sort of did this with an iOS app, back before IAP when the way to let people purchase "consumables" was to distribute multiple versions of an app at different prices.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Subjunctive posted:

I guarantee that there are SDETs in Redmond

wrong!

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Sinestro posted:

The Something Awful Forums > Discussion > Serious Hardware / Software Crap > The Cavern of COBOL > Coding horrors: how is T_PAAMAYIM_NEKUDOTAYIM formed. how girl get preg_match()

not emptyquoting.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

ChickenWing posted:

I'm relatively new to work-programming and I started to worry that I was overusing hashmaps.


Seriously am I crazy or are they the best option for approximately everything?

Hash maps are so good that in Clojure you just use them for everything vaguely object-like. The language provides tools to create actual objects that still act exactly like hashmaps so that you can improve performance on the "expected" fields without changing all of your code that you wrote back when your object was just a map.

Like was said above, use them until you have a reason not to.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Ender.uNF posted:

Second horror is that Windows is crap at allowing apps to specify awareness flags or SDK versions they link against so you can't just say "oh you linked against Windows SDK 8.0? OK, MAX_PATH for you is 32k".

this would be super exciting for Subjunctive's reason but also because my class which declares an array of char[MAX_PATH] would suddenly grow by 32KB per instance depending on which OS I was compiling for.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
One of Perl's uses is in shell one-liners, and writing "use sloppy;" at the beginning of those would be kind of a pain.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
Checking .elems == 1 is the new != null

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Bognar posted:

C# code:
// assume EST local timezone
var dst    = DateTime.Parse("2015-11-01T05:30:00Z");
var nonDst = DateTime.Parse("2015-11-01T06:30:00Z");
Console.WriteLine(dst);    // 11/1/2015 1:30:00 AM
Console.WriteLine(nonDst); // 11/1/2015 1:30:00 AM
Console.WriteLine(dst == nonDst); // true
In .NET, DateTime.Parse automatically converts UTC times into local time and loses information in the case of daylight savings time.

There's a reason DateTimeOffset exists and all new code should use it.

ExcessBLarg! posted:

The first horror is that, that timestamp doesn't include a zone offset. I imagine that the result would still be amusing (and probably useless) if it did, though.

The parsed string does, in fact, include a zone offset ("Z" means Zulu, or UTC, or GMT, or whatever other name we're using today).

The default ToString() on a DateTime doesn't include the time zone because timezone information is not included in the DateTime struct. Again, the DateTimeOffset struct was introduced to address this exact shortcoming, and all new code should avoid use of DateTime and only use DateTimeOffset.

Dessert Rose fucked around with this message at 22:27 on Sep 17, 2015

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

fleshweasel posted:

Aren't there problems with serialization of DateTimeOffsets?

Some cursory searching suggests that XmlSerializer doesn't do it out of the box, but if you use a DataContractSerializer it's fine.

You're going to have to do some work either way: you have to send the timezone offset separately if you use a DateTime (or standardize on UTC), or you have to do a little bit of lifting to serialize a DTO properly.

Seems like a pretty poor oversight, though.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Bognar posted:

I agree that DateTimeOffset should be used for capturing timezone information, but don't you think that parsing a time should result in the same representation of that time? If DateTime doesn't have timezone information, then parsing "5:30 AM" should result in 5:30 AM and not be converted based on whatever your local timezone is.

So I dug deeper.

First, I would argue that there is a bug here, but it's simply in DateTime.operator==:
code:
Console.WriteLine(dst.IsDaylightSavingTime()); // true
Console.WriteLine(nonDst.IsDaylightSavingTime()); // false
Console.WriteLine(dst == nonDst); // true???
So there's that. But it does keep the information about DST in the struct, and converting it back to UTC results in sensible behavior:
code:
Console.WriteLine(dst.ToUniversalTime() == nonDst.ToUniversalTime()); // false
At this point, that bug is unfixable. Some code, somewhere, depends on this behavior, and will break in subtle and fun ways if it changes.

To address your argument that it shouldn't be converted to your local timezone, the interface of Parse() is more complicated than you're making it out to be, and if you bothered to read the documentation, you would find that you can get the behavior you want:
code:
var dst    = DateTime.Parse("2015-11-01T08:30:00Z", null, System.Globalization.DateTimeStyles.RoundtripKind);
Console.WriteLine(dst);   // 11/1/2015 8:30:00 AM
DateTimeStyles has a bunch of different ways you can treat the string, including "always make it UTC if there's timezone information", "always make it local time", and "leave it the gently caress alone".

In summary, time is never as simple as developers want it to be. News at 11.

Dessert Rose fucked around with this message at 00:33 on Sep 18, 2015

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Bognar posted:

No need to be a dick about it. I'm well aware of the Parse overloads, but I still don't understand why Parse(string) defaults to converting to local time instead of just setting Kind to Utc.


Sorry, I just have low patience when people call things horrors without doing much research :shobon:

Think about this: if you have a time in any other timezone but your own or UTC, what should happen by default? It has to get converted to something, because DateTime doesn't have offset information. It can only be "local timezone" or "UTC", so it has to pick one. I would argue that, given the rest of the API defaults to local time, converting to local time is consistent with the semantics of DateTime. For example, DateTime.Now returns the local time; you need to call UtcNow if you want UTC, instead of Now returning UTC and LocalNow returning local time.

So what should happen if you call Parse with a UTC time? Should it suddenly decide to leave it alone? That would be pretty surprising, because in every other case Parse is converting to local time. If I test my app with a couple random timezones (but not UTC) and see that Parse is converting to local time, I'm going to be pretty mad and probably even post in this thread if it suddenly decides not to convert UTC times.

The single-parameter Parse is a convenience method. It's going to make some decisions for you that might not be the right ones, and that's totally fine! That's why you should always look at the other overloads and understand the decisions you can make, that the convenience method is making for you.

The lesson here is pay attention to the APIs you're calling. Especially with something as complicated as time, don't assume that the defaults fit your use case.

Adbot
ADBOT LOVES YOU

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

HardDisk posted:

I think the biggest horror is that people were being confused by the arcane term "Transfer money".

What makes you say that?

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