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
prefect
Sep 11, 2001

No one, Woodhouse.
No one.




Dead Man’s Band

chumpchous posted:

the reason regex are so popular in perl is because regex syntax is actually much better than perl syntax

:ssj:

Adbot
ADBOT LOVES YOU

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
i feel like regex only exist out of a mistaken attempt to impress girls

'yeah that's a pretty scary lookin regex, just gonna leave it up on my screen here, that'll impress her'

prefect
Sep 11, 2001

No one, Woodhouse.
No one.




Dead Man’s Band

chumpchous posted:

i feel like regex only exist out of a mistaken attempt to impress girls

'yeah that's a pretty scary lookin regex, just gonna leave it up on my screen here, that'll impress her'

:confused: how would a girl see your screen?

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
clearly you open up a shell for some reason or another "just gotta check some computer stuff" while you're installing her printer

PleasingFungus
Oct 10, 2012
idiot asshole bitch who should fuck off
java question time. my understanding is that, taking advantage of the fact that java strings are immutable, identical strings are stored at the same location in memory. e.g.:
code:
String foo = "butts";
String bar = "butts"; //should be stored in the same place as foo!
googling tells me this is called "string interning", and that java's implementation is called the 'string pool'. anyway.

wouldn't that imply, then, that the == / != operators would work for comparing strings? I'd assumed that ==/!= were just comparing the values of the internal pointers (and wiki agrees with me here), so...?

coaxmetal
Oct 21, 2010

I flamed me own dad
iirc they do work but its been a while since I did java. And I think maybe you were supposed to use .equals anyway for safety or something

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
Seems reasonable

coaxmetal
Oct 21, 2010

I flamed me own dad
I think its dumb that == compares identy (memory reference) by default.

In python, it uses either a default implementation (I think comparing the __dict__ of the objects) or calls the __eq__ method. If you want object identity, you use the word "is" istead of "==".

PleasingFungus
Oct 10, 2012
idiot asshole bitch who should fuck off

Ronald Raiden posted:

I think its dumb that == compares identy (memory reference) by default.

In python, it uses either a default implementation (I think comparing the __dict__ of the objects) or calls the __eq__ method. If you want object identity, you use the word "is" istead of "==".

Ronald Raiden posted:

Java has that too only it does it backwards. The less common usecase, identity comparison, is the operator '==', while the more useful one is the object method object.equals. Also java generics suck.

Ronald Raiden posted:

It depends on the language. Most modern high level languages have sane object equality comparison, which would allow 2 different objects with thesame value tobe equal. Generally, in languages that allow that, the notion of identity comparison, which is what you are referring to, is different. (for instance, 'is' in python)

code:
while (ronald_raiden.hates(JAVA_EQUALITY))
    java.compare_to(python);

PleasingFungus
Oct 10, 2012
idiot asshole bitch who should fuck off
also here's a fun bug I found in my code this morning

code:
		private function get MAX_SPEED():int {
			return 65 / currentZoomLevel;
		}
		private const ACCEL:int = MAX_SPEED / 2;
this compiled & sat in my codebase for the last few months

tbqh, I'm kind of really startled that it compiled at all.

Nomnom Cookie
Aug 30, 2009



java interns constant strings. it also interns strings that you tell it to. using == to compare strings by value only works properly when both sides of the comparison are interned strings. don't do it

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

Ronald Raiden posted:

I think its dumb that == compares identy (memory reference) by default.

In python, it uses either a default implementation (I think comparing the __dict__ of the objects) or calls the __eq__ method. If you want object identity, you use the word "is" istead of "==".

Yeah but you have to remember that Java doesn't do operator overloading (except in the case of + for String concatenation and the interning that Nomnom mentioned) :suicide:

Janitor Prime fucked around with this message at 18:23 on May 21, 2013

Nomnom Cookie
Aug 30, 2009



