I want to write myself a simple program in Windows

It’s years since I’ve done any coding but I knew C and a bit of C++. I want to do a fairly simple program that will do a few calculations based on an input. What I don’t want is to have to download much more than a few meg’s worth of compiler/editor. But I do want the program working in XP (not via command prompt).
What are my options? Any suggestions?

Fire up Excel and look at VBA.

If you knew C and a bit of C++, you can try either using C# with Visual Studio Express, or going the pure C++ route with QT 4.5 (http:/www.qt.com).

You could write a web page with nothing but a text editor that does it. You need to look at HTML (for the front end) and javascript (for the calculation itself).

It’s as easy as opening up a text editor, typing out the html, saving it with as an .html file, and then opening it with your browser.

What Quartz said. Except, most of the time you don’t even need to bother with VBA. You designate input cells and output cells and create formulas that produce one from the other.

If the javascript math functions are enough for your purposes, I would use javascript.

[li]It’s free.[/li][li]Javascript is built into your web browser.[/li][li]There’s no compiler to download. [/li][li]You can build a user interface that works on PC and Apple Mac and mobile devices.[/li][li]javascript syntax looks like C/C++[/li][/ul]

I use Excel VBA every day but I recommend it as a last resort.

As mentioned upthread, Microsoft offers C# Visual Studio Express for free. However, it is more than a few megabytes, and is even longer if you need to download the Windows .NET Framework. That alone is several hundred megabytes (but you may already have it on your computer).

Really, though, using something like C# Visual Studio Express is a great way to go for writing Windows programs.

You could also create an HTML Application (.hta file) to provide a friendly front-end to VBScript or JavaScript. They can be completely coded in a text editor like Notepad.

Can you elaborate on the details of what the program is supposed to do?

SharpDevelop is pretty good - it’s a freeware VB-alike RAD environment, with the option of using VB.Net, C# or Boo for the coding

okay thanks guys. I guess I should’ve mentioned that a big part of the reason I moved away from coding was because my options at the time of not coding anything MS based were minimal fading to zero :wink:
I’ll have a look at JS, call me irrational but no way I’m touching anything “visual”.

Really? MS has its issues, definitely, but its developer tools have always been top-notch. Even the die-hard Linux junkies I know have high opinions of Visual Studio.

That said, there’s plenty of ways out there to do non-MS development, they just usually involve websites nowadays. But I doubt you want to set up a whole Apache (or other non-MS Web server) environment just to do what you describe.

But for a simple HTML/Javascript thing, you don’t need any development environment beyond a text editor and a browser. Let us know if you need a hand, doing what you describe is pretty simple.

I have long wanted the same thing the OP describes and have searched pretty intently for it on and off. If I become a bazillionair, I would cause it to be created.

But I think it doesn’t exist, incredible as that sounds. I think it means something went wrong with PC evolution (did you know that “PC” actually stands for “personal computer”, and that at one time these things were controllable by the person that owned them, and they computed things?).

I think the closest thing is C#, in the free version of VisualStudio. It is bigger and more involved than the OP wishes but would come the closest. The C# language itself is textual and elegant and inspiring and well documented.

Other options:

If you are already familiar with C and want to build on that knowledge, you can get a C compiler for windows, for example MinGW, a GCC C compiler for windows

If you want to learn a new language, you can always try Python

I’m confused - there are many small, free solutions suggested on this thread. What, exactly, is it that you are saying doesn’t exist?

Napier, what do you think of FreeBasic?

I am being way too glib. And I don’t know that I’m really right, either. But…

What I am really saying doesn’t exist is a programming environment that can deliver something executable in Windows, and that is simple enough that the problems of devising and specifying an algorithm to solve a problem are the primary things the programmer will work on.

I had never heard of FreeBasic, for example, but went and checked out their web site. FreeBasic has to make calls to the Win32 API. I’m betting that somebody that already understands the programming language and can easily correctly deduce how to do a few calculations based on an input would still have to spend days, even weeks, working with it to write something that does those simple calculations under Windows and not in a command prompt. In other words, even Hello World takes considerable study to understand, if it is a real Windows program where you just call the Win32 functions.

Nowadays, to speak with sweeping generality, programming for Windows applications is done with tools that are aimed at full time coders, and there is more effort in managing the user interface than in all the other stuff. People are either professional Windows application developers or they buy solutions from those developers to solve their problems. Normal people don’t try to do with computers things that a developer didn’t already work out for them.

You’re not going to find CD’s crammed with hundreds of tiny Windows programs for calculating obscure numerical things, the way various professionals and hobbyists did under DOS in the '80s. The industry fixed the wrong problems much faster than it fixed the right ones. Those of us who grew up learning that computers would solve problems repetitively and effortlessly once we had taught them how to solve the problem once, that is those of us who thought of programming as the way you USE a computer, saw a bunch of business and flare hijack this mindset.

So, you can still program computers to solve your own problem, inside some special environment. I happen to often use SAS (a statistics system with a pretty complete language) for this kind of thing, because I learned it so well more than 20 years ago, but I can only use those solutions on a box with an active SAS license, and I practically cannot share my solutions with people here who don’t happen to use that particular environment.

It seems like providing a clean, simple, versatile programming environment for the end user to use has become the exclusive domain of expensive apps. The idea that you would sit down at the kitchen table with a Z-90 driven CPM machine, which has a version of BASIC in ROM, and figure out how to make a map of what the distance and bearing angle is to all the world’s cities, because you’re a HAM operator and want the result for yourself - that idea seems to be gone.

I don’t know if I’m underestimating the complexity, Napier, or if you’re overstating it, or both, but ISTM that creating simple calculator-type programs in things like VB or Sharpdevelop couldn’t really be any easier (without resorting to non-exeuctable solutions such as spreadsheets).

For example (and I realise this is a vast oversimplification of what I think I understand you as requiring) to multiply two user-entered numbers and display the result, in VB, you need to:
[li]Open the VB application[/li][li]Add two text boxes (to the default blank form that appears automatically)[/li][li]Add a button in the same way[/li][li]Double-click the button[/li][li]Add the code: MsgBox "the answer is " & Me.Text1 * Me.Text2[/li][li]Click the ‘play’ icon to compile and run your program[/li][/ul]

I don’t see how development of visual interfaces for Windows can be made very much simpler than the drag and drop interface in VB - if you can create a Powerpoint slide, you can create a form design (not necessarily a good-looking one) in a visual form tool such as VB, or Delphi, or SharpDevelop. And if you can write a ‘hello world’ program in QBasic, you can do it in VB.

I’m not seeing where the learning curve gets steep :confused:

I have to agree with Mangetout on this one.

Napier, I think you’re getting too hung up on the UI bits of modern languages. It is entirely possible to create what you’re talking about without any use of the API calls. It’s also very easy to create something with a very minimal user interface (say, two text boxes for input and one label for output) by knowing maybe one or two lines of API calls.

Like I, and others, said above - a lot of what you describe can be done with a text editor and a basic knowledge of HTML and Javascript. You don’t get any simpler than that, and for all intents and purposes it’s built in to your computer, much like BASIC used to be in ROM.

“Normal people”, even in the past, didn’t do stuff for computers that developers didn’t work out for them, either. 30 years ago, if you had a computer, you were a hobbyist who was interested in learning how to program. By definition, that’s not a “normal person.”

No, you don’t find CDs crammed with hundreds of tiny Windows programs, because we’ve evolved beyond that. Now, you have web sites that do all those little things. Sometimes you can download standalone programs.

I think you’re just looking in the wrong places; no, it’s not exactly like it was 20-30 years ago. But what you describe is alive and well and entirely possible to do.

Just to demonstrate how easy this is to do in HTML & Javascript, here’s an example of various math operations done one a couple user-input variables. Copy & paste it to your favorite text editor, save as an .html file, and open in your browser. No downloads, compilers, dev environments or anything needed, beyond a text editor.


<script type="text/javascript">
function multiply()
	var n1 = document.getElementById("n1").value;
	var n2 = document.getElementById("n2").value;
	var n3 = n1 * n2;
	var result = document.getElementById("result");
	result.innerHTML = n3.toString();
	return false;

function subtract()
	var n1 = document.getElementById("n1").value;
	var n2 = document.getElementById("n2").value;
	var n3 = n1 - n2;
	var result = document.getElementById("result");
	result.innerHTML = n3.toString();
	return false;

function divide()
	var n1 = document.getElementById("n1").value;
	var n2 = document.getElementById("n2").value;
	var n3 = n1 / n2;
	var result = document.getElementById("result");
	result.innerHTML = n3.toString();
	return false;

function add()
	var n1 = parseInt(document.getElementById("n1").value);
	var n2 = parseInt(document.getElementById("n2").value);
	var n3 = n1 + n2;
	var result = document.getElementById("result");
	result.innerHTML = n3.toString();
	return false;

<form action="form_action.asp" method="get">
  Number 1: <input type="text" id="n1" /><br />
  Number 2: <input type="text" id="n2" /><br />
  <input type="submit" value="Multiply" onclick="return multiply();"/>
  <input type="submit" value="Divide" onclick="return divide();"/>
  <input type="submit" value="Add" onclick="return add();"/>
  <input type="submit" value="Subtract" onclick="return subtract();"/>
  <br/>Result: <label id="result"></label>

Well, maybe I am wrong about this one.

But, still, I compared the code you show to a program I wrote a few years ago in Microsoft “Quick C” that runs in a command prompt. My program solved for the fourth variable given the first three, using an equation relating all four. The equation involves a fraction with exponentials and three levels of parentheses in numerator and denominator. The program prompts the user for each input and writes the answer into a line of text, and tests for two different kinds of violation of the assumptions implicit in the equation, giving error messages that state what violated what. It loops until you tell it to exit, and also gives a paragraph of explanation if you supply “?” instead of numbers at any of the prompts. This program was 43 lines long, with the standard C layout conventions, including a few lines of comment, compared to your 66 lines.

And I think you are probably a better programmer than I am, and that I’m not very good or elegant at it. I think there’s just way more baggage today. By way of example here’s the VB Hello World at http://en.wikibooks.org/wiki/List_of_hello_world_programs#Visual_Basic_.NET_2003.2F2005, which I don’t really understand:

Visual Basic .NET 2003/2005
Private Sub Form_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
MessageBox.Show(“Hello, world!”)
End Sub
Note that the previous example will only work when the code is entered as part of a Form Load Event, such as the one created by default when generating a new project in the Visual Studio programming environment. Equivalently, the following code is roughly equivalent to the traditional Visual Basic 6 code by disabling the Application Framework and setting ‘Sub Main’ as the entry point for the application:

Public Module MyApplication
Sub Main()
MessageBox.Show(“Hello, world!”)
End Sub
End Class
or using a class;

Public Class MyApplication
Shared Sub Main()
MessageBox.Show(“Hello, world!”)
End Sub
End Class
The point about normal people is well taken. Somebody showed me a little VB a couple years ago before I tried C#, and I don’t remember it being as simple as Mangetout describes, but also don’t remember what made it more complicated, so maybe I can’t use that old data point of mine. Maybe the problem is indeed looking in the wrong places. I am interested, for example, in Javascript - maybe I should try to learn that next.