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
Thermopyle
Jul 1, 2003

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

sunaurus posted:

Yeah, it's not a shortcut to text search, but it does err on the side of showing false positives instead of hiding them, and there can be A LOT of false positives in a larger app. It's definitely my normal experience when I work with Python for anything other than scripting and prototyping (where it excels).

Here's a small example, just throw this into an empty .py file in PyCharm and watch how it finds 5 usages for a method that is never used at all:

code:
class Foo:

    def bar(self):
        pass

[][1].bar()
[][1].bar()
[][1].bar()
[][1].bar()
[][1].bar()
To be clear, I'm not saying that Python is bad or even that you should write ambiguous method names or whatever - that wasn't my argument at all. I'm saying that it's much easier to navigate an ambiguously written codebase written in Java/C# than it is to navigate one written in Python (using the tooling I know about).

The impression you gave in your first post on the subject was that it isn't easy to navigate a python project.

sunaurus posted:

At least it's actually easy to navigate in the code in C#/Java projects.

My point wasn't that you can't write code that is hard to analyze (I specifically said as much), my point was that it's not terribly common to have pycharm to give you inaccurate results to the point where there's some sort of difficulty in navigating/exploring/wrapping-your-head-around a project.

It's not uncommon for me to explore large python projects and I've never seen that dialog you shared a screenshot of. I'm not saying you made it up or whatever, I'm saying that the implication you made that you can't expect to be able to "find usages" is incorrect.

Thermopyle fucked around with this message at 18:16 on Jul 11, 2019

Adbot
ADBOT LOVES YOU

Master_Odin
Apr 15, 2010

My spear never misses its mark...

ladies

sunaurus posted:

To be clear, I'm not saying that Python is bad or even that you should write ambiguous method names or whatever - that wasn't my argument at all. I'm saying that it's much easier to navigate an ambiguously written codebase written in Java/C# than it is to navigate one written in Python (using the tooling I know about).
Except that unless you're doing really awful reflection business, an ambiguously written Java/C# codebase still has the type information, though you may not know what concrete implementation you might want.

Volte put it best above:

Volte posted:

It should be able to do a pretty good job if you put type info on your function parameters, return values, and class members. You can probably leave most local variables un-annotated, as long as they get assigned to something that can be analyzed. I find it a good excuse to put type info on stuff.
And everyone should be using Python 3.5+ that has access to typing. Death to old versions lacking these (and other) features! :colbert:

SupSuper
Apr 8, 2009

At the Heart of the city is an Alien horror, so vile and so powerful that not even death can claim it.

Janitor Prime posted:

Seriously this is one of the best features of Java, navigating a new project is so much easier in Java compared to other langs.
How's it any different from doing the same in an IDE for any language?

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

ratbert90 posted:

Not on our team. :shrug:

Must be nice, I guess. It doesn't agree with my experience of how Other Developers work.

quote:

Your entire argument is "Well, it won't always work, so why do it at all?"

More that it usually doesn't work for this kind of thing (stuff that doesn't per se break the code when it's allowed to rot) and as I said in an earlier post I'm skeptical about how much it value it adds when it's an internal method. (Publicly exposed library methods are a different story.) Methods should document themselves via their names and parameters; I'm not saying that additional clarification is never needed but it should be the exception rather than the rule. If the classes and methods in a codebase aren't almost always self-explanatory, then that is the problem that should be fixed - not the presence or absence of documentation.

DELETE CASCADE
Oct 25, 2017

i haven't washed my penis since i jerked it to a phtotograph of george w. bush in 2003
if you want your ide's static analyses to work, try using a language that isn't an arbitrary dynamic ball of mud

Pentecoastal Elites
Feb 27, 2007

“Just don’t allow the comments to rot” is the programmer’s “just build the whole plane out of the black box material”

qntm
Jun 17, 2009
JavaScript code:
/* ##########################
 * Function for Type Checking
 * ##########################
 */
