Personal computing discussed

Moderators: renee, SecretSquirrel, just brew it!

 
BurntFingers
Gerbil First Class
Topic Author
Posts: 131
Joined: Sun Jan 19, 2003 10:41 pm
Location: Japan

Programming help for the confused (me)

Mon Mar 01, 2004 1:29 am

I know that a lot of the guys who read this forum have extensive knowledge when it comes to programming matters, so please clear a few things up for me.

I'm looking to get into programming but, I've NEVER done any programming before. I've been doing a lot of reading/searching/surfing over the weekend and have gotten myself a little confused! Am I right in thinking that, firstly, although there are many languages the most popular are C and C++? Secondly, C++ is based upon C but, the two are not compatible? Thirdly, C and C++ can/are used to write code used in Win32 and MFC programming???

Visual C++ seems to able to handle the previously mentioned languages (and others), but is it any good?

Thanks for your help :D
that doesn't look too hard... oh dear!!!
 
cy_a253
Gerbil Team Leader
Posts: 276
Joined: Sat Jun 28, 2003 4:47 am

Mon Mar 01, 2004 2:36 am

Python is quite the best language to learn first and has the best syntax of all the languages I know.

Lots of tutorials on the web, just search python.org, http://www.python.org/topics/learn/overview.html

And it gets updated often, and is used everywhere by a lot of different people (Google.com for instance)

http://www.python.org/2.3.3/

Ideally, Python is used to code the majority of a given application, and the more computer intensive parts are done in C++, simply because C++ code is faster (moderately, but still significant in massive calculations). For example, I use the MMTK library for chemistry work:

MMTK is developed in and around Python, a high-level object-oriented general-purpose programming language. In fact, MMTK consists of nothing more than a collection of Python modules, most of which written in Python itself, with only a small time-critical part (e.g. energy evaluation) written in C. MMTK applications are Python programs that make use of these modules. Python was chosen because it allows rapid code development and testing, while providing a very convenient C interface for dealing with time-critical calculations.


http://starship.python.net/crew/hinsen/MMTK/

Name comes from Monty Python's Flying Circus, if that rings any bell....

Even the "How To Become A Hacker" document recommends starting with Python!

http://www.catb.org/~esr/faqs/hacker-howto.html

And if you can, you WILL want to learn as many computer languages as you can, (Python, Java, C/C++, Perl, and LISP, as the document recommends), as this will bring you invaluable experience and skill. :P
 
LJ
Gerbil Elite
Posts: 883
Joined: Wed Apr 10, 2002 2:24 am
Contact:

Mon Mar 01, 2004 2:59 am

Languages are simply tools--no one can really be considered the best. However, you could consider one tool the best for a specific job. Python, for example, is very good for shell scripting and general stuff that doesn't require a speedy GUI (comedy wxwindows option!) Interpreted languages like Python aren't going to be fast enough to do serious GUI stuff anytime soon. The trick is to find the *correct* tool for the job rather than adapting a tool because you like it or don't feel like getting another one. Wrenches make poor hammers, after all.

As to your "are c and c++ compatable" question, you can think of C++ as C with an extra wrapper added to it. You can still use your C code in a C++ program (since C++ is merely an extension of C) but you generally only want to use a single paradigm for programming. Mixing a C mindset program with a object oriented one is a bad idea--you'll end up with a code that is difficult to work with, inconsisent, and hard to maintain.

Yes, you can use MFC with C/C++.

A word of warning: programming in an object oriented sense with C++ requires quite a bit of discipline. You can break the object oriented paradigm by using pointers in various common ways and you have to be sure to delete extra allocated memory, etc. If you want to learn object oriented programming the right way then your absolute best bet it to use Java. Sun's documetation is awesome, the language is easy and pleasurable to use, compiler errors make more sense than most C/C++ compilers, and the language can reasonably be used for a lot more things that strickly interpreted languages like Python/Perl.
 
sativa
Grand Gerbil Poohbah
Posts: 3044
Joined: Sun Apr 14, 2002 7:22 pm
Location: lafayette, la

