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
MononcQc
May 29, 2007

crazypenguin posted:

quickcheck doesn't help with the DI part of it, but you can still quickcheck IO/stateful stuff like mad, it just takes a bit more work. You have to build a simple little state machine simulator, and randomly generate a list of actions to perform, and then verify the simulator and the real thing give the same results at every step. Possibly also checking invariants on the real thing at each step. It's pretty awesome actually.

I saw Hughes give a talk about quickchecking a database implementation and finding concurrency bugs. He did this cool live demo showing a quickcheck finding a concurrency bug that was open on some erlang db for months or years or something that nobody was able to reliably reproduce until he whipped his thing up. It was awesome.

DI stuff is slightly overused, imo. It's useful for unit testing business logic, and not much else. The special thing about business logic is that usually there's a crapton of state you have to set up like a rube goldberg machine to test the particular path you're interested in, and then it's better to just fake it than try to create that fragile mess. For the most part, I think actually just running the real thing is underrated, though I understand some databases (and other external services) can make it really difficult to do so.

Yeah, I'm aware of that presentation and saw it a few times. The demo was with DETS, a disk version of some in-memory database that ships with Erlang. It's pretty subpar quality and routinely corrupts files for me, and still can't store more than 2GB of data. It's a dinosaur that needs to go.

I do a decent amount of quickcheck testing whenever I'm able to figure out some system property or can use an alternative implementation as a model somewhere else.

The other extremely difficult stuff with quickcheck is to have the proper generator distribution for what you require. If for example what you figure out you error out on is that you implemented UCS-16 instead of UTF-16, you won't find out about it until you generate a valid surrogate pair that UCS won't support but UTF will ask you to. Unless you generate that proper sequence, your test case might be verifying the wrong thing.

An example I gave when I used to give some Quickcheck training for Erlang Solutions Ltd. was to test a serializing/deserializing function that be similar to one of the early formats of socket.io's scheme. Basically, I'd give you one string in, and I'd ask you to check that the parser for deserialization worked as well as the encoder. The starting trick was simple:

The implementation I gave was the identity function so encoding = decoding, and when people inevitably wrote the property 'X = decode(encode(X))', it would always pass despite being useless. Once people had found that bug, they had to come with alternative implementations.

The particularly tricky one was that I had encoded a bug in there in which the parser didn't support escaping escape sequences (i.e. "\"" is a valid string, but "\\\"" was undefined behaviour that would generally fail the entire sequence). When people would serialize data or generate random strings according to the string type, and given this was Unicode, there was roughly 2N/110,000 chances of seeing either " or \ in the string, and the chances of seeing both together were extremely minimal (that's not entirely true because quickcheck grows its random set from smaller to bigger values, and " and \ are lower in the unicode standard than most characters, so the probability was likely higher).

That's where I tend to have problems with a lot of quickcheck tests. It's easy to put up a bad general series of test cases up. It's really really hard to set things up so you have a valid set of tests that will generate relevant risky input on your behalf. It's even harder to test things right when you want to generate a specific result of a state machine or precise process: "generate valid JSON" or "generate valid HTTP requests" is often as hard as generating a proper parser in the first place. At best your property-based test is likely to check that your generator and your parser are broken in the same way for such cases, unless you decide to depend on a third party to work.

They're really really nifty tests, but I find them far more useful for data structures and specifically well-defined algorithm with known properties than anything else.

Adbot
ADBOT LOVES YOU

Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.

kalstrams posted:

is dvorak/colemak something to look into or not

I changed to Dvorak well before I was doing paid development work, or just needing to be productive in general. I mean, It didn't take too long to speed up, but it's a pretty drastic change and it will hurt your productivity badly while you're making it. I like the layout, but yeah, big outlay.

All that said, I'm a wierdo who is using Dvorak, a trackball, vim, and terminal for everything.

gonadic io
Feb 16, 2011

>>=

Maluco Marinero posted:

