SitePoint Sponsor

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 25 of 27

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Mar 2008
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP-GTK: Do you use it?

    Hey,

    So I've recently stumbled onto PHP-GTK, and with my growing interest in developing desktop apps, this looks promising. I've run through a few tutorials and it seems very well put together.

    Will PHP-GTK allow me to create robust programs like the C languages or Java can do?

    Since I already know PHP, I love the idea of being able to use it for desktop applications. I've bought a few books on Java though, so if this doesn't pan out... I'll hop back into those.

    Any thoughts on this PHP extension would be awesome!

  2. #2
    SitePoint Member
    Join Date
    Apr 2009
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've been a PHP developer for over 4 years. I've seen PHP-GTK, and used it lightly, but my opinion is PHP does not lend itself as a language to desktop programming.

    I've done some work in Java(Swing), C# and D (DWT) and all these languages use event driven paradigm heavily in their APIs. It lends to the idea of user-interface driven application programming very naturally (you do some sort of processing when the user acts with the interface).

    Also, from a commercial standpoint, Java jobs have better pay and a much bigger market.

    But dont let me stop you from having fun with it!

  3. #3
    SitePoint Member
    Join Date
    Mar 2008
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the thoughts!

    I'm not worried about pay, as the only desktop apps I'll be building will be for my own products that I sell. What I'm looking for is simply a language that can do whatever I need it to... and if Java or C is it, then I'll use that.

    I think I'll play with this a little more, and unless I run into any road blocks... stick with it.

    I honestly don't see myself creating too many desktop apps, but I'd like to know how, just in case I do!

    Although I think Java is definitely in my 'must-learn' pile. I'd love to be able to write some mobile apps in the future as well.

  4. #4
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I'd recommend against PHP for the desktop; It really isn't the right language for that kind of thing.

    Java's great, however as it runs through a virtual machine it isn't as fast as some other languages.

    If you've tried out other programming languages, I'd recommend giving C++ a go. I'm learning it at the moment, and it's a great language to learn. However, if you haven't touched on statically typed languages (i.e. declaring variables by certain types etc) and especially if you haven't done anything with OOP, it'd probably be too much as there are other concepts to learn; so try learning something simpler like Java or C# before getting to that stage.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  5. #5
    SitePoint Wizard
    Join Date
    Mar 2008
    Posts
    1,149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Java code running in Sun's JVM generally runs just as fast as native code, if not faster. The only issue is the excessive memory and CPU usage necessary to make it work.

    Java and C# are just as statically typed as C++, so you'll probably not find it much easier. The advantage of Java and C# are that it's a bit more organized (plus the memory management), and that might help learning easier.

    But on the subject of the topic, I have to agree. PHP is the wrong language for desktop programming.

  6. #6
    SitePoint Member
    Join Date
    Mar 2008
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by sk89q View Post
    Java code running in Sun's JVM generally runs just as fast as native code, if not faster. The only issue is the excessive memory and CPU usage necessary to make it work.

    Java and C# are just as statically typed as C++, so you'll probably not find it much easier. The advantage of Java and C# are that it's a bit more organized (plus the memory management), and that might help learning easier.

    But on the subject of the topic, I have to agree. PHP is the wrong language for desktop programming.
    As far as statically programmed languages, I'm not having that difficult of a time in learning Java as it is.

    I've actually found it pretty easy! The book I bought has been great and done very well for me. I haven't gotten into the GUI section yet though... so I can't say for sure.

  7. #7
    SitePoint Enthusiast the-webber's Avatar
    Join Date
    Mar 2009
    Posts
    82
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    haven't messed with c# but I definitely think Java's a bit easier to start with than c++ ... pointers definitely take a bit to get used to ...but personally, i prefer statically typed languages to dynamic ones like php. i defintely find them easier to debug .

  8. #8
    Floridiot joebert's Avatar
    Join Date
    Mar 2004
    Location
    Kenneth City, FL
    Posts
    823
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Even though I had experience with PHP, I opted to learn C for GUI application programming. I still use PHP from the commandline to script certain tasks though.

  9. #9
    We're from teh basements.
    Join Date
    Apr 2007
    Posts
    1,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've used PHP-GTK2 for some small apps for personal use. It's worthwhile if you want to gain experience with GTK, which can be used as well with other languages more appropriate for desktop development. (Pidgin and FileZilla use GTK for their GUIs.)

  10. #10
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    I strongly believe in 'The right tool, for the right job.' IMHO, PHP for anything other than server-side scripting is an abuse of the language.

    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  11. #11
    We're from teh basements.
    Join Date
    Apr 2007
    Posts
    1,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SilverBulletUK View Post
    I strongly believe in 'The right tool, for the right job.' IMHO, PHP for anything other than server-side scripting is an abuse of the language.

    Language abuse is synonymous with poetic license though.

  12. #12
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How do they handle the lack of threading in php-gtk? Spawn new processes and communincate via non-blocking sockets?

  13. #13
    We're from teh basements.
    Join Date
    Apr 2007
    Posts
    1,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by crmalibu View Post
    How do they handle the lack of threading in php-gtk? Spawn new processes and communincate via non-blocking sockets?
    That's how I do it. There is no ready-made solution in PHP-GTK itself.

  14. #14
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    "To a man with a hammer everything looks like a nail."

    Its May already and I havent started this years resolution, start learning another lang.

    Simple desktop widget that can talk to my website, what about Python then?

  15. #15
    SitePoint Member
    Join Date
    Mar 2008
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Cups View Post
    Simple desktop widget that can talk to my website, what about Python then?
    This is actually what I'm looking at right now after hearing all the opinions of this post.

    I've Googled for reasons why I should learn Python, since I've heard so many times how great it is... I've just never been given real reasons why.

    I'm still not finding much in that way either, but it's supposed to be super quick to learn, so why not!

  16. #16
    We're from teh basements.
    Join Date
    Apr 2007
    Posts
    1,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP-GTK is good enough for that sort of thing. Or you could use PyGTK. Same difference, as far as I know.

  17. #17
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    I have asked in several places at what tasks is Python better than PHP for (easier, or faster, better fit, has the capabilities) and apart from "it is better at number crunching" I never really got a satisfactory reply.

    There is lots of information about the differences of the languages (cleanness, syntax, oop, indenting etc) but not much about what it does better.

    Perhaps those are enough for some people ... but its not motivation enough for me to stop what I am doing to learn it.

    I guess to paraphrase old Mark Twain again : "If I had a screwdriver would I then be able to differentiate between nails and screws?" or is Python just another type of hammer?

    Can anyone here chip a in with a comment and enlighten me/us?

  18. #18
    SitePoint Member
    Join Date
    Mar 2008
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Cups View Post
    I have asked in several places at what tasks is Python better than PHP for (easier, or faster, better fit, has the capabilities) and apart from "it is better at number crunching" I never really got a satisfactory reply.

    There is lots of information about the differences of the languages (cleanness, syntax, oop, indenting etc) but not much about what it does better.

    Perhaps those are enough for some people ... but its not motivation enough for me to stop what I am doing to learn it.

    I guess to paraphrase old Mark Twain again : "If I had a screwdriver would I then be able to differentiate between nails and screws?" or is Python just another type of hammer?

    Can anyone here chip a in with a comment and enlighten me/us?
    Good post, although it might better be fit for a different forum. I posted this question over at the Warrior Forums this morning. Here's the link. Maybe I'll get some good answers there.

    http://www.warriorforum.com/programm...rn-python.html

  19. #19
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Thanks

    Yeah, thats just like the questions I posed before, you should prod that Tyrus fellah into telling you more...

    edit:
    Unit testing built in, sounds cool

  20. #20
    SitePoint Wizard
    Join Date
    Mar 2008
    Posts
    1,149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Because Python is built for the desktop and people use it for desktop programming, you have the advantage of having features and libraries that people don't write for web-oriented scripting languages. Off the bat, you don't have threading in PHP, which is a huge disadvantage. You can spawn multiple processes and communicate with sockets, but spawning processes is expensive compared to spawning threads (and it's a very ugly way to do it), especially if spawning a second copy of PHP doubles memory usage. As far as libraries go, you'll eventually find yourself needing to do certain tasks for which there are no libraries in PHP to do it with (because no one bothers to make them), while you can find them in Python. PHP is also slower than Python, and if Google finishes unladen-swallow, Python will be miles ahead of PHP in speed.

    PHP is also not designed so that you can easily distribute your desktop applications. If you need to do anything outside of PHP's core libraries, you have to distribute extensions with your application, and there is no system for people to easily just package and/or install these extensions in a cross-platform manner.

    Using PHP is just asking for a ton of trouble down the road. If you know both PHP and Python, then there is is absolutely no question as to what language you would use.

  21. #21
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Those are some pretty emphatic reasons, thanks sk89q

    Did you learn Python, and do you use it?

    Off Topic:

    BTW - I came across this Django Template clone for PHP called h2o, in the spirit of at least having some kind of familiarity with something when I eventually start to learn it. I have not generally been a fan of templates, but am enjoying using this.

  22. #22
    SitePoint Wizard
    Join Date
    Mar 2008
    Posts
    1,149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, I learned Python a while ago and I use it. I haven't tried it for web development yet though.

  23. #23
    SitePoint Enthusiast
    Join Date
    Apr 2009
    Posts
    46
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm using python in a first-year university computer science course.

    It is a truly great language.

    I have already made some very good programs. For instance, I've made a program to automatically generate and print all the different possible combinations of timetables for courses that someone inputs. The first part of the assignment was given to us: an HTML parser to automatically go online and write the information for the courses from the online course calendar to a text file. But, it was still a signifcantly difficult assignment. btw, there had to be no overlaps in any of the timetables that were generated.

    I've also created a game that has to do with rotating trees. Every time someone wins, I have a "card show" like when someone wins solitare. (Mine is not as good as solitare's winning display, but I didn't spend too much time on it.)

    The point is, python is a great language to program in, and, it enables you to efficiently create good programs. Also, it has such a logically built structure. Python comes with a library of modules, and when you want to do certain things, you import the modules and use their functions. If you don't know how to use a function, you do not usually have to search online, you just write help(module.function), and you get the well-written docstring that tells you how to use the function.

    I highly recommend python, if you're just starting, you might want to get this book: http://www.amazon.com/Practical-Prog.../dp/1934356271
    My prof. was actually Paul Gries this semester.

    There is also this book: http://www.greenteapress.com/thinkpython/ which you can both buy or just read online.

  24. #24
    SitePoint Enthusiast
    Join Date
    Apr 2009
    Posts
    46
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Also, python is just enjoyable to program in. Take a look at this:

    def rev(n):
    '''Return the result of reversing the digits in integer n. For example,
    rev(512) should return 215.'''
    if n / 10 == 0:
    return n

    return int(str(n % 10) + str(rev(n / 10)))
    print rev(4231)


    Doesn't this recursive function just look good? It's simple and short, and there's not a lot of punctuation.

    btw, here's what it does:
    ("/" is integer division here)
    let's say n=215

    the program will do this
    215 % 10 = 5
    215 / 10 = 21
    21 % 10 = 1
    21 / 10 = 2
    2 % 10 = 2
    2 / 10 = 0

    then it takes the results of the "% 10" lines and concantates the strings of the results backwards:
    '5' + '1' + '2' = '512'
    then it integerfies it: int('512') = 512

  25. #25
    SitePoint Enthusiast
    Join Date
    Apr 2009
    Posts
    46
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can follow the instructions here to install python:
    http://www.cdf.toronto.edu/~csc148h/winter/python.shtml


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •