开发者

Scripting Languages vs. Compiled Languages for web development

开发者 https://www.devze.com 2023-01-01 21:45 出处:网络
Though I come from a purely PHP background on the web development side of programming, I have also spent much time with C# and C++ on the desktop.

Though I come from a purely PHP background on the web development side of programming, I have also spent much time with C# and C++ on the desktop.

I don't rea开发者_JAVA技巧lly want to spark any flame wars, but:

When should you use scripting languages over compiled languages for website development?

(and vice versa)

Just to clarify, for the sake of this question, I define a "scripting language" to mean an interpreted language like PHP, Python, or Ruby, and a "compiled language" to mean a strongly typed, compiled language like C#, C++, Java, or VB.


It depends :-)

On...

  • ...where and how you want to deploy the application
  • ...the skillsets of the engineers in your organization
  • ...what third-party components you want to integrate with or incorporate

Deployment

If you need to be able to deploy the solution on any of dozens of different possible platforms, you may find that you're better off with PHP than Java (for example). There are hundreds of thousands of Java hosting providers out there, but there are probably millions of PHP hosting providers. (And I say this as a Java-head who finds PHP "so so" at best.)

This goes to OS as well. Mono aside, .Net stuff is going to limit you to Windows-based deployment (or lagging behind the cutting edge and having to very, very rigorously test each and every 3rd party component you bring in, to ensure that it doesn't have Mono...issues).

Skillsets

Coming up to speed in an environment or language is non-trivial. For most of us, picking up the basics is pretty quick, but you may not be making the best architectural/design decisions because you're (comparatively) weak on the environment/language. Skillsets count.

Related to this: Skillset hiring counts. Is it easier (and/or cheaper) to hire PHP devs with 3-4 years of experience, or Java devs with 3-4 years of experience, or C# devs, or...?

Buying/finding/integrating vs. building

In your target area of development, which server-side components or packages will you want to integrate with? PHP has a vast array of things available for it, as does Java, as does C# or ASP.Net. But they're different things (by and large), so you'll want to look at what you actually want to use.

Conclusion

So I think it's less a matter of compiled vs. scripted (in today's world), and more a matter of what's the best fit by other criteria for what you're trying to do.

Addendum: Both/And

And of course, there's always "both/and". For instance, I do work in two main, unrelated environments right now, both using a combination of scripted and compiled resources. (One of them is Java + JavaScript via Rhino on Tomcat, the other is compiled COM objects + JScript [again, server-side] on IIS.)


A programmer can write good/bad fast/slow scalable/unscable code in any language. Although, some language and technologies make it harder to do. In my experience, with scripting languages you can produce a small to medium scale application faster than you can with compiled languages like Java. However, as applications grow in size, compiled languages become more suited to the task I think this comes from strongly typing objects, deeper layers of architecture to manage tasks, and more QA frameworks to verify things are running as they should be as changes occur.


I find it to be mostly a matter of opinion. At first I hated the pre-compiled web applications asp.net provides, but I've gotten used to it so I don't hate it anymore. It has advantages and disantages:

Pro

  • pre-compiled web applications are easy to deploy, often you'll only have to update the bin-directory
  • pre-compiled web applications perform well
  • you don't have to upload source code, which is nice imho.

Con

  • updating a pre-compiled web app generally means the web application is reset, so unless you've changed the session state, it'll end all sessions and log everyone out
  • rebuilding a large web application can take some time, which is added to the time it took you to write the changes in the first place. I am sometimes impatient.

I've always liked how easy it is to just update one file in a PHP project without having to rebuild a project or something like that, on the other hand, .net has a nice IDE that allows you to debug everying, from back end (C#, VB.net) to front end (Javascript), in one package. But again; both have advantages and disadvantages.


I wouldn't draw such a sharp distinction between compiled and interpreted languages - this is really just an implementation detail, and tends to change with time (faster than the languages themselves change.) Case in point - thanks to Facebook, PHP is now a "compiled language" too. Another case in point - I enjoy web development with Scheme - and my preferred Scheme implementation now runs a VM and in that sense is at least as compiled as Java is.

So I think the issues to focus on are the expressiveness of the language, its performance, and its ease of deployment - compiled vs. interpreted is only important insofar as it relates to these things.


I'm a big fan of compiled languages everywhere, if for nothing more than the static typing. On the other hand, scripting languages are very convenient -- no binaries to deal with, only text files, which is a big win for web servers.

In the end, it doesn't really matter -- use whatever language you know and feel most comfortable with for the job.


I think that speed is a key concern in a web application, in particular

  • how fast is it to write my code
  • how fast is it to fix my code
  • how fast is it to refactor my code
  • how fast is it to test my code

That is, I am concerned about the speed of the slowest link: myself. Anything else is fast enough for Twitter-like loads.

Today, the number one on my evaluation list for a new project would be Tornado and Python.

If I had a choice of platforms, of course.

Ah, Python is among the fastest in scripting languages.


For scripting languages, anyone that has a copy of your software could potentially modify your source code because it's open source.

For programming languages, anyone that has a copy the software cannot simply modify your source code because it is compiled.

So I guess, it depends upon your preferences.

0

精彩评论

暂无评论...
验证码 换一张
取 消