Hi to everyone, i'm a beginner and you will realize it when you read my question.
I'm learning C++ with the Principles of C++ by Stroustrup, and reading some cpp forums etc. But i see all the exploits or low level *nix (mostly) applications are written in basic C (a lots of uses of strcpy and company, arrays and so on).

So...am i making a mistake by learning C++? I want to undersand and even code my applications/exploits or whatever i may need, and i have the feeling i'm walking in the wrong way.

Thank you!

PD: i choosed CPP cause i wanted to code some day "real" GUI applicatoins for whatever use, i still don't know but probaby network/security oriented, of course there's a looong path to go through yet but i'm in no hurry.

If you're interested in security, exploits, reverse engineering and the likes, I would most definitely advise you to learn C. Learn C, and some x86 assembly won't do you harm either.

As for a higher level, general purpose, language for coding "normal" applications... learn Python. It's a great language, and it's actually well thought out, as opposed to C++.

Regarding C++... My personal advice would be: don't bother with it. It's neither a good low level language, nor a good high level language. It tries to be both, and fails in both counts. There are certainly much better high level languages out there -- Python being an excellent example... or Perl... (Lisp and Haskell are very nice too, but those are niche languages, leave those for later).

Of course, in these matters, others will have different opinions. Some will swear by Perl instead of Python, some will say Java is good, some will defend C++.

My advice is to try as much as you can, over time. The more different languages you learn, the wider your point of view will be. To begin with, though... learn C to get a solid foundation (other languages just hide too much, they work magically and you learn nothing), and Python to be a productive programmer.

I knew IT pro like you would code in C because that's what i've been seeing in exploits and scripts etc, but, discouraging me to learn C++? I though it was an excellent language that's why i choosed. Cause i'm told it was photoshop's language, and also windows, and other huge programs where coded with it.
And i'm already at page 150 of C++ Stroustrup book! hahah lol
Also C++ is supposed to be good (i'm talking from a beginner's prespective of course) because it's object oriented, and that seems to be the new sensation of coding.
I think python ain't OOP right?

I learned some python back in the days, in school, and i gotta tell you i liked it. But, can you make "real apps" with it? I'm so lost in this matter too, because a part from VB, all i see is console apps, so it's hard for me to imagin that you can code a Superscan, or a Firefox, really hard.

Learning various languages is definately my dream, but i have to start first with one, and i'm willing to be very good at any language, to have gone to the end of it and really know how to code at least in ONE languge.

I knew IT pro like you would code in C because that's what i've been seeing in exploits and scripts etc, but, discouraging me to learn C++? I though it was an excellent language that's why i choosed. Cause i'm told it was photoshop's language, and also windows, and other huge programs where coded with it.
And i'm already at page 150 of C++ Stroustrup book! hahah lol

Don't take me wrong, there are many people using C++ out there. It is widely used, although I wouldn't know whether or not Photoshop was done in C++ -- being as though it's proprietary and closed source. Windows, on the other hand, I can tell you it used to be done in C, at least up to a couple versions ago... (don't ask me how I know that )

Looking at this from a popularity point of view, Python definitely wouldn't rank first. Within the general purpose languages, globally the most popular are probably Java and C++. As in, you'll find Java "programmers" anywhere you look. Then again, the most popular OS is Windows... popularity doesn't necessarily mean quality.

There's always a matter of personal taste when choosing a programming language. Many low level programmers have a strong dislike for C++... The whole thing is just an inelegant mess, from a language design and implementation point of view. "Little" details such as there being no well-defined ABI (Application Binary Interface), meaning there's no portable way to link a C++ library (DLL in Windows-speak) unless it was compiled with the exact same compiler (and same compiler settings) you're using.

J0k3us wrote:

Also C++ is supposed to be good (i'm talking from a beginner's prespective of course) because it's object oriented, and that seems to be the new sensation of coding.
I think python ain't OOP right?

