Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

C++, java, or python programming

  1. Mar 24, 2012 #1
    i know this topic has been discussed, but i would really want a direct reply and soon
    Do i have to learn java or c++ in order for me to learn how to be a hacker?... good intentions off course, for security and privacy needs... please let me know. Thank you.
  2. jcsd
  3. Mar 24, 2012 #2


    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    I would say that starting out by learning a low-level language in which you actually have to worry about things like data types and memory allocation is better than starting out with high-level language where such things are abstracted away from you. The former case forces you to think about what's actually going on.
  4. Mar 24, 2012 #3

    Get a good basis in C (for example), then C++ will be a piece of cake. Java has quite dropped out of fashion, I'd prefer Python to that.
  5. Mar 24, 2012 #4
    awesome.. thanks guys...
  6. Mar 25, 2012 #5
    I respectfully disagree.

    Having used all three, I say you should start with Python. Apart from being the easiest to learn, it's also much easier to actually learn to become a programmer in Python. Because, first of all, you spend much less time doing lower-level stuff and thus more time actually producing useful code; second, the other two forcing you to think about what's actually going on on a lower level is *not* useful for a beginner. You don't *need* to know what's 'actually happening in the CPU' if you want to learn programming - if that's what you want to learn, start with assembly. Personally, I found it much easier to first learn good programming and *then* learn how the bits and bytes moved around, not to mention that the latter actually only becomes useful *after* you've gained some proficiency in programming. :wink:
  7. Mar 25, 2012 #6
    C++ is an extremely versatile language, if you want, you don't need to use all the low level C stuff, you can start out just using STL and later picking up pointers etc. later. There is also a lot of learning material available for C++ and a large community, but this of course is valid for JAVA and Python as well.
    What do you eventually want to accomplish?
  8. Mar 25, 2012 #7
    thanks man... I'm using a website called codeacademy... really helps a lot....
  9. Mar 25, 2012 #8
    my facebook , computer has been hacked, so I want to learn how to secure my browsers, files and so on....
  10. Mar 25, 2012 #9
    Then you should study how browsers, networks, operating systems etc work. Learning to program will not make you an expert in the field of security, although it's crucial if you want to make tools yourself.

    But from this description seems you should 1) use strong passwords 2) use security software firewall/antivirus.
  11. Mar 25, 2012 #10
    You don't need to know programming for that. Use strong passwords, DON'T reuse your passwords, and don't try to install every little piece of software you find on the web. :smile:
  12. Mar 30, 2012 #11
    A 'hacker' is a term so generic and overused that it almost has no meaning. If I had to define a hacker I define it as someone with a deep understanding of how computers work, with a drive to constantly learn more.

    This is similar to a car mechanic. Generally if one has an interest in cars one will spend a lot of time trying to figure out how they work, taking them apart, and making improvements. Eventually they will build up more and more knowledge. There will be no point at which they are suddenly a mechanic (ignore professional mechanics for this analogy, as realistically no one is going to employ you as a hacker).

    If you have a deep interest in how computers work you will seek out knowledge and eventually develop an equally deep understanding. If you simply want to learn what is necessary to protect yourself online, then there are plenty of simple guides online that you can search for. In either case, realize you will never be done. New technologies and attacks come out every day.

    The whole of human knowledge is at your finger tips. Just start searching for how things work. Start with an article like this:

    Read that, and open up in new tabs anything you don't understand or that sounds like it might be interesting. Do that with every article.

    Here is a great site for tech Q&As:

    Read through a lot of questions. Use the search function. Here is a good search to get you started:
    http://security.stackexchange.com/search?tab=votes&q=avoid hacked
  13. Mar 30, 2012 #12


    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    Aaah no!! Among programmers, C programmers are one of the richest sources of terrible C++ programmers.

    There's an old joke:
    A "real" programmer can write Fortran code in any language​
    referring to the tendency of a programmer who is very fluent in Fortran and no other language to continue programming using Fortran idioms no matter what programming language he's using. This tends to result in lots of unnecessary effort to produce code that is very out-of-place, and thus meshes poorly with other features of that language and is difficult for programmers of that language to maintain.

    This isn't limited to Fortran, of course; that's just the joke's origin. The particular combination of fluent C programmers writing in C++ is rather notorious for both how easy it is to trigger this behavior as well as how dramatic the effect is -- C++ as used by C programmers is practically an entire different language than C++ as used by C++ programmers!
  14. Mar 30, 2012 #13


    User Avatar
    Gold Member

    So what's the alternative? Only ever learn one programming language in your life?

    or more start with high-level and then move towards low-level?

    I honestly think it's a matter of taste, style, and purpose.
  15. Mar 30, 2012 #14
    I am very familiar with the joke and the essay it came from.


    However, I have seen people that know only high-level languages like Python, Java or C++, and that write code that looks OK at first look, but that runs rather slowly. When you check you find tons and tons of unnecessary instances of objects being created and deleted all over the place, and these guys have no clue where they come from...

    You can of course write rather efficient code in C++, but you have to be careful and understand what the compiler does. The beauty of C is that there are no such things going on behind your back.

    To confirm your point, I plead guilty to writing C-style code in C++. 20 year old habits are hard to kill. I am struggling to do the same in Python, however :-)
  16. Mar 30, 2012 #15
    Although the OP seems to just want to know how to secure his computer, I'll offer my opinion for future reference.

    If you want to "hack" or "crack" in the sense of security related issues, you're probably going to want to focus on low-level programming languages, and really get a thorough understanding how things work at this level. So, you'd probably want to learn C, C++, and especially assembly. Assembly will be required to reverse engineer proprietary code to find vulnerabilites like potential buffer overlows, and stuff like that.

    Of course, this depends on the kinds of things you want to mess with. For example, if you want to mess around with web apps, you'd want to know more about JavaScript, Java, PHP, Ruby, SQL, Apache, Linux, or IIS.

    Keep in mind that it will take a long time to gain enough understanding to become a proficient "hacker" or security professional. Like many skills, the "10,000 hour rule" probably applies.

    Hacking is using creativity to make a system behave in a way it was not intended. This is harder than just programming a system in a straigforward manner, and requires a very deep understanding of the nuts and bolts of the system.

    Oh, and just to join in on ripping on Fortran:
    "FORTRAN's tragic fate has been its wide acceptance, mentally chaining thousands and thousands of programmers to our past mistakes."

    Dijkstra's always a good source for funny quotes :)
  17. Mar 30, 2012 #16
    hmm.. ok thanks guys... ill take this all into consideration. And yes i know it will take me a long long time to learn to be... what i have in mind to be... just want to know where and what to start with.
  18. Mar 30, 2012 #17


    User Avatar

    Staff: Mentor

    That's a valid point. In the end, a good, well-rounded programmer has to be able to work easily and well at both high and low levels. The question here is which level a person who knows nothing about programming yet, should start at.

    The answer surely depends somewhat on the person's own learning style, but I lean towards starting at a high level and working one's way down. First learn the basic constructs and techniques that apply in most any procedural programming language: variables, basic I/O, if-statements, loops, procedures/subroutines (and the general ways of passing data to/from them), techniques for effectively decomposing a complex problem into smaller parts, basic techniques for organizing large amounts of data (arrays, lists, strings, etc.).

    When I taught C++, I used "C++ style" I/O streams instead of C-style I/O, and the standard library containers like vectors and strings instead of C-style arrays and char* "strings" for most of the course, because then I didn't have to introduce pointers until later in the course, after the students were (hopefully) already comfortable with the basic concepts.
  19. Mar 30, 2012 #18
    *shrugs* I don't really think it's that important. To quote from ESR's Hacker Howto:
    I very much agree with him on that point. For most applications, the availability of system resources really isn't much of an issue. This obviously doesn't mean that people who want to be good programmers can do with only learning high-level languages, but neither does it mean that a low-level language is a must for programmers, per se. Especially if you're not going to create kernels, videogames or other very computation-intensive applications.

    Also, when did C++ become a high-level language? C++ is, as far as I'm aware, intermediate-level! (C++ compilers can use inline-assembly, which can make an application architecture-dependent, which makes it middle-level.)

    I agree that it's best for most students to see some text on the screen before starting with pointers. On the other hand, pointers are extremely important, so it might be practical to introduce them sooner rather than later.
  20. Mar 30, 2012 #19
    Random, uncontrolled creation and annihilation of instances is at least as important a source of bugs and crashes as badly managed pointers and manual memory allocation are - in my opinion, I have seen plenty of examples.

    The waste of compute time is indeed irrelevant for most codes on most of today's machines, with the notable exception of graphics and image processing. For writing 2-3 pages long programs, the language hardly makes any difference.

    However, there is now a proliferation of low-powered machines with realtively little memory (smartphones and pads, embedded machines, Arduinos, Rasberry Pies etc) where you have to be a bit more careful with your resources. One can only hope that the libraries for image shuffling etc were written by "real programmers".

    Requiring beginners to manage pointers to deal with basic string operations is indeed a bit steep on the learning curve. But as far as I know, it has not killed anyone yet. That a string has a length, and that you have to provide memory space for that should be required knowledge for each programmer, even if in Python you never really get exposed to such details.

    Just my personal opinion.
  21. Mar 30, 2012 #20


    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    This reminds me of one of my favorite quotes. I can't find the amusing version, so I'll cite the more serious version by Knuth:
    We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. Yet we should not pass up our opportunities in that critical 3%. A good programmer will not be lulled into complacency by such reasoning, he will be wise to look carefully at the critical code; but only after that code has been identified​

    Not true. The compiler still does lots of things behind your back. I know at least one programmer (who is rather good at various assembly languages) who frequently laments the C compiler doing things he didn't want.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook