View Full Version : I want to write myself a simple program in Windows
Random Design
01-06-2010, 05:00 AM
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?
Quartz
01-06-2010, 05:48 AM
Fire up Excel and look at VBA.
Crowbar of Irony +3
01-06-2010, 08:00 AM
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).
Athena
01-06-2010, 09:07 AM
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.
Johnny Angel
01-06-2010, 09:53 AM
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.
Ruminator
01-06-2010, 10:02 AM
What are my options? Any suggestions?
If the javascript math functions (http://www.w3schools.com/jsref/jsref_obj_math.asp) are enough for your purposes, I would use javascript.
It's free.
Javascript is built into your web browser.
There's no compiler to download.
You can build a user interface that works on PC and Apple Mac and mobile devices.
javascript syntax looks like C/C++
I use Excel VBA every day but I recommend it as a last resort.
BobArrgh
01-06-2010, 01:22 PM
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.
Number
01-06-2010, 01:44 PM
You could also create an HTML Application (http://msdn.microsoft.com/en-us/library/ms536496%28VS.85%29.aspx) (.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?
Mangetout
01-06-2010, 01:46 PM
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
http://www.icsharpcode.net/OpenSource/SD/
Random Design
01-07-2010, 02:12 AM
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 ;)
I'll have a look at JS, call me irrational but no way I'm touching anything "visual".
Athena
01-07-2010, 08:07 AM
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 ;)
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.
Napier
01-09-2010, 09:54 AM
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.
Arnold Winkelried
01-09-2010, 10:06 AM
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 (http://www.mingw.org/wiki/HOWTO_Install_the_MinGW_GCC_Compiler_Suite)
If you want to learn a new language, you can always try Python
Python (http://www.python.org/download/)
Athena
01-09-2010, 11:28 AM
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.
I'm confused - there are many small, free solutions suggested on this thread. What, exactly, is it that you are saying doesn't exist?
Crowbar of Irony +3
01-09-2010, 09:41 PM
Napier, what do you think of FreeBasic?
Napier
01-10-2010, 06:43 AM
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.
Mangetout
01-10-2010, 07:45 AM
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:
Open the VB application
Add two text boxes (to the default blank form that appears automatically)
Add a button in the same way
Double-click the button
Add the code: MsgBox "the answer is " & Me.Text1 * Me.Text2
Click the 'play' icon to compile and run your program
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:
Athena
01-10-2010, 08:05 AM
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.
Athena
01-10-2010, 08:24 AM
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.
<html>
<body>
<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;
}
</script>
<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>
</form>
</body>
</html>
Napier
01-10-2010, 09:31 AM
Just to demonstrate how easy this is to do in HTML & Javascript, here's an example....
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!")
Me.Close()
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.
Ruminator
01-10-2010, 10:56 AM
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.
But the ability to program your own algorithms wasn't exactly true during the monochrome 1980s MSDOS days either. To make EXEs, you had to buy a compiler... either MS Quick Basic, MS Quick C or Professional C, or Borland Turbo Pascal, etc. The only thing "free" was BAT files or running DEBUG at the command line and entering assembly instructions by hand.
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 idea of tiny programs is still there but it's just in a different form: thousands of websites with javascript. There are websites to calculate the capacity of DVDs, or mortgage amortization, astronomy, etc. The paradigm of distribution has simply shifted. Instead of CDs or floppies, it's personal websites with javascript.
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.
The free alternative to SAS is R Statistics (http://en.wikipedia.org/wiki/R_(programming_language)).
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 think javascript fulfills this type of hobby problem solving very easily. With Windows 7, another free scripting environment builtin is PowerShell (http://en.wikipedia.org/wiki/Powershell).
beowulff
01-10-2010, 11:20 AM
It's not free, but: RealBasic (http://www.realsoftware.com/realbasic/).
It's an awesome rapid-prototyping or one-off tool, and it can create cross-platform (OS X, Linux, Windoze) applications.
Of course, OS X has a very full-featured development system available for free - Xcode (http://developer.apple.com/tools/xcode/), and command-line compliers built-in. But, this probably doesn't help with your Windows issue.
Napier
01-10-2010, 01:51 PM
But the ability to program your own algorithms wasn't exactly true during the monochrome 1980s MSDOS days either. To make EXEs, you had to buy a compiler... either MS Quick Basic, MS Quick C or Professional C, or Borland Turbo Pascal, etc. The only thing "free" was BAT files or running DEBUG at the command line and entering assembly instructions by hand.
This is confusing two points. It is one thing to have to pay for something like Quick C to be able to write programs. It is another for anyone who wants to use your program to also have to pay for a special environment that can run it, or for you to have to pay for such a special environment for each of your dozen miscellaneous computers on which you might want to run it (if it's licensed per box). The difference is practically the difference between being able to write for "Windows" as opposed to being able to write for users of a specific package.
Napier
01-10-2010, 01:54 PM
[...]The idea of tiny programs is still there but it's just in a different form: thousands of websites with javascript. There are websites to calculate the capacity of DVDs, or mortgage amortization, astronomy, etc. The paradigm of distribution has simply shifted. Instead of CDs or floppies, it's personal websites with javascript.
[...]
I think javascript fulfills this type of hobby problem solving very easily. With Windows 7, another free scripting environment builtin is PowerShell (http://en.wikipedia.org/wiki/Powershell).
OK, at this point I am thinking I'm wrong, and I need to learn about javascript (and perhaps others). I hope this has been relevant to the OP and not a derailment, but, folks certainly seem to be understanding what I meant but pointing out counterexamples. Thanks!
Napier
01-10-2010, 01:59 PM
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.
So it is. Athena, you've taught me something useful. This might have been my most productive moment all week.
Thanks, everybody!
Athena
01-10-2010, 02:52 PM
So it is. Athena, you've taught me something useful. This might have been my most productive moment all week.
Thanks, everybody!
Well shucks... and here I was thinking that posting code was far too geekish for this thread!
This is confusing two points. It is one thing to have to pay for something like Quick C to be able to write programs. It is another for anyone who wants to use your program to also have to pay for a special environment that can run it, or for you to have to pay for such a special environment for each of your dozen miscellaneous computers on which you might want to run it (if it's licensed per box). The difference is practically the difference between being able to write for "Windows" as opposed to being able to write for users of a specific package.
Nope, that's not the case for just about every programming environment out there. If you have to pay for them, you only pay for the development environment, not the runtime environment. That's almost universally something you give away free, or, in the case of most Windows-based Microsoft tools, built into the OS.
EXE files sometimes can be run without anything else. Most often nowadays for Windows at least, they need a few extra .dll files. The most common ones come with newer Windows versions; older versions may require a download, but it's a free download, and once you have them, you don't need to re-download them every time you get a new file that needs them.
I've never seen a dev environment except maybe VERY specialized ones that require a license just to run a program written for them.
Napier, reading between the lines, I think some of the reason you're a bit confused about the newer programming languages/environments is the bit shift from procedural programming to event-driven and OO programming that happened about 15 years ago.
Procedural programming is what you're used to. You type out a program, and when you execute it, it starts at the first line (or the first line of the "main" function) and goes from there.
Nowadays, things are almost universally event-driven. Meaning, code reacts to user events. Programs are built around objects - like a window can be an object. You can tell the program to do something when the window is first displayed, or when a user presses a button, or moves a scroll bar.
It's a different way of thinking, but it's not particularly harder once you get your head around it. But it's definitely confusing at first.
(and for all you techies - this post is definitely a very general post. Yes, I'm sure you can find a dozen things that you can take exception to or make a point about. I'm just talking in generalities, not trying to explain the whole programming world right now in this thread.)
UncleRojelio
01-10-2010, 03:05 PM
Just for completeness, if you are thinking of going the browser route, try PHP (http://php.net/index.php).
Of course, OS X has a very full-featured development system available for free - Xcode, and command-line compliers built-in. But, this probably doesn't help with your Windows issue.Also for completeness, AppleScript is a fantastic way to write quick, one-off apps.
Recliner
01-10-2010, 06:53 PM
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.
Definitely going to second this. I've used a ton of IDEs (integrated development environments), and Visual Studio is simply the best out there. As stated above, Microsoft currently makes C# (and a number of others) available in free versions, which, while not tiny in size, aren't likely to fill up your drive.
For something quick-and-dirty, the aforementioned Javascript method is quite workable, but its going to require you to learn both JS and some HTML (in order to create a front-end).
I'm a huge fan of Flash, especially for quickie things, but its not for everyone. However, the ability to "draw" out a UI and then use Actionscript (very similar to Javascript) makes it something of an all-in-one for Web-based applications.
Napier
01-11-2010, 11:20 AM
Nope, that's not the case for just about every programming environment out there. If you have to pay for them, you only pay for the development environment, not the runtime environment. That's almost universally something you give away free, or, in the case of most Windows-based Microsoft tools, built into the OS.
[...]
I've never seen a dev environment except maybe VERY specialized ones that require a license just to run a program written for them.
Napier, reading between the lines, I think some of the reason you're a bit confused about the newer programming languages/environments is the bit shift from procedural programming to event-driven and OO programming that happened about 15 years ago.
About paying for the runtime - I mean, if I write a program in SAS, or Mathematica, or FlexPDE, you have to have the application to run my program. These don't compile to executables. Even environments like LabVIEW that now give away the runtime for free haven't made any promises that the runtime will always be free. The environments I am describing might more often be thought of as applications than as programming environments, but they are still used entirely by writing programs. Even writing mathematically oriented things in C#, I found it expedient to buy the IMSL numerical library for things like its iterative solver, but then have to deal with licensing issues to distribute what I wrote.
I did do, by the way, the step from procedural to OO with C# (and a little Java and C++). And to event-driven with C# and, if you include it as programming, LabVIEW. About C#, I do have to say the OO approach seems very smart. But it is smart in a logical sort of way, which is clear when you read examples about a shopping cart on a web site being an object. All the time with the shopping carts. For programs where the math is a bigger deal than the logic of the interface, such as in the extreme a program that reads a file of numbers and generates another file with numbers, with a user interface that has a single button labeled "Run", it doesn't seem like OO necessarily matters.
vBulletin® v3.7.3, Copyright ©2000-2013, Jelsoft Enterprises Ltd.