Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jan 26, 2013, 03:44 PM   #1
Astroblu
macrumors newbie
 
Join Date: Aug 2012
Starting to learn to program. (C++)

Hi, I'm currently trying to learn how to program. I'm 15 and I only know basic Java. I've decided to attempt C++ but I have no idea how to start, I will try look up some tutorials and maybe buy a book about it but what I'm really asking is what can I use C++ for? I have a mac and I know that Xcode has an option for C++ but what kind of things can I do with the language after learning it? I just struggle trying to grasp the whole concept of a programming language and I'd really like someone to explain it to me. I'm not sure if I explained what I'm trying to say very well but if you understand, can you please help!
Astroblu is offline   0 Reply With Quote
Old Jan 26, 2013, 06:13 PM   #2
lee1210
macrumors 68040
 
lee1210's Avatar
 
Join Date: Jan 2005
Location: Dallas, TX
You can do anything with C++. You can do anything with Java. The edge cases are generally interaction with the OS or hardware, and that's not something you should worry about right now. Is there something you need to do that Java can't handle? Is there something that you feel you need C++ for? There's nothing wrong with learning a new language, but it might just confuse things for you right now. I think a more important question than what C++ can do is what do you want to do? If it's learning a new language, then C++ will work. If it's something else, maybe there are better options.

-Lee
lee1210 is offline   0 Reply With Quote
Old Jan 26, 2013, 10:11 PM   #3
ytk
macrumors regular
 
Join Date: Jul 2010
That's like saying “I'm learning to fly and I'm attempting to start on a 747”. I know a bunch of people here will disagree with me, but having started pretty much the same way as you (nearly two decades ago), I'd say you'd be much better off tackling a higher level language like Perl, Python, or Ruby first. Personally, I'm a fan of Ruby, but I can see a good argument for Perl or Python as providing a more “traditional” approach to programming (Ruby does a lot of things differently from—and in my opinion, better than—most other languages).

Higher level languages take care of a lot of the low-level stuff like declaring variables and memory management for you, so you can focus on learning the theory of programming. There will be a time in your programming career (whether or not you pursue it professionally—I never did) when you will want or need to learn about pointers, type conversion, memory management, and other concepts that I would describe as things you just need to know because you need to know them, not because they necessarily have anything to do with the art of writing code. Understanding those things will make you a better programmer, but they are very hard to grasp for newcomers, and your time is better spent learning the basics like functions, control structures, and objects. You'll make much more progress more quickly with a higher level language, and more importantly you'll understand what you're doing, rather than simply copying code out of a book because the book says to do it.
ytk is offline   0 Reply With Quote
Old Jan 27, 2013, 01:24 PM   #4
iSee
macrumors 68030
 
iSee's Avatar
 
Join Date: Oct 2004
I would start by focusing on something you want to make.

There are an almost infinite number of ways to go. So the problem is that you will get lost in the options and never get very far in any direction. If you focus on the goal (especially if it's something you want to do, because you won't have to struggle as much with motivation) -- you can pretty much figure out which way to go without wandering too much. ("Wandering" is not exactly a bad thing when you are learning, but you need to go somewhere at some point too.)

So I suggest: pick something you want to make, post it here, and (most) people will give you good and specific advice on a path to accomplish it.
Keep your first goal very modest, because there is plenty of software development stuff you will have to learn even for a simple goal.

E.g., if you are generally interested in programming games, start with tic-tac-toe or whatever, not Assassin's Creed 3.

All that said, I'll give you my perspective (as a C++ programmer for about 20 years): You can use C++ to develop almost anything. For performance-critical things it's not too hard to write code that compiles to very efficient machine code. And it supports a wide variety of high-level concepts for higher-level code. However, it has some drawbacks: (1) it is very difficult to master. It will let you do things wrong in so many ways it takes a long time to learn how not to do things wrong; (2) I don't think you can say it is the "native" language of any major application platform. E.g., it is possible to develop Mac OS X apps using C++, but realistically you will probably end up doing Objective-C++ (which is roughly C++ combined with Objective-C) because a lot of the frameworks the you will want to use to work with OS X are Objective-C. And if you're going to use Objective-C frameworks, it's usually a lot simpler to just use Objective-C.

In my opinion, C++ is difficult to master and has become a niche language, so I wouldn't make it one of the first languages I learned. If you are interested in OS X or iOS, I'd go to Objective-C, for Windows, I'd learn C#, and for Android, I'd continue with Java.
__________________
"Nobody ever reads these things so I can write anything. I'd eat bananas every day if they were crunchy."
iSee is offline   0 Reply With Quote
Old Jan 28, 2013, 06:46 AM   #5
ArtOfWarfare
macrumors 603
 
ArtOfWarfare's Avatar
 
Join Date: Nov 2007
Send a message via Skype™ to ArtOfWarfare
Quote:
Originally Posted by iSee View Post
In my opinion, C++ is difficult to master and has become a niche language, so I wouldn't make it one of the first languages I learned. If you are interested in OS X or iOS, I'd go to Objective-C, for Windows, I'd learn C#, and for Android, I'd continue with Java.
Interesting. I agree with your assessment of Objective-C for OS X/iOS and Java for Android, but C++ is a niche language and C# is what is used for Windows? I'm a Computer Engineering student and I don't know anyone who knows C# but I know plenty of people who only know C++.

My understanding is that you can't write native code for Windows (everything is run by a virtual machine, regardless of language) so I just use Java given all its performance problems go right out the window if everything else is going to be run in a virtual machine just the same anyways. I might be mistaken, though – I hardly have any experience with Windows at all... what I stated is what I found from Wikipedia.

I think learning higher level languages first is the wrong approach. I think you should learn C first... nothing is handled for your automagically. You have a decent idea about what exactly is going on on your computer when your code is executing. I think assembly might be better still, but it's so platform dependent and the odds of you ever needing to work with it directly are slim to none.... so... learn C first, is my suggestion.

I suggest learning from Learn C The Hard Way:

http://c.learncodethehardway.org/book/
__________________
Don't tell me Macs don't last: 2007 iMac, 2007 Mac Mini, 2008 MacBook Air, all Vintage.
(iMac obsoletion: April 28, 2015, MBA: October 14, 2015, Mac Mini: March 9, 2016)

Last edited by ArtOfWarfare; Jan 28, 2013 at 06:53 AM.
ArtOfWarfare is online now   0 Reply With Quote
Old Jan 28, 2013, 07:38 AM   #6
960design
macrumors 6502a
 
Join Date: Apr 2012
Location: Destin, FL
Writing Java since 1996, works on everything, can do everything my little mind can imagine. Java protects you much better from developing bad habits that can lead to huge headaches of C++ ( although those headaches, when done properly is what makes the code extremely fast ).

Java is very much like C++. Focus on getting java perfected, then when you wish add C++. It will be a very easy transition, plus you'd have solidified good programming habits.

If you want to code for Mac, you need to learn Objective-C. Objective C is not really much like C++ at all. Objective C is exactly C with additional libraries. Pure C will compile under XCode, but C++ will not.

I currently do web and mobile developemnt, so I use a smattering of Java, Objective-C, and PHP ( I think that is all, that is all I used so far today, anyway ).

Pick a project and start working on it, when you get stuck, post your code and ask your questions. We like answering, it makes us feel smart.
__________________
TI-99/4A, tape cassette, 12" B&W Zenith
960design is offline   0 Reply With Quote
Old Jan 28, 2013, 07:57 AM   #7
jon3543
macrumors 6502
 
Join Date: Sep 2010
Quote:
Originally Posted by ArtOfWarfare View Post
My understanding is that you can't write native code for Windows (everything is run by a virtual machine, regardless of language) so I just use Java given all its performance problems go right out the window if everything else is going to be run in a virtual machine just the same anyways. I might be mistaken, though – I hardly have any experience with Windows at all... what I stated is what I found from Wikipedia.
Whatever you read, it was either incorrect, or you misunderstood it. Didn't you find it at least a little hard to believe that you "can't write native code for Windows"?

Quote:
I think learning higher level languages first is the wrong approach. I think you should learn C first... nothing is handled for your automagically. You have a decent idea about what exactly is going on on your computer when your code is executing. I think assembly might be better still, but it's so platform dependent and the odds of you ever needing to work with it directly are slim to none.... so... learn C first, is my suggestion.
Just learn C++. It is almost a proper superset of C, and Stroustrup was fond of noting that every program in K&R is a C++ program. The question really should be, do you want to learn procedural programming vs. OOP or generic programming? That will dicate your focus in C++. I can't think of any more pointless approach than to learn assembly language first.
jon3543 is offline   0 Reply With Quote
Old Jan 28, 2013, 08:04 AM   #8
balamw
Moderator
 
balamw's Avatar
 
Join Date: Aug 2005
Location: New England, USA
Quote:
Originally Posted by iSee View Post
I would start by focusing on something you want to make.
This. The language is a bit of an afterthought, a means to an end. What is your goal?

If you already know some Java, stick with it until something you want to do with it is easier to do in another environment/language.

B
__________________
MBA (13" 1.7 GHz 128GB), UMBP (15" SD 2.8 GHz), UMB (13" 2.4 GHz), iMac (17" Yonah), 32GB iPad 3 WiFi+LTE, 64 GB iPad WiFi, 32 GB iPhone 5, Airport Extreme
balamw is offline   0 Reply With Quote
Old Jan 28, 2013, 08:30 AM   #9
ArtOfWarfare
macrumors 603
 
ArtOfWarfare's Avatar
 
Join Date: Nov 2007
Send a message via Skype™ to ArtOfWarfare
Quote:
Originally Posted by jon3543 View Post
Whatever you read, it was either incorrect, or you misunderstood it. Didn't you find it at least a little hard to believe that you "can't write native code for Windows"?
I was/am still under the impression that all applications written in C#, VB.NET, or any other language were compiled to CIL bytecode, which the CRL then interprets at execution time... with the CLR being a virtual machine not unlike a JVM for Java bytecode.

Here's the page that makes me think that:

http://en.wikipedia.org/wiki/Common_Language_Runtime
__________________
Don't tell me Macs don't last: 2007 iMac, 2007 Mac Mini, 2008 MacBook Air, all Vintage.
(iMac obsoletion: April 28, 2015, MBA: October 14, 2015, Mac Mini: March 9, 2016)
ArtOfWarfare is online now   0 Reply With Quote
Old Jan 28, 2013, 08:39 AM   #10
balamw
Moderator
 
balamw's Avatar
 
Join Date: Aug 2005
Location: New England, USA
Quote:
Originally Posted by ArtOfWarfare View Post
I was/am still under the impression that all applications written in C#, VB.NET, or any other language were compiled to CIL bytecode, which the CRL then interprets at execution time... with the CLR being a virtual machine not unlike a JVM for Java bytecode.
This is generally true for those languages, but Visual C++ can generate either managed code under the CLR or not (a.k.a. "native" Win32 applications).

http://en.wikipedia.org/wiki/Managed_code

EDIT: I think one additional wrinkle here is that "Metro" apps are all managed. That's how they can work on both x86 and ARM/RT.

B
__________________
MBA (13" 1.7 GHz 128GB), UMBP (15" SD 2.8 GHz), UMB (13" 2.4 GHz), iMac (17" Yonah), 32GB iPad 3 WiFi+LTE, 64 GB iPad WiFi, 32 GB iPhone 5, Airport Extreme

Last edited by balamw; Jan 28, 2013 at 08:45 AM.
balamw is offline   0 Reply With Quote
Old Jan 28, 2013, 12:57 PM   #11
jon3543
macrumors 6502
 
Join Date: Sep 2010
Quote:
Originally Posted by balamw View Post
This is generally true for those languages, but Visual C++ can generate either managed code under the CLR or not (a.k.a. "native" Win32 applications).

http://en.wikipedia.org/wiki/Managed_code
C++/CLI was a major improvement over the original managed extensions, but I don't know to what extent it caught on. I think most people writing managed code use C#. C++ remains the primary language for native code. Most of the programs I use day to day are native code.

Quote:
EDIT: I think one additional wrinkle here is that "Metro" apps are all managed. That's how they can work on both x86 and ARM/RT.
Sounds right, but I'm happily mostly ignorant about "Metro" and plan to remain that way.
jon3543 is offline   0 Reply With Quote
Old Jan 28, 2013, 03:04 PM   #12
Persifleur
macrumors member
 
Join Date: Jun 2005
Location: London, UK
Quote:
Originally Posted by balamw View Post
EDIT: I think one additional wrinkle here is that "Metro" apps are all managed. That's how they can work on both x86 and ARM/RT.
I believe you can write Metro apps in C++/CX, which compiles to native code. If you deigned to do such a thing...
Persifleur is offline   0 Reply With Quote
Old Jan 28, 2013, 07:27 PM   #13
Yoder54
macrumors newbie
 
Join Date: Mar 2009
Your problem seems to be one of understanding the concepts of computer programming. I started teaching computer programming in the mid-80's, and taught at both the college level and high school for over 25 years. I also worked in industry as a software engineer for six years. It is hard work learning how to be a good programmer, but I bet I would be correct in assuming that most of us here who have done much programming are primarily self-taught (especially us older folk, and to think we did it without the internet.) So, it can be done.

I admire your desire to learn programming at your age, and will be honest in telling you the most teenagers give up rather quickly. The primary problem seems to be two-fold. First, programming is very abstract in some ways, but pure logic at its core. This is a concept that the still developing brain has a problem grasping. Finally, the computer does what it is told to do and nothing more. Unfortunately, far too many teenagers are driven by "instant gratification" and lack the patience to learn a language.

Many good arguments are given above in the above posts, but it seems that your primary concern is to learn the format of computer languages, and just what it is that drives them. From an educational perspective Java would be easier to learn than C++, but in my experiences I would not consider it the best language to use to teach/learn OOP. I always found Pascal to be one of the easiest languages to teach, and loved using myself. You may wonder why I am suggesting that you learn an antiquated language? For me, learning to program is like playing cards...master one, two or three different card games and learning any others is a piece of cake. The same applies to computer programming, learn/master (I use the term "master" lightly) one or two higher languages and then it is merely an issue of learning the idiosyncrasies of a "new" language before you have mastered it also.

There are some free Pascal compilers out there that run on OS X:
You may find the role of Pascal and Apple Computers rather interesting when you learn about it in your studies.

A great resource about anything having to do with computer can be found at: http://www.dmoz.org/Computers/

MIT also offers numerous FREE courses in almost any field of study including computer programming and electrical engineering: http://ocw.mit.edu/courses/electrica...puter-science/

I have taken correspondence courses from Cal Berkeley in the past. http://extension.berkeley.edu/catalog/prolang.html They were cheap at the time for college courses (you also get college credit), you get help from the instructor, and now they have forums where students can discuss their projects. They are many online course out there. Some are cheap (U of Texas Austin, or any Texas school for that matter) and some are insanely expensive (Penn State.)

What you seem to want is a structured learning program that you can do on your own (get a compiler, find tutorials/books on the Web, etc.) or one that you can do with others (instructors, students, etc.) I would suggest that if you do it on your own that you find an existing course syllabus and adopt it,. You will also need good resources, and must have the patience/drive to find solutions on your own. A big problem with high school students is that they want to jump straight to the end while doing little in the middle.

Finally, I always found that I learned the most when I would come up with a program that I wanted to write and start writing it. There were always the little things that I had to battle with that taught more than I ever learned in a classroom.

Regardless of the language you choose, or the method you use...Good luck
Yoder54 is offline   2 Reply With Quote
Old Jan 29, 2013, 06:20 AM   #14
N-M
macrumors newbie
 
Join Date: Jan 2013
Quote:
Originally Posted by iSee View Post
If you are interested in OS X or iOS, I'd go to Objective-C, for Windows, I'd learn C#, and for Android, I'd continue with Java.
Yeah, or just go the easy way and learn C++ to cover OS X, iOS, Android, Windows Phone, Windows, and Linux.

