C++ coming from Java and Objective-C - java

So, I know both Java and Objective-C quite well, but (perhaps strangely) never really learned C++. Obviously, the languages are all related, but there are syntactical differences that I don't fully understand. Is there a nice document that describes the basics of C++, but still assumes the learner knows a programming language? Perhaps even a tutorial that aims to describe the differences between the languages. This is what I'm looking for.
Also, is there a good tutorial on how to use C++ code inside a Mac or iOS app? The reason I feel the need to learn C++ is I'm trying to port a C++ program, and I heard you can use C++ code and just wrap it in an Obj-C GUI. Could someone point me to some documentation/tutorials on how to do this?
Thanks!

Even though the languages of this family are all related, that does not mean that you can casually move from one to the other and expect to write beautiful code. You have to learn the language's idioms and idiosyncrasies, and experience its strengths and way of thinking.
I would recommend reading Stroustrup's original book (a modern edition, of course). It's the most definitive reference (short of the actual standard) and it is very clearly written. The benefit of this approach is that you will be taught to think "how would I do this in C++", rather than "how do I transliterate this piece of Java code to make it compile". (Also this approach does away with any risk you might have of thinking you should "learn C first". Don't.)
On MacOSX, either download and build the free GCC, or get XCode (which comes with GCC). For iOS I don't know, I have a suspicion that you cannot deploy native code on it.

I would go for a pure C++ route, the quality of the material being the guide rather than finding ObjC+Java->C++ material.
At the university I am working for we have tried both ways for teaching C++ to students with a lot of programming experience, in particular Java experience, for obvious reasons.
The conclusion was that the specialized course did no better in teaching C++ than the generic one with some extra exercise materials. It's the quality of the teaching materials that matters.
Edit: You will probably receive a lot of good answers on the actual differences, also Voo's comment on your question is relevant.

I know what you feel - to have already worked on a couple of languages and learning C++. I was in the same boat too. While I was thinking for a while that it should be easy for me to learn it right away, it wasn't all that easy. So then I went back to the basics and started as a fresher to learn C++. 'C++ Primer' is an extremely good book to start with. Since you know most of the basics of programming, some of the first few chapters can be skimmed through. Once you are through with this, I'd recommend 'Effective C++' book and the C++ FAQs maintained here [http://www.parashift.com/c++-faq-lite/].
In fact, you could go through this FAQ first and see how much of it makes sense, and use that as a guide for figuring out where to do a deep dive.
HTH, K

Related

Clojure presentation for beginners?

I need to make a presentation for beginners about the Clojure language. What are your suggestions on selecting topics on it? What are the points I need to include?
Note: By beginners, I mean that they are experienced in other programming paradigms, but not in the functional programming model.
I personally think this presentation is a great introduction to Clojure:
Clojure:Functional Concurrency for the JVM - Howard M. Lewis Ship
And obviously any presentation by Rich Hickey himself, for example
Clojure: A dynamic programming language for the JVM
You've got to think about your target audience. I'm going to make an assumption that they probably know Java.
The best authority on Clojure is the source himself, Rich Hickey. He's written an introduction to Clojure for Java Programmers.
Slides are here.
Him giving the presentation with audio is here and part2 is here.
If need, you can take my presentation about Clojure - PDF is freely available...
I found this blog entry yesterday -- impressive how easy is to make Clojure programs parallel (pmap in place of map :D ). Sadly, on my PC it didn't run on multiple cores but I haven't investigated it yet.
Use examples from books like Joy of Clojure -- they are very idiomatic and well designed. In this book there are also reasons on design of language and -- what is most important to you -- why functions+immutability is better for multithreaded programming than procedures+OO mutability.
Yes, I think parallelism is important to tell. But also -- in my opinion -- it is always crucial to convince non-lisp-listeners that The Parentheses Hell is not a hell but blessing ;) Tell about Beating the Averages and why Lisps are the most powerful languages in the world.
Try not to teach them a language but show why to learn it.
Oh, and prepare that someone in the audience will ask "why no for loop" or "why no constants" or "how come immutability doesn't lead to performance problems".
I would demonstrate the basics of the language by firing up a REPL and running through a bunch of basic language features, slowly building up to something more interesting.
This Clojure quick tutorial gist may give you some ideas.

What Visual C++ references are worth a look for a Java programmer looking to get up to speed?

I have a lot of experience with Java/OO. There are tons of C++ tutorials/references out there, but I was wondering if there are a few key ones that a Java programmer might find useful when making the transition.
I will be moving from server-side J2EE to Windows Visual C++ desktop programming.
I have googled and found tons of resources, but am overwhelmed and don't know where to best spend my time. I have only a few days to get a good start.
Is Visual Studio Express / Microsoft Visual C++ the best IDE for me to start with?
Also, any words of wisdom from others who know and work with both languages?
The widely recommended books here are Scott Meyers Effective series. "Effective C++", "More Effective C++" and "Effective STL".
I would also recommend the C++ FAQ Lite and The C++ Programming Language.
I have been in these shoes before and I constantly find myself referring to two sources:
The first is C plus plus reference
Here you will find the basic standard C and C++ libraries that you will always need. They are the bread and butter.
The second is Microsoft's Visual Studio Development Center.
Here you'll find the linker error support for Visual Studio and their built in libraries.
Don't forget to give Visual Assist a try! Quite often intellisense breaks in VS2005 if your doing some serious business, though I can't speak for newer versions.
Good luck!
Visual C++ is a good way to go, you can get the express version for free from here
As far as books It really depends what you want to do. I like the Horton book as far as learning Visual C++, GUI, CLR and Database programming. The Lippman book is a very good tutorial on C++, but it only covers the basic language, which is large.
This will get you going with basic
constructs.(Lippman)
This will get you going with Visual
C++.(Horton)
Once you get past the basics then look at the Meyers books, as stated in other answers.
Effective C++: 55 Specific Ways to Improve Your Programs and Designs (3rd Edition)
There are a couple of others from this author, they are real good but have not been updated in a long time.
A real good online C++ FAQ is here.
If you put a comment stating what you plan to do with C++, we could give you narrower guidance to point you in the direction you want to go in
If to choose only one book for high-quality development - Scott Meyers "Effective C++". Because there are some quirks in C++, and you will definitely hit them without this (or few similar) book. Also reading it is a pleasure (hence you can read it fast), because of a mix of humor and easy to understand insightful points.
But it's not a tutorial though.
I haven't ever tried "fast" tutorial, but here is pretty good looking tutorial. I think it's perfect for experienced programmer - short articles explaining distinct language features with some examples and comments

Going from PHP to C/C++ & Java & beyond

I've been a LAMP developer for 5+ years. I have learned quite a bit on my own, but I feel like my "context" as a software developer is limited (ie. I can only create scripts & web applications). Ultimately I'd like to be able to create a range of applications from daemons to desktop apps. Additionally I'd like to learn more about the "internals" of programming (ie. PHP is a wrapper for c, perhaps I should learn more c?)
I'd like to know what resources & methods that have helped people further their knowledge of computer science / software creation. Unfortunately I don't think I'll be able to go back to school and get another degree :-P
If you want to jump in with both feet, there's MIT's Open Courseware. For example, here's the online version of the famous course "6.001 Structure and Interpretation of Computer Programs".
To take smaller steps, I'd suggest learning other programming languages that are complementary to PHP, like Python or Ruby. Maybe eventually Java. The more languages you learn, the easier it becomes to learn even more languages, or to deepen the knowledge you have of the languages you already know.
I would really recommend Stroustrup's excellent book to learn modern C++ :)
I don't recommend that you directly move to the MIT course ware and SICP. Start from some basics. Read the "C Programming Language" by Brian Kernighan and Dennis Ritchie. Write some C extensions to PHP. After you are comfortable with C move on to C++ (Read "The C++ Programming Language" by Bjarne Stroustrup) or Java (tons of documentation and tutorial are available at http://java.sun.com/). Note that the books you choose are important. While learning a new language, a book written by it's creator should be preferred, as it will show you the right idioms, which is very important. Then move on to learn about new paradigms, like functional programming. At this point I think SICP will be a good choice. Learn one or more functional languages - Lisp/Scheme, Clojure, Haskell etc.
Make it a point that you never stop learning!
Pick a language, then seek out resources for learning it.
The one thing I'd suggest is to treat C, C++ and Java as sibling languages. Don't think "If I start with C, I can proceed to C++ and then to Java" or similar. Each of them can and should be learned independently of the others.
Java is often said to be inspired by C++, which any C++ programmer can see is clear nonsense. It is inspired by the earliest versions of C++, the ones that had more in common with C. And likewise, C and C++ have little in common as well. Good C code is almost guaranteed to be horrible C++ code.
All three languages are worth learning, and all of them will probably teach you a lot about programming. So pick one, and buy a good book on it.
Have a look over at Stanford's online courses it is a great place to start programming in more complex languages.
the site has both java and c++ courses online and much more.
When i started to learn PHP i found this really good site http://tizag.com
It kept all the stuff i needed to learn basic.. When any complex programming was required i looked else where, However without tizag being my cheat sheet for web bassed languages i would have been lost;
My cheat sheet for C++ was http://cplusplus.com/doc/tutorial/
Its basic stuff, with very clear explination. However i do recomand you try coding the examples rather than just read over it.
Practice Makes Perfect (Speaking of Which gota beat Suzuka in GT5 Proluge in under 1:33:487)
Get a job as a starting C++ developer. A bit of fiddling around at home isn't going to do much good, except for getting your foot in the door at an interview. To get to that level, anything is good - Accelerated C++ being a good book, or The C++ Programming Language (quite hard to learn the basics from, but if you're proficient in other languages its doable).
Everyone here made great recommendations, here are my two cents to the lot. You can learn language internals, there is no dearth of them. There is so much to learn about them that you can go on for years. I suggest you read Art of Programming by Donald Knuth, it was a great experience for me and I don't know why it is not a standard textbook in our universities.
Programming is an art indeed and it's the only art I know.

