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
VikingofRock
Aug 24, 2008




Volte posted:

Yes, but it tends to be a lot more invasive because you actually have to wrap each function call in an identity function with side effects, and if you're trying to analyze all the intermediate values to see where things went wrong, it can get tedious fast.

Not so! You can use Debug.Trace to smuggle in your nefarious value-printing side effects.

Adbot
ADBOT LOVES YOU

Volte
Oct 4, 2004

woosh woosh

VikingofRock posted:

Not so! You can use Debug.Trace to smuggle in your nefarious value-printing side effects.
Well, sure. Debug.Trace is an example of the identity function with side effects I was talking about. My point was that it's not just a matter of adding a bunch of extra lines that you can then delete, you actually have to change the bindings to incorporate the trace function, when in an imperative language it would be as simple as putting a breakpoint at the end of the function and using the debugger to inspect each variable without having to change the code at all.

LOOK I AM A TURTLE
May 22, 2003

"I'm actually a tortoise."
Grimey Drawer

Volte posted:

Well, sure. Debug.Trace is an example of the identity function with side effects I was talking about. My point was that it's not just a matter of adding a bunch of extra lines that you can then delete, you actually have to change the bindings to incorporate the trace function, when in an imperative language it would be as simple as putting a breakpoint at the end of the function and using the debugger to inspect each variable without having to change the code at all.

I've only dabbled with Haskell, but I've had some success with this pattern:

code:
import Debug.Trace (trace)

printf = flip trace

f :: Integer -> Integer -> Integer
f a b = a + b
  `printf` ("a: " ++ show a)
  `printf` ("b: " ++ show b) -- this one actually gets printed first lol
Of course it's not as ergonomic as in an imperative language, and it's nowhere near as good as setting breakpoints in a debugger. It also forces you to grapple with Haskell's sometimes counterintuitive evaluation strategy.

Athas
Aug 6, 2007

fuck that joker
The technique I usually use for this is pattern guards:

code:

f :: Integer -> Integer -> Integer
f a b | trace  ("a: " ++ show a) True, trace  ("b: " ++ show b) False = undefined
f a b = a + b
This behaves as you'd expect with respect to evaluation order, the fact that it's built into control flow means you avoid most laziness shenanigans, and it is easy to add/remove.

In a monadic context, you can just put traces in front of most monadic operations.

qntm
Jun 17, 2009
JavaScript code:
/**
 * Returns an object with only the desired properties of the source object. Note that this
 * does **not** handle recursion. Won't be the fastest thing for large filters or objects,
 * but the hashtable look-ups are restricted to exact matches (e.g. in operator). Deletes the
 * properties of the original object.
 * @param srcObject
 * @param filter: an Array of property names to search for in the srcObject.
 * @param filterType: String. "exclude" to add only match properties that are *not* in the filter
 * "include" to match only properties that *are* in the filter.
 * @param partialMatches: Boolean. If partial match "fun" will also match "funny" or "malfunction".
 * If false, only "fun" will match "fun".
 * @ param ignoreCase: Boolean.
 */
function filterObject(srcObject, filter, filterType, partialMatches, ignoreCase)
{
    //log
    filterType = filterType ? filterType : "include";

    filterType = filterType.toLowerCase();
    var matched;
    var filteredObject = {};

    if (!isObject(srcObject))
    {
        throw new Error("srcObject expected to be an object was : " + srcObject);
    }
    if (!isArray(filter))
    {
        throw new Error("filter expected to be an array, was: " + filter);
    }
    if (!((filterType === "exclude") || (filterType === "include")))
    {
        throw new Error("filter type must be a string that is 'ignore' or 'require'. You provided: " + filterType);
    }

    for (var property in srcObject)
    {
        for (var i = 0; i < filter.length; ++i)
        {
            matched = strCompare(filter[i], property, partialMatches, ignoreCase);
            if (filterType === "exclude" && !matched)
            {
                filteredObject[property] = srcObject[property];
            }
            else if (filterType === "include" && matched)
            {
                filteredObject[property] = srcObject[property];
            }
            else
            {
                // maybe put recursion here later?
            }
        }
    }
    return filteredObject;
}
Devotees of this continuing series of dreadful JavaScript utility functions will recall the definition of strCompare.