Mon Mar 01, 2004 4:08 am

the best way to learn is to take a class.

or pick up your TI calculator manual and start programming on that thing. it will teach you the basics. to jump into C++ without having *any* programming experience might be a bit difficult if you aren't taking a class.
Science is forbidden. Laboratories manufacture danger!
 
fc34
Minister of Gerbil Affairs
Posts: 2816
Joined: Wed May 08, 2002 8:39 am
Location: Somewhere

Mon Mar 01, 2004 6:58 am

sativa wrote:
or pick up your TI calculator manual and start programming on that thing. it will teach you the basics.


The TI calculator is simply a simplified BASIC that is slow. If you want, you can start with Python or BASIC then move to other languages like C++ and Java.
Windows XP - The 64-bit wannabe with a 32-bit graphics interface for 16-bit extensions to a 8-bit patch on a 4-bit operating system designed to run on a 2-bit processor by a company that can't stand 1-bit of competition
 
just brew it!
Administrator
Posts: 54500
Joined: Tue Aug 20, 2002 10:51 pm
Location: Somewhere, having a beer

Mon Mar 01, 2004 8:02 am

C/C++ are the most versatile, in that you can write everything from device drivers (very low hardware level stuff) to GUI and database applications (very high-level) in it. That does not necessarily mean it is the best tool for every task, though. Languages like Perl and Python (and VBScript on Windows) are better for scripting, and if all you need to do is get a simple GUI interface up and running in the shortest possible time, Visual Basic is probably a better bet.

C++ is essentially a superset of C. If your goal is to write Windows applications in C/C++, then Visual C++ is the way to go. The Win32 API and MFC library are designed from the ground up to be used with C/C++.
Nostalgia isn't what it used to be.
 
sativa
Grand Gerbil Poohbah
Posts: 3044
Joined: Sun Apr 14, 2002 7:22 pm
Location: lafayette, la

Mon Mar 01, 2004 1:14 pm

fc34 wrote:
The TI calculator is simply a simplified BASIC


Which is exactly why I mentioned it. Also, nearly everyone in high school or college has one and they are quite portable.
Science is forbidden. Laboratories manufacture danger!
 
Hawkwing74
His Holy Gerbilness
Posts: 13961
Joined: Wed Aug 20, 2003 5:51 pm
Location: Streamwood, IL

Mon Mar 01, 2004 3:55 pm

I would also say jumping to C++ with no programming experience at all is difficult, but can be done if you have the mind for it and are diligent.
 
LJ
Gerbil Elite
Posts: 883
Joined: Wed Apr 10, 2002 2:24 am
Contact:

Mon Mar 01, 2004 6:41 pm

There is a reason that most intro to programming courses are in C/C++ or Java.

