Python Forum
Learning python specific syntax after using other scripting languages for years
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Learning python specific syntax after using other scripting languages for years
#11
I was curious to find out what PHP looks like after I read the stat: PHP has over 83% market share of websites. I bought a course on Udemy. The instructor makes lots of errors. When he debugs his code, the culprit turns out to be "Missing $ sign". Why do one keep typing the $ once a variable is declared? Never said never, but my gut instinct is "No go area for me". Why? I do not want to type $ in front of every variable.
I am not a big fun of "Dynamic Languages" and had hated the "off-side" rules of Python when I first tried it years ago, but I have now overcome my phobia and seem to like it.
Reply
#12
The big percentage of the market share if because years ago there was nothing else but PHP when you have to build a dynamic website.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#13
Quote:now if you want also the index, then you need enumerate
same apply for any other iterable. Actually this is the pythonic way, not using indexes

Maybe so... but indexes especially in associative arrays are a very important thing used in coding all the time. You might often have a hash of product ids to product names for example. There's other ways to do it (a list of objects, or two lists with sync'd indexes), but they add more steps and hash lookups are super fast. So it's not a replacement so much as limiting your use and changing your approach. I don't really care about pythonic or any other way I just want to get stuff done in an efficient and productive manner with a result that is easy to interpret.

Quote:I was curious to find out what PHP looks like after I read the stat: PHP has over 83% market share of websites. I bought a course on Udemy. The instructor makes lots of errors. When he debugs his code, the culprit turns out to be "Missing $ sign". Why do one keep typing the $ once a variable is declared? Never said never, but my gut instinct is "No go area for me". Why? I do not want to type $ in front of every variable.
I am not a big fun of "Dynamic Languages" and had hated the "off-side" rules of Python when I first tried it years ago, but I have now overcome my phobia and seem to like it.

Well, this is getting off topic and I'm not looking to start any language wars but I'll answer you.

Python is dynamic any scripting language/interpreted langauge tends to have looser typing it just confused me as to why they reintroduce typing with objects. The $ syntax comes from Perl which heavily influenced PHP. The $ also allows you to do things like in my example and put variables in the middle of strings you don't have to concatenate them which is messy and hard to read or use printf syntax which is also cumbersome and hard to read, and Perl was a very strong and still is a very strong language for string manipulation (take regex for example, Perl's gift to the world in many ways). PHP just followed suit but isn't as hard to read as Perl which can drop regex out of nowhere and uses % for arrays and more. As for the market share, it got popular, who knows why things get popular but my opinion is it had a lot to do with the fact it was more accessible than Perl, and was being made for web development and it's very accessible with very good documentation and tons of libraries and community support. There was plenty of alternatives out there, and still are more every year. PHP retains such a large market base because of its ease of use and tons of libraries and it's just a fantastic language imo. Even it's convention of function naming is quick and concise and easy to use and remember ex. a lot of languages might choose to say something like string.StringPosition("test") put PHP is just strpos($mystring,"test") it goes back to a simpler ideology and assumes the user doesn't need everything under the sun spelled out to them and can understand str means string and pos means position.


Anyway, thanks again all for the feedback, good to know the differences and at least why some of the things are the way they are. My favorite things about python don't stem from its syntax however, but some of its powerful and unique libraries (looking at you numpy and pandas and tensorflow)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Converting days to years in loop while computing values across grid cells Lightning1800 2 2,594 May-15-2018, 08:44 PM
Last Post: Lightning1800

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020