Oh, Python is most definitely OOP! Much more so than C++, mind you... For starters, in Python, everything is an object. Also, things like multiple inheritance and operator overloading are actually done right and can be used in a simple way.

The neat thing about Python, though, is its flexibility. It's dynamically typed (more precisely, duck-typed), functions are first-class objects (meaning you can manipulate a function like you would any other variable, create new functions, new code, at runtime)... It also lends itself very well to neat things such as metaprogramming (Python's function decorators rock), and you can even stretch it somewhat to use some functional programming (although for purely functional programming, other languages such as Haskell would be more directly suited).

For me, personally, Python is that language where "programming is fun again". It's well thought out and it "just works". Of course, others will prefer Perl. Some will say C++, some will say Java. Some might even say Ruby. In the end, it's a matter of finding what fits you best.

J0k3rus wrote:

I learned some python back in the days, in school, and i gotta tell you i liked it. But, can you make "real apps" with it? I'm so lost in this matter too, because a part from VB, all i see is console apps, so it's hard for me to imagin that you can code a Superscan, or a Firefox, really hard.

Google uses Python as the backend for Gmail, Google maps and other services. Youtube uses it for their site, and Industrial Light and Magic used it in their rendering process for Star Wars II, and other movies. [*] Real enough for ya?

As for GUIs, you can indeed program GUI applications in Python. You've got Python bindings to several GUI toolkits, such as PyQt and PyGtk for example, or wxPython. And the beauty of it is, all of these are cross-platform!

J0k3rus wrote:

Learning various languages is definately my dream, but i have to start first with one, and i'm willing to be very good at any language, to have gone to the end of it and really know how to code at least in ONE languge.

In the end, programming languages are tools for a job. Most of the time it just comes down to which tool helps you the most in what you want to achieve, and of course which tool works best for you.

If you want to have some knowledge of how things work on the inside (which you will certainly need if you have an interest in security), I strongly recommend you take the time to become proficient at C. Don't just treat it as "eh I changed something now it's working, dunno why, who cares" -- make yourself know why things are happening. Make yourself know every aspect of the syntax and semantics of the language. C will teach you the discipline it takes to be a good programmer at any language.

Mastering C will take some time, though. And while I very much love the language, I do admit it's not the best for quickly producing something largeish that works. Part of the fun in learning to program is being able to see things happening in front of you. For that, I'd recommend... Python

Looking at this from a popularity point of view, Python definitely wouldn't rank first. Within the general purpose languages, globally the most popular are probably Java and C++. As in, you'll find Java "programmers" anywhere you look. Then again, the most popular OS is Windows... popularity doesn't necessarily mean quality.

Yes, i didn't look it that way. I've checked all the links you wrote me in this post and i have really seen through examples that Java (and therefore C++ for its code-structure similarity) are extremely ofuscated and verbose in comparsion to python. I wonder why python doesn't have a better rank. If it's OOP, so easy to write and recall things of it, you can GUI through wxWidgets or whatever..
I found this chart:

It's a 7th place in that chart.

capi wrote:

There's always a matter of personal taste when choosing a programming language. Many low level programmers have a strong dislike for C++... The whole thing is just an inelegant mess, from a language design and implementation point of view. "Little" details such as there being no well-defined ABI (Application Binary Interface), meaning there's no portable way to link a C++ library (DLL in Windows-speak) unless it was compiled with the exact same compiler (and same compiler settings) you're using.

Although it was supposed to be a better version of C right? That's what i suppose the ++ stand for.

capi wrote:

For me, personally, Python is that language where "programming is fun again". It's well thought out and it "just works". Of course, others will prefer Perl. Some will say C++, some will say Java. Some might even say Ruby. In the end, it's a matter of finding what fits you best.

But everyone fits to the same thing right? We all want those "pros", flexibility, simplicity, reliability etc
That's what bumbs my head on python's rank and popularity.