The best course of action is to determine which tool is best for your job (if you want to write MFC applications then it's probably C++) and then learn it.
 
BurntFingers
Gerbil First Class
Topic Author
Posts: 131
Joined: Sun Jan 19, 2003 10:41 pm
Location: Japan

Mon Mar 01, 2004 6:57 pm

Sorry for the late reply, but there's a bit of a time difference between you guys and my location.

just brew it! wrote:
C++ is essentially a superset of C. If your goal is to write Windows applications in C/C++, then Visual C++ is the way to go. The Win32 API and MFC library are designed from the ground up to be used with C/C++.


That's pretty much my goal and the reason I mentioned C/C++ along with Visual C++.

As for taking classes to learn the languages, it's not really possible. Not that I don't want to, but because I can only attend such classes after work (7-8PM), so getting to any classes (if they have them at night) would be impossible :(

Thanks to everyone who replied, your help and advice is much appreciated as always. I love this forum :D
that doesn't look too hard... oh dear!!!
 
Craig P.
Gerbil Team Leader
Posts: 285
Joined: Tue Dec 31, 2002 3:12 am
Location: South Bend, IN

Re: Programming help for the confused (me)

Mon Mar 01, 2004 8:29 pm

BurntFingers wrote:
Am I right in thinking that, firstly, although there are many languages the most popular are C and C++?

Depends what you mean by "popular". I think C and C++ are probably big on market share, but java has been an "in" language for a while, VB has always been wildly popular among the less skilled and more pragmatic set, and C# is making inroads. As much as I like the things you can do with C++ (particularly with templates), I still will often turn to VB to get stuff done when I need a user interface and don't need the abstractions that C++ offers.

Secondly, C++ is based upon C but, the two are not compatible?

Although there is not strict compatibility (I believe there are a small set of C programs that are not legal C++ programs), most C code is valid C++ code.

Thirdly, C and C++ can/are used to write code used in Win32 and MFC programming???

Win32 is a C API. MFC is a very, um, mature C++ class library wrapper around Win32, as well as an application framework. ATL and WTL combine to form a modern C++ class library and application framework that are not burdened with the history of MFC.

Visual C++ seems to able to handle the previously mentioned languages (and others), but is it any good?

Visual C++ is an excellent package. VC7.1 is probably one of the best C++ compilers available (Comeau is more capable, but I don't know that anything else measures up).
 
fc34
Minister of Gerbil Affairs
Posts: 2816
Joined: Wed May 08, 2002 8:39 am
Location: Somewhere

Thu Mar 04, 2004 9:43 am

sativa wrote:
fc34 wrote:
The TI calculator is simply a simplified BASIC


Which is exactly why I mentioned it. Also, nearly everyone in high school or college has one and they are quite portable.


Not true, even between calculators its not as easy. I program myself in a variety of calculators, and its not as easy as it seems.
Windows XP - The 64-bit wannabe with a 32-bit graphics interface for 16-bit extensions to a 8-bit patch on a 4-bit operating system designed to run on a 2-bit processor by a company that can't stand 1-bit of competition
 
IntelMole
Grand Gerbil Poohbah
Posts: 3506
Joined: Sat Dec 29, 2001 7:00 pm
Location: The nearest pub
Contact:

Thu Mar 04, 2004 1:03 pm

The first language I learnt was VBA. Now that was no fun.

The second I learnt last summer after seeing it in university course. C is a fantastically raw language (that's a pro as well as a con), and you may well need a good deal of technical know-how to understand how your particular book approaches. I got the ANSI C book from the creators of C, I'll dig it and the ISBN out if you want. Needless to say, it's possibly the most clearly written programming stuff I've read in a while.

Never touched any C++, so I can't say much about that.

Now doing Java, which was based around C, and I'm finding it shockingly easy to be honest. If encapsulation is your bag, Java's a good way to start... As for how useful it is in Big Tin environments where time is money, I'm not sure how much the virtual machine approach affects things...

Hope that helps,
-Mole
Living proof of John Gabriel's theorem
 
Craig P.
Gerbil Team Leader
Posts: 285
Joined: Tue Dec 31, 2002 3:12 am
Location: South Bend, IN

Thu Mar 04, 2004 6:46 pm

IntelMole wrote:
The first language I learnt was VBA. Now that was no fun.

You might be surprised at just how much you can make VB/VBA do with a little knowledge of the Windows API. I usually work in regular VB, but since the core language is the same, I could do exactly the same things in Excel (or Word) if I needed to.

The real beauty of C++ is templates, which I'm not sure you can really appreciate until you use them.
 
IntelMole
Grand Gerbil Poohbah
Posts: 3506
Joined: Sat Dec 29, 2001 7:00 pm
Location: The nearest pub
Contact:

Mon Mar 08, 2004 1:43 pm

Craig P. wrote:
You might be surprised at just how much you can make VB/VBA do with a little knowledge of the Windows API. I usually work in regular VB, but since the core language is the same, I could do exactly the same things in Excel (or Word) if I needed to.


You certainly sound like you know what you're talking about. Unfortunatly, the stuff I was doing was strictly limited to databases and the like...
-Mole
Living proof of John Gabriel's theorem
 
HowardDrake
Grand Gerbil Poohbah
Posts: 3523
Joined: Thu Dec 27, 2001 7:00 pm
Location: Action Jim's Rumpus Room
Contact:

Mon Mar 08, 2004 2:01 pm

IntelMole wrote:
Craig P. wrote:
You might be surprised at just how much you can make VB/VBA do with a little knowledge of the Windows API. I usually work in regular VB, but since the core language is the same, I could do exactly the same things in Excel (or Word) if I needed to.


You certainly sound like you know what you're talking about. Unfortunatly, the stuff I was doing was strictly limited to databases and the like...
-Mole


VB can do amazing things with databases. I've done tons of coding in that direction. It's useful and far more readable than other languages.
No wonder television's a medium. It's so seldom rare or well done. -Mighty Mouse
Image
 
fc34
Minister of Gerbil Affairs
Posts: 2816
Joined: Wed May 08, 2002 8:39 am
Location: Somewhere

Tue Mar 09, 2004 5:47 am

IntelMole wrote:
Craig P. wrote:
You might be surprised at just how much you can make VB/VBA do with a little knowledge of the Windows API. I usually work in regular VB, but since the core language is the same, I could do exactly the same things in Excel (or Word) if I needed to.


You certainly sound like you know what you're talking about. Unfortunatly, the stuff I was doing was strictly limited to databases and the like...
-Mole


How about trying some specialized DB software, like FP5 or MySQL ?
Windows XP - The 64-bit wannabe with a 32-bit graphics interface for 16-bit extensions to a 8-bit patch on a 4-bit operating system designed to run on a 2-bit processor by a company that can't stand 1-bit of competition
 
halfline
Gerbil
Posts: 46
Joined: Mon Apr 21, 2003 5:15 pm

Tue Mar 09, 2004 6:24 am

I agree with LJ.

It depends on what u want to do with that language. If u just want to start learning a programming language, I recommend an object-oriented imperative language such as Java, C++, or C#. Java and C# were a pleasure to learn; very clean lanugages. Most CS majors start with Java or C++ and I agree it's a good beginning.

I can't be sure, but I think VB and C++ are on the top of the list for most used programming lanugage.

Yes, C++ is based on C. I think all C code will work in a C++ compiler, but not the other way around.

Ah, MFC! A lot of Win32 apps use MFC (and a bunch of other languages) to make their applications. But as a warning, MFC is complex. For simple things, it's easy. For professional things, it's a nightmare, unless u really know ur stuff.

Visual Studio (or VC++) is an awsome product along with the .NET line.
 
just brew it!
Administrator
Posts: 54500
Joined: Tue Aug 20, 2002 10:51 pm
Location: Somewhere, having a beer

Tue Mar 09, 2004 9:31 am

halfline wrote:
I can't be sure, but I think VB and C++ are on the top of the list for most used programming lanugage.

That would not surprise me at all. Most software development is still done for the Windows platform, and VB/C++ have both been around for quite a while.

Yes, C++ is based on C. I think all C code will work in a C++ compiler, but not the other way around.

C++ isn't a strict superset of C. IIRC there are a few (mostly obsolete and/or obscure) C constructs which will result in warnings/errors if compiled with a C++ compiler. But yes, most well-written C applications should port easily (usually with just a recompile).

Ah, MFC! A lot of Win32 apps use MFC (and a bunch of other languages) to make their applications. But as a warning, MFC is complex. For simple things, it's easy. For professional things, it's a nightmare, unless u really know ur stuff.

Yes, there are better 3rd party class libraries out there... and there's also STL. But MFC is still the defacto standard for doing Windows GUI development in C++, because of its tight integration with the Win32 API.

Visual Studio (or VC++) is an awsome product along with the .NET line.

Yup, I would say that Visual Studio is proof that Microsoft can produce a truly kick-a** product if they really try.
Nostalgia isn't what it used to be.
 
IntelMole
Grand Gerbil Poohbah
Posts: 3506
Joined: Sat Dec 29, 2001 7:00 pm
Location: The nearest pub
Contact:

Thu Mar 11, 2004 2:46 pm

fc34 wrote:
How about trying some specialized DB software, like FP5 or MySQL ?


The stuff I was doing was for GCSEs at school. And that was based on Access, rather than VBA. It was just that my project had a fair bit of VBA in it...
-Mole
Living proof of John Gabriel's theorem
 
fc34
Minister of Gerbil Affairs
Posts: 2816
Joined: Wed May 08, 2002 8:39 am
Location: Somewhere

Sat Mar 13, 2004 8:28 pm

Access and VB...both M$...figures
Windows XP - The 64-bit wannabe with a 32-bit graphics interface for 16-bit extensions to a 8-bit patch on a 4-bit operating system designed to run on a 2-bit processor by a company that can't stand 1-bit of competition
 
blitzy
Gerbil Jedi
Posts: 1844
Joined: Thu Jan 01, 2004 6:27 pm
Location: New Zealand

Sat Apr 03, 2004 11:18 am

didnt think it would be worth starting a new thread over, but just out of curiousity what are your opinions on object pascal with delphi?

im doing some introductory programming this semester, and that is the language we are being taught... any opinions? good? bad? I dont think I see it mentioned anywhere in this thread yet
 
HowardDrake
Grand Gerbil Poohbah
Posts: 3523
Joined: Thu Dec 27, 2001 7:00 pm
Location: Action Jim's Rumpus Room
Contact:

Sat Apr 03, 2004 2:38 pm

Pascal was created as the original training language. VB nowadays is far more like Pascal than Basic actually. I liked using Delphi and if you want to try it for Linux download a copy of Kylix from Borland :)
No wonder television's a medium. It's so seldom rare or well done. -Mighty Mouse

Image
 
harbichidian
Gerbil
Posts: 61
Joined: Fri Dec 26, 2003 5:06 pm
Location: Wherever they put me.
Contact:

Sun Apr 11, 2004 7:07 pm

Of course, all true programmers know C++ is the only language worth knowing ;)

But seriously, as I do everything in C++ and have completely abandoned Visual BASIC for its... simplicity... I may give a slightly biased opinion. BASIC (not visual) is a good stepping stone for the beginning programmer, but C++ is the pinnacle, the peak of all programming evolution. There is nothing you can't do in C++. Period.

... and C++ is the only language you can ascend into the Tao with.
Greer's Third Law: A computer program does what you tell it to do, not what you want it to do.
 
just brew it!
Administrator
Posts: 54500
Joined: Tue Aug 20, 2002 10:51 pm
Location: Somewhere, having a beer

Sun Apr 11, 2004 9:46 pm

harbichidian wrote:
Of course, all true programmers know C++ is the only language worth knowing ;)

But seriously, as I do everything in C++ and have completely abandoned Visual BASIC for its... simplicity... I may give a slightly biased opinion. BASIC (not visual) is a good stepping stone for the beginning programmer, but C++ is the pinnacle, the peak of all programming evolution. There is nothing you can't do in C++. Period.

... and C++ is the only language you can ascend into the Tao with.

Whoa... this is the Developer's Den, not Religion & Politics! :lol:

Seriously... I agree with you, to an extent. I think C++ is the most versatile and powerful, in that there isn't a programming task in existence that can't be accomplished with it. But it is not always the best tool for every job, where the determination of "best" must also include factors such as ease of implementation and maintenance.

Like you, I also do nearly everything in C++. But I also realize that in some cases, I do it because I am comfortable with it... other tools may actually be more suitable.
Nostalgia isn't what it used to be.
 
Craig P.
Gerbil Team Leader
Posts: 285
Joined: Tue Dec 31, 2002 3:12 am
Location: South Bend, IN

Tue Apr 13, 2004 4:40 pm

VB is still attractive to me for the ease of assembling an interface. If you know enough about the crufty corners of the language and the Windows API, you'll find that it can be astonishingly capable. The only area that I would prefer to stay away from if at all possible is subclassing -- I've found that I can do pretty much anything I want in the way of shifting memory around as long as I'm careful about it.
 
thegleek
Darth Gerbil
Posts: 7460
Joined: Tue Jun 10, 2003 11:06 am
Location: Detroit, MI
Contact:

Fri Jun 10, 2005 11:40 am

harbichidian wrote:
BASIC (not visual) is a good stepping stone for the beginning programmer, but C++ is the pinnacle, the peak of all programming evolution.


i couldnt resist printing this:

The Evolution of a Programmer- read to the end ...

High School/Jr.High 

10 PRINT "HELLO WORLD"
20 END


First year in College

program Hello(input, output)
begin
writeln('Hello World')
end.


Senior year in College

(defun hello
(print
(cons 'Hello (list 'World))))


New professional

#include
void main(void)
{
char *message[] = {"Hello ", "World"};
int i;

for(i = 0; i < 2; ++i)
printf("%s", message[i]);
printf("\n");
}


Seasoned professional

#include
#include

class string
{
private:
int size;
char *ptr;

public:
string() : size(0), ptr(new char('\0')) {}


string(const string &s) : size(s.size)
{
ptr = new char[size + 1];
strcpy(ptr, s.ptr);
}

~string()
{
delete [] ptr;
}

friend ostream &operator <<(ostream &,
const string &);
string &operator=(const char *);
};

ostream &operator<<(ostream &stream, const
string &s)
{
return(stream << s.ptr);
}

string &string::operator=(const char *chrs)
{
if (this != &chrs)
{
delete [] ptr;
size = strlen(chrs);
ptr = new char[size + 1];
strcpy(ptr, chrs);
}
return(*this);
}

int main()
{
string str;

str = "Hello World";
cout << str << endl;

return(0);
}


Master Programmer

[
uuid(2573F8F4-CFEE-101A-9A9F-00AA00342820)
]
library LHello
{
// bring in the master library
importlib("actimp.tlb");
importlib("actexp.tlb");

// bring in my interfaces
#include "pshlo.idl"

[

uuid(2573F8F5-CFEE-101A-9A9F-00AA00342820)
]
cotype THello
{
interface IHello;
interface IPersistFile;
};
};

[
exe,
uuid(2573F890-CFEE-101A-9A9F-00AA00342820)
]
module CHelloLib
{

// some code related header files
importheader();
importheader();
importheader();
importheader("pshlo.h");
importheader("shlo.hxx");
importheader("mycls.hxx");

// needed typelibs
importlib("actimp.tlb");
importlib("actexp.tlb");
importlib("thlo.tlb");

[
uuid(2573F891-CFEE-101A-9A9F-00AA00342820),
aggregatable
]
coclass CHello
{
cotype THello;
};
};

#include "ipfix.hxx"

extern HANDLE hEvent;

class CHello : public CHelloBase
{
public:
IPFIX(CLSID_CHello);

CHello(IUnknown *pUnk);
~CHello();

HRESULT __stdcall PrintSz(LPWSTR
pwszString);

private:
static int cObjRef;
};

#include
#include
#include
#include
#include "thlo.h"
#include "pshlo.h"
#include "shlo.hxx"
#include "mycls.hxx"

int CHello::cObjRef = 0;

CHello::CHello(IUnknown *pUnk) :
CHelloBase(pUnk)
{
cObjRef++;
return;
}

HRESULT __stdcall CHello::PrintSz(LPWSTR
pwszString)
{
printf("%ws\n", pwszString);
return(ResultFromScode(S_OK));
}

