programming language & alogirthm

Wednesday, March 21, 2007

AJAX in the Enterprise

Is AJAX ready for the Enterprise? The answer to this question may lie in its relationship to open standards, vendor lock-in, conformity to popular skill sets, and web services and service-oriented architectures.

  1. Open standards are preferred by corporations who do not want to be tied to a specific vendor or plugin for their mission-critical systems. The building blocks of AJAX, (X)HTML, CSS, JavaScript, and XML, are all open standards supported widely across different browsers and platforms. Some alternatives to AJAX do not enjoy the same level of ubiquity. For example, XUL and XAML are both browser dependent, while Java, Flash, and SVG all require proprietary plugins.
  2. Vendor lock-in has always been an issue for IT investment, and continues to be on the web. By avoiding proprietary technologies on which to build large-scale enterprise applications, firms are mitigating some long-term financial risk. AJAX is a set of technologies that are based on open standards and partially avoids the issue of vendor lock-in.
  3. Another big selling point for AJAX is the way web developers who are familiar with the underlying technologies can begin developing with AJAX relatively quickly, while the learning curve for alternative technologies is comparatively steep. By leveraging the synergies of skill transference, firms do not have to invest in significant retraining of their developers.
  4. Service-oriented architectures (SOA) have been gaining popularity in major enterprises around the world for several years now. SOA is an approach to building large distributed systems on a composite set of loosely coupled business services. Just about every major enterprise software vendor has an SOA strategy and product suite match. In many SOA models, business services are exposed through XML web services, and AJAX clients are ideal consumers of these services.

