What language should I learn as a bridge to C (and derivatives) [closed]

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 also tried to learn Objective-C but I gave up.

So, what language should I learn to bridge between Python to C

Asked by: Roman318 | Posted: 28-01-2022

Answer 1

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.

Answered by: Kevin578 | Posted: 01-03-2022

Answer 2

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.

Answered by: Michael624 | Posted: 01-03-2022

Answer 3

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 built in 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 built in libraries
    Languages like PHP nowadays 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, you'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 :)

Answered by: Emma866 | Posted: 01-03-2022

Answer 4

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.

Answered by: Rebecca483 | Posted: 01-03-2022

Answer 5

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.

Answered by: John459 | Posted: 01-03-2022

Answer 6

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 ;)

Answered by: John164 | Posted: 01-03-2022

Answer 7

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 ...

Answered by: Sophia472 | Posted: 01-03-2022

Answer 8

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.)

Answered by: Lily901 | Posted: 01-03-2022

Answer 9

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.

Answered by: Brad255 | Posted: 01-03-2022

Answer 10

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.

Answered by: Agata740 | Posted: 01-03-2022

Answer 11

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++).

Answered by: Marcus242 | Posted: 01-03-2022

Answer 12

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

Answered by: Emily624 | Posted: 01-03-2022

Answer 13

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.

Answered by: Kellan163 | Posted: 01-03-2022

Answer 14

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

Answered by: Thomas424 | Posted: 01-03-2022

Similar questions

python - TensorFlow: Compute Hessian matrix (and higher order derivatives)

I would like to be able to compute higher order derivatives for my loss function. At the very least I would like to be able to compute the Hessian matrix. At the moment I am computing a numerical approximation to the Hessian but this is more expensive, and more importantly, as far as I understand, inaccurate if the matrix is ill-conditioned (with very large condition number). Theano implements this through symbolic...

Still can't find your answer? Check out these communities...

PySlackers | Full Stack Python | NHS Python | Pythonist Cafe | Hacker Earth | Discord Python