views:

147

answers:

7

I'm a Python programmer who knows a bit of Ruby and PHP as well. I don't really know enough about Java to do anything meaningful, and I certainly don't know C, C++, or other low-level languages. I've heard all the "Who cares about speed because hardware is cheap, but coders are expensive" arguments, and I'm not trying to raise a debate here. I want to understand 2 things about the community of lower level programming languages (whether it's C or even assembly):

  1. What is the main reason you choose to still use it (job requirements, speed, desktop vs web, etc)?
  2. Is it still worth me taking the time to learn C++ (monetarily speaking) or others this late in the game, or will I benefit?

Also, consider the benefits / disadvantages of dynamic vs static typing, when choosing your reasons. I primarily program for the web, but don't take that fully into consideration because it's partly due to the fact that the web is all I know.

+2  A: 

Unashamed Fortran programmer here. Speed speed speed. Oh, and all the scientists I work with are reasonably fluent in Fortran. But then I work in computational electromagnetics on large clusters and supercomputers and wouldn't recognise a web application if it leapt up and bit me on the nose.

I wouldn't regard Fortran as low-level or less-expressive, I think it's a DSL for linear-algebra and more general number-crunching. So why did I take the bait and respond to this question ?

Dynamic vs static typing ? Static please, everything tied down at compile time so the compiler can work its socks off optimising.

High Performance Mark
@High-Performance Mark (Nice name BTW), thanks for your reply. Looks like 1 vote for performance. And, 1 vote for Static typing (for speed again).
orokusaki
What a mumbling ... full of deep love ;)
honk
Common Lisp's approach to typing is interesting here. If you do nothing special, the typing is strong but dynamic (any data object is of a rigidly defined type, but isn't specified at compile time). You can specify types, making part or all of the code statically typed, and you can typically either run in debug mode (where the run-time will verify the types) or performance mode (where the compiler will trust you to get it right, and optimize accordingly).
David Thornley
+1  A: 

For the numerical calculations I do writing straight C++ is just faster than using e.g. straight Python. Sure, I can interface my C++ libraries to higher-level languages (and I do), but since most of my work is done on the low-level numerical side, I wouldn't gain too much.

Also consider that a lot of libraries especially in scientific computation are in FORTRAN, C or C++ and linking against them from C++ is much faster (especially if you just want to get done with it) that creating wrappers and interfaces all yourself.

If you would gain anything from learning a low-level language depends a lot on your problem domain.

honk
You might consider trying Haskell or O'Caml for scientific or numerical computation. These are very expressive high-level languages but they have optimizing compilers that can do nearly as good a job as a C or C++ compiler.
Justice
@Justice just get me bindings for http://root.cern.ch, http://wwwasd.web.cern.ch/wwwasd/geant/ and http://www.geant4.org or maybe http://home.thep.lu.se/~torbjorn/Pythia.html.
honk
Sorry, I didn't realize you were doing particle simulation and were relying on advanced C/C++ libraries. Perhaps Haskell or O'Caml would be appropriate for other types of numerical calculations.
Justice
@honk what is your profession?
orokusaki
@orokusaki Nuclear physics, which means I have to deal with people (non-CS types) writing `F77` all the time. But as always, bad programmers can write `FORTRAN` in any language ...
honk
+2  A: 
  1. I'd think the big three reasons here are going to be Performance, Legacy System Support, and Embedded Development.

  2. So mega subjective it renders any answer next to useless.

Jason Punyon
@Jason It's subjective, but for me it's important. I see the world as moving toward dynamic, expressive languages, but I see a number of new developers still going the direction of C++ and I'm wondering if it's because it's A) more lucrative, B) not going away anytime soon due to newer languages taking over, and/or C) more fun?
orokusaki
@orokusaki: And, without knowing more about you, I can't make recommendations on what you should do. I do suggest learning either C or C++ as a matter of professional development, but I have no idea how likely you are to be on projects where one or the other is indicated.
David Thornley
Useless, like most water-cooler talk. That's why I'm hanging around here.
High Performance Mark
+1  A: 

There are several good reasons for lower-level languages.

First, there's a lot of applications where performance does matter. The main application I work on is slow enough as it is (it does a whole lot of things), and would be unusable in Python.

