Live data from Hacker News

Ask HN: Bet the farm. Python or PHP?

news.ycombinator.com

71–80 of 106 posts

Re: Ask HN: Bet the farm. Python or PHP?

#71
post #54
post #6

Earlier quoted context omitted.

I really would like to use PHP or Python in a big project to at least get some experience. I tell ya, I do love Perl. With limited exposure to PHP and Python, could you elaborate on some of the things PHP and Python are lacking compared to Perl?

Most fundamentally, PHP combines Perl's array and hash data structures. Although you can access name/value pairs as even and odd array elements, code that doesn't need both sets of properties will run slower and consume more memory because a structure implementing both sets of properties is implemented automatically. Why use a languge like that when you're already familiar with Perl?

If I recall correctly, a PHP "array" doesn't necessarily iterate (with foreach) in numerical order. That's just weird.

Re: Ask HN: Bet the farm. Python or PHP?

#72
post #31

Earlier quoted context omitted.

Python being readable is FUD. I've seen tons of horrible Python. Of course, I've also seen tons of horrible Perl (and PHP, and even Lisp). Basically, in the hands of incompetent programmers, everything is unreadable. If you are disciplined, you can write easily-readable Perl. I (and my coworkers) do it every day. Oh, one other thing... the linked article is from 2000. In the last 8 years, the Perl community has figur…

one can write readable anything, but some languages encourage it more, both in the language features and syntax, and also in the community, tutorials, etc

Incidentally, I often see people complaining about non-idomatic python tutorials here.

What I see from this is that people will try to TMTOWTDI regardless of whether or not that's the language's philosophy. At least Perl prepares you to expect people writing code that doesn't look like yours.

(And I'm used to people's weird styles. I have one friend who makes every line of code its own subroutine, and another that gives every method a super_descriptive_but_way_way_too_long_name. You get used to it, and emulate it when appropriate. It's better to decide on a style with your friends/coworkers instead of being told what to do by some guy that works at Google you've never met.)

Re: Ask HN: Bet the farm. Python or PHP?

#73

Earlier quoted context omitted.

The whole references thing is the biggest pain in the ass in Perl syntax. List flattening, and the fact that arrays and hashes can only store scalars (or a reference to something else), etc. just expands into every nook and cranny of the language. I still have a hard time with this aspect of the language after 10 years of Perl coding (with a three year break where I mostly worked with Python). And given how strong th…

And given how strong the tools in Perl are for working with hashes and arrays (grep, map, join, splice/unsplice, shift/unshift, sort, etc.) it really is a pain point. Not really: my $ref = [qw/foo bar baz/]; my $ref2 = [map { uc } @$ref]; # [qw/FOO BAR BAZ/] References, if anything, are just slightly ugly. I could live without non-reference values, however. They're basically useless, but sometimes they make the progr…

My point was that it is an additional bit of friction that isn't present in Ruby or Python (though they also have their own bits of friction). Even though I've written a lot of code in my life, I've never been a full-time software developer, and so it's one of the tricky bits that drops out of my head during the breaks in between writing code. I'm interacting with code written by someone very comfortable with these idioms, and so they show up all over the place, and I never quite get them right the first time. I just think it's an area that makes Perl trickier than it ought to be...it's not a deal breaker (PHP's lack of first class functions, for example, now that's a deal breaker). I'm basically a raving Perl fan, but arrays only holding scalars is a nuisance.

And, as I mentioned, Perl 6 goes a long way to correcting pretty much everything I don't like about Perl 5.

Re: Ask HN: Bet the farm. Python or PHP?

#74

I've used all three of the languages you mention for relatively large web applications. People will say PHP sucks because it is ugly and retarded and only has one namespace. People will say Python sucks because of the whitespace issue and mod_python doesn't work on a $5/m shared hosting plan. Perl sucks of course because "the syntax is crazy!" But, huge sites are built in PHP (Facebook, Hype Machine, Flickr, half of…

Mod up for saying that language choice is primarily a matter of taste.

But, there were a few other considerations for me when I chose Python as my development language over PHP and Ruby.

I think that as far as language growth is concerned, Python has more buzz right now (no disrespect to PHP or Ruby intended). Google's app engine is all about Python right now, and that's going to dramatically increase the traction of Python in the web development world. Google is actively supporting Python development. Google has a lot riding on Python because it's one of the 4 sanctioned languages at the GOOG. I could be wrong, but I get the impression that Python is growing as a community and as a language faster than Ruby. This is why I chose Python over Ruby.

I also chose Python, because I think that there's aspects to Python that will broaden my horizons and stretch me as a programmer as I learn it. I don't really get that impression with PHP. All things being equal, I'd rather learn a language that will stretch me as a programmer.

Re: Ask HN: Bet the farm. Python or PHP?

#75
post #62

Earlier quoted context omitted.

while completely ignoring the right hand side, i can tell they are all scalars. Looking at the right hand side, I can tell the type of the value in that scalar type! ... the value type is a different thing than the variable type We can really debate and argue about the value of typeful variables ... the value seem to be that it allow a combination of syntactic sugar and availability of the reference type! So basicall…

I don't understand most of your post (too many ...s that aren't clear), but you should probably stay away from the word "type" when you are talking about Perl variables. "Scalar" doesn't really mean anything. If anything, it describes the cardinality of the contained value, but certainly not the "type". Even values stored in variables have very flexible "types" that I wouldn't really call a "type". If you store "42 i…