capi wrote:

Google uses Python as the backend for Gmail, Google maps and other services. Youtube uses it for their site, and Industrial Light and Magic used it in their rendering process for Star Wars II, and other movies. [*] Real enough for ya?

More or less, cause all those examples are "back" processes, such as rendering processes and stuff like that. But now that i think i've understood how GUI stuff works, i kind of see every language is almost as efficient as others in creating real apps, because all of them can get to GUI toolkits (as i read wxWidgets supports a lot of languages including python) so you wouldn't even notice which language has a program built in. I can't wait to create my first GUI app!

capi wrote:

If you want to have some knowledge of how things work on the inside (which you will certainly need if you have an interest in security), I strongly recommend you take the time to become proficient at C. Don't just treat it as "eh I changed something now it's working, dunno why, who cares" -- make yourself know why things are happening. Make yourself know every aspect of the syntax and semantics of the language. C will teach you the discipline it takes to be a good programmer at any language.

Mastering C will take some time, though. And while I very much love the language, I do admit it's not the best for quickly producing something largeish that works. Part of the fun in learning to program is being able to see things happening in front of you. For that, I'd recommend... Python

I've been always like that. I've always wanted to know how things worked so down that sometimes i event lost the initial point, so i even have to brake myself in that matter

You definately convinced me, specially on learning C. I makes me sad somehow because i was very focused on C++ and i see is the language that have a huge support in form of forums etc but i think i won't be isolated either with C.