the + thing is kinda dumb but w/e. == is okayish and at least makes sense if you consider references as values separate from objects. then == is "compare the values of these variables". then problem is string interning, you can call an instance method to put an object in the perm gen and dedupe instances and poo poo. also the compiler will do this for you. it's terrible poo poo from 1995 when computers had 8 MB RAM and it's in the language forever

Nomnom Cookie
Aug 30, 2009



tbh overall i think the + concatenates strings feature is a good thing. if thats the biggest criticism someone has about java then you know that they don't know much about java, or theyre obsessed with trivial poo poo

BONGHITZ
Jan 1, 1970

chumpchous posted:

i feel like regex only exist out of a mistaken attempt to impress girls

'yeah that's a pretty scary lookin regex, just gonna leave it up on my screen here, that'll impress her'

this is the reason why everything exists

tef
May 30, 2004

-> some l-system crap ->

PleasingFungus posted:

java question time. my understanding is that, taking advantage of the fact that java strings are immutable, identical strings are stored at the same location in memory. e.g.:
code:
String foo = "butts";
String bar = "butts"; //should be stored in the same place as foo!
googling tells me this is called "string interning", and that java's implementation is called the 'string pool'. anyway.

wouldn't that imply, then, that the == / != operators would work for comparing strings? I'd assumed that ==/!= were just comparing the values of the internal pointers (and wiki agrees with me here), so...?

they work for comparing memory addresses, so if all your strings have unique locations in memory, yes you can use it to check equality. the assumption that every string you create has only one possible address is not a pleasant one.

if you need to check string equality, use equals. if you need to check object identity, use ==. if you're needing to check object identity on strings, you will be better off using an enum to represent your constants, not strings.

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

tef posted:

they work for comparing memory addresses, so if all your strings have unique locations in memory, yes you can use it to check equality. the assumption that every string you create has only one possible address is not a pleasant one.

if you need to check string equality, use equals. if you need to check object identity, use ==. if you're needing to check object identity on strings, you will be better off using an enum to represent your constants, not strings.

Holy poo poo you nailed that one on the head

I didn't think of it that way, but in hindsight it's obvious that checking object identity on strings implies that they are using them as enums.

tef
May 30, 2004

-> some l-system crap ->
enums also make great singletons

Shaggar
Apr 26, 2006

PleasingFungus posted:

java question time. my understanding is that, taking advantage of the fact that java strings are immutable, identical strings are stored at the same location in memory. e.g.:
code:
String foo = "butts";
String bar = "butts"; //should be stored in the same place as foo!
googling tells me this is called "string interning", and that java's implementation is called the 'string pool'. anyway.

wouldn't that imply, then, that the == / != operators would work for comparing strings? I'd assumed that ==/!= were just comparing the values of the internal pointers (and wiki agrees with me here), so...?

for string litteralls this will work, but not string objects

Java code:
//these are automatically interned afaik so they are the same reference
String a = "butts";
String b = "butts";
		
System.out.println(a==b); //prints true
System.out.println(a.equals(b)); //prints true

String c = new String("butts");

System.out.println(a==c); //prints false as it points to a new string object w/ a different reference!
System.out.println(a.equals(c));  //prints true b/c .equals is the right way to compare strings

//SAVAGE OPTIMIZATION!
c=c.intern(); // replaces the reference to c with a referenced to an already interned instance of "butts" if it exists.  if it doesn't, then the string is interned and a reference to the interned string is returned
		
System.out.println(a==c); // true

interning strings manually (as w/ String c in this example) allows you to use ==, but at the cost of permanently storing the string in perm gen (if its java 6, in 7 its heap). if you did not intern c, then it would be collected once it goes out of scope.

Shaggar
Apr 26, 2006
but yes, use enums instead.

Bloody
Mar 3, 2013

hi i am still a terrible programmer

just thought id keep you updated

PleasingFungus
Oct 10, 2012
idiot asshole bitch who should fuck off
to clarify, I haven't actually worked with java in over a year, & don't intend to do so any time soon. I just ran into the notion of string interning a few months ago, and started wondering how it interacted with ==. I hadn't realized that only constant & manually specified strings were interned; now that I know that, everything has fallen into place.

it was a matter of idle curiosity and I am very satisfied with all answers, except tef because his answer assumed I knew more than I actually did (& was therefore useless w/o the other answers). actually - that's pretty flattering, so on second thought I'm happy with that answer too.

terrible programmer update: ran into a bug in my personal project, failed to fix it or even find the root cause of it over several attempts/hours. eventually gave up & slapped on a lovely patch that appears to have "fixed" the problem. putting the over/under on 2 weeks until it shows up again in some horrible metastasized form.

uugh.

uG
Apr 23, 2003

by Ralp
we will always be a terrible programmer, no need to keep reminding us

Farmer Crack-Ass
Jan 2, 2001

this is me posting irl

Bloody posted:

hi i am still a terrible programmer

just thought id keep you updated

does your php program 'run out of numbers' because you used a lovely random number function

X-BUM-RAIDER-X
May 7, 2008

prefect posted:

in my (limited) experience, the perl community is pretty sensible :shrug:

oh right, this is a computer jokes thread. cool

prefect
Sep 11, 2001

No one, Woodhouse.
No one.




Dead Man’s Band

OBAMA BIN LinkedIn posted:

oh right, this is a computer jokes thread. cool

i apologize for being a worthless human being

tef
May 30, 2004

-> some l-system crap ->
it's ok we all know you're a programmer

X-BUM-RAIDER-X
May 7, 2008
so how long will it be before people realise that programming is a lifelong gravy train and wages then fall to account for increased supply of programmer? will this ever happen?

Squinty Applebottom
Jan 1, 2013

OBAMA BIN LinkedIn posted:

so how long will it be before people realise that programming is a lifelong gravy train and wages then fall to account for increased supply of programmer? will this ever happen?

as long as computer nerds continue being truly awful people it should be good

i'm doing my part. what terrible things have you done today (other than posting)?

Posting Principle
Dec 10, 2011

by Ralp

OBAMA BIN LinkedIn posted:

so how long will it be before people realise that programming is a lifelong gravy train and wages then fall to account for increased supply of programmer? will this ever happen?

ceos are way ahead of this. when zuck supports immigration reform it's because he wants to deflate wages. the golden age of easy work for fat stacks is dying this decade

MononcQc
May 29, 2007

super easy way to deflate wages, without immigration: allow people to work remotely, let them live in bumfuck nowhere and pay them competitive prices according to where they live. near-shoring supremacy.

Bloody
Mar 3, 2013

Farmer Crack-rear end posted:

does your php program 'run out of numbers' because you used a lovely random number function

i wish my problems could be such frivolities

my thesis is written in c++

poorly

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

MononcQc posted:

super easy way to deflate wages, without immigration: allow people to work remotely, let them live in bumfuck nowhere and pay them competitive prices according to where they live. near-shoring supremacy.

i won't lie, i'm thinking of moving out of metro miami basically so i get a raise without more money

Shaggar
Apr 26, 2006
do it and then get another job where u have to move back to the city w/ higher pay based on the cost of living differential.

MononcQc
May 29, 2007

Cocoa Crispies posted:

i won't lie, i'm thinking of moving out of metro miami basically so i get a raise without more money

Still at the same job btw? I'll be in SF for a few days for work in June (10-15) if you're around during that time.

double sulk
Jul 2, 2010

people who offshore work/hire nothing but contractors out of country are scum

uG
Apr 23, 2003

by Ralp
i only hire offshore contractors for work that really sux and isn't going to be fun or creative. suck it 3rd world.

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

MononcQc posted:

Still at the same job btw? I'll be in SF for a few days for work in June (10-15) if you're around during that time.

Same job, far side of the country though.

AWWNAW
Dec 30, 2008

:negative:

AWWNAW fucked around with this message at 23:52 on Aug 20, 2013

Adbot
ADBOT LOVES YOU

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
do you accept applications from terrible developers willing to relocate

  • Locked thread