Second, there are applications that require standalone executables that aren't all that big.

Third, there's a tremendous amount of legacy code in C and C++, and it isn't going away any time soon.

Fourth, operating systems are normally written in C or C++ or similar languages, and expose APIs in them. If you need to get chummy with the OS, for whatever reason, you're better off using the OS language.

Dynamic typing is very clearly better for getting an application up and running fast, and my Lisp background pushed me to believe that static typing is normally just premature optimization. However, lots of people believe that static typing is much better for enforcing correctness in large projects, and C and C++ are well suited for large projects.

For your second question, I have no idea what you want to do in the future, so I don't know if it would be worthwhile for you to learn C++. For professional development, I'd strongly suggest learning a variety of languages, including C or a similar language. There are other questions on SO about what languages to learn.

David Thornley
+3  A: 

For a web programmer, C/C++ will offer you virtually no advantage. It is less expressive than Perl, Ruby, Python, etc. and requires more code and attention to detail of memory management. Unfortunately, choosing a language for its "features" is often second to choosing for its platform. C++ isn't as clean and elegant as C#, most of that comes from its C compatibility. Sadly, even though there are better languages for certain things, most aren't compiled and most aren't widely supported.

If you plan to develop a commercial product that the customer will download or receive on CD, then C/C++ offers you protection of your Intellectual Property (hard to reverse engineer), and a small runtime footprint, as well as ability to target older platforms like Windows XP.

It is not too late in the game to learn C/C++. C/C++ will be around as long as all the higher level languages are around, because those languages are implemented in C/C++. It is not as if we will all move to Python one day and C/C++ will be retired. High level, non-compiled languages are not self-hoisting, so they cannot exist without C++.

It is the tool to use if you are going to implement higher level things like languages, APIs, toolkits, drivers, IDEs, etc. But C++ is not the tool to use if you want the fastest way to develop an internal GUI app or a Web app.

Just learn the tool for the job. If the job changes, or you wish to change the job, then you may want to push yourself to learn C++ to see the other side of the Computer Science world, the side between the CPU and what you currently write your web apps in.

mrjoltcola
+1 Nice answer. I was really looking for a subjective answer because I have nothing to go on other than the stated.
orokusaki
+1  A: 

Why aren't Python, Ruby and PHP written in itself?

Mission critical applications need best possible performance and algorithms and doesn't need things like metaprogramming. C++ has some great ideas and libraries, which I then found in those modern languages, sometimes better sometimes worse (compare power of templates in C++ and generics in Java). Low level languages will make you learn something more about lower level abstractions of the computer, operating systems or networks.

Static restricts you in programming and often makes you write out the types, however it also let's you better express your intent in a way, which is automatically provable by compiler and you can get support for tools. Dynamic gives you free hands, you can do more and maybe easier, however you have to test better.

Gabriel Ščerbák
@Gabriel +1 - Well, I understand that Python is implemented in C, but that doesn't concern me much because I see a movement to get JICs and other mechanisms for Python and other languages (Unladen Swallow for Python, HipHop for PHP, etc). The main thing I'm trying to understand is, even if they increase the speed of Python to match C for functional purposes (which isn't happening anytime soon), is it still worth me understanding C for other reasons.
orokusaki
I more of a Ruby than Python guy, however I don't know if you could for example write a garbage collector or any other type of memory management, filesystem or network server in Python as efficiently as in C. For web, you don't need any C imho, however in overall, C may teach you about sockets and OSes.IMHO it is best to know a bit from every corner.
Gabriel Ščerbák
A: 

I may be misunderstanding you here but it sounds like you're under the impression that C++ is the appropriate language for every kind of project. It isn't. You wouldn't use a Liebherr truck for a cross country road trip. Every popular language in existence got that way because it works well for some situations. There was a time when C++ was used to write web applications which quickly gave way to Perl scripts because the trade-off between production and performance. So in response to your first question, mainly people still use it because in certain situations it's the best tool for the job.

As far as whether or not you should learn it, I say if you have the time and the desire go for it. Even if C++ is never the correct tool for any of the projects you take on a decent understanding of concepts that are necessary in C++ will make you a better developer in every language.

Spencer Ruport
@Spencer real men drive Liebherr trucks to the grocery store, or even daycare.
orokusaki