I changed to Dvorak well before I was doing paid development work, or just needing to be productive in general. I mean, It didn't take too long to speed up, but it's a pretty drastic change and it will hurt your productivity badly while you're making it. I like the layout, but yeah, big outlay.

All that said, I'm a wierdo who is using Dvorak, a trackball, vim, and terminal for everything.

if young: gauged ears? if old: long grey hair?

Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.

gonadic io posted:

if young: gauged ears? if old: long grey hair?

What are gauged ears?

Asshole Masonanie
Oct 27, 2009

by vyelkin

Maluco Marinero posted:

What are gauged ears?

old man spotted

Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.
I may be due for my mid life crisis but I'm not even 30. :D

GameCube
Nov 21, 2006

"gauged" lmao

GameCube
Nov 21, 2006

the command line... so quirky

Notorious b.s.d.
Jan 25, 2003

by Reene

Maluco Marinero posted:

All that said, I'm a wierdo who is using Dvorak, a trackball, vim, and terminal for everything.

in yospos that is not even close to weird

Notorious b.s.d.
Jan 25, 2003

by Reene

eschaton posted:

I'm actually on that list (not forum) and it has not just CVS but RCS/SCCS adherents and ClearCase (or was it PVCS?) advocates

people who consider locking everyone else out of a file while it's being edited by one person a serious advantage

who think sharing should code be done via a shared filesystem - and possibly sharing build intermediates too

rcs, i get. people like simple

but cvs? no. nobody defends cvs. ever.

Notorious b.s.d.
Jan 25, 2003

by Reene

Stringent posted:

i wonder if there's some other forum where some dude 10 years older than rotor is vociferously defending cvs

eschaton is making it up, nobody defends cvs

svn doesn't add very much. it's just cvs done right. and it came with a tool to migrate your cvs poo poo. it's cvs without the bugs and the pain and the misery

b0lt
Apr 29, 2005

eschaton posted:

I'm actually on that list (not forum) and it has not just CVS but RCS/SCCS adherents and ClearCase (or was it PVCS?) advocates

people who consider locking everyone else out of a file while it's being edited by one person a serious advantage

who think sharing should code be done via a shared filesystem - and possibly sharing build intermediates too

just do pair programming and share computers instead

hobbesmaster
Jan 28, 2008

rrrrrrrrrrrt posted:

inheritance is bad. just use mixins :downs:

i need giant posters that say "premature optimization is bad" and "composition is ok!"

Stringent
Dec 22, 2004


image text goes here

Notorious b.s.d. posted:

eschaton is making it up, nobody defends cvs

svn doesn't add very much. it's just cvs done right. and it came with a tool to migrate your cvs poo poo. it's cvs without the bugs and the pain and the misery

i refuse to believe that any software that has ever been used by more than three people doesn't currently have partisans arguing its supremacy, on the internet, right now

fritz
Jul 26, 2003

Stringent posted:

i wonder if there's some other forum where some dude 10 years older than rotor is vociferously defending cvs

I'm sure my former co worker is posting somewhere

bobbilljim
May 29, 2013

this christmas feels like the very first christmas to me
:shittydog::shittydog::shittydog:
rename thread to "perverted ways to use outdated source control"

rotor
Jun 11, 2001

classic case of pineapple derangement syndrome

Bloody posted:

three is the first odd prime number, so that's nifty.

I still count 1 as prime. If it was good enough for Hardy, it's good enough for you animals.

fritz
Jul 26, 2003

rotor posted:

I still count 1 as prime. If it was good enough for Hardy, it's good enough for you animals.

good enough for olliver hardy

rotor
Jun 11, 2001

classic case of pineapple derangement syndrome

fritz posted:

good enough for olliver hardy

look at this pleb who doesn't know Hardy or his works

fritz
Jul 26, 2003

rotor posted:

look at this pleb who doesn't know Hardy or his works

he should have apologized for his apology

Flat Daddy
Dec 3, 2014

by Nyc_Tattoo
rotor wants everyone to know his hardy works

rotor
Jun 11, 2001

classic case of pineapple derangement syndrome

Flat Daddy posted:

rotor wants everyone to know his hardy works

in what weird country is that slang and what is it slang for

Stringent
Dec 22, 2004


image text goes here
only hardy rotor knows about is hardee's

PokeJoe
Aug 24, 2004

hail cgatan


rotor posted:

in what weird country is that slang and what is it slang for

cell phones by europe

e: actually i think im thinking of a handy

gonadic io
Feb 16, 2011

>>=

rotor posted:

I still count 1 as prime. If it was good enough for Hardy, it's good enough for you animals.

If 1 is prime, then pretty much every time you say "for all primes" you now need to say "for all primes except for 1".

Workaday Wizard
Oct 23, 2009

by Pragmatica

gonadic io posted:

If 1 is prime, then pretty much every time you say "for all primes" you now need to say "for all primes except for 1".

which 1? :haw:

karms
Jan 22, 2006

by Nyc_Tattoo
Yam Slacker

PokeJoe posted:

cell phones by europe

e: actually i think im thinking of a handy

european is a language? thats new

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
C terrible programmer s: implementing a ruby dsl

compuserved
Mar 20, 2006

Nap Ghost

gonadic io posted:

If 1 is prime, then pretty much every time you say "for all primes" you now need to say "for all primes except for 1".

this

Blinkz0rz
May 27, 2001

MY CONTEMPT FOR MY OWN EMPLOYEES IS ONLY MATCHED BY MY LOVE FOR TOM BRADY'S SWEATY MAGA BALLS

MALE SHOEGAZE posted:

C terrible programmer s: implementing a ruby dsl

but enough about the color of your lipstick

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord

MononcQc posted:

Then number kinds like 'primes' (by the usual definition), 'squares' and 'Fibonacci' kind of don't belong in the exercise anymore in the first place :shobon:

you don't know how to have fun :mad:

I just wanted someone to suggest initializing the largest variable to -inf or something.

qntm
Jun 17, 2009
code:
def isPerfect(num):
    return num in [6,28,496,8128,33550336]

quote:

Will work for all 32-bit integers, let me know when you need 64-bit capability

Egan Yardley
Jun 11, 2010

idk what this thread is for but i write puppet modules and bad python so i assume i belong here

MononcQc
May 29, 2007

Symbolic Butt posted:

you don't know how to have fun :mad:

I just wanted someone to suggest initializing the largest variable to -inf or something.

Put in an assertion that the values need to be positive then walk away for the day :toot:

Valeyard
Mar 30, 2012


Grimey Drawer
code:
workingHours = workingHours*2
assert(mood > 0)

Baxate
Feb 1, 2011

never posted itt but I don't "get" javascript

I still do everything server side.
why should I use a dumb and bad client side scripting language where I have to write a mile long line of code to write some freaking html

prefect
Sep 11, 2001

No one, Woodhouse.
No one.




Dead Man’s Band

Ludwig van Halen posted:

never posted itt but I don't "get" javascript

I still do everything server side.
why should I use a dumb and bad client side scripting language where I have to write a mile long line of code to write some freaking html

you get to offload all the processing work to the clients, and gently caress up their computers instead of your nice servers

Valeyard
Mar 30, 2012


Grimey Drawer

Ludwig van Halen posted:

dumb and bad client side scripting language

hold up a minute there buddy

Baxate
Feb 1, 2011

true story, I work for a newspaper and I Adblock our paywalls because javascript lol

Adbot
ADBOT LOVES YOU

leftist heap
Feb 28, 2013

Fun Shoe

Ludwig van Halen posted:

never posted itt but I don't "get" javascript

I still do everything server side.
why should I use a dumb and bad client side scripting language where I have to write a mile long line of code to write some freaking html

not that I disagree with the idea that all webpages should be static, server generated html but yeah it sounds like you don't get JS at all. like, do you think pages should have no scripting at all ever?

  • Locked thread