tags:

views:

499

answers:

14

The first language i learnt was PHP, but i have more recently picked up python. As these are all 'high-level' languages, i have found them a bit difficult to pick up. I tried a bit of objective-c, and i just gave up.

So, what language should i learn to bridge between python to C

+13  A: 

It's not clear why you need a bridge language. Why don't you start working with C directly? C is a very simple language itself. I think that hardest part for C learner is pointers and everything else related to memory management. Also C lang is oriented on structured programming, so you will need to learn how to implement data structures and algorithms without OOP goodness. Actually, your question is pretty hard, usually people go from low level langs to high level and I can understand frustration of those who goes in other direction.

aku
A: 

I'm feeling your pain, I also learned PHP first and I'm trying to learn C++, it's not easy, and I am really struggling, It's been 2 years since I started on c++ and Still the extent of what I can do is cout, cin, and math.

If anyone reads this and wonders where to start, START LOWER.

Unkwntech
+7  A: 

The best place to start learning C is the book "The C Programming Language" by Kernighan and Ritchie.

You will recognise a lot of things from PHP, and you will be surprised how much PHP (and Perl, Python etc) do for you.

Oh and you also will need a C compiler, but i guess you knew that.

Mark Nold
A: 

Learning any language takes time, I always ensure I have a measurable goal; I set myself an objective, then start learning the language to achieve this objective, as opposed to trying to learn every nook and cranny of the language and syntax.

C is not easy, pointers can be hard to comprehend if you’re not coming assembler roots. I first learned C++, then retro fit C to my repertoire but I started with x86 and 68000 assembler.

titanae
A: 

Java might actually be a good option here, believe it or not. It is strongly based on C/C++, so if you can get the syntax and the strong typing, picking up C might be easier. The benefit is you can learn the lower level syntax without having to learn pointers (since memory is managed for you just like in Python and PHP). You will, however, learn a similar concept... references (or objects in general).

Also, it is strongly Object Oriented, so it may be difficult to pick up on that if you haven't dealt with OOP yet.... you might be better off just digging in with C like others suggested, but it is an option.

Mike Stone
A: 

Python is about as close to C as you're going to get. It is in fact a very thin wrapper around C in a lot of places. However, C does require that you know a little more about how the computer works on a low level. Thus, you may benefit from trying an assembly language.

LC-3 is a simple assembly language with a simulated machine.

Alternatively, you could try playing with an interactive C interpreter like CINT.

Finally, toughing it out and reading K&R's book is usually the best approach.

Nick Retallack
A: 

Forget Java - it is not going to bring you anywhere closer to C (you have allready proved that you don't have a problem learning new syntax).

Either read K&R or go one lower: Learn about the machine itself. The only tricky part in C is pointers and memory management (which is closely related to pointers, but also has a bit to do with how functions are called). Learning a (simple, maybe even "fake" assembly) language should help you out here.

Then, start reading up on the standard library provided by C. It will be your daily bread and butter.

Oh: another tip! If you really do want to bridge, try FORTH. It helped me get into pointers. Also, using the win32 api from Visual Basic 6.0 can teach you some stuff about pointers ;)

Daren Thomas
+1  A: 

C is a bridge onto itself.

K&R is the only programming language book you can read in one sitting and almost never pick it up again ...

Purfideas
+1  A: 

My suggestion is to get a good C-book that is relevant to what you want to do. I agree that K & R is considered to be "The book" on C, but I found "UNIX Systems Programming" by Kay A. Robbins and Steven Robbins to be more practical and hands on. The book is full of clean and short code snippets you can type in, compile and try in just a few minutes each.

There is a preview at http://books.google.com/books?id=tdsZHyH9bQEC&printsec=frontcover (Hyperlinking it didn't work.)

Claes Mogren
A: 

I think C++ is a good "bridge" to C. I learned C++ first at University, and since it's based on C you'll learn a lot of the same concepts - perhaps most notably pointers - but also Object Oriented Design. OO can be applied to all kinds of modern languages, so it's worth learning.

After learning C++, I found it wasn't too hard to pick up the differences between C++ and C as required (for example, when working on devices that didn't support C++).

Matt
+4  A: 

I generally agree with most of the others - There's not really a good stepping stone language.

It is, however, useful to understand what is difficult about learning C, which might help you understand what's making it difficult for you.

I'd say the things that would prove difficult in C for someone coming from PHP would be :

  • Pointers and memory management
    This is pretty much the reason you're learning C I imagine, so there's not really any getting around it. Learning lower level assembly type languages might make this easier, but C is probably a bridge to do that, not the other way around.
  • Lack of builtin data structures
    PHP and co all have native String types, and useful things like hash tables built in, which is not the case in C. In C, a String is just an array of characters, which means you'll need to do a lot more work, or look seriously at libraries which add the features you're used to
  • Lack of builtin libraries
    Languages like PHP now days almost always come with stacks of libraries for things like database connections, image manipulation and stacks of other things. In C, this is not the case other than a very thin standard library which revolves mostly around file reading, writing and basic string manipulation. There are almost always good choices available to fill these needs, but you need to include them yourself.
  • Suitability for high level tasks
    If you try to implement the same type of application in C as you might in PHP, you'll find it very slow going. Generating a web page, for example, isn't really something plain C is suited for, so if you're trying to do that, ou'll find it very slow going.
  • Preprocessor and compilation
    Most languages these days don't have a preprocessor, and if you're coming from PHP, the compilation cycle will seem painful. Both of these are performance trade offs in a way - Scripting languages make the trade off in terms of developer efficiency, where as C prefers performance.

I'm sure there are more that aren't springing to mind for me right now. The moral of the story is that trying to understand what you're finding difficult in C may help you proceed. If you're trying to generate web pages with it, try doing something lower level. If you're missing hash tables, try writing your own, or find a library. If you're struggling with pointers, stick with it :)

Matt Sheppard
A: 

try to learn a language which you are comfortable with, try different approach and the basics.

sasayins
A: 

Languages are easy to learn (especially one like C)... the hard part is learning the libraries and/or coding style of the language. For instance, I know C++ fairly well, but most C/C++ code I see confuses me because the naming conventions are so different from what I work with on a daily basis.

Anyway, I guess what I'm trying to say is don't worry too much about the syntax, focus on said language's library. This isn't specific to C, you can say the same about c#, vb.net, java and just about every other language out there.

Giovanni Galbo
+1  A: 

Pascal! Close enough syntax, still requires you to do some memory management, but not as rough for beginners.

Max Caceres