Author Topic: Another reason PHP > Java  (Read 2431 times)

ober

  • Ashton Shagger
  • Ass Wipe
  • Posts: 14305
  • Karma: +73/-790
  • mini-ober is taking over
    • Windy Hill Web Solutions
Another reason PHP > Java
« on: August 15, 2011, 04:42:18 PM »
Lists can only have integer keys?  Fo reals?  So I have to use a Map instead??  Who designed these objects??

Perspective

  • badfish
  • Jackass In Charge
  • Posts: 4635
  • Karma: +64/-22
    • http://jeff.bagu.org
Re: Another reason PHP > Java
« Reply #1 on: August 16, 2011, 01:20:53 PM »
the integer key is the position (index) in the list... any other type and it's not a list, it's a map.

charlie

  • Jackass In Charge
  • Posts: 7896
  • Karma: +84/-53
Re: Another reason PHP > Java
« Reply #2 on: August 16, 2011, 01:41:47 PM »
Yeah... as a C++ programmer my first reaction was what the hell is PHP doing allowing non-integer keys to a list. (And why is it called a list anyway, isn't that an array?)

ober

  • Ashton Shagger
  • Ass Wipe
  • Posts: 14305
  • Karma: +73/-790
  • mini-ober is taking over
    • Windy Hill Web Solutions
Re: Another reason PHP > Java
« Reply #3 on: August 16, 2011, 02:06:06 PM »
That's my point.  Java has like 3 or 4 objects where PHP uses one object to do all of them.  You can do all of that stuff with an array in PHP.

Mike

  • Jackass In Charge
  • Posts: 11248
  • Karma: +168/-32
  • Ex Asshole - a better and more caring person.
Re: Another reason PHP > Java
« Reply #4 on: August 16, 2011, 02:35:15 PM »
Sorry but the best reason PHP > Java is multi-line string literals.

hans

  • Guitar Addict
  • Jackass In Charge
  • Posts: 3523
  • Karma: +46/-18
Re: Another reason PHP > Java
« Reply #5 on: August 16, 2011, 08:08:55 PM »
Aren't you guys using Groovy yet? It's time to give it a shot if you're not. JVM life has never been as wonderful.

Join the cool kids.
This signature intentionally left blank.

ober

  • Ashton Shagger
  • Ass Wipe
  • Posts: 14305
  • Karma: +73/-790
  • mini-ober is taking over
    • Windy Hill Web Solutions
Re: Another reason PHP > Java
« Reply #6 on: August 17, 2011, 09:00:29 AM »
That's not exactly an easy change, unless I'm misunderstanding it.  We're not even running the latest version of Java (that's currently on our roadmap).

PJYelton

  • Power of Voodoo
  • Jackass In Charge
  • Posts: 1597
  • Karma: +56/-12
    • TheRecursiveFractal
Re: Another reason PHP > Java
« Reply #7 on: August 17, 2011, 11:39:40 AM »
Just started learning Groovy, so far I am a big fan.

Mike

  • Jackass In Charge
  • Posts: 11248
  • Karma: +168/-32
  • Ex Asshole - a better and more caring person.
Re: Another reason PHP > Java
« Reply #8 on: August 17, 2011, 11:45:36 AM »
But, does it have multiline string literals?

hans

  • Guitar Addict
  • Jackass In Charge
  • Posts: 3523
  • Karma: +46/-18
Re: Another reason PHP > Java
« Reply #9 on: August 17, 2011, 11:48:30 AM »
This signature intentionally left blank.

Mike

  • Jackass In Charge
  • Posts: 11248
  • Karma: +168/-32
  • Ex Asshole - a better and more caring person.
Re: Another reason PHP > Java
« Reply #10 on: August 17, 2011, 11:50:32 AM »
So kinda, but in a really lame ass way

hans

  • Guitar Addict
  • Jackass In Charge
  • Posts: 3523
  • Karma: +46/-18
Re: Another reason PHP > Java
« Reply #11 on: August 17, 2011, 11:52:03 AM »
Ober, you might be able to hook in Groovy classes to your project since they get compiled down to class files and are able to be called from regular Java files without impedance.

You can gradually move over without changing the whole codebase. That's the way I started to go with my old Spring/Hibernate projects. Some classes were much easier to write and maintain in Groovy.

And then you get hooked on Grails...
This signature intentionally left blank.

ober

  • Ashton Shagger
  • Ass Wipe
  • Posts: 14305
  • Karma: +73/-790
  • mini-ober is taking over
    • Windy Hill Web Solutions
Re: Another reason PHP > Java
« Reply #12 on: August 17, 2011, 12:21:19 PM »
I'll certainly bring it up to see if anyone else on the team knows much about it.

webwhy

  • Jackass IV
  • Posts: 608
  • Karma: +15/-10
Re: Another reason PHP > Java
« Reply #13 on: August 22, 2011, 02:13:21 PM »
Quote
Lists can only have integer keys?  Fo reals?  So I have to use a Map instead??  Who designed these objects??

computer scientists! hahahaha...

In PHP you basically have one data structure available: an ordered Hash Map.  They term it an array, which can be confusing for people who expect arrays to behave a certain way, since it's not really an array at all.

Java gives you a diverse set of containers to address a diverse set of problems efficiently.

I agree that the syntax for a lot of Java data structure allocation and initialization sucks compared to php (even more so to python, ruby, etc), but that's a different issue...or is it?