isObject and isArray are other utility functions which do pretty much what you would expect but are not horrific enough in their own right to be worth sharing.

OddObserver
Apr 3, 2009
Aww, confusing for ... in with the in operator. How adorable.

fritz
Jul 26, 2003

Javascript drama : https://github.com/standard/standard/issues/1381

quote:

What's the experiment? Whenever standard 14 is installed, we'll display a message from a company that supports open source. Currently, these are Linode and LogRocket. The sponsorship pays directly for maintainer time. That is, writing new features, fixing bugs, answering user questions, and improving documentation.

(the package appears to be some kind of config file for someone else's linter)

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
lmao feross

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
also lmao @ github putting a political compass on everyone's profile page

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


Is there anybody who does mostly PRs? I'm not even sure how that would work.

Absurd Alhazred
Mar 27, 2010

by Athanatos

ultrafilter posted:

Is there anybody who does mostly PRs? I'm not even sure how that would work.

Erling?

Pie Colony
Dec 8, 2006
I AM SUCH A FUCKUP THAT I CAN'T EVEN POST IN AN E/N THREAD I STARTED
edit: nvm, I thought PRs meant code reviews

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

ultrafilter posted:

Is there anybody who does mostly PRs? I'm not even sure how that would work.

Some of the linux intermediary people who spend their time gathering changes from other people and pushing them to linus might be mostly PRs (although obviously they aren't doing it on github).

Phobeste
Apr 9, 2006

never, like, count out Touchdown Tom, man
It's really perfect that as far as I can tell that package is a wrapper script and an eslint config file and like nothing else

NtotheTC
Dec 31, 2007


Phobeste posted:

It's really perfect that as far as I can tell that package is a wrapper script and an eslint config file and like nothing else

It's far too heavyweight for JS. Strip the wrapper out into it's own NPM package. Bonus: double the ads!

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
One comment on that issue went something like "I use this in all my js projects" and I couldn’t help but read it as an indictment.

Doom Mathematic
Sep 2, 2008
Having a highly popular public canned configuration for ESLint is surprisingly valuable because it enables us to immediately terminate all kinds of tedious, expensive bikeshedding discussions about code style and formatting and many kinds of best practice. Every question about correct brace placement or tabs versus spaces or string quoting just goes away instantly and we can get on with actual work. Even in the cases where there are rules I personally disagree with (there are one or two), the value from just having consistent formatting and best practices across all of our repos is worth it.

That doesn't mean "Standard" is the last word in canned configurations for ESLint, it's a pretty obnoxious and fundamentally inaccurate name and there are others out there which are just as good.

Sagacity
May 2, 2003
Hopefully my epitaph will be funnier than my custom title.
Is there a particular reason why eslint can't just provide some sane defaults?

Steve French
Sep 8, 2003

Pie Colony posted:

edit: nvm, I thought PRs meant code reviews

But, yes:

xtal
Jan 9, 2011

by Fluffdaddy
I don't like anything that makes it more obvious to my coworkers how little work I do

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Doom Mathematic posted:

Having a highly popular public canned configuration for ESLint is surprisingly valuable because it enables us to immediately terminate all kinds of tedious, expensive bikeshedding discussions about code style and formatting and many kinds of best practice. Every question about correct brace placement or tabs versus spaces or string quoting just goes away instantly and we can get on with actual work. Even in the cases where there are rules I personally disagree with (there are one or two), the value from just having consistent formatting and best practices across all of our repos is worth it.

That doesn't mean "Standard" is the last word in canned configurations for ESLint, it's a pretty obnoxious and fundamentally inaccurate name and there are others out there which are just as good.

This is true, but right now we've moved the bikeshedding from configuration options to which configuration-free linter to use.

Thankfully, I think it seems like prettier is winning that war.

boo_radley
Dec 30, 2005

Politeness costs nothing

xtal posted:

I don't like anything that makes it more obvious to my coworkers how little work I do

Oh, I don't there's anything that could make it more obvious.

LOOK I AM A TURTLE
May 22, 2003

"I'm actually a tortoise."
Grimey Drawer

Suspicious Dish posted:

also lmao @ github putting a political compass on everyone's profile page



Issues = Libertarian
Code reviews = Authoritarian
Pull requests = Left
Commits = Right

Stalin sends you to the gulags if your pull requests don't pass CI. Hitler force pushes to master.

Munkeymon
Aug 14, 2003

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



Volguus posted:

This proves you cannot ever please everyone. If there would just only be a way to allow multiple kinds of clients talk with the central server and between themselves. You know, to open the protocol and allow other people that prefer the black client/white client/pink client/compact client to just ... you know, use it and don't worry about it. And the protocol to be well designed that a client only implementing a part of it can still function perfectly fine. I guess the technology is simply not there yet.

What's proven to not be there time and again is the small army of people to implement good, useable clients, HTH.

duz
Jul 11, 2005

Come on Ilhan, lets go bag us a shitpost


Sagacity posted:

Is there a particular reason why eslint can't just provide some sane defaults?

It does.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
reminder that feross is already a millioniare because yahoo bought his stupid company lol

it was a cdn where the user visiting the site also dn'd the c to other users visiting the site

only yahoo was dumb enough to fall for it

https://web.archive.org/web/20150810065820/https://peercdn.com/

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

dn'd the c

what?

nielsm
Jun 1, 2009



deliverynetworked the content

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

Thermopyle posted:

dn'd the c

what?

cdn's dn the c

Dirty Frank
Jul 8, 2004

LOOK I AM A TURTLE posted:

Issues = Libertarian
Code reviews = Authoritarian
Pull requests = Left
Commits = Right

Stalin sends you to the gulags if your pull requests don't pass CI. Hitler force pushes to master.

i always knew stalin was a good guy

No Safe Word
Feb 26, 2005

Suspicious Dish posted:

cdn's dn the c

they're an n to d the c

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
I assumed the name peercdn was the result of "I’m making a cdn, I’ll call it *spins wheel of tech-ish words* peer. Peer cdn". I had no idea it was... that.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...
BCDN

Blockchain Delivery Network

Investors: :homebrew:

Absurd Alhazred
Mar 27, 2010

by Athanatos
I mean, peer-to-peer content distribution isn't that bad of an idea. It's like realtime bittorrent! :v:

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
it should be of no surprise that feross's next gig was webtorrent, which implements torrent, in web

https://github.com/webtorrent/webtorrent

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

Sagacity posted:

Is there a particular reason why eslint can't just provide some sane defaults?

eslint's defaults are arguably better than what Standard picks.

moostaffa
Apr 2, 2008

People always ask me about Toad, It's fantastic. Let me tell you about Toad. I do very well with Toad. I love Toad. No one loves Toad more than me, BELIEVE ME. Toad loves me. I have the best Toad.

Absurd Alhazred posted:

I mean, peer-to-peer content distribution isn't that bad of an idea. It's like realtime bittorrent! :v:

The Blizzard Battle.net App does this

tankadillo
Aug 15, 2006

It’s always funny to me how Standard’s name is literally “Standard.”

Gonna publish my ESlint config with the name “Official ISO-420-69."

Munkeymon
Aug 14, 2003

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



Suspicious Dish posted:

it should be of no surprise that feross's next gig was webtorrent, which implements torrent, in web

https://github.com/webtorrent/webtorrent

Sponsored by Brave :barf:

e: still, first BT client I ever used was written in Python ~2.2 or so

Adbot
ADBOT LOVES YOU

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

moostaffa posted:

The Blizzard Battle.net App does this

They moved away from bittorrent something like a decade ago.

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