Portability of windows apps compiled with jsc - compilation

I recently discovered you can compile JScript into console apps using a built in tool in the .NET framework called jsc. It is already installed on my computer, and other windows computers which have .NET.
I want to know if the final compiled exe is dependent on .NET. Also, is it completely portable. Can I build an app on my machine, and then distribute it, and expect it to work on everyone else's machine?
What technical details would I need to put in the release notes? Maybe that it depends on .NET etc...

OK I'll put it into an answer format then :)
Concerning the JScript compiler (jsc):
The compiled exe will be dependent on .NET being installed on the target machine, just as any other .NET executable concerning versions, etc.
JScript.NET is a separate product from JScript (Microsoft's implementation of ECMAScript), so not everything will work in jsc that might work in the browser or in Windows Scripting Host.
I've read that JScript.NET was more-or-less abandoned by MS
Dynamic Language Runtime Discussion on JScript.NET
JScript.NET abandoned mentioned in IronJS article
SO question concerning JScript.NET
ie:
it doesn't know anything about generics, and won't let you reference generic types, or call generic methods. In terms of implementation, it uses reflection heavily with no additional optimizing layers (like DLR), and so is rather slower than e.g. IronPython.
You can also make console applications from other languages.

Related

Programming language without additional requirements

Soon I will be coding the file patcher for my application (check if the files are up-to-date and download newest if not) so its not much to code.
The problem is that I don't want the application users to be forced to use additional libraries like .NET (even though I like to code in vb.net or C#). I keep in mind that the .NET framework is installing together with the Windows but still there are plenty people who somehow doesn't have this framework installed, and thats why I'm looking for the programming language that wont require an additional libraries to run the application.
I haven't got much knowledge about programming in C++/Java but I have some experience with the AutoIT, vb.net, C#.
So the question is, what programming language will be the best for this purpose?
This answer is for "what language is available on any version of Windows without additional requirements". There are many other options for "what I can use to create application that can be xcopy deployed on any version of Windows".
JavaScript is probably your best bet - it is supported on most recent versions of Windows (according to Wikipedia article - Windows Script Host JavaScript available for scripting starting with Windows 98). Allows basic operation with files and HTTP communication - maybe enough for simple patching application.
Next would be native Win32 application, but lack of C++ experience will make it hard.
Freepascal, D and Go — to name a few — are much easier to program than C++ and could be told to produce statically-compiled binaries (not dependent on anything but certain system DLLs).
I, personally, would use the latter as it has all the necessary tools (including HTTP and binary I/O) in its standard library and is super-easy to get started with.

MS Windows Programming advice for Mac/Unix developer

I have a few years of experience writing Unix command line tools (no GUI experience) in python, C and C++, and only recently crossed into the GUI world (Cocoa and IOS only). I've learned quite a bit of objective-C and am getting to understand how cocoa MVC works. However, one of the apps I am developing needs a Windows version and I was wondering what a good place to start would be given that I have absolutely no Windows development experience.
I was thinking about using Visual C++ 2010 Express as my development platform (because it's free and because I don't need to learn C++). My application is relatively simple, it will have only two windows and spend most of the time running in the background. It will however need to communicate with the OS (load dll's etc) and an online server (HTTP methods) and I'm not sure whether Visual C++ Express edition gives me access to the required API's. Would a Windows Forms application suffice? Am I going about this the wrong way? Do I need to learn C#? Any advice will be appreciated.
If you are already happy with proper c++, visual Studio C++ express should suit you fine. Given that you are not making a complicated GUI, you don't even need to dip into the managed code - C++ express allows you to create proper c++ console and GUI apps. You also don't need to install the platform SDK - it is part of VS C++ express.
Not being managed C++, you will be able to share source files between your various projects. managed c++, despite the c++ in the name, really is a different enough language that it will be annoying to work with if you simultaneously have to deal with iso C++.
--
Note: The native windows API is a C api, not a C++ framework. So it does not provide a rich set of classes in a coherent framework to deal with. On the other hand, while, large, it is actually quite simple to work with.
Also: Given that you are already familiar with Mac development, there is a LGPL (iirc) package called CFLite that builds on windows and that implements the C api that underlays the Objective-C Cocoa API.
If you use its abstratcions you can share a greater part of code between windows and Mac (and other platforms).
Other C++ IDE's you might want to consider:
Code::Blocks
QT Creator
both of which can be configured to use the MINGW port of GCC to windows.
you'll be better off with c++ than c# if you need more "low-level" stuff. Loading dlls (that is, libs) is simple (pragma comment lib...), as is pure HTTP transfer and communication.
So, VC++ with windows form will suffice, and it is "very c++".
You have access to all global APIs, and loading specific apis like http requires only two lines: one to include wininet header, and other lib (libs are actually "references" to dlls).
If you go the C++ Express way then you need to install Windows SDK separately, and set it up for Visual Studio to use it. And you can't use MFC.
I would however, suggest C#, because it feels like putting little toy bricks together. Easier to debug and maintain. Problem with C# is that it has so many library functions that you can not possibly know if what you want is already made to a function. But that's why we are here :-) If you feel that something you want to do should already exist then ask a question about it. One notable feature that C# lacks is zip archives (it has something similar, but not quite). For zips you can use public libraries, like SharpZipLib or DotNetZip.
If I were you, I wouldn't jump into a whole new API so quickly. Have you considered using Python on Windows? Most of the Python packages I've seen are also available for Windows, so you'll feel at home. And if you need some GUI, you can opt for wxPython, pyGTK or something similar.
For Windows specific things, you can always use ctypes. Especially if they're as simple as loading a DLL.
have you considered approaching Adobe AIR? it allows you to deploy on Mac, Linux, Windows, iOS, etc. communicating with and launching native processes has been possible since 2.0 and the the latest 2.5 SDK can target Android OS and TVs. with your experience you should be able to pick up ActionScript3 / MXML in no time.
additionally, there are a handful of free IDEs you can use with the Flex and AIR SDKs. or, if you're a student or low-income developer, you can get a free copy of Flash Builder 4 from Adobe: http://www.adobe.com/devnet-archive/flex/free/
edit: i believe deploying AIR applications on iPhone requires Flash Professional CS5, which includes the packager for iPhone options. at the same time, i've read that AIR and other cross-compilers for iOS are painfully slow, so it's perhaps best to develop natively in Objective-C for iOS.

Which programming languages that can generate self contained windows .exes?

I want to make an easy to deploy Windows application and was was wondering which programming systems can create totally self contained Windows .exe files?
As a plus, if the same can be done with MacOSX and Linux from the same source this would be a bonus. I took a look at Realbasic but they have since abandoned the single .exe concept.
update: i am looking for something that can run from Windows XP up to Windows 7, no matter what version of .NET is installed. Is this even possible?
Delphi compiles to one executable, and generates native windows executables. So no dependencies to any kind of framework. If you use Free Pascal (fpc) and the Lazarus IDE, you could even develop for Linux and Apple from the same source.
If your using external dll's this would become a bit more tricky, but you could pack them up in your resource file and still maintain the one exe property.
Update 2020: since #Vassilis & #Marco van der Voort commented on this, I would like to update my old andswer and add that go is a very good way to make self-contained executables. Even crossplatform compilation is realy simple.
You can certainly do this with C/C++. Technically the runtime libraries are required, but they should already be installed on any windows, mac or linux system.
With .NET you can compile to an EXE, but of course the .NET framework is required. For newer versions of windows it should be installed by default, but on older versions (XP or older?) it may or may not be there. And of course you couldn't expect mono to be there by default on linux or mac either.
For Windows the following languages are viable:
C (MS, gcc)
C++ (MS, g++, Digital Mars)
D (Digital Mars)
Delphi (Embarcadero??? how do you spell that? just trips off the tongue doesn't it?)
Fortran (Intel, Salford Software)
Visual Basic 6 (MS)
Lua (you'll need a special tool to do it, but it is doable)
C#, VB.Net, F#, J#, etc (assuming that you don't mind using .Net technology)
You can use Tcl/tk. The technology you should research is a "starpack", which combines a runtime executable (a starkit) with a platform-specific runtime (a "tclkit") to create a single-file executable. It's remarkable in the fact that it's not just compiled code, but an entire self-contained virtual filesystem that can include images, sound, data, etc.
This same technology works for many platforms from the same code base. The only thing that is different is the platform-specific runtime. You can even "cross compile" in that you can copy the runtime for multiple platforms onto your dev box and then build starpacks for each platform without having to actually be on each platform.
Tcl can do this, especially through producing starpacks. They can be produced for all platforms from the same code. Note that this also includes all the necessary runtime libraries (except for things like the C library, but you don't want to make that static under normal circumstances).
JavaFX 2.2 supports that. It allows creation of self-contained applications targeting Windows, Mac OS, and Linux.
Please follow this link for more information: http://docs.oracle.com/javafx/2/deployment/self-contained-packaging.htm.
I would recommend taking a look at AutoIt. It is an easy-to-use scripting language that will compile into an exe, so there are no runtimes needed. This would be for windows only though.
http://www.autoitscript.com/autoit3/index.shtml
From the website:
AutoIt v3 is a freeware BASIC-like
scripting language designed for
automating the Windows GUI and general
scripting. ... AutoIt is also very small,
self-contained and will run on all
versions of Windows out-of-the-box
with no annoying "runtimes" required!
c/c++
purebasic
delphi
vb6
i hope this help :)
Here's a good source for a number of basic-like programming languages that build small stand-alone EXEs. Some are cross-platform for Windows and Linux:
www.basic.mindteq.com
You can use Liberty Basic which is easy and cheap, you can easily make stand alone programs for windows but not possible to transfer to MacOS or Linux.
You can do this for Windows with .NET languages using ILMerge
ILMerge is a utility for merging multiple .NET assemblies into a single .NET assembly. It works on executables and DLLs alike and comes with several options for controlling the processing and format of the output. See the accompanying documentation for details.
However:
Currently, ILMerge works only on Windows-based platforms. It does not yet support Rotor or Mono.
QBasic can :-)
I wrote a few command line tools using it!

Adding support of Windows to POSIX project... How painful? Is it worth the effort?

I'm trying/thinking of making CppCMS - C++ Web Framework project little bit more cross platform.
Today I can easily support Linux, OpenSolaris, FreeBSD and even Cygwin. But when it comes to Native Windows it becomes really painful:
The overview of the situation:
I'm POSIX/Linux developer and I'm barely familiar with Native Windows development tools like Visual Studio and Win32 API. However I do some work for this platform so I understand the limitations and the fact that Windows is totally different world.
This is web project that uses APIs that popular in Unix world, like: CGI, FastCGI and SCGI that implemented in most UNIX web servers; but I understand that I would not be able to use it with IIS because it does not support FastCGI over TCP/IP (only Windows pipes).
So even when it would work it would probably run only with Windows port of Apache.
I relay heavily on POSIX API:
Pref-forking allows be keep high survivability in case of crashing (not supported under windows) so this feature would be missing.
I use some file-locking facilities (but I can probably give them up without forking)
I have intensive use of native pthreads, even I can replace them with Boost.Thread
I probably would never be able to support Visual Studio (maybe 2010 with C++0x support), because I relay on C++0x decltype/auto feature or typeof/__typeof__ extension that is supported by most compilers I worked with: gcc, intel, sun studio. (To be honest: I can work without them but it makes the life much easier to framework user.
I relay heavily on autotools and I can't replace them with CMake, bjam or friends, because when it comes to support of internationalization, cross copiling, package management, they just does not give me a solution.
There are many annoying points like missing gmtime_r, or localtime_r under windows and many others that just require from me to rewrite them or replace them with 3rd part libraries.
There are still many "UNIX like" libraries that ported to Win32 like: iconv, gcrypt and some others that are barely ported like libdbi that have many limitations on windows.
Bottom line:
There is lots of non-trivial work to do, and even when it would be complete, it would probably work only with MingW tools and not "native" tools that Windows programmers are
familiar with.
So, my questions are:
Does such MingW port worth an effort? Would this help to build bigger community?
Does anybody have experience on how painful porting big projects from POSIX environment to
Win32 API is?
Would it be useful for Windows developers at all?
Edit:
It is also important for me to understand, how many of windows developers prefer to use
Open source development tools, MingW over Microsoft development solutions like VS.
Edit #2: Clearification about "native" windows solusions and IIS.
In fact, running framework with IIS is really hard problem. I explain:
The project relates to standard web server API as FastCGI or SCGI that allows to accept many requests over sinlge socket. Thus, on application side, I accept new request proceed it and returns the answer. Sometimes several threads process several requests.
Thus, implementing one or two standard protocols I open communication with any existing server: Apache, lighttpd, nginx, cherokee... or any other servers; with small exception of IIS
IIS has implementation of FastCGI, but... It supports only 1 connection per local process only that controlled by web server...
So... there is absolutely no standard way to connect my application to IIS.
Please note, I implement standard Web server API, I do not implement Neither IIS proprietary ISAPI nor Apache proprietary API, even the second is more important as for targeting UNIX world.
So, just Windows IIS Web world is just not really ready for cooperation for such project, so if anybody would use it under Windows it would use it with more open web servers.
You should base your decision on user demand. Have users ever requested using the framework on Windows? If so, did they explain why they wanted to use Windows (e.g. what additional constraints they had, what webserver they wanted to use, etc.)?
Typically, Windows users do expect that things work the Windows way. That means Visual Studio support, IIS support, MSI installer, and so on. If something still feels like being Unix, I would rather use Unix proper, instead of fighting with a half-working port.
As a windows client app developer it sort of hurts me that the development environment division currently is essentially Win32 and everything else and that they are mostly incompatible. That's why I'm preparing to move to MinGW for my personal windows app projects and to try to make them cross-platform.
I would suggest gradually moving to more cross-platform libraries like, as you suggested, refactoring pthreads to boost::thread, or going from fork() to multi-process with IPC, probably also using boost's facilities. Date/time stuff can be dealt with Boost libs as well. As for database support, there are
Microsoft compiler support is not that important I think, as MinGW provides a decent build environment with all the IDEs that support it, Eclipse CDT and Dev-C++ being among the most popular. But if you are going to make your project msvc-compatible, make sure users will be able to use Express editions of Visual Studio 2010 (as soon as thay come out) - that way no one will have to fork out for a Visual Studio 2010 (upgrade) just to use your project and there will be no problem for you to require the latest in Microsoft technology.
Most likely you won't avoid some amount of ifdefs for a code base of your project's size, but surely the effort might be worth it, if not only for gaining valuable experience and expanding the community with a few new happy and grateful members.
Your saying that you can support Cygwin quite easily reminds me that I've seen commercial Windows software that simply bundled in cygwin1.dll to support some originally-Unix code. If adding cygwin1.dll to your installer is all it takes, try it out.
I think you only have to look at the questions asked on SO to work out that MinGW users on Windows (of which I am one) are in a minority in the development community - the vast majority of Windows developers are using MS tools. Anyway, the compiler is only half (or less) of the issue - if your architecture depends on forking lots of processes, using MinGW is not going to help you. My advice is, if you really want to do cross platform development:
look at how Apache do it
consider using the Apache libraries as your base
don't use very new or compiler-specific language features
use multi-threading rather than multi-process
Does such MingW port worth an effort? Would this help to build bigger community?
I am still working myself on this issue with my own large POSIX project and my conclusion is that if you need to later interface with Microsoft products, then its worth while, however then I would only use MingW if project is medium small, if it is very large, then I would go all the way with MSDN Microsoft development tools - Huge amount of help will be available there - however it will cost
Does anybody have experience on how painful porting big projects from POSIX environment to Win32 API is?
sofar my own conversion of my POSIX project have been constantly put on hold, because of the amount of time each issue takes to handle is enormous - not finished converting yet - If I ever will be
Would it be useful for Windows developers at all?
Sure working inside the Microsoft IDE using tools from MSDN will definately decrease development time, however it will increase your dependence on Microsoft libraries - something you need to decide from beginning if that is an issue
**
Actually you could just add the necessary cygwin dlls to your projects make and then you would beable to run it in windows
I managed to make my POSIX project run when I added following dlls
cygboost_filesystem.dll
cygboost_system-mt-1_53.dll
cygboost_thread.dll
cyggcc_s-1.dll
cygstdc++-6.dll
cygwin1.dll
Probably your project will have different dependencies, however if you think conversion is not worth it, then perhaps this is a solution for you
You could also add your libs as static, then you would end up with only having to provide the last cygwin1.dll

What languages require no external libraries/references/dependencies?

Have a quick project I need to put together for windows that can have no external references or dependencies; the stalwarts like C are obvious but if you are a .NET developer and need to build something like this very quick what language/tool would you use?
EDIT: Ultimately I want to be able to take JUST the exe produced by the compiler and put it alone on a windows machine and have the app run.
If you're a .net developer, you could consider something like using Remotesoft's Salamander or another similar tool that compiles everything into a single executable (including the framework).
This option lets you develop in .net, but not install the .net framework on your client's systems. If you're deploying on non-MS systems, you can use the Mono's deployment tools to accomplish the same thing for free.
In general, I'd say stick to the tools and languages you know. It's easier to build an installer to install the .net framework then it is to learn a new suite of tools, libraries, etc.
You can do it for practically any language (I'm excluding the obvious C/C++)
You can bundle the .NET runtime into your .exe and write the app in C#
You can write the app in Python and bundle everything into a single .exe using a tool like py2exe. I do this regularly. One can create great-looking and powerful applications with Python and PyQt, bundle everything into a single no-dependencies executable and deploy to users w/o a need to install anything else. The executable is a few MB large (~9 with PyQt), and loads and runs quickly.
Etc.
It's more important which language / environment do you currently know well. Focus on that, because the tools do exist for anything you'd want to use.
Delphi has always been the best product for producing stand-alone .EXEs for Windows. No Microsoft product has ever come near it in that regard.
I think a good allround answer to this is Free Pascal via the Lazarus IDE.
Free Pascal applications are native and dependency-free, and a lot of platforms are supported. Too many to list here! Free Pascal itself is a free and open source compiler.
For better convenience, I strongly recommend using the Lazarus IDE. Now you even get a RAD IDE for cross-platform GUI applications (as well as console), with a sizable set of builtin features, like database support. Really a pretty lovely all-in-one, often underestimated or even unknown, platform that produces self contained, native executables. There aren't all too many of those tools if you think about it. You can even cross-compile from it, for example to compile a GUI application for Linux on Windows, no virtual machines necessary.
One day, I wish .NET Native could get this far, but it is currently far from capable and I'm not sure if Microsoft even intends to go there. Google's Go language is also nice in that it compiles to native cross-platform code, but lacks a GUI library. Python can have its code packaged into executables but it's kind of a kludge and not native code. And so on...
C/C++ would be your language but don't use any fancy libraries like MFC, MSVCRT, etc. or if you do link them statically to your executable.
"No external references" is a bit vague. Are you talking about a deployment solution for an application?
For example, you can use Tcl which supports the ability to create a single file executable that contains both the application code and a virtual filesystem that can contain any other files needed by the application. If your goal is to create a single file that can be deployed without having to install extra files, read up about "starkits" and "starpacks".
If you target a Windows Vista .NET 3.0 is preinstalled,
If you target a Windows 7 .NET 3.5 is preinstalled, if you use no other libraries than the ones included in those distributions then you app will run. Installing .NET isn't really that much work anyway, just ship with the redistributable.
Assembler. Your only dependency is the CPU
Here's a left field answer...
Tcl
combined with starkits, you can create a simple double-clickable .exe with no need for an installer.
the downside, of course, is that it'll be written in tcl.
As an added bonus, you'll be able to port your app trivially to mac or linux (or a range of other odd operating systems)
Do you consider the .NET Framework "external"? If you stick to .NET Framework and use C#, your code should run anywhere the .NET Framework of appropriate version is installed, and you'll only need to deploy your .exe and .exe.config.
It is not possible to run a .NET program without the .NET Framework. If you can't require the .NET Framework to already be installed, then you cannot use a .NET program. That's what I meant.
I've no clue what the downvotes are about, but let me try once more to clarify. The original post said:
the stalwarts like C are obvious but
if you are a .NET developer and need
to build something like this very
quick what language/tool would you
use?
The answer is that if you are a .NET developer, there is no tool or language you can use for this purpose, as every .NET program requires the .NET Framework be installed. If you need a program that is entirely independant, then don't use .NET. As others have replied, you can bundle .NET into your exe. You can also have .NET installed with your application, if you're willing to ship a .MSI file and not just your exe.
But, by definition, a .NET program cannot be independent of the .NET Framework.

Resources