The question then becomes, is the AJAX platform powerful enough to build enterprise-quality Rich Internet Applications (RIA). This issue is highly debated in the web development community (http://blogs.ebusiness-apps.com/dave/?p=32). Here are some of the arguments against AJAX for RIA:

  1. There is a stigma attached to using JavaScript to accomplish any intensive processing tasks since JavaScript is an interpreted scripting language, and quite inefficient. That said, the average desktop computer is becoming more powerful. In the past, most JavaScript applications only performed very simple tasks where efficiency is not a concern, and so techniques for writing efficient JavaScript are not widely known. As AJAX matures, coding standards will improve and push the language to its limit. As this happens, the efficiency argument against using AJAX for Smart Client implementations will weaken.
  2. As an interpreted language, JavaScript must be sent up to the client as source code. This causes problems for protecting intellectual property, since the source code must be distributed to anyone using the application. There are techniques for obfuscating the JavaScript, but like all copy protection they just make it a bit harder to steal, not impossible. This argument fails for a number of reasons, though.

First of all, Java suffers from a similar problem, with source code weakly protected in its distributed form. This, however, has not stopped businesses from deploying large Java-based applications. Another reason this argument fails in an SOA environment is that the AJAX application doesn't need to possess all the business secrets required for the program; they just need to orchestrate the business services that perform these activities.

This broad argument against using AJAX in the RIA realm may be somewhat short sighted. Within an enterprise, the need for interoperability may outweigh more fine-grained standards centering around performance, IP, and code inefficiencies. Consequently, looking into the future, approaches like AJAX which focus on platform independence and RIA will become important in the realm of enterprise applications.

Conclusion

The trend in web application development is towards open standards and vendor neutrality. Current HTML web applications don't provide the user experience users have come to expect, so the development community has long needed a viable technology suite to develop rich internet applications. AJAX fits all of these requirements and has experienced significant uptake by developers and enterprises over the last year. It's always challenging to predict technology trends, but if we look back at Java's evolution we can see that there are a number of similarities.

A decade ago, Java was going to revolutionize the way that developers built applications. Instead of building different versions of an application in order for them to run on different operating systems, developers could target the Java Virtual Machine, and then their software would run on Macs, Windows, and Unix-based platforms without any further customization. Huge corporate information systems are being built on the Java platform, and a number of large client applications are also built using Java. Java also suffered from performance and usability issues related to poor user-interface libraries, but overall it was quite successful.

As internet applications became more prevalent, we ran into the same problems of being forced to either write software to target a specific environment, or be very limited in the quality of the user experience. Technologies like HTML, CSS, and JavaScript gradually evolved with the promise of providing a platform on which very powerful applications could be based, but that promise was unfulfilled until now. Now that all the major web browsers have relatively consistent support for the technologies AJAX requires, AJAX will become a crucial piece in the RIA puzzle and will offer the potential for dramatically more powerful and user-friendly web applications.

Monday, March 19, 2007

Process Affinity

Processor affinity is a modification of the native central queue scheduling algorithm. Each task (be it process or thread) in the queue has a tag indicating its preferred / kin processor. At allocation time, each task is allocated to its kin processor in preference to others.

Processor affinity takes advantage of the fact that some remnants of a process may remain in one processor's state (in particular, in its cache) from the last time the process ran, and so scheduling it to run on the same processor the next time could result in the process running more efficiently than if it were to run on another processor.

win32process.SetProcessAffinityMask

SetProcessAffinityMask(handle, mask)

Sets a processor affinity mask for a specified process.

Parameters


win32process.SetThreadAffinityMask

int = SetThreadAffinityMask(handle, mask )

Sets a processor affinity mask for a specified thread.


def SetProcessorAffinity(self):
try:
import win32api, win32process

# get number of processors
systemInfo = win32api.GetSystemInfo()
numprocs = systemInfo[5]

# if multiple procs, set processor affinity to the first
# this sets proc affinity for children also, so vic will get this
# (vic is ill-behaved on multiproc machines)
if numprocs > 1:
log.info("Found %d processors; setting affinity",numprocs)
cp = win32api.GetCurrentProcess()
win32process.SetProcessAffinityMask(cp, 1)

except Exception,e:
log.exception("Exception setting processor affinity")

Saturday, March 03, 2007

Python, Php Web programming

-- collection of comments from others
http://blog.ianbicking.org/why-web-programming-matters-most.html

"Trying to explain to people how to do Web programming in Python, or even trying to convince them to let me do Web programming in Python (instead of say PHP) has been an embarrassment. (This despite my opinion that PHP is an embarrassment to the term "programming language".)

I have long believed that Web scripting is the domain with the biggest bang-for-buck you can get out of a high-level language, mainly because the Web is the universal user interface. Once a program is placed on the Web, its functionality becomes instantly accessible to millions of people. Tiny, simple programs can become useful groupware tools.

Not all is lost, though. PHP succeeded at displacing Perl as a widespread Web programming language, so maybe it can happen again. Python can still do many things that other languages can't -- for example, cgitb exploits Python's unique strengths to provide a huge win for Web developers. "

" The vitrol that Python programmer's have for PHP has always baffeled me. Frankly, part of the reason I've avoided learning Python is because every Python programmer I've ever met has been a prick about my current choice in programming language. PHP works, I enjoy programming in it, I like the way it feels and reads, and the user community is incredibly supportive. More importantly, I've built some seriously effective web applications using it. If you want me to bother learning Python, loose the 'tude, dude.

Seriously, every language has its problems and it's quirks. PHP is far from perfect (e.g. no namespaces), but many of Python's language design features, such as the meaningful whitespace concept, I find unpleasant to work with. (A little too much like FORTRAN for my taste.) That doesn't mean that I don't think its a good language, or that Python programmers are bad people. (Just pooly socialized.) Obviously people have done a lot of great work in Python, and its a very useful tool. But its also a language that has a very different syntax from PHP, PERL, JavaScript, Java - languages that web people are familiar and comfortable with. If you want to get us to part with our semicolons, curly braces, and crazy bohemian whitespace, you're going to have to be nicer to us, and more polite about the tools we love. "


"I'm a PHP/Java/Ruby/Python programmer. I tried once to talk (but it's amazing how some people does not know how to talk) with a influent Python local dude about this. I told him that mod_python will spread more easily if it could show all it's power running on Apache 1.x, since there's is a LOT of websites still running Apache 1.x.

That was worst than insult his mother. He became mad, angry, asked me if we need to use old tools, that is a stupid idea blah blah blah.

He did not see the point there. I was thinking in a way that could help to, for example, THOUSANDS of PHP coders try mod_python (easy), without upgrade their webservers (harder) while PHP still marked Apache 2.x as experimental. But he was not able to talk about that. I told his so beloved tool could not work perfectly (and I was able to help if there was a way, on that moment) on a older enviroment, and he became mad, offended. Stupid. Idiot.

While this kind of behaviour still exists on the Python community (and believe me, there is a lot of situations like this), the tool will not even go closer where PHP is. While PHP is not a half of the language Python is (and I think Python is very better than PHP), some Python dudes are really hard to deal."

" You've clearly articulated a deep frustration that I have felt for several years now. I would love to do web programming in Python but I know that pragmatically PHP is a better choice despite its inadequacies as a language. Finding affordable Python hosting is not easy ; choosing a framework is not easy. Even when frameworks are well documented - like modpython - I would like more than just the bare documentation i.e. books.

For commodity hosting to emerge and books to be written the community has to agree on one framework, develop it further and make it easy for new programmers to get started. I worry that by failing to recognise the importance of the web and adding further complexities to the language Python will actually begin to lose users.