At least that's what's been the experience of most who are actually in the business:
http://blog.algolia.com/need-perform...ile-use-c-cpp/
http://blog.burhum.com/post/36166554...pp-development
http://www.infoworld.com/t/mobile-de...p-dev-c-208770

If you need a framework (make sure you actually do -- the beauty of C++ is that it lets you make this decision), check out Qt: http://qt.digia.com/

One advice -- ignore the tutorials. 99.9% of what you'll find on-line is gonna be, politely speaking, outdated, useless crap (written by people stuck in the 1990s who still think that you *have* to manage resources manually when using C++ ;]).

Instead, get a good *recent* book (so it covers modern C++11) and go through it *systematically*; I recommend: http://www.informit.com/title/032174113
N-M is offline   0 Reply With Quote
Old Jan 29, 2013, 09:36 AM   #15
notjustjay
macrumors 603
 
notjustjay's Avatar
 
Join Date: Sep 2003
Location: Canada, eh?
Quote:
Originally Posted by Yoder54 View Post
I admire your desire to learn programming at your age, and will be honest in telling you the most teenagers give up rather quickly. The primary problem seems to be two-fold. First, programming is very abstract in some ways, but pure logic at its core. This is a concept that the still developing brain has a problem grasping. Finally, the computer does what it is told to do and nothing more. Unfortunately, far too many teenagers are driven by "instant gratification" and lack the patience to learn a language.
I learned programming as a teenager (even earlier, actually; my first programs, though stupidly simple, was when I was about 11). I remember having an Apple ][ in my room from grades 6 to 8. Back then there was no internet and hardly any video gaming so if you sat down at a computer you were either going to fire up something like Oregon Trail or WordStar or you were going to learn to program it yourself. So I did.

I found I was quite good at thinking through logic puzzles and as a socially awkward child in the 80's, the computer was a welcome relief from the puzzling world of junior high. People were hard to understand (especially girls! ) but it was nice to know that I could always get the computer to do exactly what I wanted, it was simply a matter of figuring out how to tell it.
__________________
.
notjustjay is offline   0 Reply With Quote
Old Jan 29, 2013, 10:07 AM   #16
robvas
macrumors 68000
 
Join Date: Mar 2009
Location: USA
I find to be 'successful' programmer you only need two things:

The drive/obsession to think up a project and stick with it
Enough technical know-how to get it done

Note that you don't need to do things the 'right' way or write the best code. So much software out there is a huge mess of a product. But it gets job X done so it sells.

Becoming a 'good' programmer is another story. That involves another level of self-discipline and being fortunate enough to have at least one great mentor, as well as having a very deep knowledge of the domain you are working in. And it's always a bonus to have a knack for something else like design.
robvas is offline   0 Reply With Quote
Old Jan 29, 2013, 01:25 PM   #17
notjustjay
macrumors 603
 
notjustjay's Avatar
 
Join Date: Sep 2003
Location: Canada, eh?
Quote:
Originally Posted by robvas View Post
I find to be 'successful' programmer you only need two things:

The drive/obsession to think up a project and stick with it
Enough technical know-how to get it done

Note that you don't need to do things the 'right' way or write the best code. So much software out there is a huge mess of a product. But it gets job X done so it sells.
Having the drive will force you to improve your code. You will go through the agony of working with previously-written, undocumented, buggy code and then you will come to your senses and write better code the next time. Plus a good programmer is always reading about best practices, learning new tricks from copy/pasting examples, etc.

But that first one is key. You must want to do something. Whatever that is. "I want to learn how to program" should not be the end, but the means to get something done. That's what sets apart people like Linus Torvalds, Tim Berners-Lee, Steve Wozniak, etc -- who have visions of great ideas and want to get them done -- from the guy who picks up a magazine and says "Ooh, it says here that programming could be a good way to earn money, I should learn."
__________________
.
notjustjay is offline   0 Reply With Quote
Old Jan 29, 2013, 01:49 PM   #18
balamw
Moderator
 
balamw's Avatar
 
Join Date: Aug 2005
Location: New England, USA
Quote:
Originally Posted by notjustjay View Post
You will go through the agony of working with previously-written, undocumented, buggy code and then you will come to your senses and write better code the next time.
Doesn't seem familiar at all.

That's why I recommend learning about revision control systems early. It can really help you understand how code can be a living/evolving thing.

B
__________________
MBA (13" 1.7 GHz 128GB), UMBP (15" SD 2.8 GHz), UMB (13" 2.4 GHz), iMac (17" Yonah), 32GB iPad 3 WiFi+LTE, 64 GB iPad WiFi, 32 GB iPhone 5, Airport Extreme
balamw is offline   0 Reply With Quote
Old Jan 29, 2013, 01:59 PM   #19
Cromulent
macrumors 603
 
Cromulent's Avatar
 
Join Date: Oct 2006
Location: The Land of Hope and Glory
Quote:
Originally Posted by notjustjay View Post
Plus a good programmer is always reading about best practices, learning new tricks from copy/pasting examples, etc.
That doesn't just apply to programmers. If you want to be good at anything then you will constantly need to update your skills. Learning is a life long process. It never stops. Ever.
__________________
Neural Advance - Mac OS X, UNIX and Windows Development
Last.fm Profile | Extreme Metal Reviews
MP 4x 2.66Ghz Xeons / 6GB RAM / 640GB + 500GB + 750GB + 1TB HDDs / ATI Radeon 4870 / iPad 3
Cromulent is offline   0 Reply With Quote
Old Jan 29, 2013, 09:30 PM   #20
iSee
macrumors 68030
 
iSee's Avatar
 
Join Date: Oct 2004
Quote:
Originally Posted by ArtOfWarfare View Post
Interesting. I agree with your assessment of Objective-C for OS X/iOS and Java for Android, but C++ is a niche language and C# is what is used for Windows? I'm a Computer Engineering student and I don't know anyone who knows C# but I know plenty of people who only know C++.

My understanding is that you can't write native code for Windows (everything is run by a virtual machine, regardless of language) so I just use Java given all its performance problems go right out the window if everything else is going to be run in a virtual machine just the same anyways. I might be mistaken, though – I hardly have any experience with Windows at all... what I stated is what I found from Wikipedia.
...
Well, the OP is new to programming, so admittedly, I was over-simplifying. I think the chances of him actually doing and learning something is increased greatly by using the best supported language for whatever platform he wants to target. It just means he'll get to concentrate more on the interesting bits of programming more than the tedious bits (no worries, there will still be plenty of those). It'll be easier to find tutorials, sample code, documentation, someone to answer questions, etc.

On the topic of over-simplying: Windows, in particular, allows for a massive number of different languages, platforms, frameworks, engines, etc., many of which are reasonable or at least arguable for a particular situation. It's hard to say there's one best language for Windows. And, it's true, C++ remains quite well supported as a development language and gives you a lot of flexibility and allows for very good performance if you know what you are doing. But the cost of that is complexity and that there are so many more ways to go wrong. Also, there are just not that many things you actually need C++ for. IMO, choosing C++ because you think you might need the performance is an extreme case of premature optimization. Build your app, profile, simplify the design to remove layers and transformations (code that doesn't execute is much, much more efficient than the best optimized code). Then, if it's still too slow, optimize that bit in C or C++ or whatever. If you really feel that performance is ultimately going to be your ultimate bottleneck, design for it by letting the anticipated bottlenecks to be parallelized/distributed.

Sorry, probably too much blathering there.

Quickly, to clear up a few misconceptions, just for your information:
You can write native code for Windows in various ways.
Over the last decade (roughly, not looking at a calendar here) it seems like MS has put the bulk of their efforts to support general development into various .NET frameworks, which do run in the CLI (sort of like a Java VM environment), which isn't quite "native". The features and capabilities of these frameworks is massive, so a lot of apps choose to use them and usually are written in a "managed" language themselves. So its true a lot of apps aren't "native" but that's by choice (usually for good, practical reasons).
Interestingly, MS's latest application framework, for windows store apps, has a native implementation. They reimplemented a bunch of .net interfaces in code that compiles to native machine code (I'm guessing they used C++, but I have no direct knowledge -- C is possible as well.) It's pretty clear they did this to provide a competitive platform for mobile (ARM) platforms. The windows store apps you write on top of the platform APIs can be managed (C# or, I think, VB.NET), C++, or (most interestingly) Javascript.

Anyway: the windows world is all over the place. But when in doubt, C# has to be the default. They add native language support to C# whenever they come up with a clever new idea (it's await/async these days, I think, unless I've gotten a cycle behind.)



Quote:
Originally Posted by N-M View Post
Yeah, or just go the easy way and learn C++ to cover OS X, iOS, Android, Windows Phone, Windows, and Linux.