CHello::~CHello(void)
{

// when the object count goes to zero, stop
the server
cObjRef--;
if( cObjRef == 0 )
PulseEvent(hEvent);

return;
}

#include
#include
#include "pshlo.h"
#include "shlo.hxx"
#include "mycls.hxx"

HANDLE hEvent;

int _cdecl main(
int argc,
char * argv[]
) {
ULONG ulRef;
DWORD dwRegistration;
CHelloCF *pCF = new CHelloCF();

hEvent = CreateEvent(NULL, FALSE, FALSE,
NULL);

// Initialize the OLE libraries
CoInitializeEx(NULL, COINIT_MULTITHREADED);

CoRegisterClassObject(CLSID_CHello, pCF,
CLSCTX_LOCAL_SERVER,
REGCLS_MULTIPLEUSE, &dwRegistration);

// wait on an event to stop
WaitForSingleObject(hEvent, INFINITE);

// revoke and release the class object
CoRevokeClassObject(dwRegistration);
ulRef = pCF->Release();

// Tell OLE we are going away.
CoUninitialize();

return(0);
}

extern CLSID CLSID_CHello;
extern UUID LIBID_CHelloLib;

CLSID CLSID_CHello = { /*
2573F891-CFEE-101A-9A9F-00AA00342820 */
0x2573F891,
0xCFEE,
0x101A,
{ 0x9A, 0x9F, 0x00, 0xAA, 0x00, 0x34,
0x28, 0x20 }
};

UUID LIBID_CHelloLib = { /*
2573F890-CFEE-101A-9A9F-00AA00342820 */
0x2573F890,
0xCFEE,
0x101A,
{ 0x9A, 0x9F, 0x00, 0xAA, 0x00, 0x34,
0x28, 0x20 }
};

#include
#include
#include
#include
#include
#include "pshlo.h"
#include "shlo.hxx"
#include "clsid.h"

int _cdecl main(
int argc,
char * argv[]
) {
HRESULT hRslt;
IHello *pHello;
ULONG ulCnt;
IMoniker * pmk;
WCHAR wcsT[_MAX_PATH];
WCHAR wcsPath[2 * _MAX_PATH];

// get object path
wcsPath[0] = '\0';
wcsT[0] = '\0';
if( argc > 1) {
mbstowcs(wcsPath, argv[1],
strlen(argv[1]) + 1);
wcsupr(wcsPath);
}
else {
fprintf(stderr, "Object path must be
specified\n");
return(1);
}

// get print string
if(argc > 2)
mbstowcs(wcsT, argv[2], strlen(argv[2])
+ 1);
else
wcscpy(wcsT, L"Hello World");

printf("Linking to object %ws\n", wcsPath);
printf("Text String %ws\n", wcsT);

// Initialize the OLE libraries
hRslt = CoInitializeEx(NULL,
COINIT_MULTITHREADED);

if(SUCCEEDED(hRslt)) {

hRslt = CreateFileMoniker(wcsPath,
&pmk);
if(SUCCEEDED(hRslt))
hRslt = BindMoniker(pmk, 0, IID_IHello,
(void **)&pHello);

if(SUCCEEDED(hRslt)) {

// print a string out
pHello->PrintSz(wcsT);

Sleep(2000);
ulCnt = pHello->Release();
}
else
printf("Failure to connect, status: %lx",
hRslt);

// Tell OLE we are going away.
CoUninitialize();
}

return(0);
}


Apprentice Hacker

#!/usr/local/bin/perl
$msg="Hello, world.\n";
if ($#ARGV >= 0) {
while(defined($arg=shift(@ARGV))) {
$outfilename = $arg;
open(FILE, ">" . $outfilename) || die
"Can't write $arg: $!\n";
print (FILE $msg);
close(FILE) || die "Can't close $arg:
$!\n";
}
} else {
print ($msg);
}
1;


Experienced Hacker

#include
#define S "Hello, World\n"
main(){exit(printf(S) == strlen(S) ? 0 :
1);}


Seasoned Hacker

% cc -o a.out ~/src/misc/hw/hw.c
% a.out


Guru Hacker

% cat
Hello, world.
^D


New Manager

10 PRINT "HELLO WORLD"
20 END


Middle Manager

mail -s "Hello, world." bob@b12
Bob, could you please write me a program
that prints "Hello, world."?
I need it by tomorrow.
^D


Senior Manager

% zmail jim
I need a "Hello, world." program by this
afternoon.


Chief Executive

% letter
letter: Command not found.
% mail
To: ^X ^F ^C
% help mail
help: Command not found.
% damn!
!: Event unrecognized
% logout
––•–√\/––√\/––•–– nostalgia is an emotion for people with no future ––•–√\/––√\/––•–-

Who is online

Users browsing this forum: No registered users and 1 guest
GZIP: On