views:

169

answers:

6

Hey guys,

I've been "programming" in PHP for about 3 or 4 years I think, and I think I'm pretty good at it already, so decided to move on to something more complex. I understand that PHP is too flexible (you don't have to declare the type of a variable, for example) and that I'll have to get used to code in such ways.

So basically I want to write applications where I could control many CPU cores and create Windowed applications. Being able to use a 3D library like DirectX or OpenGL would be plain awesome.

I really don't know much about languages that would be appropriate for this kind of applications. So, in your opinion, what language should I learn? And what book should I buy to learn it?

+2  A: 

C++ is the typical choice for large cross-platform projects. Mastering how to write cross-platform applications in C++ is quite a challenge though, but definitely worth it IMO.

StackedCrooked
+6  A: 

Python would be the easiest step for you (there's no "declaring types of variables" in it either, for example) and meets your other requirements (multiple cores via multiprocessing, OpenGl, etc). C# is next easier (you do have to declare variable types, but, like Python and PHP, it manages memory on your behalf) but the multi-platform aspects (everywhere but on Windows you'd have to rely on the Mono project) are less convincing; Java might still offer a better "multiplatform" experience, though for other aspects C# is richer (but, they're two languages with basically similar power and difficulty).

C++ is definitely going to be the hardest one (you have to manage your memory as well as declare things), but also the most powerful (as you get to manage your memory, as well as doing everything you mention and much more besides).

So, it's your call: how much do you value ease of learning / transition / use, vs sheer power, flexibility, multiplatform goodness, and the like? The right choice may depend on what relative weight you put on these factors. As for the book, if you pick Python (I won't recommend my own books as that would surely be biased;-), Wesley Chun's Core Python may be best; if C++, my favorite is Lippman's, Lajoie's and Moo's "C++ Primer". Not sure what books are best for C# (or Java).

Alex Martelli
Thank you, that was exactly the kind of answer I was looking for. And sorry SO for making this inappropriate answer.
Daniel S
The Core Java book by Horstman is a good book
jpartogi
In modern C++ though, if you're doing it right, the amount of (explicit) memory management you have to do is almost negligible. The "doing it right" part is the hard bit of course, C++ is not an easy language.
DrJokepu
A: 

PHP is more similar in syntax to C / C++ than Python, but Python is easier to learn and more modern.

If you're on Windows, you might like to try C# or if not, Java. Both of these languages have a C++ style syntax but are easier to learn than C++.

Adam Pierce
I don't think C# is really cross platform even with Mono.
jpartogi
A: 

"Cross platform" is a bit too general. What, exactly do you want to do across platforms?

Rich internet platforms like Silverlight and Flash/Flex are definitely cross browser, and will run outside of the browser on Windows and Mac.

If you want a programming language that you can use in any environment, then C++, Python, Ruby, and Java are strong choices (also C# if you're willing to consider Mono), but that does not guarantee that code you write on one platform will run well (or at all) on other platforms. The problem isn't the languages as much as interfacing to the operating system, platform-specific libraries, user interface platforms, etc. Portability is hard, and probably won't get easier when you look at coming problems like highly parallel programming.

You don't say exactly why cross-platform is important; that may also shape your choice. Particular application or service types? Particular tools that you like that happen to also be cross-platform? Are you interested in application code, infrastructure code, platform code?

My personal bias is towards C# and .NET. The next version of .NET is going to have some awesome parallel programming tools and greatly improved threading models. WPF and Silverlight are exciting on the graphics front, but that's much higher level than DirectX or OpenGL, so it depends very much on your goals.

Cylon Cat
I want to be able to have my applications on many platforms simply because I am a full supporter of Linux and Open Source in general, I don't really want to create more windows-only applications. I think I'll go with C# and Mono, as you said I'm starting to like the .Net framework.
Daniel S
.NET has a significant open source community, even on the Windows side of the world. Drop by http://www.codeplex.com/ and take a look. Some of these projects are collaboration between MS development teams and open source community..NET's interop story is also pretty good. Silverlight runs in pretty much all browsers and all platforms (needs Moonlight for Linux, but it's there and MS will redirect users who need to download). WCF supports all WS-* standards and can use SOAP, JSON, or REST protocols. LINQ has an excellent model for parsing, searching, and updating XML.
Cylon Cat
A: 

Flex, Flash, and the AIR Platform could be your best bet.
Failing that, mastering the Mozilla XUL Platform might be the way to go.

Both platforms are already cross-platform, and you'd only need to build your application once, and it should run across all OS that support the platform (Mac, Windows, Linux, and more)

phalacee
+1  A: 

I really liked Alex Martelli's answer, but I would add a couple more ideas. In terms of ease of use, you could try Visual Basic or REALbasic. Both would get you windowed programs very quickly, and REALbasic would definitely be cross-platform in that it allows you to compile for Mac, Linux, or Windows easily. However, I'm not sure how much control either one gives over use of multiple cores or multiprocessing.

Like Alex Martelli said, there are a lot of options, so you can really pick whichever suits you best, but whichever you pick, I wouldn't rely on only one book to learn it. Since learning a programming language takes time and patience, use several books, friends, and the internet to teach yourself the language and the logic. And you might consider getting books on Computer Science in general (for example, The Art of Computer Programming by Donald E. Knuth).

Abinadi
Thanks for that link! It was very helpful :)
Daniel S