views:

1249

answers:

13

I'm a .Net developer but I have a situation where I can't guarantee that the .Net Framework will be installed on the target machine.

I've seen a few questions (here and here) that suggest using NGen to compile to native code. Both point out that you still need the framework though.

I want to write a fairly lightweight app (basic GUI, no database, nothing complicated) but for various reasons, I don't want to have to install any frameworks or bytecode interpreters.

This question suggests Python and py2exe. I'm not familiar with Python, but if it's the best tool for the job, I can probably learn enough to write this app (I'd prefer not to though). I've also thought about writing it in DHTML and javascript - I can rely on the machine having a relatively new browser.

I'm familiar with the C family of languages and I've dabbled in Java, PHP, and Ruby.

Can anyone suggest a language that I can easily compile to native Win32 code?

Edit: Clarification

There have been a few answers suggesting that if I'm familiar with the C family of languages, why not just use C? I should probably clarify. I use C# every day and I was brought up on C+ and C++ (but haven't used either for quite a few years).

It does look like C/C++ might be the way to go, but I'll have to refresh my memory on them :)

+12  A: 

if it's lightweight and nothing complicated, and you are familiar with the C family of languages.. then why not C and the Win32 Api? It's harder than writing .net or java programs, sure but it's definitely going to compile to native windows code, and doesn't need bytecode or an interpreter.

Also, you might be able to use Mono to statically link a C# application with the Mono runtime. http://www.mono-project.com/Guide:Running_Mono_Applications

I see you need to brush up on C..here's another idea, then : Delphi.

There are some more answers in this thread

Jean Azzopardi
+1 for mono
Joel Coehoorn
Clarified RE my knowledge of C. I guess I really want something a bit quicker to write in.
Damovisa
+1  A: 

NGen is designed to optimise .NET code by compiling to native code. You still require the .NET framework. Also, NGen runs in the installer on the client machine - you can't distribute native code.

Create the .NET installer project, which will check for the framework, and install it automatically.

Kazar
A: 

Either C++ or VB6 will work for you. Take a look at VB6. It's pretty easy to learn and is very easy to do GUIs with.

JP Alioto
I've actually had a long history with VB6 as well which I should have mentioned... That's not a bad suggestion.
Damovisa
VB6 no longer has support, so its probably not worth even learning anymore unless you work on legacy systems.
Steve
@Steve: I'm not suggesting VB6 in a vacuum. I think based on the question, it's a reasonable response. What is the relevance of "support" in this case?
JP Alioto
Actually in this case it's a useful suggestion - it's more or less a throwaway app. I do take your point on support though Steve. For a long-term application, it would probably not be the best choice.
Damovisa
A: 

I loved C++Builder. The .NET Framework was designed by some of the same people who did Borland's Visual Component Library, so if you go that route, it'll seem very familiar to you.

overslacked
+3  A: 

The Windows API itself is in C.

If C is not lightweight enough, you could consider C++/MFC which is good for making simple GUI programs with minimal coding on your part.

Shmoopty
+3  A: 

I would try C++ with Qt... I think it is a very important framework to learn, considering it just turned LGPL.

kotlinski
I actually ended up trying this last night (Australian time) - not too bad :)
Damovisa
+1  A: 

Without knowing what specific genre of application you're going to be writing, it's a little hard to say definitively...but MFC (if you know it) or plain C/C++ and the Win32 API would be a reasonable choice, based on the info you've given.

Certainly, MFC is a bit dated..but zillions of apps shipped with it and, its warts aside, it does "work" for many purposes. If you can get ahold of a copy of Visual C++ 6.x there are plenty of wizards/etc which will help you get an app out quickly. That said, I definitely wouldn't suggest learning MFC just for this purpose.

DarkSquid
+4  A: 

If you are willing to consider a bytecode interpreter that can be entirely contained within your installation (which the python solution you mention would be doing), then you might consider using Lua and something like srlua to bundle your script along with the interpreter into a single .EXE. To get a quick GUI going with Lua, IUP is a good choice, but there are bindings for other GUI frameworks out there too.

If the issue is more one of a clean installation without a lot of system dependencies rather than attempting to get a single EXE with no DLLs, then consider using Lua without the bother of srlua to package it. It doesn't need to be installed in any magical way, and can live in a single folder along with your script and any required modules in either DLL or script form.

It is easy to bind C callable functions to the Lua core because the authors designed it from the beginning to be embedded in a larger application. It only requires a few lines of boilerplate to create a Lua-callable module written in C that is distributed in a DLL, for example.

An easy way to get started with Lua along with a full kit of useful modules is the Lua for Windows project which maintains a "batteries included" installation kit for Lua.

RBerteig
+2  A: 

for me its powerbasic (www.powerbasic.com). it compiles native exe's (real ones, not byte code with the compile embedded). the syntax is like old pds or quick basic (but much further advanced). it allows in-line assembler, object oriented classes (optional, you can also just do procedural code). if you have a background in c, then stick with it. if you like basicy languages, then pb is a no-brainer. its like c with strings. other than that, if you like pascal, delphi's compiler can produce native exes.

-don

Don Dickinson
My god, powerbasic is still around? I bought a copy in 1996, but I assumed Visual Basic would be a stake through its heart.
MusiGenesis
in 1996 powerbasic didn't even have their 32 bit compiler out. they were still 16 bit (for windows) and had a dos compiler. they've come a long way, have a strong following. their forums are among the best i've encountered. it is far from dead.
Don Dickinson
To me the combo of FireFly and PowerBasic is unbeatable for getting small fast fully featured apps with the only run time requirement being windows.
bruceatk
firefly 3 is on the way:) http://www.planetsquires.com ... paul squires is doing a fantastic job
Don Dickinson
A: 

Another option is to stick w/ .Net and use a .Net linker such as Salamander .NET Linker or Thinstall - this way you don't need to worry about what's on the client machine.

Scott Weinstein
+3  A: 

Pascal/Delphi maybe?

Actually, if you want compatibility there is nothing better than a Win32 app without using MFC. Not sure if STL is not sitting in some extra DLL installed by VS.

On the other hand, I remember seeing messages like VC++ redistributables missing on installation, not sure if it referred to MFC or even core libraries. Better not use MFC at all.

You could use WTL for GUI, it will compile to your executable.

User
+1  A: 

Along the lines of C/C++ you might take a look at the D programming language. It's got most of the advantage of D including native binaries by default but is a lot closer to C# or Java in the features department. Unfortunately, in the tools and, to a lesser extent, libs domain it's sadly lacking (although that is changing fairly quickly).

BCS
A: 

Could u tell me what is light weight programming.......Dont tell me scripting lang's are lightweight programming lang..I want exact definition of lightweight programming lang..and tell me Why scripting lang are called lightweight programming lang..

I'm really talking about something that's very easy to pick up and write something with, and that doesn't leave much of a footprint on the user's machine. Native C programs (for example) will generally compile to a single, very small executable that will just run on a Windows machine. Fast, small, and you don't have to worry about installing supporting software.
Damovisa