Web service API - which language is better? [closed] - php

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 months ago.
Improve this question
I wrote a web service API which services REST requests in php. It didn't take much time to actually setup this on apache. But, I am more comfortable writing python code rather than php code. Can python be used as a server-side scripting language like php? What changes are necessary to make it work with apache?
Thanks
Bala Mudiam

For a REST full API I would suggest that you take a look at Tornado. It's what Facebook uses. It's fast, efficient and easy to work with (written i Python). You may use nginx as a proxy in front of it to server static content and allow more Tornado services for scaling.

Python is a very capable server-side language. Large sites (such as AG Interactive) use Python for server-side programming and have had great results. mod_python and mod_wsgi are 2 popular modules for Apache that allow you to serve Python.

Yes Python can be used as server-side language (as well as Perl, Ruby or even C/C++). Just use mod_python for Apache http://www.modpython.org/

I'll dare to say that mod_wsgi is probably closer to the de-facto choice (vs. mod_python) if you're stuck with Apache as your web server these days. One benefit is that you'll find a wide range of active frameworks and libraries that are WSGI compatible. Please don't read too deeply into "framework" - some things I'd lump in there are quite minimal, providing a few nice conveniences on top of raw WSGI to help you organize your code. Imagining that you're not looking to invest into a web framework itself just to get a REST interface up, you might check out restish as an option.

In my opinion python which is a popular language is better.

Related

Web server to handle multiple ad hoc Scala scripts? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
For one of my simple appplications, all the routing is handled by nginx. I just put the php files in the directory referenced and they are serve requests: no framework is used. I am trying to migrate this scheme to Scala: I want to do it by gradually replacing each php script with one in Scala.
Is there a Scala counterpart of a php server that can automatically compile and serve all scala files under a directory? So that when I put code in /book/new.scala, /book/buy.scala, /user/login/auth.scala, etc, the server would compile and serve all of them for corresponding requests?
In the strictest technical sense, Scala can be used as a "scripting language," but it's rather limited in what can be reasonably done that way.
As others have commented, you should make a proper server for or out of you Scala application. There are many options from simple and lightweight to big and fancy. Most use the Java Servlet Container, but some implement their own HTTP server side.
You have many options to choose from, but "scripting" really is not among the viable ones.
You might look at the Lift Framework, and aim to only use the endpoint/RESTful part of the framework. In this way you can identify key requests to the webserver and pass them off to Scala-based code. Lift would manage the webserver part of everything.
That said, this is a very strange way to manage a web application, and harkens back to the 90s-era CGI-script based architectures. Ask yourself why you're attempting to model things this way before proceeding, and ask if the difficulty of running two containers (php and Scala) is really worth the trouble in order to 'ease' migration.

Can php and C++ run on the same server and communicate in a web site? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I have a client that wishes to have a website written that involves a fairly simple cms driven website that sorts and displays daily reports. The website will require subscriptions and include membership, free trials, etc...
Originally I was going to write the site in PHP, as none of the requirements are too heavy and I am very experienced in it. However, after speaking with the client, he has worked closely with someone who has a C++ product that offers a workflow that includes the entire process of handling subscriptions, logins, and trials and (apparently) can be used on a web platform.
This throws a wrench into my original plan, because even though I know C++ I have never had to deploy it on a webserver or have it communicate with PHP. I've already written a good deal of the site in PHP, so would prefer not having to re-write.
Can I have the two communicate on the same server? What would be required to do so? Would it be worth my time or should I just decide to scrap PHP and use C++? Or should I tell my client he's nuts?
That's about all the info I have about the project right now. Not sure if I can provide much more info, but will try if it's needed.
Thanks for all answers.
Tel him he is nuts.
The reason is that none of those tasks requires the benefits C++ can offer over PHP. It is heavy maintenance pain. And in the big picture putting those two together is more work (in hours) than writing those things in php.
The only thing that would justify C++ is if there is some heavy math business logic involved in there. And i mean heavy.
For problems. Just think about debugging.
In addition to what Thomas says (which is all true), your hosting company will most likely prohibit running custom binaries. Hosting packages short of virtual private server normally don't allow user-written compiled code on the Web server, only scripts.
VPS hosting is, on average, 5 times as expensive.
You can re-write the C++ code in PHP. You can also convert C++ to Java using a converter and then use the Java virtual machine if your host allows that. You can use the C++ code if your host allows that. You can host the C++ code from a local machine if that is a good idea in your case.
I would tell the client that in case there is no explicit need for the C++ language I would go with implementing PHP. You know, the communication between C++ and PHP adds to server load even if the host allows you to use the C++ module. And in the future you will have a lot of pain maintain

Event-Driven PHP Framework? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
I'm wondering if there are any completely event-drive frameworks out there for PHP which are based around dependency injection for decoupling. I know there are some frameworks that make use of these patterns - but in the end the entire life-cycle of the application is still pre-defined and linear in style.
For example, most frameworks are built to receive, process, and return results from HTTP requests. An event drive framework would have handlers for that, but also be able to be used for new purposes like background processing, command line interaction, or other non-standard use cases.
It sounds to me like the Photon framework fits closest to your description - the key point is that you can't have event-driven code without php running in a daemon-like process. Your choice of webserver in fact dictates whether what you ask is possible or not - photon is dependent on mongrel2.
I have never used it for a project personally, but I believe that Prado covers what you are asking. It is componentised, but I cannot be sure about the dependency injection aspect.
From their site:
PRADOTM is a component-based and event-driven programming framework for developing Web applications in PHP 5. PRADO stands for
PHP Rapid Application Development Object-oriented.
I know of it because one of my university class mates designed the logo and website for the project.
Not used it, but I believe in addition to Prado, which Treffynnon has mentioned, Qcodo is a pure event-driven framework.
I was looking what is around as well and i came across p4e which is based on zend framework,and nette, hope it can help!
Off the bat there are these 2 as well:
Zend Framework 2 (still in beta)
symfony 2
Both have all the things you are looking for I believe.
Symfony2. Simple as that.
http://symfony.com/
Yii ,It is a component based and event-driven framework, Pure OOP and MVC. It is very clean and neat. Check it out.
http://www.yiiframework.com
The Qbix Platform is heavily event-driven in PHP, although it does not use dependency injection.
Reactphp is what you are looking for.

What would you recommend as a transition language on the desktop for a PHP programmer? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
I've been using PHP for some time now, and though I certainly don't claim I am a PHP guru, I feel I know my way around the language enough to get most things done elegantly enough.
Up 'til now, I haven't really wanted to do much desktop programming. I've hacked together tiny things with AutoHotKey and (I'm sure) rather poorly written C#, but I have never gotten into these languages in the same way that I have with PHP.
Now, I'm looking to change that, so I am asking you guys what you think would be the best language for me to try for programming on the desktop. Preferably, I would like something that is
Typed similarly to PHP (Wikipedia lists it as "dynamically/weakly" typed
Interpreted
Can be compiled (or at least packed) to an executable, and easily
Thanks in advance for any help!
EDIT:
Thank you all for the helpful answers - I wish I could have accepted all of them. I decided to try learn into Python, keeping in mind the differences between web and desktop development. Thank you all for your generous help!
My recommendation would be to try python. It is dynamically/strongly typed, and has syntax and features relatively similar to php. It can't be compiled to an executable, but it can be compiled to byte-code, like java is.
I have been programming in php for several years and recently picked up python and have really enjoyed it. I have also used c++ and java quite a bit and find them to be more difficult to master, and more frustrating to use.
There's not much value is learning a "PHP for the desktop language". I'd recommend that you explore language with different principles (say Python or Ruby) and use Desktop apps as your learning vehicle. PHP is written to be embedded inside a web page and that carries over even when you use it as a regular scripting language.
You can learn the ropes a little before picking up a new language by using something like PHP GTK.
PHP's design principles are fine on server side, but in many places they don't really fit in the world of Desktop development. For example, native Windows applications follow entirely different paradigms. Being able to work with these in a PHP-like language requires an additional (performance-intensive) layer between your language and the Windows API.
Bottom line: Much of Desktop app programming is so fundamentally different from how a PHP web app works, you won't get far with PHP's paradigms anyway.
I would therefore recommend to drop the requirements, and look/ask for the optimal language for the task instead. I don't know your situation of course, but if you have the time, chance and inclination at all, it's a great way to expand the programming horizon; also from a professional and CV perspective, it doesn't hurt to have another language under your belt.

which web development tools and languages should i use? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I started programming in january of this year and have covered a lot of ground. I have learnt javascript, ruby on rails, html, css, jquery and every now and then i like to try out some clojure but i will really get into that in the middle of next yr. I really didnt like rails and prefer using netbeans with pure javaScript, html and css, i just feel like i have more control. I really like javascript, but when it comes to sever side programming i have a problem.......for my level of experience i just feel like server side js will not be a good fit yet as it is still not as mature/user friendly as php or ruby on rails.
What server side language should i invest in, should i learn php? There is so much info on source code on php. I know that there is node.js and emerging frameworks like geddy.js but i need something more user friendly....or am i just being a woos.I would really like some help on this.
Thanks in advance
PS. Update: Thanks all for advice, i have settled on python and web2py framework. I decided between django and web2py by doing a couple of simple tutorials and preferred web2py by a huge margin.
If you like ruby as programming language, but find rails to be just too much to take in it once, I'd recommend trying Sinatra. It's also a ruby-based web framework, but it's a lot simpler than rails, and offers you a lot more control over how you want to set things up. For smaller projects, it's often a much better fit than Rails.
Not sure why you don't like rails, but you might want to try the newly released "Rails for Zombies" tutorials by Envy Labs: http://railsforzombies.org/. Or if you like books instead of online stuff, check out Agile Web Development with Rails
As ben states, sinatra is nice for smallish stuff.
A few things to choose from, broken down by language and order of their complexity/learning curve:
Ruby
Sinatra
Rails
Python
web.py
Django
PHP
Code Igniter
CakePHP
Symfony
EDIT: I removed my comment about php and added in some PHP specifics. Personally I started with Symfony but it is rather complex. Code Igniter would be a good starting place if you want to learn a PHP framework.
Python language and Django web framework are another good alternative. Both elegant and easy to get started with.

Categories