okay, in summary, I wanted to say.

In Perl $ means scalar, @ means array and % means hash

Those are variable types, you learn them by looking at the variable syntax or name

The value pointed to by those TYPED variables can be more complex, you can have integers, floats, strings, references, reference to a string, reference to array, reference to hash, array of strings, array of references etc .....

but the variable type won't tell you about these complex structures, it will only tell you that the value is $ scalar or @ array or % hash ... and in that there is no confusion, all the variables you mentioned above are typed scalar and can only point to values of type scalar

I understand your problem, since a scalar can be a reference to an array

you want to think that $ref = [] points to an array but it doesn't it points to scalar which happens to be a reference to an array!

you can for example do this

my $ref = [];

$ref->[0]= 0;

say $ref->[0];

$ref = {};

$ref ->{0} = 1;

say $ref->{0};

but you can't do this

my $ref = [];

$ref->[0]= 0;

say $ref->[0];

## $ref = {};

$ref ->{0} = 1;

say $ref->{0};

because in $ref ->{0} = 1 the assignment is to value referenced to by te scalar, and this value type is not a hash and can't have a hash member {0}

Re: Ask HN: Bet the farm. Python or PHP?

#76
Python. PHP is really good for hacking things out, and there's a case to be made for using Python for the back end programming, and odds-and-sods of PHP to extract data into templates and so on - but fundamentally if you have real code to write, use Python.

PHP ain't bad, but PHP code is fragile. The language, over a year or two, meanders about breaking code willy-nilly, and that alone is good enough reason to steer clear of it for serious applications.

Re: Ask HN: Bet the farm. Python or PHP?

#77

Earlier quoted context omitted.

And given how strong the tools in Perl are for working with hashes and arrays (grep, map, join, splice/unsplice, shift/unshift, sort, etc.) it really is a pain point. Not really: my $ref = [qw/foo bar baz/]; my $ref2 = [map { uc } @$ref]; # [qw/FOO BAR BAZ/] References, if anything, are just slightly ugly. I could live without non-reference values, however. They're basically useless, but sometimes they make the progr…

My point was that it is an additional bit of friction that isn't present in Ruby or Python (though they also have their own bits of friction). Even though I've written a lot of code in my life, I've never been a full-time software developer, and so it's one of the tricky bits that drops out of my head during the breaks in between writing code. I'm interacting with code written by someone very comfortable with these i…

PHP's lack of first class functions

Thanks for that lil' tidbit.

Re: Ask HN: Bet the farm. Python or PHP?

#78
i never used Perl, one of the few languages i havent even tested.

so it has a culture of libraries people say but what kind?

making a lot of really high-quality ones like in python or just spewing out tons of buggy libraries with poor documentation and it is hard to find what you need or something in between?

Re: Ask HN: Bet the farm. Python or PHP?

#80
post #17

Earlier quoted context omitted.

I guess, for a lot of people, PHP would be easier to dive into than Python? I get your point; without any other knowledge, you'd be better off selecting from a pool of Python developers than PHP developers when looking for good hackers. Correct? Although I would be able to somehow separate the good hackers from bad by initially chosing Python, would you say that good hackers would also stay clear of opportunities whe…

You won't find any PHP hackers. The good PHP developers realized that PHP was a waste of their time a long time ago. All the novices have significantly lowered the average PHP developer's salary compared to other languages. Basically, there's no skill and no money in PHP, so the good people don't use it.

You won't find any hackers who use sweeping generalizations. Oh, wait!

I'm a hacker. I use PHP. I use Python. I use C++. I use Java. I use JavaScript. I use Prolog. I use C#. I use whatever language or tool is best for the job and I innovate with them however I can. I love getting my hands on new SDKs for every language and framework, learning their quirks and implementing fun things with them.

There is skill in any language you choose to use. That's up to you, not the language. In fact, a "bad" language require significantly more skill to use successfully and securely.

Now, I'm not going to disagree with someone if they provide cons/pros for different languages, PHP has its faults, maybe even more than other languages. But it strikes me odd that you'd be upvoted so much for saying that no hackers use PHP.

The presence of "novices" aren't going to scare away someone who likes to code and get the job done in clever ways. I'll also note, as someone who runs a game scripting community around Python, that novices produce some of the cleverest little tricks and really shouldn't be shunned anyway. We were all novices once.

Post reply on HN