What is the best approach for a Java developer to learn C++ [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I consider myself an experienced Java developer and am planning to get started with learning C++.
If you had same experience, i.e learn C++ after Java, I would like to hear your thoughts on what is the best approach at doing this.
[Update] "the best approach" was not well quantified. What I am looking for is to leverage my existing java knowledge and programming experience so that I can quickly ramp up on C++.
I've taught C++ to Java people, even though I learned them the other direction.
Are you comfortable with C? If not, read Kernighan and Ritchie. Many many peculiarities of C++ are explained by the desire for C++ to be a "Better C" with C's basic expression syntax.
You should get Stroustrup.
I think well of Thinking in C++ by Bruce Eckels.
I've used The C++ FAQ Book, by Cline, Lomow, and Girou; I refer to it pretty often. Marshall Cline has C++ FAQ content on his site, too.
Update
You might also look at C++ for Java Programmers. I don't know the book but it looks decent.
My proposal would be to write highly pointer-based thing, like a linked list library, BST library, etc. The code should be STL-free, similar to pure C. You should build application using such library (eg. sort algorithms?) and learn how to deal with all the pitfalls which will for sure come up, if it's your first C/C++ code.
In my opinion the most important fundamental in knowing C++ is to understand pointers and low level memory representation of classes and structures. It's like an enlightenment after which everything is simple and clear ;)
I would start with Effective C++ and More Effective C++ by Scott Meyers. These two books go over some really good best-practices for C++.
http://www.aristeia.com/books.html
Others have already specified the required books. I would like to add just couple of points to be noted: ( as background is java)
C++ doesnot provide you the Garbage
collection ( as in Java). Hence, you
must be very perticular about memory leaks. Always use delete the memory allocated on heap using new.
Try to remember the Free-Store
management in FAQ while writing
the C++ applications.
Most often in C++ you may have to
work with pointers ( missing in
Java). Learn pointers ( books
suggested by #Charlie Martin)
effectively and use them.
One you are familiar with C++, learn
the basics of STL and use
effectively. ( Book By Josuttis
and Scott Meyers)
Good luck.
I strongly disagree with learning C first, and with trying tgo learn C++ from the Effective books, excellent though they are. Instead, get hold of a copy of Accelerated C++ by Andrew Koenig and Barabra Moo - this is written by two of the original C++ development group and will teach you how to use modern C++ features.
"C++ for Java Programmers" by Mark Allen Weiss is a good intro book for seasoned Java programmers.
Andy and Charlie already gave you the books, so I will indicate the boost libraries and the Qt framework.
Boost gives you some basic functions to work with so you don't need to create everything from scratch.
Qt, as you may know, is a GUI framework, and I find it very enjoyable to use. There is a book called "C++ GUI Programming With Qt 4" that covers all the important topics to learn Qt.
This is going to sound a little funny, but you asked for the best way, not the quickest. I'd suggest you start by learning C first, before you learn C++. Kernighan and Ritchie is one of the best language books ever written. When you know C and Java, you'll be able to write good, clear programs in a sensible subset of C++ with almost no additional effort.
Learn Qt. Trust me on this; I'm both a Java and C++ developer; I can tell you Qt makes C++ language closer to Java. Don't just learn the bare-bone C++.
C++ with Qt makes you infinitely more productive. I used to combine so many different libraries (Boost, Intel's, database connectors, etc..) just to achieve the kind of stuff we do (high-performance/real-time computing). At the end, I found that more than 80% of what I need is already included in Qt.
Not to mention, imo, Qt has the best documentation on any framework/library I've worked on, which makes it very easy to just learn everything on your own.
Try it, and see for yourself.
Disclaimer: I'm just a developer--I dont work for Nokia. =p
K&R and Stroustrup are classics, and eventually you should get them, but I don't think they are good introduction for C++ beginners. Thinking in modern C++ is thinking in classes, templates, exceptions, and streams, none of which available in C language.
I would recommend a college-level textbook on C++ like Deitel and Deitel.
After playing around, you should focus on learning to write a class that behaves like a built-in class. That means providing a copy constructor, operator=, operator==, operator<<, etc.. Along the way you'll meet various concepts embedded in the language of C++. I would agree with others on Effective C++ is a must read once you are comfortable with the basics.

Which sector of software industry uses C++? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
Locked. This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions.
Like most people, I learnt C++ after C. I learnt C++ because it was one of those languages which fetched jobs. I am still studying (doing masters) though. One of my cousins has been working as a developer for around 12 years.
He advises me to learn Java so that I can land up in a good job. He says only few sectors like tele communications use C++ and almost all the enterprise software is developed in Java. I am working as a student technician in my university. The job involves Windows programming in C++. I learnt core Java. I do not know any of those Struts, Hibernate or whatever is out there.
To be on the safer side, I am planning to master both. But I think Java is an ocean, though it's easier to program in Java than C++ (this is my opinion. C++ lovers don't kill me).
What do you geeks and professionals out there advise me. Do you think I should learn both of them. Which sectors of the software industry use C++?
Best advice I ever got as an undergraduate was from my languages professor, who told me (paraphrasing here): "Don't memorize languages; don't marry yourself to a language. They're just tools. They all do the same basic things. Instead of learning a specific language, learn the foundations of good software development. Then you'll be able to take any language and be successful with it."
I feared learning new languages before he told me that. Afterwords, I took his advice to heart and it's made all the difference. Languages are just tools in your toolbox. If you can program and write good software in one language, you can do it in another.
C++ is still used extensively for performance intensive tasks. For example, I do a lot of work with video compression and decompression - it's all C++. Partly because we need the performance, and partly because all the 3rd party libraries which need to use are C++ so it's easier to integrate with them if we're using the same language.
A brief off-the-top-of-my-head listing of projects that use C++:
Device driver development
Games
Advanced engines (audio, image processing, etc)
Telecom
Embedded software (devices and such)
C++ is not even close to being dead.
My experience:
Bloomberg, Reuters, and all their bank/trading clients who want low latency market data feeds use C++. (Fidelity, JPMorgan, BNP, Citibank, etc.)
The defense industry uses C++. (among other languages - Java is also popular)
These industries also use java and other languages, but C++ is hard to beat. Note also that there is a HUGE existing C++ code base that will take a long time to go away (if ever)
It is not hard to know and use them both. Don't worry too much about a particular language. That is not the real crux of developing software.
Some site calling itself Google reckons it uses C++ extensively. Thank God they don't need performance to index the few websites out there.
If this Interweb thingy takes off, they'll be in real trouble though. (-:
Seriously though, apart from the current change of channel (reversion?) to C and Perl, the previous four projects were all C++.
a large scale departure control system for several of the world's major airlines (30,000 10MB log files per day)
a flight training simulator and ground based software proving platform for a new military aircraft
a large scale framework for an existing air-traffic control simulator that was used to incorporate the new Aeronautical Telecommunications Network (ATN)
an advanced radar processing and display system for an on-route air traffic control centre
All really interesing.
Video games still use C++. One example that comes to mind is the Torque engine which can be used for iphone and xbox game development.
C++ is not anywhere close to being dead, and as suggested by others, don't marry yourself to a language.
If you're learning C++ in terms of job prospects, I'd rather suggest you pick up a representative of a programming paradigm.
C - Imperative programming
C++/Java/Obj-C - OOP
Lisp/Haskell/Scheme - Functional Programming
Getting adjusted to the paradigms is usually harder than picking up the language itself. Hope others would chime in for other suggestions.
Many defense contractors, especially when dealing with hardware, use C++
Many makers of advanced medical equipment (e.g., MRIs) use C++.
I say learn both if you can. It's good to have the C++ foundation even if you end up in a sandboxed language like C++/C#. Too many people don't understand the basics.
Note that different cities have a majority of jobs in a specific language. Go to the craigslist job boards for the city you think you'd end up in and see what they seek. For example, Pittsburgh is a C# town whereas New York is more balanced.
C++ is still used extensively in engineering applications, such as high-end CAD/CAM systems.
I think the death of native code is much exaggerated. Even Microsoft has backed away from making C++ all about .NET in Visual Studio 2008. It seems to be actively improving its native C++ development tools again as well as making interop with the managed world more easy.
My advice, learn C#. These days almost 50% of the job listings were Java and almost the other 50% were C#, there were only a few listing C++.
That said, the people using C++ know why they are using it and probably have good use cases for it... meaning you would really learn how to use the language at the highest levels... meanwhile companies slogging out business logic applications in Java/C# will probably not teach you as much about programming as quickly.
If you do decide to take a C++ job, make sure the shop uses the STL effectively and that they are using Boost. Not looking at using Boost/STL, but actually using it.
Keywords: Banking (financial institutions), games
Oh, and also particle physicists and other scientists using the (in)famous ROOT framework.
And check out this list of C++ based applications.
Bjarne Stroustrup has a list of companies/applications written in C++.
Your university didn't have any Java based courses? That's odd!!
You should learn not just C++ and Java, but should be exposed to several languages and paradigms
I tend to agree with your cousin. Java definitely is used in more enterprise applications (think things that a bank or insurance company would need), while C++ is used in more "niche" markets. I also agree with you that Java is easier to learn and master than C++. No shame or offense in admitting that.
We use both where I work, writing embedded software in C++, but communicating with it from GUI apps written in Java. There's definitely plenty of room in the software industry for both (and many more) languages.
Most packaged software is still written in C++. That means games, office applications, graphics and video editors, and operating systems. In fact, if you think of the software you use every day that isn't online, chances are it is written in C++ (or C or objective-C). It's not written in Java, Python, Ruby, Perl, etc. While packaged software is becoming less prevalent, it's still used a whole lot and isn't going away anytime soon.
Operating systems, whether embedded or for the desktop are almost exclusively written in some C language. Attempts have been made to write them in Java or C#, but none of those have worked out. All of your drivers are written in some C variant as well. I don't see this changing any time soon.
Java is great until you have to start caring about the details it abstracts away. Most people don't need to do that.
My advice is to master whichever language you enjoy more. I know C++ and Java well, and have used both professionally. However, I would never accept another C++ job because I find C++ tedious and mind-numbing. I rather invest my time mastering more interesting languages.
I've been writing in C++ primarily for internal and external desktop applications within manufacturing and telecom companies for a long time, and only worked full time with Java for about 1 year out of 16.
Java never seemed to take over the desktop like they were predicting back in the mid 90s when it first came out, and now C++ seems to have more competition from .net and AJAX/web applications.
I can't really speak for it's use in back end systems, but I have seen more of it there than I've seen C++, so it depends of what kind of programming you are talking about (e.g. user facing vs. internal systems).
Well I suggest learning more than a couple languages. I work in the communications industry and yes we use C++, however a lot of projects we are working on are in Java as well.
I suggest you learn:
1) C++ / C
2) Java
3) Erlang or Haskel
4) Ruby
This will help you understand concepts that exist in one language but not in another. Also helps with marketability.
Take a look at the tiobe programming index and you will get a feel for languages on the rise.
C++ is heavily used in embedded systems.
It is being used in UI development. For eg. famous QT framework is written in C++.
Ultimately it depends on what you want to do. If you want to work in embedded systems, better learn C/C++.
I use C and C++ regularly at my job where I work on embedded devices. We're not talking super low level stuff, here, either. I do mid-level and UI work. Think Qt, Gtk+, Windows Mobile SDK, etc.
C++ is heavily used by ISVs. Think Microsoft, Adobe, Oracle, Sun, Symantec...
Game industry looks like go with C++ forever.
I had to scroll all the way to the bottom to finally see a post mentioning video games. C and C++ are huge in that industry.
As far as the "What should I learn question." That's pretty open ended, you want to learn as much as possible. So yes, you should learn both of them. As a few people have said, C# is a good one too. You should also learn Python, Ruby, or PHP and some web frameworks (Rails, Symfony, Django, ASP.Net). Web apps are pretty big these days.
If your bubble consists of only C++ you aren't going to be very marketable.
EDIT: Oops, I guess games were mentioned a lot more than I initially saw in here. My bad.
In my career I've developed C++ for:
Server applications (Securities industry)
Embedded software (Wireless telecoms)
Desktop application software (Wireless telecoms)
I've also seen a lot of adverts for C++ developers in the defense industry. There is work out there for C++ developers, not as much as there has been in the past, but still plenty of work.
Though I say it wouldn't hurt to learn Java, it is a good skill to have under your belt.

Categories

Resources