About python...i though you need to supplay some kind of libraries or something like that so it can run on a computer? I mean, python does not compile into a *.EXE right? (maybe that's the "con" i was searching haha) (EDIT: ok i just discovered py2exe, i hope it will work with wx/GUI scripts)

Thank you, i am learning a lot.

BTW would you happen to know a very good C learning tutorial, maybe focused on security matter?

EDIT: oh BTW, my books just arrived! Among of them is the art of explotation which it doesn't look easy but i expected it to be worst.

Sorry for not having replied, it's been a busy couple of weeks at work. I haven't had much time for the forum, and when I do manage to be here it's usually to delete some spam -- you wouldn't believe how much of our time here we moderators spend on deleting spam and dealing with other nuisances...

It is unfortunate that our programming forum has been rather quiet in recent months. I was hoping someone else might be able to pitch in to the thread to liven things up...

In answer to your question about learning resources, I'll quote myself from a previous post:

I wrote:

As for learning resources, I'm afraid I can't really recommend anything from personal experience. My knowledge of C comes from many years of experience; there is no one resource I used to learn, and I wouldn't know about what's currently out there anyway. Perhaps others here may suggest something, though.

What I do of course heartily recommend is familiarizing yourself with the official C99 standard, available from the WG14 standards page. This is definitely not light reading, though. If you're like me and like to learn from formal specifications then you'll enjoy reading the standard. Otherwise, at least keep it around for reference.

Apart from that: practice, practice, practice. Nothing beats practice. Write code, lots of it. Read code, lots of it. Take advantage of the free software philosophy and learn as much as you can by reading code written by others. When you don't understand something, experiment with it. When you do understand something, try to understand why it was done that way. When you know why it was done that way, try to think of better ways to do it. Improve on what you read, and while you're at it share what you've improved with the rest of the world

hi.
i advice you that c++ is better langhage.in c you reate 32 variale name but in c++ no limitation of use of variable.input & output functionality is also diffirent in both.c++ use cascading style for input & output.you can also cerate class & you can publicaly or privatly store the data.you can also create inhetitance,constracter & destuctor.you can use same name varible in different data tyep & in c you can not use dataoverloading functionalitiy.

tonyadams, if you're going to post something please take the time to do so in a proper and readable way. Using abbreviations and skipping letters and words not only looks ugly and unprofessional, it also makes it very hard to read what you type.

tonyadams wrote:

i advice you that c++ is better langhage.

"Better" is a relative concept. There are languages which are better suited for specific tasks, there are languages which are more or less readable, there are languages which are faster or slower. But there is no "better" language, period.

tonyadams wrote:

in c you reate 32 variale name but in c++ no limitation of use of variable.

I'm not sure what you're saying here, but if what you're trying to say is "in C you can only create variables with a length of 32 characters", that is just wrong. Or if what you're trying to say is "in C you can only create 32 variables" then that is just absurd.

I would suggest that you read the specification of the C language. Specifically, section 6.4.2 of the C99 standard, defining identifiers:

Quote:

An identiﬁer is a sequence of nondigit characters (including the underscore _, the
lowercase and uppercase Latin letters, and other characters) and digits, which designates
one or more entities as described in 6.2.1. Lowercase and uppercase letters are distinct.
There is no speciﬁc limit on the maximum length of an identiﬁer.

Some obsolete compilers had technical limitations on the variable length, or other arbitrary things such as the number of nested function calls. This is an implementation problem, though, and has nothing to do with the language itself. And you really don't want to go into implementation problems when it comes to C++ compilers...

Incidentally, if you routinely use 40-character variables in your code, I would humbly suggest that You're Doing It Wrong.

tonyadams wrote:

input & output functionality is also diffirent in both.c++ use cascading style for input & output.

I have absolutely no idea what you're talking about here.

tonyadams wrote:

you can also cerate class & you can publicaly or privatly store the data.you can also create inhetitance,constracter & destuctor.

Uh, yes, because C++ is an object-oriented language, whereas C is not. Your point being? Do you honestly believe that OOP is the end-all-be-all of programming?

Besides, C++ isn't even a purely object-oriented language... No, and Java isn't a purely object-oriented langauge either. If you want true OOP, go with Smalltalk. Or Ruby. Or Python.

tonyadams wrote:

you can use same name varible in different data tyep & in c you can not use dataoverloading functionalitiy.

Wrong. You can't "use same name variable in different data type" in C++. C++ is statically typed: data types are associated with variables, not values. You declare a variable as int, it's going to be an int forever. What you said applies to dynamically typed languages, such as Lisp, Prolog or (you guessed it) Python.

What you probably meant to say was "you can use functions with the same name to work with different data types", something also known as "method overloading". Again, your point being? C is not an object-oriented language. Everything depends on what you're trying to achieve, and how you go about it.

Try using C++ for anything involving shared libraries. You know them, right? They're called DLLs in Windows. I'm sure you'll have fun trying to get your users to be able to actually use your DLL when there is no standard ABI.

It would sure be fun to see C++ in a kernel executive, too. Who cares about the bloat, right? A language that's bloated by design, produces bloated binaries and whose source code is massively unreadable with all the bureaucracy -- there's a winning mix.

I could also say that Python is a better language than C++ because functions in C++ aren't first class objects. Or because multiple inheritance actually works and makes sense in Python. Or because Python does everything you said C++ could do (even the stuff that wasn't true) and more.

I've been away from this place for a (very) long time. I periodically stop by to read a few of the latest posts and see if things have improved, but usually I don't stick around long enough to write a response to anything.

That said, I feel I must make some comments here...

Python is a great language; it makes programming fun again, is flexible and powerful, and is even fast, all things considered. I've been using Python a lot in recent years, including for GUI programming and physics simulation and reconstruction work. Those last fields require fast, efficient software, and it is possible to write such software in Python (of course, it will always run faster in C, C++, etc. but will probably take a lot longer to write, debug and maintain. It's a trade-off.

C is also a good language; it's been around forever, it's fast and powerful. The disadvantage to C, these days, is that people expect all of the wonderful functionality of languages such as Python. If you want that functionality, use Python. If you want speed, control and power, use C. This is why C still dominates the operating system and device driver market, as well as many other fields which require high levels of control over memory or hardware.

In all of these points, I agree completely with capi. (Nothing new there, though most current forum members probably don't recall the lengthy discussions which were once the norm in the programming forum)

Where I disagree is on the topic of C++; I happen to like C++, and I have my reasons. Actually, I don't disagree on any of the specific points capi makes regarding C++, but I would say that it can be very useful, and very rewarding to learn. On the other hand, C++ is a very large language. By this I mean that there are a great many aspects to it, and it is very difficult to learn them all (or even most of them). I've been programming in C++ for around 12 years now and I still don't know everything... I probably never will.

The fact of the matter is that C++ has its uses, although these days they are mostly localised into fields with a history of C++ use. One of those fields is particle physics, where the vast majority of modern simulation and analysis code is written in C++. (It used to be FORTRAN, so we're gradually getting better).

The code is written in C++ because it lets us do the things we want to do, quickly and efficiently. The problem with this is that it requires physicists, who don't necessarily know a lot about programming, to code in C++. C++ is not a good language for people who are just 'trying to get something done'. We have a fairly unique problem here, trying to balance the requirement for power and efficiency with the requirement to have something users (that is, physicists working on their data analysis) can code parts of. Python is just too slow for some aspects of simulation and data analysis (but great for others!), while C doesn't readily provide the structure you need to write software in a large collaboration. The "solution", then, appears to be C++. It's close enough to C to allow those writing the core system to make it fast and efficient, and it's friendlier than C for people who want to make an object and manipulate it.

Personally, I'd rather see something like a C/C++ backend, written by physicists with a proven track-record in programming, coupled to something like a Python front end so that users can write their analysis code in Python, and defer the computationally intensive work to the C/C++ backend, but we don't live in an ideal world.

The point I'm trying to make here is that there is no single answer to the question of which programming language(s) to learn. One should pick up two or three languages to use on a regular basis---C and Python should probably be amongst those, the third you're at liberty to choose for yourself---but never forget that you should always use the language most suited to the task. If that happens to be one you don't know yet, go learn it. Chances are, once you've been programming for a year or two, you'll pick up new languages in almost no time; at least to the level of being able to make something that does the job.

My laptop battery is about to run out, so I have to end this post now. I probably didn't make all of the points I wanted to, and I'm sure capi will tear apart my argument for C++ having its place, but I just wanted to put across the point that, while some languages might be better designed (Python; seriously, learn Python, it is fantastic!), it is always worth keeping an open mind (except where Java is concerned; avoid that like the plague )

Both are very important in programming language. There is some differences between them. Such C++ is slower than C. C is a procedure oriented language while C++ is a object oriented programming language. As my personal view is C. Because it is basic and wide compare to C++. So you have to learn it.

Ah, no. C++ is not "slower than C". Identical code compiled with a C or C++ compiler will perform broadly the same. Don't forget that (almost) all valid C is valid C++.

If you start to use some of the additional features C++ provides, you will incur overheads. Knowing about these; where they occur, and what the effects are, is important when comparing C to C++. Note that in many cases, a C++ feature is implemented in broadly the same way one might choose to do the same task in pure C; virtual member functions are implemented through a lookup table and a couple of pointers, while in C one might obtain the same functionality in a similar way. In many cases, C++ simply provides features that people have been manually implementing in C for a long time.

The difference is that these things are much easier to do in C++; perhaps too easy. People incur overheads without realising it. By coding a C routine to look up a value in a table and run the function pointed to, you know the overhead of the lookup and indirection. By calling a virtual C++ member function, you can easily forget what goes on in the background.

My point is that, while many of the extra features C++ provides incur overheads, these (or similar) would be precisely the same if the same mechanism was implemented in pure C. There are some situations where this argument doesn't hold; using the std::string class is likely to be slower than using a char*, but it has other advantages. It's all about a tradeoff between speed and expressiveness, and between speed and safety. Those tradeoffs exist in C just as in C++; some of them are just more hidden in C++.