What are the usable compiled server side languages as of today? - asp.net

I've heard of ASP.NET compiled DLLs which only works on Windows Server, but I would like to know if there are any other compiled server side languages?, maybe even ones for Apache server?
Installation of the runtime shouldn't be a problem because I will have physical access to the Unix/Windows servers, but if it is a CGI plugin its an added benefit since I can install it using only FTP.

Java would be at the head of the list of compiled languages for use with Apache - especially when you get away from Windows.
Also, you can use ASP.NET on non-Windows platforms with Mono.

You can run ASP.NET using Mono and it's mod_mono for Apache

JSP with Tomcat

PHP is compiled at runtime similar to ASP.NET. Or if you want to take the extra step you can use a PHP compiler to pre-compile your PHP (also a capability of ASP.NET).
PHP is not as pleasant to work with as ASP.NET in my opinion, but if I were restricted to Linux it would probably be my choice for its speed, overall popularity and support.

The term "compiled language" doesn't make any sense. A language isn't compiled. A language isn't interpreted. A language just is.
Whether a particular implementation uses a compiler or an interpreter is a trait of the implementation and has nothing to do with the language. Indeed, every language can be implemented with either an interpreter or a compiler. In fact, the vast majority of modern language implementations (CPython, Perl, PHP, YARV, IronRuby, HotSpot, Mono, CLR, TraceMonkey and so on) use both an interpreter and a compiler. HotSpot for example constantly switches between compiler and interpreter depending on which is faster.
So, to answer your question: every language that can access environment variables, read text from stdin and write text to stdout can be used with CGI and thus Apache (and indeed pretty much every webserver on the planet). And every language can be compiled. Therefore, every language can be used in the way you describe.

Related

Google Native Client - How to protect the source code?

With Google Native Client, can the source code be protected so that, unlike JavaScript, it is not visible in the client?
If so, how? Thanks!
As the name says, Google Native Client uses native code.
That means, your code is compiled, just like with your average executable binary on the desktop. It can be disassembled, but the source code can't be recovered.
Native client means that you are running native code on the client. In most cases, you'll be running i386 or amd64 machine language on your client. If you're using a compiled language, then your users cannot directly recover it. Users could disassemble your software to recover some information about your code, but they cannot recover the original source code (unless it is assembly language). Rewriting a piece of software from the disassembled binary is difficult, but given enough time, it can usually be done. It really depends on how paranoid you are about the people using your code.
Native Client's structural requirements to enable reliable disassembly so that it can perform static analysis can make some techniques for code obfuscation unusable. These are often the same techniques used by malware to make malware analysis difficult, i.e., have two valid interpretations of the instruction stream if decoded by different offsets. Native Client does, however, permit a form of self-modifying code since it has JIT support. Mono uses just-in-time code generation, for example, and the same interfaces can be used to create obfuscated code, as long as the JIT'ted code continue to conform to the NaCl security requirements.
Using the JIT interface would of course make your code non-portable to other CPU architectures.

Can C/C++ software be compiled into bytecode for later execution? (Architecture independent unix software.)

I would want to compile existing software into presentation that can later be run on different architectures (and OS).
For that I need a (byte)code that can be easily run/emulated on another arch/OS (LLVM IR? Some RISC assemby?)
Some random ideas:
Compiling into JVM bytecode and running with java. Too restricting? C-compilers available?
MS CIL. C-Compilers available?
LLVM? Can Intermediate representation be run later?
Compiling into RISC arch such as MMIX. What about system calls?
Then there is the system call mapping thing, but e.g. BSD have system call translation layers.
Are there any already working systems that compile C/C++ into something that can later be run with an interpreter on another architecture?
Edit
Could I compile existing unix software into not-so-lowlevel binary, which could be "emulated" more easily than running full x86 emulator? Something more like JVM than XEN HVM.
There are several C to JVM compilers listed on Wikipedia's JVM page. I've never tried any of them, but they sound like an interesting exercise to build.
Because of its close association with the Java language, the JVM performs the strict runtime checks mandated by the Java specification. That requires C to bytecode compilers to provide their own "lax machine abstraction", for instance producing compiled code that uses a Java array to represent main memory (so pointers can be compiled to integers), and linking the C library to a centralized Java class that emulates system calls. Most or all of the compilers listed below use a similar approach.
C compiled to LLVM bit code is not platform independent. Have a look at Google portable native client, they are trying to address that.
Adobe has alchemy which will let you compile C to flash.
There are C to Java or even JavaScript compilers. However, due to differences in memory management, they aren't very usable.
Web Assembly is trying to address that now by creating a standard bytecode format for the web, but unlike the JVM bytecode, Web Assembly is more low level, working at the abstraction level of C/C++, and not Java, so it's more like what's typically called an "assembly language", which is what C/C++ code is normally compiled to.
LLVM is not a good solution for this problem. As beautiful as LLVM IR is, it is by no means machine independent, nor was it intended to be. It is very easy, and indeed necessary in some languages, to generate target dependent LLVM IR: sizeof(void*), for example, will be 4 or 8 or whatever when compiled into IR.
LLVM also does nothing to provide OS independence.
One interesting possibility might be QEMU. You could compile a program for a particular architecture and then use QEMU user space emulation to run it on different architectures. Unfortunately, this might solve the target machine problem, but doesn't solve the OS problem: QEMU Linux user mode emulation only works on Linux systems.
JVM is probably your best bet for both target and OS independence if you want to distribute binaries.
As Ankur mentions, C++/CLI may be a solution. You can use Mono to run it on Linux, as long as it has no native bits. But unless you already have a code base you are trying to port at minimal cost, maybe using it would be counter productive. If it makes sense in your situation, you should go with Java or C#.
Most people who go with C++ do it for performance reasons, but unless you play with very low level stuff, you'll be done coding earlier in a higher level language. This in turn gives you the time to optimize so that by the time you would have been done in C++, you'll have an even faster version in whatever higher level language you choose to use.
The real problem is that C and C++ are not architecture independent languages. You can write things that are reasonably portable in them, but the compiler also hardcodes aspects of the machine via your code. Think about, for example, sizeof(long). Also, as Richard mentions, there's no OS independence. So unless the libraries you use happen to have the same conventions and exist on multiple platforms then it you wouldn't be able to run the application.
Your best bet would be to write your code in a more portable language, or provide binaries for the platforms you care about.

What are the equivalents of Microsoft ASP.NET and Visual Studio for Linux?

I just wonder what are the similar frameworks and tools for Linux web development.
And can I use Visual Studio to develop websites for Linux Apache? Thanks.
Mono (it supports ASP.NET) and MonoDevelop, I guess.
Web development on Linux isn't specifically tied to one programming language, framework or IDE. More commonly they are related in terms of being Free and Open Source (free as in cost, and also the ability to do what you want with the code).
I loved Visual Studio when we used it for classes, however I haven't quite found a tool that is the same. The only thing near to this would be Eclipse or Netbeans.
In general, many Linux enthusiasts use emacs or vi (or vim) for their editing. At first glance you may not see the power they have, but emacs is definitely a wonderful editor, and vi is very good once you become familiar with it.
For Web programming langauges and frameworks, you have a variety to pick from.
Python is one of the most popular languages to use for Web development. This language has been used by Google, Reddit, Quora and a host of others. Perhaps the most popular framework for Python is Django, and each (Python and Django) have their own following, as well.
Ruby is a wonderfully beautiful langauge, too. Most likely you may have heard of Ruby on Rails, which is a great Web framework allowing you to quickly turn an idea into something actual in no time.
PHP is another popular language, and has the PEAR framework. Many of the online forums that you can buy are written in this language, such as vBulletin and the ever famous phpbb.
In my opinion, it depends on what you want to accomplish. Python and Ruby are great for Web development, as well as non-Web, too.
Ad 1) There are several IDEs. I prefer eclipse, no matter if for html, php, python, c or java.
Ad 2) Yes you can. Create your websites, copy them to your /var/www (or wherever your ww-root) is and you are set.
EDIT: < personal opinion > By the way, I mean there is no thing like "windows web development" and "linux web development". In the end it is of no importance at all on which OS you developped your web application, on which OS the web server runs, which OS the client has or which server- and client-side languages you used (as long as you don't use something certain clients can't provide). You have a web server that communicates via HTTP, HTTPS (or whatever) with clients. This server passes certain data via CGI, lib-apache2-mod-XYZ, WSGI, the interface IIS uses for ASP (or whatever) to executable scripts. These yield a result that the web server then publishes via (fill in arbitrary OSI layer 7 protocol) to the client, no matter what the content: HTML, CSS, images, JSON, you name it. Your operating systems has nothing to do with this.
Not all interfaces are available on all hosting server OS, but you always have a bunch to choose from and what counts is the result in the end. Quidquid agis, prudenter agas et respice finem. < /personal opinion >
There are a ton. You can use mono for ASP.NET that runs on Apache. There are even other languages. PHP, JSP, Djanjo, Ruby on Rails, Node... just to name a few languages/frameworks. There isn't a build of Visual Studio for Linux and you would be hard pressed to set it up to compile Linux assemblies on Windows.

ActiveX on Linux using Mono?

Is there any way for ActiveX controls to work on Linux? I'd imagine the answer is no, but just want to be sure.
My company is considering a Linux port of a ASP.NET project (using Mono), but it uses ActiveX controls quite heavily, so we wonder if it's even feasible.
Sorry if the question is dumb!
Even if ActiveX were supported on Linux, you still should not use it, since it is rather alien (as in 'hard to maintain') on that environment.
My advice is to rewrite the entire project with AJAX or flash in such a manner that it will run in any browser on most any platform.
Mono is not ActiveX! Even if you could rewrite using client side mono for activeX, your code would only run if the client machine has a mono installation.
If you're forced to use some third-party ActiveX controls, you can't use them directly on Linux - they expect a certain runtime enviroment thats not trivial to provide (it could be done, but its not viable).
The best thing you can do is to write a small host-program, running in WINE, that loads the controls and provides an alternative interface to them via a IPC mechanism.
As a variation on gf's answer, you could run Mono within Wine on Linux. Mono has some COM Interop support, and Wine supports COM, so in theory this will work.
Whether you want to run Mono atop Wine atop Linux is another matter, as it increases the number of things that can break.

OS-independent API to monitor file system?

I would like to experiment with ideas about distributed file synchronization/replication. To make it efficient when the user is working, I would like to implement some kind of daemon to monitor changes in some directory (e.g. /home/user/dirToBeMonitored or c:\docs and setts\user\dirToBeMonitored). So, I could be able to know which filename was added/changed/deleted at every time (or within a reasonable interval).
Is this possible with any high-medium level language?. Do you know some API (and in which language?) to do this?
Thanks.
The APIs are totally different for Windows, Linux, Mac OS X, and any other Unix you can name, it seems. I don't know of any cross-platform library that handles this in a consistent way.
A bonified answer, albeit one that requires a largish library dependency (well-worth it IMO)!
QT provides the QFileSystemwatcher class, which uses the native mechanism of the underlying platform.
Even better, you can use the QT language bindings for Python or Ruby. Here is a simple PyQT4 application which uses QFileSystemWatcher.
Notes
A good reference on on creating deployable PyQT4 apps, especially on OSX but should work for Windows also.
Same solution previously posted here.
Other cross-platform toolkits may also do the trick (for example Gnome's GIO has GFileMonitor, although it is UNIX only and doesn't support OSX's FSEvents mechanism afaik).
In Linux it is called inotify.
And on OS X it's called fsevents. It's an OS-level API, so it's easiest to access from C or C++. It should be accessible from nearly any language, although bindings for your preferred language may not have been written yet.

Resources