There seems to be two major ways to set up a web server backend. You can use a LAMP stack, with the server-side code in something like PHP or Python (or Ruby or JavaScript, which don't start with a P.) These scripting languages tend to be dynamically typed, with all of the disadvantages in performance, correctness and maintainabilty that dynamically typed languages bring, but it's easy to update the server because all the page generation logic is stored in external scripts.

The other major architecture style in wide use is ASP.NET, where the page generation logic is written in compiled code. This tends to use statically typed languages, so you get code that's had the benefit of a compiler, but all of the page generation logic is compiled into the server, which means if you need to change something, you have to take the server down and replace it with a new build.

So that makes me wonder. Are there any server-side scripting languages that use static typing, for the best of both worlds?

  • 2
    Have you thought about using Go? – p.s.w.g Apr 14 '13 at 16:55
  • 10
    TypeScript? – Oded Apr 14 '13 at 17:27
  • 4
    "all of the disadvantages in performance, correctness and maintainabilty that dynamically typed languages bring". These assertions are debatable at best, and wrong at worst (the fastest JITs nowadays are for dynamically typed languages). – Javier Apr 14 '13 at 17:33
  • 2
    "page generation logic is compiled into the server, which means if you need to change something, you have to take the server down and replace it with a new build." There are several server environments that can handover to a new binary without service interruption. ie. uWSGI graceful reload – Javier Apr 14 '13 at 17:35
  • 1
    For the JVM there's a couple of frameworks that allows you to recompile and hot swap on the fly. – back2dos Apr 14 '13 at 19:04

UPDATE: More current solutions include AtScript

You should try Google Dart.

It has optional typing, which means that you can add type annotations that will be checked in 'checked' aka developer mode at runtime, but they are not required and the language provides many of the advantages of other dynamic languages like python. However, the editor will do type inference to try to help you find errors ahead of time. The dart VM is fast and can produce snapshots, which can accelerate startup time up to 10x. It also compiles down to javascript and it's fast.

The main downside here is that is a somewhat new technology, so there aren't as many libraries for it, and honestly, interoperability with javascript is not as simple as it should be. Also, the language is still in development, so there are breaking changes from time to time.

| improve this answer | |
  • I would rather recommend TypeScript. Like dart, but it is compatible with JavaScript. – Knerd Nov 14 '14 at 9:34

Your question is based on several incorrect assumptions.

Python, Ruby are both compiled to bytecode before execution. The process is automatic, but application changes require a full restart. Node.JS behaves the same way but compiles to machine code.

ASP.NET code can be precompiled and copied to the server or dynamically compiled on demand from source code on the server. IIS handles both forms of updates without zero down time (the first requests after the update will be slow.) Zero downtime updates are possible with Python and Ruby, but with so many deployment options, are not something to be taken for granted.

Based on that, I would think that you would be happy with any .NET language.

| improve this answer | |
  • 3
    A scripting language is when you can write some bits of it in a file and run it. There's no reason it shouldn't be statically typed. – Florian Margaine Apr 14 '13 at 18:34
  • @FlorianMargaine So C is a scripting language? – user7043 Apr 14 '13 at 19:30
  • @delnan c++ too. – mikerobi Apr 14 '13 at 19:35
  • @mikerobi Actually "mine" is C++ too (and AFAIK the successor of CINT), I just screwed up that bit. – user7043 Apr 14 '13 at 19:39
  • 2
    @mikerobi If you explore picoc, you'll notice the whole point it was written in the first place is to be a scripting language. It's not just an interpreter for c, it's an interpreter small enough to be embedded in larger applications and devices and give their users the ability to write small scripts in c. Some languages are may be better at scripting than others, but a language isn't bad at scripting just because it hasn't been used for it (yet). At the end of the day, a language is just syntax and semantics, implementations may vary wildly. – yannis Apr 15 '13 at 3:14

IMHO, the best statically-typed Web scripting language is D.

Like interpreted scripting languages, it can compile scripts on the fly and at lightning speeds.

The language itself feels like a strongly-typed super-powered JavaScript, much more powerful than Go for instance.

All the concurrency stuff is hidden, like in PHP, and the templates are compiled in native code.

Hard to find better than that...

| improve this answer | |

There is no reason that a compiled language has to be strongly typed or hard to update.

You may want to look at some of the erlang web setups like Cowboy, Webmachine and nitrogen. With Dialyzer you can get some very nice type checking for correctness and you can reload modules on the fly at run time as erlang was designed to be able to upgrade software in place without interrupting existing users.

In addition webmachine (the one I have used most) can be quite fast. I have seen webmachine have average responses on API endpoints of less than 10ms on an amazon EC2 small node!

If you want static typing try the Yesod framework which is for the Haskell language. Haskell is strongly typed with a very rich type system.

I have not used it personally, but the folks I know who use it love it.

| improve this answer | |
  • 3
    Don't confuse strong and static typing. Haskell has strong static types, Python has strong dynamic types. – mikerobi Apr 16 '13 at 14:50

Not the answer you're looking for? Browse other questions tagged or ask your own question.