The C family, should I dig deeper?

As many of you know, I have been browsing and taking part in this forum for around a year now. If it was not for this forum, I would have never gotten this far with Java and more importantly programming in general.

I feel I have gotten to a point in my quest, I want to dig deeper into the C family.

In college I am being “forced” to use C# for my graded unit (using XNA), I have spent most of my time in Visual Studio writing little utility classes that are no doubt going to make my progress a little easier next year for the unit. However, it has got me curious.

I want to take a look at lower level languages.

Some of you guys on here have 15+ years experience and I want your opinion, is there any real purpose to learn C?

Now don’t get me wrong, I am fully aware I will walk away from the experience with a broader understanding and appreciation for higher level languages, but I mean functionally, will I be able to apply anything I learn in say, C# or Java?

Will this help me with low level wrappers? Like OpenGL and DirectX?

So many questions, don’t want to flood the OP :p.

It will certainly be useful for OpenGL shaders and OpenCL kernels and possibly for better understanding the corresponding APIs. Note that C# is as high level as Java, but experience with C will be beneficial if you ever try a modern system language, like Go or Rust.

Ha yeah, I knew that :p. It basically identical to Java besides a few things and the awful (imo) practices. Like methods that begin with capitals and such lol.

DirectX shaders is something we learn in year 2, however I was told they are not terribly different from OpenGL shaders, that’s good!

I don’t have much experience with C#, but I got the impression that C# can more easily dig closer to the metal. C# has pointers (enabled via the unsafe keyword) and some notion of structs. There’s probably more stuff as well, but nothing I recall atm.

Other goodies in C# not found in java:

  • reified generics
  • implicit types for locally scoped variables (var i = “hello, I’m a string”)
  • operator overloading

Completely agree about pascal casing though, even if it’s something one gets used to.

I think working with c might give you some inside how certain things work in an unmanaged language. It definitely helps you appreciate our high level languages, when you worked for a while with them. Also as far as I know c is still used to program embedded devices.

Don’t agree with the naming nor with the statement that c# practices are bad. The naming is simply a convention. I used c# first and when I started with java I needed some time to get used to the method naming conventions. Doesn’t make it any better or worse. You havn’t mentioned any other ‘bad practices’ but in my opinion c# has almost always the better practices, features, usage patterns, syntax sugar etc. in contrast to java at the places where both languages chose different approaches.

Whoops, didn’t mean to be cheeky with that lol. It was strange to me, like you said I required time to get used to it.

But C# naming convention and layout of the code makes less sense to me that Java does, probably just me being biased. Example this drives me crazy:


if(something)
{
    // Do something
}
else
{
    // Do something else
}

I had to change it to place brackets after statements and such, it was just way more easier to read for me lol.

Like you said, these things are sugar coating and actual layout/naming can be up to the coder (although frowned upon when different from standard).

Thanks for your input, I am leaning further and further into this, so far I have started to download VirtualBox and CrunchBang.

I presume that if I learn C, or at least try to learn C then taking a step into low level C++ coding will be easier?

Maybe from a memory managment POV, but even then, later C++ versions (C++11) offer a lot of concepts and idioms that handle these things quite differently. If your end goal is C++ - start with it. Maybe a little advanced for an intro, but nevertheless a good primer on the C++ style of thinking: http://channel9.msdn.com/Events/GoingNative/GoingNative-2012/Keynote-Bjarne-Stroustrup-Cpp11-Style

Ultimately I have no real goal at the moment, I just know I want to delve into a lower level C language. One that will hopefully help me in some form or another and build on what I know from Java/C#, although I have only been using C# for about 2 months, it feels like I am just using Java with every so slightly different syntax.

I shall have a look at this and see what I think, thanks.

And don’t forget those beautiful delegates and events! I love those… but I still mostly dislike C#.

I highly recommend you learn C followed by C++. The experience and knowledge will be absolutely invaluable for your future, especially if you are interested in system-level development. I went through a similar path, starting by teaching myself Java, then doing C# in school, and now in college I’m learning assembly, C, and C++. I’ve realized how much I love low-level/system-level development and that’s where I’m focusing my energy.

  • Roi

A quick Google and damn, delegates are cool.

Think Java will ever have those? Like it took years to get lambdas lol.

C? Please. Learn ASM.

C is just a portable assembly language. And a jolly good one at that.

Cas :slight_smile:

Learning assembly and C in college right now, I’m absolutely loving it. C really is a portable assembly language, there’s very very little syntax sugar which makes it simple and beautiful. I’ll be doing much more C now and C++ soon!