At least that's what's been the experience of most who are actually in the business:
http://blog.algolia.com/need-perform...ile-use-c-cpp/
http://blog.burhum.com/post/36166554...pp-development
http://www.infoworld.com/t/mobile-de...p-dev-c-208770
...
Well, I've been in the business (including cross-platform development for ~7 years) more years than I care to admit. C++ *is* the Mike Tyson of cross-platform development languages (this analogy would work better if Tyson was unbeatable in the '90's rather than the '80's). But so what? Judicious use of C++ is an answer to the question, how can I develop software for multiple platforms without rewriting/porting for each platform (especially high-performance software). It's not a good answer for getting started in programming for most situations. (Also, you should read the articles you're linking to carefully. They don't suggest that C++ "covers" those platforms. One is by a newb IOS developer who may not fully understand how to optimize objective-c code -- e.g., there's nothing forcing you to send messages in your inner loops. The third one is an indirect sales pitch by a guy with a cross-platform C++ solution to sell. There's a reason it's title ends with a question mark. And the middle one -- the only experienced developer without an axe to grind -- it suggesting C++ as a cross-platform language use to implement parts of an app, mixed with native code and doesn't exactly suggest it's a panacea.) Don't get me wrong. I love C++. It's probably my "native" language. But I review C++ code routinely, written by smart, experienced programmers that nevertheless contains serious flaws. If the OP wants to start with K2, then fine. If he can climb it with little experience and preparations, then great! But that's not where I'm going to recommend someone start.

Wow, what a long and rambling post. Sorry, just unwinding after a long day. Oh well, what else is the internet for, anyway?
__________________
"Nobody ever reads these things so I can write anything. I'd eat bananas every day if they were crunchy."
iSee is offline   0 Reply With Quote
Old Jan 30, 2013, 07:24 AM   #21
N-M
macrumors newbie
 
Join Date: Jan 2013
Quote:
Originally Posted by iSee View Post
Well, I've been in the business (including cross-platform development for ~7 years) more years than I care to admit. C++ *is* the Mike Tyson of cross-platform development languages (this analogy would work better if Tyson was unbeatable in the '90's rather than the '80's). But so what? Judicious use of C++ is an answer to the question, how can I develop software for multiple platforms without rewriting/porting for each platform (especially high-performance software). It's not a good answer for getting started in programming for most situations. (Also, you should read the articles you're linking to carefully. They don't suggest that C++ "covers" those platforms. One is by a newb IOS developer who may not fully understand how to optimize objective-c code -- e.g., there's nothing forcing you to send messages in your inner loops. The third one is an indirect sales pitch by a guy with a cross-platform C++ solution to sell. There's a reason it's title ends with a question mark. And the middle one -- the only experienced developer without an axe to grind -- it suggesting C++ as a cross-platform language use to implement parts of an app, mixed with native code and doesn't exactly suggest it's a panacea.) Don't get me wrong. I love C++. It's probably my "native" language. But I review C++ code routinely, written by smart, experienced programmers that nevertheless contains serious flaws. If the OP wants to start with K2, then fine. If he can climb it with little experience and preparations, then great! But that's not where I'm going to recommend someone start.

Wow, what a long and rambling post. Sorry, just unwinding after a long day. Oh well, what else is the internet for, anyway?
I see your points, I also have a few notes:

- for me goals like "programming for most situations" are too vague to be meaningful; I'd even say that such a thing as an "average developer" is more of a statistical concept than any real person at any point in time, we all have different needs -- if we were going by what's the "majority" using (and majority isn't necessarily equal to average), we'd have to stop at suggesting OP learns PHP + JavaScript. Clearly, as OP states he/she already knows Java (so, pending clarification from the OP, my working assumption is that he/she's not "just starting"), this is not guaranteed to be the way to go (although that's also why it would really help if OP stated what the goals are);

- yeah, "covers all" is not to be understood as "is perfect for all", nothing is a panacea, I think we agree on this one; it's just that sometimes imperfect solution with hurdles is still better than no solution at all -- e.g., Objective-C is simply not used outside of Apple ecosystem; so, even if admittedly one might have a hard time with C++'s learning curve (although it would be rather controversial to say that Obj-C is any easier for someone coming from Java, BTW), one is going to face an infinitely hard (read: mission impossible) time with adopting Obj-C for all of the other mentioned platforms;

// Regarding Windows, there's a tremendous amount of work Microsoft is putting into C++ support, DirectX is the officially recommended way for graphics-intensive Windows Store apps: http://msdn.microsoft.com/en-us/libr.../br229580.aspx
// one may also point out DirectXTK which some describe as "XNA for C++": http://blogs.msdn.com/b/chuckw/archi...directxtk.aspx

- I don't think the first author is that much of a "newb", 2004 doesn't sound like yesterday:
http://www.reddit.com/r/cpp/comments...rmance/c71efh8
Further, there's an important point to be made here -- often, others like to criticize C++ for complexity, while forgetting the fact that it's all relative and there's an inherent complexity in the available alternatives. In this case, you may criticize him claiming that spending 8 years on Obj-C is not enough and spending more would theoretically make him a better programmer -- but in practice, he was simply more productive in C++. Statements like "C++ might result in lower productivity" are a myth -- you have to qualify "productivity compared to W in task X when doing Y given knowing Z", and then you might often find it's the best available choice after all;

- going back to "it's relative" -- I still think that learning C++ and the minimal amount of copy-pasting occasionally necessary to invoke it is easier, faster, and more productive than learning three different programming languages and re-writing the code three times; this was (and is) my main point of contention: "OS X or iOS, I'd go to Objective-C, for Windows, I'd learn C#, and for Android, I'd continue with Java";

- that being said, you're right if it turns out that, for instance, OP prefers to gamble on only one of the above-mentioned platforms being relevant (there are strong reasons to focus on mastering the platform-specific tool-chain in such a case);

- I don't agree with your reading of the third one, given that it cites several sources with differing viewpoints (note not all agree on the conclusion, BTW);

- serious flaws will crop up in any code base written in any language over time. For instance, anyone claiming that Java makes the memory mgmt. situation any better hasn't seen a java.lang.NullPointerException flood. Also, production Java code isn't as clean as on-line discussions / textbooks like to present, often littered with annotations, workarounds to suppress warnings, etc. Note I'm not saying all that to criticize Java. Instead, this is a so-far-unavoidable result of the fact that complexity is a simple fact of life. A good way to reduce or alleviate the flaws is to follow modern, best practices from the start, which requires learning them ASAP. That's why I feel comfortable stating that over 99% of on-line tutorials for C++ do more harm than good and are to be avoided, suggesting systematically going through a good, recent book instead (for instance, most of the resource management bugs in pre-C++11 are nearly impossible to make now, and resource management used to be the major criticism against C++).

Last edited by N-M; Jan 30, 2013 at 07:43 AM.
N-M is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Where to learn? gadgetgirl85 iPhone/iPad Programming 5 May 31, 2014 04:59 PM
I want to learn to DJ Miguel760 MacBook Pro 5 Dec 31, 2013 08:58 AM
Looking for courses to help me learn to program (for credit) crafty184 iPhone/iPad Programming 1 Mar 21, 2013 01:32 PM
How do I learn more about OS X? nj908 Mac Programming 2 Aug 6, 2012 09:07 PM

Forum Jump

All times are GMT -5. The time now is 07:20 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC