Which programming language suits web critical application development? - programming-languages

According to this page,it seems that Perl,PHP,Python is 50 times slower than C/C++/Java.
Thus,I think Perl,PHP,Python could not handle critical application(such as >100 million user,>xx million request every second) well.But exceptions are exist,e.g. facebook(it is said facebook is written with PHP entirely),wikipeida.Moreover,I heard google use Python extensively.
So why?Is it the faster hardware fill the big speed gap between C/C++/Java and Perl/PHP/Python?
thanks.

Computational code is the least of my concerns in most heavy usage web applications.
The bottle necks in a typical high availablility web application are (not nessecarility in this order, but most likely):
Database (IO and CPU)
File IO
Network Bandwidth
Memory on the Application Server
Your Java / C++ / PHP / Python code
Your main concerns to make your application scalable are:
Reduce access to the database (caching, with clustering in mind, smart quering)
Distribute your application (clustering)
Eliminate useless synchronization locks between threads (see commons-pool 1.3)
Create the correct DB indexes, data model, and replication to support many users
Reduce the size of your responses, using incremental updates (AJAX)
Only after all of the above are implemented, optimize your code
Please feel free to add more to the list if I missed something

The page you are linking only tells half the truth. Of course native languages are faster than dynamic ones, but this is critical to applications with high computing requirements. For most web applications this is not so important. A web request is usually served fast. It is more important to have an efficient framework, that manages resources properly and starts new threads to serve requests quickly. Also the timing behaviour is not the only critical aspect. Reliable and error-free applications are probably better achieved with dynamic languages.
And no, faster hardware isn't a solution. In fact Google is famous for using a cluster of inexpensive machines.

(such as >100 million user,>xx million request every second)
To achieve that sort of performance, you are going to HAVE to design and implement the web site / application as a scalable multi-tier system with replication across (probably) all tiers. At this point, the fact that one programming language is faster / slower than another probably only affects the number of machines you need in your processor farm. The design of the system architecture is far more significant.

there is no JIT compiler in php which Compile the code into machine code
Another big reason is PHP's dynamic typing. A dynamically typed language is always going to be slower..
click below and read more
What makes PHP slower than Java or C#?

C is easily the fastest language out there. Its so fast we write other languages in it. Nobody seriously writes web sites in C. Why? Its very easy to screw up in C in ways that are very difficult to detect and it does almost nothing to help you. In short, it eats programmers and generates bugs.
Building a robust, fast application is not about picking the fastest langauge, its about A) maintainability and B) scalability.
Maintainability means it doesn't have a lot of bugs. It means you can quickly add new features and modify existing ones. You want a language that does as much of the work as possible for you and doesn't get in the way. This is why things like Perl, Python, PHP and Ruby are so popular. They were all written with the programmer's convenience in mind over raw performance or tidiness. C was written for raw performance. Java was written for conceptual tidiness.
Scalability means you can go from 10 users to 10,000 users without rewriting the whole thing. That used to mean you wrote the tightest code you can manage, but highly optimized code is usually hard to maintain code. It usually means doing things for the benefit of the computer, not the human and the business. That sacrifices maintainability and you have to tell your boss its going to take 3 months to add a new feature.
Scalability these days is mostly achieved by throwing hardware at it and parallelizing. How many processes and processors and machines can you farm your work out to? If you can achieve that, you can just fire up another cheap cloud computer as you need it. Of course you're going to want to optimize some, but at this scale you get so much more out of implementing a better algorithm than tightening up your code.
For example, I took a sluggish PHP app that was struggling to handle 50 users at a time, switched from Apache with mod_php to lighttpd with load balanced, remote FastCGI processes allowing parallelization with a minimum of code change. Some basic profiling revealed that the PHP framework they used to prototype was dog slow, so it was stripped out. Profiling also suggested a few indexes to make the database queries run faster. End result was a system that could handle thousands of users and more capacity could be added as needed while leaving most of the code implementing the business logic untouched. Took a few weeks, and I don't really know PHP well.
It may be beneficial to reimplement small, sharp pieces in a very fast language, but usually that's already been done for you in the form of an optimized library or tool. For example, your web server. For the complexity and ever-changing needs of business logic the important thing is ease of maintenance and how good your programmers are.
You will find that most of the web is written in PHP, Perl and Python because they are easy to write in, with small, sharp bits written in things like C, Java and exotics like Scala (for example, Twitter). Wikia, for example, is a modified Mediawiki which is written in PHP but it is performant (amongst other reasons) by doing a heroic amount of caching.

Google is using Python for GAE and Windows Azure is providing PHP. The LAMP architecture is a great for application scalabilty.
I also think that the programming language is not that important regarding performance. The most important thing is to look at the architecture of your app.
I hope it helps

To serve a web page, you need to:
Receive and parse the request.
Decide what you wish to do with the request.
Read/write persistent data (database, cache, file system)
Output HTML data.
The "speed" of the server side language only applies to steps two and four. Given that most scripts strive to keep step 2 as short as possible, and that most web languages (including PHP) optimize step 4 as much as they can, in any serious web site most of the request processing time will be spent in step 3.
And the time spent on step 3 is independent of the server-side language you use ... unless you implement your own database and distributed cache.

For php, there are lot of things you can do to increase performance. For example
Php Accelerator
Caching Queries
Optimize Queries
Using a profiler to find slower parts and optimize
These things would certainly help reduce the gap between lower level languages. So to answer your question there are other things you can do inside the code to optimize it and make it run faster

I agree with luc. Its the architecture that really matter and not the programming language.

Related

What would be the disadvantages of building a website purely in Eiffel using EWF (Eiffel Web Framework)?

We are looking to build a website on top of an existing Eiffel business-tier core, which is sitting over a MS SQL Server database. I am presently considering the advantages and disadvantages of writing the web and mobile tiers either purely in Eiffel, purely in typical web-stacks, or some hybrid.
For us, there are clear advantages to pure Eiffel, not the least of which are:
Inheritance and other language notation mechanisms not found in other languages.
The compiler cannot see into code from other languages, so we are at the same disadvantage one we cross out of Eiffel into something else.
Auto-Test is something we heavily rely on in our Eiffel code, which takes clear advantage of Design by Contract. In other languages, we lose this power and are left with TDD (e.g. their version of Auto-Test in Eiffel).
We now have to learn more than: Eiffel, HTML-5, CSS-3, JS, and whatever JS framework(s) we use.
Every new language and tool adds more complexity to the project.
Eiffel programs are compiled to C --> EXEs, which are far faster than their scripted and interpreted counterparts.
I think there are also some clear advantages to existing, non-Eiffel languages as well:
Existing frameworks and tools can develop simple to moderate web sites and mobile applications rather quickly.
Existing "best-practices" are not terrible and producing reasonably reliable and maintainable code.
I am not sure what all of the advantages and disadvantages are, so I am asking. However, at the end of the day: Our core business suite is pure Eiffel. That will never change.
Thanks in advance for the feedback!
Here is what I can say from my own experience (I have create several web applications in different frameworks including one in Eiffel). First, the Eiffel Web Framework is quite usable right now. The advantage of other frameworks are their features. Here is a list of the major problems I encounter when I created my web application with Eiffel:
I had to create the MVC design myself (other frameworks like Django, Rails or Laravel does that automatically).
Eiffel lack is a good templating system. The Smarty library is ok, but it really lack some really good template features that other has. Also, trying to work with UTF-8 file in Smarty can be quite difficult (this has been a pain for me).
I had to do some session management based on cookies because the one in Eiffel Web Framework was quite primitive.
The release process (removing Nino) was not easy and lack good documentation (I was using Apache, I don't know about IIS)
That's it, other than that, every thing went quite smoothly.
The next list of disadvantages is from my naïve point of view:
The EWF package is not finished, it's going to have more nice capabilities in the future, therefore you may need to follow the new development to take advantage of new functionality.
Eiffel compiler makes it impossible to update a web program on the fly, it needs to be recompiled and redeployed.
If the program is going to be multithreaded, you need to learn a structured way to deal with concurrency based on the SCOOP model.
Some tools (e.g., XSLT processors) are not readily integrated into EWF, you may need to do this yourself.
The current EWF API is rather low-level, so before higher-level frameworks built on top of EWF become widespread, you may need to do more low-level programming than expected (by low-level I mostly mean the way to generate HTML/XML/or some other format your web service is going to produce).
Having to use just one language to do both application logic and HTML generation, that allows for easy debugging, may lower the requirements for the developers and their skills, that may affect your business model.
There are several tools that address specific needs like wiki, simple web-page creation, authorization, etc., but you may need to enhance them to get richer functionality as well as to design the architecture of your software, because some idioms and usage patterns are not established yet.

HTTPS on Cocos2d-x

I'm implementing a game app based on cocos2d-x. In order to technically prevent cheating, one of the ideas to do is using HTTPS for all the client-server communication, which make it difficult to get the data format / game logic and send modified request to cheat. (I know "prevent" is actually impossible but for increasing the cost of making game cheating it's ok : ). My question is,
In Cocos2d-x, how to make HTTPS request? Possible?
In a more general case, technically what to do to reduce such game hacking? What strategy to hold?
For native cross platform C++ networking you may consider using Boost C++ libraries. Boost.Asio is the one used for networking.
Boost.Asio link:
http://www.boost.org/doc/libs/1_53_0/doc/html/boost_asio.html
Boost.Asio tutorials link: http://www.boost.org/doc/libs/1_53_0/doc/html/boost_asio/tutorial.html
Although not officially supported (only due to lack of regression testing on iOS and Android), Boost runs without any problems on iOS and Android (and probably other C++ based mobile platforms as well).
To prevent cheating you usually rely on an external source (which can be your game server) e.g. if your game relies on the time of day you may get the time form an external server. You may use encryption libraries for data transfer on the client and server side.
by using curl library you can make https connection.
if you want technically protect your game use you own strong encryption technique.
Thanks
Hi this is a problem we face all the time. If the cheating is limited to the cheater's instance the questions is academical and should be studied on your spare time.
On the other hand when your income is impacted or when the cheater's actions impact other players and degrade the game experience you should put some effort on testing the game state for inconsistencies, secure the client/server transactions and deal with cheating in very subtle ways to avoid completely deterring the cheaters' interest.
C++ https implementations are available with curl and boost.
Concerning the game data, the simplest way to test for inconsistencies are scores. You can add a few indicators to avoid polluting your leaderboards. You can add special checksums based on the score's components (time spent in game, number of power ups and score multipliers received...) if you can recalculate the score on the server and if inconsistencies are discovered you can deal with it.
Also you can grab instants of the game state and a few commands, encode that and replay the sequences on the server to check for inconsistencies. Deal with cheaters however you like.
When playing on a server let the server manage the gamestate and allow no client side game state changes that would impact players. Check for input consistency etc...
When using micro transactions each micro transaction should be verified with the vendors servers before being fully committed to the player's account.
Even if these papers 1, 2 from valve refer to fps games they should give you some pointers as to how to deal with state inconsistencies (introduced by communication delays). It should help in avoiding fake positives and ruining the experience for non cheaters.

Is that the concept of Node.js event loop the same as CICS pseudo-conversational programming?

I am asking this question from an architectural point of view. I have been looking up tutorials and blog posts related to Node.js. Apart from a server-side implementation of Javascript, I don't see anything new when compared to the basic concepts used in CICS since the 1970s.
I must admit that the implementation and other technical details are different (PC vs Mainframe, Scripting language vs COBOL, UNIX vs MVS). However, other than those, I don't see any difference.
Can someone offer some insights from the architectural view?
The purpose of CICS psuedo-conversational programming is to release common resources while the user is filling out the screen.
Node.js keeps a single thread for your code while all input / output runs in parallel with your code.
With CICS, the developer has to code in a certain way (psuedo-conversational) so that the shared CICS system would run efficiently. With node.js, the design lets you code without worrying about the underlying architecture.
I'd say that the concepts are different. The developer serves CICS, while node.js serves the developer. It's like the difference between a dictatorship and a facilitator.
Actually they are quite similar in many ways. There are, several important differences in their implementations. Similarities first... both are examples of a monitor style of programming, both react to events in a more or less message passing style and both are designed to keep from blocking on allocated resources. Both also work very well with message passing middleware. CICS code can even be structurally similar (if you ignore the large and mostly mysterious number of constants and bizarre function names). there are also some profound differences, particularly with regards to transactionality, built in security ease of management. While CICS has GUI management, it is a long way from the simplicity of Node. I believe Node is now available natively on mainframes as well.
I realize this is an old question, but thought it deserved an update. The short answer is they are not the same, but that CICS can support a model very similar to node.
Ps... i have written code for both. In some ways CICS seems more friendly in C and Java than Cobol, which is what most people are familliar with. The respondent above is also right in that they do not serve exactly the same purpose although they can be used similarly. Node seems much easier to code for, but requires a lot of libraries and/or external components if you need some of the features that CICS provides out of the box.

Language Choice for Multi-Tier/Multi-Threaded/Event-Based Container

I would like to start a new project that consists of multiple tiers, the web tier, event-driven business logic, data processing, etc. I had worked on PHP and Java-based projects for the past few years and speaking from experience, Java (and given the open source libraries to achieve scheduling, ORM, AOP, etc.) is usually a good choice - and of course, you DON'T ALWAYS need a container as different tiers and services can be written with different languages, integrated, together with other processes such as cron jobs.
Now, given that I am starting a new project, I am wondering how would others advice me on the language choice. I am trying to find some answers from Python, Ruby, Erlang Google searches, but certainly this is a good place to collect some good advices and criticisms.
Thoughts?
What I use regularly is the omnipresent LAMP stack (Linux, Apache web server, MySQL database, PHP server logic) and if I need to do something more intensive on the backend, such as processing lots of language data, or running network commands and sorting the output before feeding it back into the system, I use Perl. All of these utilities/languages are available in almost every distribution's repositories, as well as the connector code to use them all together (php5-mysql, for instance, to import PHP functions that allow you to use MySQL).
UPDATE: I would like to add a few ideas to this answer, since someone upvoted it and called my attention to it today. When I wrote this, I was experimenting with a few different technologies, and in many ways I still stand by what I said earlier. LAMP is vastly more mature than any other web platform out there. It's still true that you just can't go wrong starting with this combination.
That being said, a year later, I have been using Nginx and Python (through uWSGI) quite a lot for my personal projects. I think now distro support for both of these technologies is mature enough that people with significant site traffic should genuinely consider switching out Apache with Nginx. It serves static resources FAR faster than Apache. If you want to use PHP, you will probably be using php-fpm to connect PHP to Nginx. If you want to use Python -- which is fast becoming one of my favorite languages, both for its performance and its language features that have grown on me -- you will have a huge choice of options to choose from in order to connect Nginx to Python, but I highly recommend uWSGI for the simple fact that it's tested and it's very fast. As for databasing, I still think MySQL is broadly-powerful enough to suit many different situations. If you disagree with this statement, I'm sure you are experienced enough to search for many thorough resources showing pros and cons for almost any situation.

Need guidance back into programming

I used to be a programmer and unix sysadmin back in the 90's and early 00's. I wrote business software mostly in BBX, which was non-compiled, procedural BASIC. It was all text based when I started, and I only just got into GUI and OOP with ProvideX by the time I got out. I did do some SQL work and understand basic database concepts.
I've continually dabbled since and tried to keep up by running my own Debian web server here at the house, doing little script programs here and there, and most recently learning PHP and Python. But I would like to get versed in the current state of the industry and hopefully make myself employable in it again.
My current learning project is to write a db app that I can use when drag racing to log run data, report based on various combinations of variables, and predict vehicle performance. This should cover IO, data management, and some complex math. I do want to make is sellable, so it has to be in Windows since all other racing software is. My two options now are to write it in MSAccess, which isn't really programming, or to write a front end in Python and use MySQL for the data.
I assume I should go the Python path out of those two, or should I choose a third path that would pay more dividends toward a job? My biggest concern is wasting my time learning pointless stuff. I assume most of the work out there is db related and web based applications, so that would be my ultimate goal. Correct me if I am wrong on that.
Thanks for any input,
Dave
If your goal is to get back into software development, then I recommend that you first ask yourself what type of industry and development setting you'd like to work in. Learn something about the skills those industries are demanding... Then hit Monster and peruse the job qualifications for companies in those industries. Don't limit your view to just language names and broad job descriptions either, but really try to get an idea what sort of developer they're looking for and whether you'd fit in well.
You will be able to find many interesting technologies in lots of different business domains, but what do you really want to be working to help deliver? Python coding, for example, may be interesting, but I'm sure you'd be more interested if it were supporting your motorsport interest in some way versus, say, baby food. When you have the business domains narrowed down, then you can focus on the background required to get jobs in those industries.
You will find an endless set of recommended "hot" techologies if you search for them. I'm sure you can find a list, or post, which will confirm any bias you have on what to learn. But chasing the technology of the day may lead to an unfulfilling day-to-day job if what you're applying it to is not something you find interesting.
I would say that the answer depends on what type of job you want to do. The Fortune 500 company I worked at last summer had everything from mainframe c and cobol, java EE, .net to ruby on rails and python in applications. There are still alot of jobs maintaining legacy desktop applications. But the web atmosphere is obviously the future of business computing, and java EE and .NET are huge players in that arena. As for the project you are describing. I've done QT applications with python and there are python libraries for GTK that I've seen used to run apps in Windows. I've also used java swing and awt to build graphical applications and other than the learning curve for the layout system it works really well for building applications. I wrote a really basic windows application using visual studio and C# one time and that seemed to me to be very easy to write.
Enterprise level Java or .NET involve a fairly steep learning curve, so I would have those as a medium-long term goal rather than try and learn that tech immediately.
It seems to me that learning a high productivity web framework is the best way for you to go. "Ruby on Rails" seems to be a hot ticket at the moment. I've only had a small look at it, but it seems pretty quick and straightforward. Your drag racing app would be a good place to start.
Build a couple of websites for yourself using the tech. Then build a couple of websites for friends for a nominal fee. After that, see if you can find a real client (perhaps a local business). If you have 2 or 3 of those under your belt, then a potential employer will at least take notice.
One warning, though - people expect web sites to look nice. If you don't have good interface design skills yourself, it will be in your best interest to hire a designer to pretty up whatever you produce.
For a Windows desktop application, you can use C# and the various .NET APIs, and store your data in either a Microsoft-provided database, or SQLite, which is a reliable, server-free SQL implementation. (I don't know anything about Microsoft tech, hence the vagueness of my answer.) There is a lot of work available using C# and .NET, and it should be easy to pick up. You'll meet less resistance on the Windows platform with Microsoft's kit than with third-party languages like Python.

Resources