EntropySink

Technical & Scientific => Programming => Topic started by: ober on August 15, 2011, 04:42:18 PM

Title: Another reason PHP > Java
Post by: ober 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??
Title: Re: Another reason PHP > Java
Post by: Perspective 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.
Title: Re: Another reason PHP > Java
Post by: charlie 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?)
Title: Re: Another reason PHP > Java
Post by: ober 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.
Title: Re: Another reason PHP > Java
Post by: Mike on August 16, 2011, 02:35:15 PM
Sorry but the best reason PHP > Java is multi-line string literals.
Title: Re: Another reason PHP > Java
Post by: hans 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.
Title: Re: Another reason PHP > Java
Post by: ober 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).
Title: Re: Another reason PHP > Java
Post by: PJYelton on August 17, 2011, 11:39:40 AM
Just started learning Groovy, so far I am a big fan.
Title: Re: Another reason PHP > Java
Post by: Mike on August 17, 2011, 11:45:36 AM
But, does it have multiline string literals?
Title: Re: Another reason PHP > Java
Post by: hans on August 17, 2011, 11:48:30 AM
http://groovy.codehaus.org/Strings+and+GString
Title: Re: Another reason PHP > Java
Post by: Mike on August 17, 2011, 11:50:32 AM
So kinda, but in a really lame ass way
Title: Re: Another reason PHP > Java
Post by: hans 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...
Title: Re: Another reason PHP > Java
Post by: ober 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.
Title: Re: Another reason PHP > Java
Post by: webwhy 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?