/**
 * Given a value, tells you whether or not it is an integer. typeof and instanceof only report
 * that a variable is a number or not, but does not distinguish between integers and decimals.
 * @param possibleInt: A value to check.
 * @param strictEquality: If true, will see if the variable is treated as an integer by
 * the implicit type conversion
 * If false, will check to see if the variable *is* of type integer
 * @param Radix: The assumed radix of the possible integer to compare. If not provided base 10
 * is assumed.
 */
function isInteger(possibleInt, strictEquality, radix)
{
    if(radix == null)
    {
        radix = 10;
    }
    var returnValue = false;
    if(strictEquality)
    {
        if(possibleInt === parseInt(possibleInt, radix))
        {
            returnValue = true;
        }
    }
    else
    {
        if(possibleInt == parseInt(possibleInt, radix))
        {
            returnValue = true;
        }
    }
    return returnValue;
}

sunaurus
Feb 13, 2012

Oh great, another bookah.

qntm posted:

horror

Hey, at least it has a function header

NtotheTC
Dec 31, 2007


the horror is it assuming base 10 by default right? haha! that's so not the javascript way :)

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?
The function shouldn't require a radix at all; integers are integers regardless.

Providing any radix other than 10 will cause bugs I'm pretty sure, since they're calling parseInt and allowing the value to implicitly convert to a string, which will use base 10. So for example parseInt(10, 8) will parse "10" as octal, giving 8, which will not be equal to 10, and the function will falsely report the value as not being an integer.

Also I'm pretty sure that the whole thing can be replaced with "Math.trunc(value) === value"

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

HappyHippo posted:

The function shouldn't require a radix at all; integers are integers regardless.

Providing any radix other than 10 will cause bugs I'm pretty sure, since they're calling parseInt and allowing the value to implicitly convert to a string, which will use base 10. So for example parseInt(10, 8) will parse "10" as octal, giving 8, which will not be equal to 10, and the function will falsely report the value as not being an integer.

Also I'm pretty sure that the whole thing can be replaced with "Math.trunc(value) === value"

Why, it's almost as though Javascript is poo poo, and shouldn't be used!

Munkeymon
Aug 14, 2003

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



Does trunc work differently than floor?

ulmont
Sep 15, 2010

IF I EVER MISS VOTING IN AN ELECTION (EVEN AMERICAN IDOL) ,OR HAVE UNPAID PARKING TICKETS, PLEASE TAKE AWAY MY FRANCHISE

Munkeymon posted:

Does trunc work differently than floor?

For positive integers, no. For negative integers, yes.

trunc just removes decimals from a number. floor rounds down to the nearest integer.

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?

Hammerite posted:

Why, it's almost as though Javascript is poo poo, and shouldn't be used!

I mean, yeah JavaScript is poo poo, but that's no excuse to pile more poo poo on top of it

Thermopyle
Jul 1, 2003

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

Whats' wrong with Number.isInteger()?

nielsm
Jun 1, 2009



Thermopyle posted:

Whats' wrong with Number.isInteger()?

I didn't write it.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...
Convert it to a string, then check for the existence of a decimal and trailing non zero numbers ezpz

Qwertycoatl
Dec 31, 2008

Volmarias posted:

Convert it to a string, then check for the existence of a decimal and trailing non zero numbers ezpz

I've legit seen "divide by 2, convert to string, check if the second last character is '.'" as a way to tell if a number is even

necrotic
Aug 2, 2005
I owe my brother big time for this!

Thermopyle posted:

Whats' wrong with Number.isInteger()?

Won't work on strings.

FlapYoJacks
Feb 12, 2009

necrotic posted:

Won't work on strings.

Coding horror:

int(Number).isInteger()

:smug:

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?

Qwertycoatl posted:

I've legit seen "divide by 2, convert to string, check if the second last character is '.'" as a way to tell if a number is even

There's a certain kind of programmer for whom strings are a hammer and every problem is a nail

Thermopyle
Jul 1, 2003

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

necrotic posted:

Won't work on strings.

I asked whats wrong with it!

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

HappyHippo posted:

There's a certain kind of programmer for whom strings are a hammer and every problem is a nail screw

Carbon dioxide
Oct 9, 2012

HappyHippo posted:

There's a certain kind of programmer for whom strings are a hammer and every problem is a nail

Ah, the people who use a stringly typed language.

taqueso
Mar 8, 2004


:911:
:wookie: :thermidor: :wookie:
:dehumanize:

:pirate::hf::tinfoil:

Well if you think about it, a string can represent any other type...

Spatial
Nov 15, 2007

in hell, strings are the only datatype programmers can use

types are strings
keywords are strings
comments are strings
arrays? no. metastrings. strings of strings.
string.length also returns a string. it's all strings baby

Spatial
Nov 15, 2007

pointers? it's strings, son

the fundamental memory unit of the computational machine. the string!

Soricidus
Oct 21, 2010
freedom-hating statist shill
if you’re not convinced just read up on string theory

Volguus
Mar 3, 2009

Soricidus posted:

if you’re not convinced just read up on string theory

I'm convinced and a bit confused. Which version of string theory should I pick: the 11 dimension one or the 26-dimensional one? Or just stick with the classical 10?

Joda
Apr 24, 2010

When I'm off, I just like to really let go and have fun, y'know?

Fun Shoe

Spatial posted:

pointers? it's strings, son

And not like reading four bytes from the string to get your 32 bit pointer value. It's ascii char values for the hex value of the address. Of course prepended with 0x to make it human readable.

VikingofRock
Aug 24, 2008




Spatial posted:

in hell, strings are the only datatype programmers can use

types are strings
keywords are strings
comments are strings
arrays? no. metastrings. strings of strings.
string.length also returns a string. it's all strings baby

Apparently hell is TCL.

iospace
Jan 19, 2038


VikingofRock posted:

Apparently hell is TCL.

It is

ToxicFrog
Apr 26, 2008


Spatial posted:

in hell, strings are the only datatype programmers can use

types are strings
keywords are strings
comments are strings
arrays? no. metastrings. strings of strings.
string.length also returns a string. it's all strings baby

I see you've written bash scripts before

Arsenic Lupin
Apr 12, 2012

This particularly rapid💨 unintelligible 😖patter💁 isn't generally heard🧏‍♂️, and if it is🤔, it doesn't matter💁.


Can I declare esr to be a coding horror all by himself?

Eric S. Raymond posted:

Epstein recruited girls as young as 14. Yes, really icky and I think it is quite right he was prosecuted for statutory rape. But women that age who are not only nubile but psychologically adult do exist, even if they’re very very rare – in 60 years I think I’ve met exactly one.

We really need a "but ephebophilia!" smily.

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


Arsenic Lupin posted:

We really need a "but ephebophilia!" smily.

No. No, we don't.

Volmarias
Dec 31, 2002

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

Arsenic Lupin posted:

Can I declare esr to be a coding horror all by himself?


We really need a "but ephebophilia!" smily.

:pedophiles:

Alternately, :reddit:

JawnV6
Jul 4, 2004

So hot ...
https://twitter.com/skirani/status/1149302828420067328?s=21

Dr Monkeysee
Oct 11, 2002

just a fox like a hundred thousand others
Nap Ghost
I kept waiting for the punchline and it never hit

Absurd Alhazred
Mar 27, 2010

by Athanatos

Dr Monkeysee posted:

I kept waiting for the punchline and it never hit

It's right there, above the first tweet.

Adbot
ADBOT LOVES YOU

Doom Mathematic
Sep 2, 2008

Spatial posted:

pointers? it's strings, son

WeeChat scripting documentation posted:

3.1. Pointers

As you probably know, there is not really "pointers" in scripts. So when API functions return pointer, it is converted to string for script.

For example, if function return pointer 0x1234ab56, script will get string "0x1234ab56".

And when an API function expects a pointer in arguments, script must give that string value. C plugin will convert it to real pointer before calling C API function.

Empty string or "0x0" are allowed, they means NULL in C. For example, to print data on core buffer (WeeChat main buffer), you can do:

code:
weechat.prnt("", "hi!")
In many functions, for speed reasons, WeeChat does not check if your pointer is correct or not. It’s your job to check you’re giving a valid pointer, otherwise you may see a nice crash report ;)

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