I just learnt C++ :stuck_out_tongue: and had my final on Wednesday that just past.

We learnt java then C++. going from Java to C++ was kinda big step to begin with, but after you actually start its fairly easy lol, I seem to be able to learn programming languages really fast once I get into a course that we learn a new language.

At my highschool they “teach” you C++ first and then Java. Of course my teacher knows nothing about the subject. We use some old ass compiler and book for C++. Obviously I have no problem with it because I’ve used C++ before, but my classmates are having a really tough time. Imagine a toddler teaching another one to walk. It doesn’t work.

School tech education is a joke (at least in high school).

C is great for microcontrollers which is my 2nd best thing from Java, MikroC for PIC is my IDE of choice which is ace (Although the latest versions have gone a bit over the top of my head). I’d suggest if you have the money to proberbly invest in a second hand kit, its not really that expensive considering. You’ll probably find a development board around the same price as as a full on Arduino kit.

I’m mentioning this due to the fact I’ve learned a hell of a lot with C and some basic ARM/PIC assembly, not an expert but it helps understand the ‘computer’ in ‘science’. basic I/O, interfacing.

This is proberly why they use C for GL shaders, because its the lowest language to the machine which where OpenGL is interfacing with the ‘hardware’ - again, I’m pretty new to Java2D not to mention OpenGL

I’ve seen your replys to my posts regarding Java 2D lately since I’ve joined and you seem to know the score when it comes to the subject so I would certainly recommened using something like C with microcontrollers rather than the Arduino with its own C++ librarys because trust me, you wouldn’t learn as good from this, its hard to explain but its like in comparison ‘Processing’ vs ‘Java2D in Eclipse’ with… ‘Arduinos C++ vs MikroC / ASM with PIC/AMTEL’ — Mentioning this just incase you did want to delve into it.

I hope this helps, I feel I need to share ‘what I know’ to contribute to your efforts with my problems :slight_smile:

EDIT: Also, my favourite book out of my C collection to understand it in lamers terms, or if things get a bit rusty - “Head First C”, explains things clearly in diagrams, pictures. Some book people would shrug themselfs upon but if your open minded it does the job.

That’s because it’s a field where all the competent people have better jobs available.

I haven’t done very much in C yet, but I’ve done Rust which is almost as low level (if you take away the standard library it is as low level). It’s great having that much control over the memory, not just for performance, but you can sometimes shorten your code a lot by just manipulating raw buffers instead of fighting a high-level type system (eg: VBOs in LWJGL).

Yes, learn C! I’ve been using it for years and despite my attraction to other languages like Java and D, I still whip up projects in C now and again to keep sharp. I’ve never really been able to get into C++, no matter how often I try – I find myself dropping back to C every time.

Aside from learning what it’s like a bit closer to the metal, it will also teach you to be more context-aware when you write your code. You don’t have safety nets like bounds checks and GC and RAII and all these other nice memory-safety features of modern languages. You’ll learn to be careful after you get tired of tracking down segfaults and access violations. However, it is extremely easy to write broken code in C that will never be caught during development, but will explode in the wild when someone discovers a security hole in your app. Because of that, you can only pick up so much learning how to program defensively in a passive way – you have to actively focus on it to really be safe.

For example, you have to really remember to validate input parameters, do your own bounds checking (usually in asserts), make sure you don’t allocate memory without also adding a statement in the appropriate place to free it, and so on. One small oversight and BOOM! Even after nearly two decades of C and despite all of the defensive measures I’ve adopted over the years, I still catch myself with a hard to find bug because I overlooked an off-by-1 error or some such and wound up stomping memory somewhere.

C can be tedious, unsafe, and often less productive than many other languages, but I will always love it.

Why not, some people learn Old Greek just for fun. ;D
Experience is king in software development. Knowledge is invaluable, question is what kind of knowledge.
A language is just a tool. Way more important is the underlying language independent knowledge. That’s what tells apart a good programmer.
If you interested, just do it. Grab a book and go twiddling a bit with C. After that I would rather recommend to dig deeper into algorithms, data structures, software architecture, patterns, etc. Always stay open minded, question what you are doing, learn how to efficienctly complete projects, choose a language when it’s appropriate by objective facts, etc.
At the end of the day, whether C, C++, C#, or Java, its still the same old crap…

C is a reasonable language to learn. It’s main downside is that is doesn’t scale terribly well to largish projects. C# and C++ are less worthwhile as you’re going to not end up learning very much about programming assuming you know java.