- Joined
- Sep 5, 2010
- Messages
- 168
Do you think Python is easier than PHP?
Do you think Python is easier than PHP?
Thanks Azareal, I'm pretty sure that any language got its tricky points.I'd say that it's around about the same. Granted, there are some parts of PHP that are a big pain, but there are also parts of Python that are a big pain.
Definitely PHP is the most widely used server-side scripting language thats why you'd find the most hackers playing within it. Python looked good for me as well when I read a bit about but its popularity compared to PHP is not that big.I think Python is nicer. Whether or not it's easier I'm not really sure.
I'm more familiar with PHP due to the necessity of using it for my sites. PHP is very hacky though, and encourages bad practice. I think python is better designed, but that said I've never had to use it in any large projects.
Thanks man, Can you suggest any good python tutorials to look through?As Azareal said, they're pretty similar. Both are dynamically typed and are interpreted languages. Python is probably easier to get started with if you've never done any programming, as PHP has a lot of quirks and there are many ways to achieve the same thing (though most of them are the wrong way...).
PHP is much faster to get in than Python, especially if you have no prior experience in the field, you can simply hack stuff together and echo all output to user and get stuff to show in browser. To do same in Python you would need to learn basics of shell-fu to make PIP install some WSGI stack for you, that you would then need to learn how to integrate your code with.
This difference is PHP's greatest strenght, but ultimately its also its greatest weakeness, because there is great deal of people within PHP world hacking scripts blissfully unaware of things like patterns, PSR's, automated testing, package management, etc ect.
Big difference between Python and PHP lies in standard library, or "core features". There's running joke in Python community that you can import antigravity due to amount of solutions available in language alone. For example there are simple HTTP, SMTP and IMAP implementations in Python stdlib, both for implementing servers and clients. There is HTTP documents parser. There is i18n and I10n implementation.
Python is very "sweet" language, which means there's ton of sugar in it. For example you may check if two collections overlap via writing custom function, but you may also do it via "set(collection_a) & set(collection_b)". You may iterate collection via for loop, or you may process it in place via [process(i) for i in collection]. instead of dedicated array_XYZ functions from PHP there is "[:]" slice operator that behaves differently depending on arguments providen (vide [a:b] doing something different [a] and [a:b:c], and you can use negative arguments there for extra magic).
Python is dynamicaly typed while PHP is weakly typed. PHP tries to convert types to another when it thinks other type is better fit, which may produce some suprising behaviours and edge bugs. Python code relies on behaviour similiarites instead, which either produces crashes ("I can't iterate on number!") or edge bugs ("I didn't know I was iterating on characters in string instead of strings in list!").
Python's type system is more complex than PHP's one. There are two basic types for list, mutable and immutable. There is separate type for map. In PHP there is just array().
Basic types in Python have methods, sometimes very suffisticated ones, like split() or title().
Python object model is very magic. Everything is an object, even object definitions are objects. But at same nothing is real object but special type of map of values and functions that just wraps around basic map type. Everything else is parser doing its magic in converting objects into simpler structures and interpreter pretending "thats really object!". This is why object methods have explicit "this" argument.
On other side such "weak" object model allows for many amazing things. Objects can inherit from many types at same time, they can change themselves on runtime, even on instatiation. Metaclasses in Python while very confusing and tricky to get into, it allow for some crazy stuff in ORM's.
Python has exception-based error handling. Every error in Python is exception that can be caught and handled. You can even catch syntax exceptions! PHP is still making transition from returning falses and error codes to exceptions.
Not really. Depends on what you're building.Do I really need this or can I learn about databases whilst learning programming?
Definitely PHP is the most widely used server-side scripting language thats why you'd find the most hackers playing within it. Python looked good for me as well when I read a bit about but its popularity compared to PHP is not that big.
Oh my badI didn't really mean that "hackers" would be using PHP. I mean "hacky" as in cobbled together - most PHP applications don't follow coding best practices, it's easy to create a working PHP application that doesn't use a sensible structure etc.
It's a very hacky language, and it's very easy to do stuff badly with it.
With PHP, you can probably start building websites within an hour or so. This might be a slight exaggeration.
With Python, it will take.. a while. The other thing is that PHP hides problems from you, which means that you might be able to get things done faster in the beginning, but then you have some mysterious bugs that have snuck in.
PHP is highly popular, as an amateur can just jump in and start building sites without having to worry about the details.
Not really. Depends on what you're building.
Many people working for big enterprises here in my country and (banks as well) do learn ASP.NET and they tell me they use it because they cannot build a bank secure system with PHP or any other language than ASP.NETI learnt coding from PHP, but you'll find that it does not really scale very well with large websites. It's good for when your site is small or moderately sized, but you'll need caching system in time, since it becomes inefficient when your site has decent traffic and serves a lot of page views at once.
For that, Python becomes a necessity as it scales better (hint: YouTube is a python based site and scales well as a result) for very big websites. But all coding languages have their weaknesses, however PHP is the easier to learn imo.
Oh my badsorry. And why is that? Is it because its a loose language?
Ah yes, Jeff Atwood. The thing is that the solution that he pushes (Rails) is simply not that fast. I'd go as far as saying that it's fairly slow.Jeff Atwood can explain it much better than I can...
http://blog.codinghorror.com/the-php-singularity/
He's critical there about people criticising PHP, but also justifies why it's so popular. It's everywhere - if you want to code web apps that you want to distribute and be able to run on any server, then you need to know PHP.
Can you guys give me links for stuff I need to read before I hop into deciding what language or maybe links that help me decide?
Ah yes, Jeff Atwood. The thing is that the solution that he pushes (Rails) is simply not that fast. I'd go as far as saying that it's fairly slow.
People don't want to pay extra money to upgrade their servers, just to use a prettier language.
As far as performance is concerned, one of PHP's greatest weaknesses as a language is multi-threading, which Python also doesn't do too well out of the box, however it does have the option of having multiple processes.