C++ on Windows V.S. Unix

I'm a beginner in C++ Programming (not to programing in general) and I wasn't sure if this post should go in beginner's forums as people might not know as much on that forum.

I'm writing and compiling my C++ programs in Windows for now. However, eventually, the plan is to code and deploy the code on large scale UNIX servers. I had the following questions.

-) Is there any difference in syntax or the underlying structure when the program/project is compiled on Windows V.S. Unix?

-) Is unix generally expected to be faster than Windows especially for large computations.

I'm basically learning the language to do numerical/scientific computing calculations.

Thanks in advance for any comments/input.

1: No with very few exceptions... system() is fairly platform specific. That said, most here are discouraged from using it. Also, expressions like int x = 2; function(x++,x++); may operate differently on said platforms owing to both the compilers.

2: I haven't run any tests because I don't have a Windows platform to test on. Reason tells me that UNIX would be faster and if it isn't can be MADE to be faster.

-Albatross
-) Is unix generally expected to be faster than Windows especially for large computations.


I think they would be about the same, since that is more of a processor issue than an OS issue.

I'm basically learning the language to do numerical/scientific computing calculations.


C++ probably isn't the best language for that. Maybe something like MatLab or Fortran would be better.
@firedraco
Was the original release of Windows Vista ridiculously slow? [/point]

Fortran is a language specifically for numerical/scientific calculations, indeed. C++ is more of a general purpose programming language, or at least that's how it seems to me.

You might also want to check out Ruby. It's more like C++ than Fortran is, IMO.

-Albatross
C++ is a general purpose language, but you can certainly do scientific computing with it.

While the language is the same cross-platform, that doesn't mean that C++ makes platform indepentant code a black-box for you...

Here is some good reading I just googled:
http://www.ski-epic.com/source_code_essays/ten_rules_for_writing_cross_platform_c_source_code.html

Hmm, there's an old thread here too...
http://www.cplusplus.com/forum/general/19810/


[derail]
My wife uses Vista (not her choice!) and it is horribly slow and bloated...

Good luck!
Thanks for your reply everyone.

@Firedraco - I already know Matlab quite well. Sometimes , if you wanna create some special libraries for Matlab even, you must know C++ for that. Besides, when it comes to large scale computation, C++ is expected to be MUCH MORE FASTER. AND, I'm expected to do lots of distributed computing and HPC stuff and I guess the standard for that is C++.

As for Fortran, I know its very fast, but its very old. I'm not sure how friendly is it in terms of HPC and distributed computing. Not to mention, how much help is available for it around?? How many updates are done on it?


@ Duoas and Albatross - I'm guessing C++ is the right choice. I know a bit of Java as well. I know that GUI and connecting to get external/internet data through sockets connection wasn't too hard in it (In terms of figuring its connection). I wonder if its as simple in C++ as well.

Right now, I started coding in Microsoft Visual C++ 2008. I'm hoping its the right choice. Is there any way for me to check if the similar code is also gonna run in Unix. I haven't installed Unix on my machine yet (and to be honest, I'm not sure how easy figuring out UNIX will be ).


Well , overall I'm looking forward to this exciting adventure. :)
Recommendation for starting your adventure:
Ubuntu 10.04 LTS, once it's out. It's a GNU/Linux OS, and highly recommended by me. :)

Anything that you write in Microsoft Visual C++ will not run on any UNIX-like system. Okay, just kidding... but seriously, .NET is nothing if cross-platform.

Fortran is still supported by the lunatics who write gcc, no?

UNIX-like systems are not that hard to figure out if you like tinkering with stuff. Though most of the figuring out that you'll probably need to do is figuring out the command line.

-Albatross

I know that GUI and connecting to get external/internet data through sockets connection wasn't too hard in it (In terms of figuring its connection). I wonder if its as simple in C++ as well.
As long as you use the right libraries, yes.

Right now, I started coding in Microsoft Visual C++ 2008. I'm hoping its the right choice. Is there any way for me to check if the similar code is also gonna run in Unix.
VC++ is more lax when it comes to certain language features (e.g. template specialization) than GCC. Not all code that compiles on VC++ compiles on GCC. The inverse is also true (e.g. unless otherwise told, GCC allows variable-sized stack arrays, which is illegal in C++), which is why you should always try several compilers when writing cross-platform code.
Also important is the fact that Windows is more resilient to memory bugs than Linux. In other words, just because it doesn't crash, it doesn't mean that it's correct. You should test on both platforms as you go. VMs help a lot to simplify this process.

.NET is nothing if cross-platform.
I can't tell if I disagree with you or not. Are you saying that it is or that it isn't cross-platform?
C++ probably isn't the best language for that. Maybe something like MatLab or Fortran would be better.


I disagree with you at 1000% with passion! C++ is not that good a language to do mathematics, but is by far the best one for the purpose (i.e. all other programming languages* claiming to do the job are even worse).


*all other programming languages that I have tried. This excludes Fortran and Matlab, but includes MAPLE and most other frequently-mentioned-languages (java-like, pascal-like and basic-like).
Last edited on
.NET is nothing if cross-platform

Badly-phrased idiomatic English: .NET is nothing if not cross-platform -- meaning that its redeeming feature is its cross-platform-ness.

I disagree. .NET is a VM specification, meaning it is its own platform, but it still requires care when writing cross-platform code because it doesn't fully abstract the underlying system.

When doing computational mathematics, any language which operates over a VM or interpreter (like .NET or VB or the like) will perform badly against a language which compiles to native code.

C++ probably isn't the best...

General purpose languages like C++ matched and exceeded the power of older languages like FORTRAN years ago. C++ can do anything FORTRAN can do, and better. FORTRAN still exists to support legacy systems, and as nostolgic fun.
I've heard Fortran is still used in scientific applications because it generates faster code than the C family, supposedly because of its lack of features.
closed account (z05DSL3A)
The plasma physicists I know mainly use FORTRAN. It may be because they can get better results (read: faster development and exacution times) without learning as much.
I know FORTRAN is used in earth/environmental sciences a lot (at least in my university) because they say that on average, they analyse two to three million data points on average and fortran is the fastest language for that...... (don't know why, I'm just telling you what I was told).

I'm using C++ because (at the end of the day) it most widely used, kind of industry standard, and you can do everything in C++.

Also, I think (based on what I searched) that Unix should be much faster than Windows, but thats only if I'm doing very intensive scientific calculations and trying to shave off milliseconds in every calculation (which we 'might' have to do). If all I'm doing is running a linear regression on a thousand points, then it doesn't matter of course.

However, we will be analyzing realtime data and would like to not only save it but process it through certain calculations (e.g. capturing Tempertature and air quality, etc. every minute or so).

For now, I'm hoping that Windows should be fine. I won't be surprised if we have to switch to Unix because the Project manager wants "faster calculations" :(.
I really can't see how the choice of kernel could affect how fast the program runs. Maybe if you're comparing a system with virtual memory to one that runs unprotected in real mode, but just about every OS you can get your hand on today has virtual memory, so...
@TheTSPSolver

You might want to look at something like Cygwin: http://www.cygwin.com/

It is basically a Unix (or Linux) like environment for Windows. It uses the GCC compiler and comes with most of the common libraries you would normally expect on a Unix system and anything written on that should compile on Unix without modification (more or less).


Topic archived. No new replies allowed.