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
return0
Apr 11, 2007

Manslaughter posted:

I always thought of typecasting as "I'm going to use my +2 programmer's staff to cast this IWankable into a WankPole"

I am going to attempt to engineer a context where typecasting is discussed at work so I can say this!

Adbot
ADBOT LOVES YOU

return0
Apr 11, 2007

qntm posted:

I've just started work on a new codebase developed by a team which is geographically distributed. I think some of them are in Toronto and some are in Bangalore but I honestly don't know. All that matters is that these developers are not where I am, which mean's I'm not able to physically confront them over JavaScript code like this:

JavaScript code:
function(arg1, id=null) {
    if(id == null) {
        // do a thing
    } else {
        // etc.
    }

    // and so on
}
and this:

JavaScript code:
var entry = "[{\"name\": \"" + name + "\", \"value\": \"" + value + "\"}]";
var component = JSON.parse(entry);

// more code uses `component` down here
Guess what the answer to the "Who does your buddy checks?" question was.

I don't know much about JS, what's the horror with the first one... looks like branching on the value of a default argument?

return0
Apr 11, 2007

HFX posted:

There is nothing wrong with using XML.

Hmm.

return0
Apr 11, 2007
Sounds like a (tiny) throwaway demonstration/test app/spike, what's the horror?

return0
Apr 11, 2007

aunt jemima posted:

That should never, ever, be a HTTP 200. :bang:

I used to work at this company where another team had a product and the web API for it would return 200 with a status/error string even in the presence of client or server errors, I asked why they didn't return 4xx/5xx as appropriate and they gave some long implausible sounding reason I can't remember.

return0
Apr 11, 2007

Karate Bastard posted:

A rule of thumb: if you're doing crypto, don't.

Or just do it right, like every other thing you have to do. Don't see what's special about crypto.

return0
Apr 11, 2007
You people do realise that humans wrote your crypto libraries right? And that you yourself could contribute code to a crypto library. "This problem is hard to get right so don't do it" sucks.

Obviously you wouldn't write a home rolled crypto library for your lovely web app, but you might write crypto if you were writing, I dunno, a crypto library?

Note that I didn't look at the specific example, my reply was a general response to a general comment.

return0
Apr 11, 2007

Janitor Prime posted:

And it is an invalid response that shows your ignorance on the subject. I'm glad that you completely disregarded all those actual posts trying to educate you instead of mocking you.

This is a completely ridiculous attitude. If everyone took your advice there would be no crypto.

At no point have I advocated people roll their own crypto libs, I'vs merely stated (admittedly somewhat obliquely initially) that the rule of thumb presented (if you're doing crypto, don't) is bad. Better advice would be to write it correctly, with respect to literature and practical implementation lessons.

My personal preference would be that we despookify crypto so it isn't so weird and scary for competent engineers.

return0
Apr 11, 2007

good jovi posted:

crypto isn't for engineers, it's for mathematicians

Implementation is engineering, and crypto defects are introduced by people doing software engineering. I guess I just feel quite strongly that the development of better primitives and abstractions for helping to not make open crypto a clusterfuck would be better accomplished by not propagating the attitude that crypto is a sacred thing for geniuses, like I guess like multithreading (and probably programming in general) was in decades past. If you disagree then fair enough?

Obviously don't write your own crypto lib, but only in the same way you don't write your own database engine, programming language or operating system (i.e., it shouldn't be special). Anyway, sorry for the derail.

return0
Apr 11, 2007

JawnV6 posted:

Do your normal standards for software engineering account for sidechannel timing attacks leaking information? I've never really taken that into account. Who should have caught the PS3 signing bug, the implementing engineer or a mathematician auditor?

Why don't you tell me what you think?

return0
Apr 11, 2007

sarehu posted:

"Don't do your own crypto" does not mean don't write your own crypto lib, it means don't use a crypto lib directly.

And it's not the same thing as writing your own database engine at all.

Source: My coworkers that I was making a database engine and programming language with tried to do their own crypto.

Also, there's nothing wrong with making operating systems. What are you, some pussyfooted little human being that's afraid to dip down into ring zero? The real rule is "don't write your own web server." Possibly the one thing that's worse than using a crypto lib directly.

Source: That database engine I was talking about? It has its own widdle bespoke web server. Making a page cache or filesystem isn't really that hard, compared to having a web server that isn't a buggy insecure piece of poo poo.

Honestly I don't even

return0
Apr 11, 2007
Okay shrughes, if it's bad to use an existing crypto library and its bad to write your own, what to do?

return0
Apr 11, 2007

Jsor posted:

I think my favorite part is typedefing std::ifstream as ifstream as if it were better than using a namespace.

is the typedef in a header

return0
Apr 11, 2007

sarehu posted:

You have to be emotionally retarded to interpret that retroactive abortion comment as vitriolic.

Linus says emotionally retarded things a lot. Like if someone else said what he said you'd totally be saying it was emotionally retarded. I mean, "retroactively aborted", jesus gently caress is he 14?

return0
Apr 11, 2007

ExcessBLarg! posted:

Android isn't bad, at all, if you start off using Android Studio and you restrict your apps to recent versions of Android only. API 16+ (Jelly Bean 4.1) is a reasonable target these days, which is compatible with 88% of the devices in current use.

Where Android becomes a problem is when you have to provide legacy support for 2.x devices, make use of a bunch of Google services, and use the old Eclipse/ADT-based build system. But you can pretend none of that exists and you're good.

What if you need to use the NDK, does that work properly/nicely with Android Studio yet?

return0
Apr 11, 2007
Are you sure you want to cancel your order?

Cancel / Yes

return0
Apr 11, 2007

Qwertycoatl posted:

code:
unsigned int is_even(unsigned int x)
{
    for (unsigned int i = 0; i < x; i++) {
        x *= x;
    }
    return !x;
}

whoa, why does this work

return0
Apr 11, 2007

Qwertycoatl posted:

It relies on integer overflow. If you repeatedly square an even number, it will become 0 mod 2^32. If you repeatedly square an odd number, it will become 1 mod 2^32.

:O

return0
Apr 11, 2007

SupSuper posted:

http://c2.com/cgi/wiki?StringlyTyped

It's sadly common in a lot of APIs. :eng99:

True story, my colleagues and I invented this term while working at a games company.

return0
Apr 11, 2007

Ekster posted:

Current management fad not a replacement for competence, news at eleven.

How is Agile a fad?

return0
Apr 11, 2007

IT BEGINS posted:

Small dev horror. Asked one of our senior devs to pair with the new guy to work on adding a feature to our 'remote' authentication. Asked him to also test drive it or at least cover it so some of the guys that are new to testing have a real example to look at.

Got told "it will only confuse the new guy" and "it's a terrible specimen to test" because it requires "heavy mocking of the incoming request". :doh:

Sounds like the senior dev has correctly identified the horrors of test-first.

return0
Apr 11, 2007

Ithaqua posted:

And? DVCS is absolutely overcomplicated for what some teams are doing. If the team doesn't need to work offline and rarely branches and their existing VCS tools work for them with no pain or angst, why should they change to DVCS? There's way too much DVCS cargo culting happening and it drives me crazy.

Here are the cases when DVCS is inappropriate:

  • Large, frequently modified binaries in source control.

return0
Apr 11, 2007

Munkeymon posted:

code:
git: merge conflict detected!
git: would you like me to:
git:    1) begin an interactive merge session
git:    2) [quit wituout making any changes]
git:    9) mash the changes into your working directory so you can deal with them yourself
git:? 9
git: are you sure? y/[n]
And of course you could set a thing in your options to bypass that directly to your preferred default and set an editor to do the interactive merge, etc.

This would be insanely bad.

return0
Apr 11, 2007

TooMuchAbstraction posted:

...why? You can't just say something like that without giving an explanation.

Git already does something perfectly sane. It puts standard merge metadata in the file which allows the use of pretty much any merge tool. It has a UI hook to allow invoking a user-configured merge tool. In the default state if there is a merge conflict, the conflicting files are unstaged - this means they will not be committed unless explicit action is taken to do so.

The current behaviour for handling merge conflicts is cool and good.

return0
Apr 11, 2007
code:
~>  irb
2.3.0 :001 > String === ""
 => true
2.3.0 :002 > "" === String
 => false
2.3.0 :003 >

return0
Apr 11, 2007
In all fairness, maybe it's not so weird after reading more about it, but definitely caught me out earlier in a ruby web service we've inherited.

return0
Apr 11, 2007
I quite like JS tbh.

return0
Apr 11, 2007

eth0.n posted:

Declaring that a function takes a function pointer of type "int(int, int)" is not as clearly defined as declaring one that takes type an object of type IntegerAdder. The former can take any kind of function that returns int given two ints, even if that function has nothing to do with adding. The latter requires something which conforms to the interface IntegerAdder. Sure, the compiler can't check that the implementation of IntegerAdder is actually an adder, but the greater specificity still has value. It's a much more obvious error when an implementation of IntegerAdder has nothing to do with adding.

Not sure what it is about this paragraph, but to me it actually feels like you're trying to convince me of the opposite of what you're claiming.

return0
Apr 11, 2007

Spatial posted:

CSS is a design language conceived by programmers so it's no surprise it's pure poo poo. It's been a couple of years since I used it, but AFAIK it doesn't even have the fundamental layout structure of a grid with column spanning. Or the ability to define colour constants. No biggie, designers don't use colour palettes or column-based layouts right? Haha.

Yeah but scss and bootstrap?

return0
Apr 11, 2007

BlackMK4 posted:

code:
<?php
    /*
        This is a PHP comment so no one sees it other than
        the poor soul (you) that has to crack this open in the future.
        
        DO NOT REMOVE THE WEIRD COMMENTS IN THE HTML BELOW, THEY ARE
        THERE FOR A REASON. (REMOVES SPACE BETWEEN INLINE-BLOCK ITEMS)
    */
?>
<div class="checkbox--div">
    <input id="numbered-1" type="checkbox" class="checkbox--numbered" name="1" checked="checked">
    <label for="numbered-1" class="checkbox--numbered-label">1</label>
</div><!--
--><div class="checkbox--div">
    <input id="numbered-2" type="checkbox" class="checkbox--numbered" name="2">
    <label for="numbered-2" class="checkbox--numbered-label">2</label>
</div><!--
--><div class="checkbox--div">
    <input id="numbered-3" type="checkbox" class="checkbox--numbered" name="3">
    <label for="numbered-3" class="checkbox--numbered-label">3</label>
</div><!--
--><div class="checkbox--div">
    <input id="numbered-4" type="checkbox" class="checkbox--numbered" name="4">
    <label for="numbered-4" class="checkbox--numbered-label">4</label>
</div><!--
--><div class="checkbox--div">
    <input id="numbered-5-plus" type="checkbox" class="checkbox--numbered" name="5-plus">
    <label for="numbered-5-plus" class="checkbox--numbered-label">5+</label>
</div>


Is this actually bad (the comments to not have spacing, rather than the repetition in the HTML itself)?

return0
Apr 11, 2007
Why would anyone want valgrind not to warn about the uninitialised memory read bugs in openssl? They were bugs.

return0
Apr 11, 2007
Is all this scraping not against the ToS for these sites? I understand it for a shits n giggles personal project, but how do businesses get away with it?

return0
Apr 11, 2007

SupSuper posted:

- Comparing floating values with ==.

What's the problem here? Not sure why they should need an epsilon for these comparisons given the context, maybe I am missing something.

return0
Apr 11, 2007
Yes?

return0
Apr 11, 2007
Like I agree say, 1.2f != 1.2, but 1.f == 1.0 should be legit.

return0
Apr 11, 2007

ulmont posted:

Pretty sure both have been posted here before, but helpful links regarding floating point:

1) A long (16 part) series with more than you would ever want to know about floating point weirdnesses.
https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/

Article from same stating that floating point ain't magic and sometimes you really do want an equality comparison (as I think was the case in the function that led to this discussion):

https://randomascii.wordpress.com/2012/06/26/doubles-are-not-floats-so-dont-compare-them/

return0
Apr 11, 2007

hobbesmaster posted:

You know what started this is testing a variable called paramDblValue against a float literal and not a double.

Yeah but comparing against 1 :)

return0
Apr 11, 2007
Hahaha perfect horror thread response

return0
Apr 11, 2007

Suspicious Dish posted:

it seems like an obvious logical next step but maybe thats just me???

Who would think this wouldn't leak though? It quite clearly states the rationale.


VikingofRock posted:

Do people really use reinterpret_cast much in practice?

I've seen reinterpret_cast for casting (appropriately padded, aligned, endianned) byte data to an array of structs, if you want to avoid a copy. I've seen this done in games where it's been used to load data from the network or disk, like an environment block.

Adbot
ADBOT LOVES YOU

return0
Apr 11, 2007

Bongo Bill posted:

It's called "stringly typed"

I worked in the team that invented this term, seriously. It was hell.

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