Thread: Language - When To Use What?

  1. #1
    Registered User
    Join Date
    Jul 2006
    Posts
    5

    Language - When To Use What?

    If this thread is in the wrong forum, I apologise, but I was not sure where to create it. I have been studying C as a first language (perhaps not the best idea) for almost a couple of months now, and while I am certainly not an expert, I am becoming more and more confidant using it. I really enjoy programming, and it is one of the career options at the top of my list. Because of that, I decided to do some research it to what it would take to have a job in computer programming. Before I did any research, I knew, like everyone else, that it is extremely useful to know more than one language. I read numerous articles and job requirements, and the majority of programming languages that came up were C, C++, Java, Perl, and Python and UNIX experience (I use Slackware Linux most of my time, so I am okay there). Because I am only really familiar with the syntax of C, and not exactly programming, I am unsure as to what each language is used for.

    Sorry if I am not making my self very clear and rambling; english is not my strongest language. Let me try and elaborate: I would appreciate it if anybody could give me an overview of each language; its strong points, weak points, how it integrates with other languages, and basically what it is used for; what kind of applications and why. For example I know that C can be used for anything, but most often it is used for kernel/driver programming and anything that needs to be low-level and quick. But what about the others?

    Also, how does Ruby fair against Perl and Python? I have read mixed opinions about it. Some think it is heaven programming, and some condemn it. Why is that?

    Much thank you anybody that answers this thread and helps me in any way.

  2. #2
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    many times, it's preference. People can treat programming languages like a religion sometimes. You'll definitely get that here.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  3. #3
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    Ruby is known for only taking 10 lines to do damn near anything. I personally dislike it and feel like I am missing too much stuff when I try and program in it. Python's syntax makes me feel like someone is stabing me in the eye when I have to read/write it... but Jython (using PushToTest's TestMaker) is the best way I have seen to write tests that are scalable for websites. Perl feels the most robust to me, does everything I need to, with CPAN there for modules to make my day easier.

    Those are all scripting languages, generally they are for RAD, Rapid Application Development, of tools and what not.

    Java/.NET are langauge/frameworks that are compiled to a middle language, making them work on any platform with an interpreter. Both of them offer strong abilites when it comes to making robust websites that need a lot of backbone. They are overkill for the average user's site but for companies they are invaluable. They also make writing crossplatform programs easier. Since you just have to check that you don't use any platform specific libraries. I perfer Java, since it runs well on Windows and Linux, and the servers at my workplace are Linux, and I work on a Windows computer all day. Also, non-Windows support of .NET is growing, but no where near what the support for Windows is, since it is a proprietory language. I have never really liked the style of .NET so I can't comment really on why it is better.

    C/C++ I see C generally being use for low level programming. When you need to access raw data and do it fast. C++ is used more on larger projects that need to be modular but still fast. C++ is the language of choice for games on most platforms, and for any program that is reasonably large.

    Just a little note, be confident and don't appologize every other line, made reading your post harder and made me want to answer it less.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    > I am unsure as to what each language is used for.
    Any general purpose language like C or C++ could be used for anything.
    Though there are a great many "niche" languages which excel at particular kinds of jobs.

    For example, text processing in C is a very fiddly task, you have to do absolutely everything yourself on the memory management front, and if you want regular expressions, you need a library. Perl on the other hand does all these things and more as part of the language.

    There are no hard and fast rules about using 'x' to implement 'y'. A lot of it boils down to
    - which languages you know,
    - how well you know each language,
    - the exact nature of the problem to be solved,
    - the preferences of the person asking you do the work.

    In the end, they're all just tools in the tool box. Practice and experience will tell you which ones to use.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Jul 2006
    Posts
    5
    Quote Originally Posted by Wraithan
    Ruby is known for only taking 10 lines to do damn near anything. I personally dislike it and feel like I am missing too much stuff when I try and program in it.
    Surely that is a good thing, no?

    Quote Originally Posted by Wraithan
    Python's syntax makes me feel like someone is stabing me in the eye when I have to read/write it...
    Why is that?

    Quote Originally Posted by Wraithan
    Those are all scripting languages, generally they are for RAD, Rapid Application Development, of tools and what not.
    For quickly writing programs to make tasks quicker and easier? Such as the cat program?
    Quote Originally Posted by Wraithan
    Java/.NET are langauge/frameworks that are compiled to a middle language, making them work on any platform with an interpreter. Both of them offer strong abilites when it comes to making robust websites that need a lot of backbone. They are overkill for the average user's site but for companies they are invaluable. They also make writing crossplatform programs easier. Since you just have to check that you don't use any platform specific libraries. I perfer Java, since it runs well on Windows and Linux, and the servers at my workplace are Linux, and I work on a Windows computer all day. Also, non-Windows support of .NET is growing, but no where near what the support for Windows is, since it is a proprietory language. I have never really liked the style of .NET so I can't comment really on why it is better.
    Would it not be better to write code using C++ instead of Java? C++ is much faster, and also works on all/most platforms. My friend told me that Java is quicker. I assume he means quicker to write, because I know for fact that C++ is faster because it is compiled.

    I am sure I will be sticking to a UNIX-based operating system (I have tried Windows but did not like it), but in case I must use both a UNIX OS and Windows, is it useful to know Java? Again I ask why not use C++ over Java? I do not know how long it would to write same program in each, but C++ seems to be the "better" language to me. Yet, why do many companies want Java programmers? Could only be because it is faster to write programs with Java. I admit I do not know much about either language though.

    Quote Originally Posted by Wraithan
    Just a little note, be confident and don't appologize every other line, made reading your post harder and made me want to answer it less.
    Point taken.

    Quote Originally Posted by Salem
    > I am unsure as to what each language is used for.
    Any general purpose language like C or C++ could be used for anything.
    Though there are a great many "niche" languages which excel at particular kinds of jobs.
    Could you explain these "niche" languages and what each job they excel at? Also, I only know one definition of "niche." Could you explain what it means here?

    Quote Originally Posted by Salem
    For example, text processing in C is a very fiddly task, you have to do absolutely everything yourself on the memory management front, and if you want regular expressions, you need a library. Perl on the other hand does all these things and more as part of the language.
    Yes, that is one of the main reasons people use Perl I see. For such tasks I have been using shell scripting (bash/ksh). Is Perl considered a better language? If so, why? And why do not people use Python instead of Perl? I have seen that Python code is much cleaner and more maintainable. In fact, I read one story which said that someone had written a quite big program, but came back to it later and found it hard to read, so moved to using Python. I understand that Perl is one of the main scripting languages on UNIX for system administrators, but why perl?

    Quote Originally Posted by Salem
    There are no hard and fast rules about using 'x' to implement 'y'. A lot of it boils down to
    - which languages you know,
    - how well you know each language,
    - the exact nature of the problem to be solved,
    - the preferences of the person asking you do the work.
    Which languages are the most important to know for a career in many aspects of programming? I shall look in to Fortran, because I know it is often used for scientific and mathematical (two other possible career options) programs. I already know C.

    If, for example, it was my job to write an accountancy program as soon as possible. The requirements were a clean and easy GUI, it must be able to run on both Linux and Windows (or easily portable), and it must be maintainable so someone else can continue support and developement of the program. Which language would be best suited for the job?

    I am not sure why an accountancy program came to mind...

    Quote Originally Posted by Salem
    In the end, they're all just tools in the tool box. Practice and experience will tell you which ones to use.
    I like that.

  6. #6
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,273
    I think what he meant by 'niche languages', was that when Salem said 'There are no hard and fast rules about using 'x' to implement 'y'.', a 'niche language', is a language specifically made to implement 'y'.

    If that makes sense. Purpose build languages for specific tasks.

    3a or b I think



    >> Point taken.
    I was hoping you were going to say sorry.



    Think about the Accounting program. What does it need? A database. Mathematical things (my literacy eloquence is hereby gone!). Write everything that you could think of down, and then think about which language would be best for that task. Which would be best. I'm assuming that the best in this case would have to compromise on some aspects of the program. But I'm going to say C++ above C because I could see a number of places where classes/inheritance would be quite benificial for dealing with clients etc.
    Last edited by twomers; 07-27-2006 at 02:22 PM.

  7. #7
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    Well... starting from top to bottom, I am too lazy to quote so but I will make it obvious what I am answering.

    To me for my purposes, shorter code isn't necessarily better. you lose customization when you move to using shorter code... atleast most times you do.

    As far as Python is concerned, I don't like that whitespace is significant.. I would much rather use symbols.

    The difference between C++ and Java is that Java is compiled once to a intermediate language then can be run anywhere with a interpreter. C++ has to be compiled on each platform unless you want to us a emulator which will make the speed gains of C++ useless. Java is good for webstuff like I said before, C++ has libraries for it, but Java doesn't require anything out of the standard to run atleast as far as webstuff goes (the majority of my Java programing has been for the web)

    Niche in this case means it fills a special role. As opposed to the definition where it means a hole in the wall to put stuff heh.

    Lots of people dislike Python for the reason I have said... also Python is newer. Perl has seniority and lots of people have come to almost master Perl so they can do what they need to do relatively fast compared to learning a new language and then learning how to use it as extensivly as they used Perl.

    If it was as soon as possible for the program... I am betting the language the managers would put you to using is some of the .NET languages or Java. Both are faster development times than C++, both run multiplatform without having to worry about too much when it comes to libraries on one and not the other, or what GUI API to use.

    Things to consider are what languages to the managers and what not say to use. C++ may run faster but they want to met a close deadline and since they don't know as much about computers or software they may pick the hot language at the time, which right now looks to be C#.NET. I am not saying all managers are this way... but most will consider the program getting done faster more important.

    Salem is right, each language is just a tool. You need to go out and learn 3-4 more languages, C, Perl/Python, Java/C#.

  8. #8
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,273
    >> the majority of my Java programing has been for the web

    I presume you mean JavaScript ... no?

    Beat ya

  9. #9
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    No.. I mean Java.

  10. #10
    Registered User
    Join Date
    Jul 2006
    Posts
    5
    I too am not going to quote. Too much.

    Thank you both for clearing up some things. It has filled in a lot of holes I had.

    C (of course), C++, Java, Perl/Python/Ruby, C#, and Fortran I am going to look in to learning. Eventually. May be a scripting language soon, to use instead of bash.

    What is Lisp/Scheme like? I know MIT use Scheme in their computer science courses, and Emacs uses Lisp. I also know that Lisp/dialect of Lisp is used often in writing Artifcial Intelligence.

    twomers, I was going to say "sorry", but did not in the end.

  11. #11
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,273
    >> C (of course), C++ .... c# etc NOTE: Small 'c' for c#

    Well, then stay on these forums, be an active member, post threads if you get stuck, and you should be well on your way on both of these languages

    Wraithan - I didn't think you would make a mistake between Java and JavaScript, but I just wanted to be sure.

  12. #12
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    > Could you explain these "niche" languages and what each job they excel at?
    Like Fortran for math / scientific work
    Like Prolog for rule based inference systems
    Like C for low level and embedded systems programming
    Like Ada because DoD told you to.
    Like Pascal for teaching structured programming
    Like Java for portable web applications
    Like lisp for people with a love of ( )
    Like AWK for those people who think Perl is too heavy.
    Like Intercal if you want to torture your readers

    > For such tasks I have been using shell scripting (bash/ksh)
    Shells can only really organise a flow of work to be performed by other programs. Where perl comes in is when you need to store that data locally and process it in some way. Perl has a rich set of data structures and text extraction and manipulation operators which a shell cannot match.

    > And why do not people use Python instead of Perl?
    Age probably - perl has been around for a good while now, the language is pretty stable and most systems are likely to have it. It was also one of the first of it's kind, so it had a chance to grow without competition.
    Python is newer, evolving and less widespread.

    > Which languages are the most important to know for a career in many aspects of programming?
    Knowing how to program is more important. Once you know a couple, it doesn't take long to pick up a new language. There are after all only so many ways you can write a for loop.
    The real skill is being able to look at what someone wants and turn that into a design and an effective programming solution which does what the user wanted.

    > If, for example, it was my job to write an accountancy program as soon as possible.
    I would use accountan-C as the language
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  13. #13
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    Salem's punny!

  14. #14
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,273
    Quote Originally Posted by Salem
    > If, for example, it was my job to write an accountancy program as soon as possible.
    I would use accountan-C as the language
    I'm not saying my jokes are the best, but even google gets this one: Google

  15. #15
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Quote Originally Posted by tjinr
    Surely that is a good thing, no?
    Basically, yes, but it often comes at the expense of flexibility, or in the case of Ruby, execution speed. All currently available Ruby implementations are really quite slow. Faster implementation might emerge, but the language has some features that make this hard.

    Why is that?
    Personal opinion and preference, mostly. I have the same problem

    Would it not be better to write code using C++ instead of Java? C++ is much faster, and also works on all/most platforms. My friend told me that Java is quicker. I assume he means quicker to write, because I know for fact that C++ is faster because it is compiled.
    Be careful of what you know "for fact". Some programs take a lot of specialized work in C++ to make them fast, while they're fast after simply writing them in Java (or C#, which is similar). VM technology has taken huge leaps these last few years.
    As for the question, I personally prefer C++, as will most people here (it's the C board, after all). But Java has its own advantages: it comes with standardized libraries for networking, GUIs, and many more things. C++ comes with a standardized library for containers and basic I/O, and a bit of internationalization.
    Java comes with a garbage collector. C++ comes with the RAII idiom, which is, in my opinion, more powerful, but more complex to learn, understand and use properly.
    Java comes with a VM that enables execution across platforms without recompiling. C++ comes with a language standard that allows anyone on any platform to implement a compiler - but every library that does system-specific things must be ported by the maintainer of that library.

    Java has a lot of advantages, and for some people, these advantages mean that they choose Java over C++. Personally, I'd hate to lose the expressive power of C++ - you can do things in C++ that Java couldn't even dream of. It's mostly syntactic tricks, but that's what high-level languages are really about anyway.
    I still use Java for server-side development, though. The libraries are so advanced that nothing I've ever seen for C++ can even hope to keep up.

    I am sure I will be sticking to a UNIX-based operating system (I have tried Windows but did not like it), but in case I must use both a UNIX OS and Windows, is it useful to know Java?
    It is useful to know Java because of where you might be employed, not what system you use.

    Again I ask why not use C++ over Java? I do not know how long it would to write same program in each, but C++ seems to be the "better" language to me. Yet, why do many companies want Java programmers? Could only be because it is faster to write programs with Java. I admit I do not know much about either language though.
    Writing programs faster is a great advantage when you have to pay programmers for the time they spend writing the programs.

    Could you explain these "niche" languages and what each job they excel at? Also, I only know one definition of "niche." Could you explain what it means here?
    There is only one definition of niche. Niche languages are designed to excel at one very specific job. They tend not to be general enough to be used for other jobs, but they do that one very, very well. One niche language you might know is AWK, which is a very good language for line-based processing of text, but awkward (pun not intended) for more complicated things. Niche languages tend to be declarative: make's language is a niche language.

    Yes, that is one of the main reasons people use Perl I see. For such tasks I have been using shell scripting (bash/ksh). Is Perl considered a better language?
    Using "better" is always a bad idea when talking about languages. Is your bash script full of complicated expressions, 1000 lines or more long, and you have no idea what's going on? You've outgrown shell scripting. Shell scripting is good for automating small jobs, but it isn't very suited to larger tasks. That's where Perl comes in.

    If so, why?
    Perl, being designed as a programming language instead of a series of commands originally meant for interactive use and enhanced with a few control structures using cute things like terminating an if-block with "fi", is more suited to larger tasks where organization plays a role. For example, Perl offers a controlled mechanism to import a module, or just a few functions from a module, and to disambiguate between functions from that module and a different one. With the shell, you need to source a file defining those functions, with absolutely no fine control and typically no lookup.


    And why do not people use Python instead of Perl? I have seen that Python code is much cleaner and more maintainable.
    Personal taste, personal experience, personal skills, legacy code, library availability, "what the other guys do", ...
    Perl is older than Python, and carries a lot more tradition. Any Unix sysadmin will already know Perl, so when he needs to hack up something, Perl will most likely be the language of choice. Not so many people know Python. (Although Python is gaining ground. It was deliberately designed to at least partially cover the same ground as Perl and eventually replace it.)
    So if you're asking yourself whether to use Perl or Python, just use Python. There's no magical feature of Perl that you'll suddenly be missing.

    In fact, I read one story which said that someone had written a quite big program, but came back to it later and found it hard to read, so moved to using Python. I understand that Perl is one of the main scripting languages on UNIX for system administrators, but why perl?
    It's largely legacy. Perl 1.000 was released in 1987 [1], specifically for Unix. Its syntax and features are familiar to C programmers, AWK users and shell scripters alike. That makes it very easy to learn for people who aren't serious programmers, but also for C programmers who need to do smaller tasks where C is overkill (or just unsuited, like text processing).
    The first Python was released in 1991, but in a completely different area. But Python 1 never really took hold - it wasn't until 2000 when Python 2 was released that it became really popular. In addition, Python is very unfamiliar to people unaccustomed to not having explicit block delimiters, no experience at all with functional languages and their list comprehensions, and similar things.

    This gives Perl a huge head start.

    If, for example, it was my job to write an accountancy program as soon as possible. The requirements were a clean and easy GUI, it must be able to run on both Linux and Windows (or easily portable), and it must be maintainable so someone else can continue support and developement of the program. Which language would be best suited for the job?
    As soon as possible? I'd probably go for Java, because I have a lot more experience doing GUIs in Java than in C++. I'd have to learn a cross-platform GUI library in C++ first, and that would take too much time.
    Of course, if you already know one ...

    Quote Originally Posted by Salem
    In the end, they're all just tools in the tool box. Practice and experience will tell you which ones to use.
    Amen to that.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. What language did they make Java in?
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 17
    Last Post: 07-03-2005, 04:18 PM
  2. Strange loop
    By D@rk_force in forum C++ Programming
    Replies: 22
    Last Post: 12-18-2004, 02:40 PM
  3. assembly language...the best tool for game programming?
    By silk.odyssey in forum Game Programming
    Replies: 50
    Last Post: 06-22-2004, 01:11 PM
  4. Language of choice after C++
    By gandalf_bar in forum A Brief History of Cprogramming.com
    Replies: 47
    Last Post: 06-15-2004, 01:20 AM
  5. Language Script..
    By vasanth in forum A Brief History of Cprogramming.com
    Replies: 12
    Last Post: 03-30-2003, 06:48 AM