Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (777)
Games in Android Showcase (231)
games submitted by our members
Games in WIP (856)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1] 2
  ignore  |  Print  
  The C family, should I dig deeper?  (Read 14363 times)
0 Members and 1 Guest are viewing this topic.
Offline Gibbo3771

JGO Kernel


Medals: 128
Projects: 5
Exp: 1 year


Currently inactive on forums :(


« Posted 2014-11-13 15:38:45 »

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.

"This code works flawlessly first time and exactly how I wanted it"
Said no programmer ever
Offline Spasi
« Reply #1 - Posted 2014-11-13 15:49:17 »

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

JGO Kernel


Medals: 128
Projects: 5
Exp: 1 year


Currently inactive on forums :(


« Reply #2 - Posted 2014-11-13 15:55:28 »

Note that C# is as high level as Java

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!

"This code works flawlessly first time and exactly how I wanted it"
Said no programmer ever
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline junkdog
« Reply #3 - Posted 2014-11-13 16:37:50 »

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.

artemis-odb: bugfixing and performance optimized fork of artemis ECS
Offline atombrot
« Reply #4 - Posted 2014-11-13 16:59:54 »

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.

Note that C# is as high level as Java

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

JGO Kernel


Medals: 128
Projects: 5
Exp: 1 year


Currently inactive on forums :(


« Reply #5 - Posted 2014-11-13 17:08:03 »

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:

1  
2  
3  
4  
5  
6  
7  
8  
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).

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.

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?

"This code works flawlessly first time and exactly how I wanted it"
Said no programmer ever
Offline junkdog
« Reply #6 - Posted 2014-11-13 17:16:26 »

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

artemis-odb: bugfixing and performance optimized fork of artemis ECS
Offline Gibbo3771

JGO Kernel


Medals: 128
Projects: 5
Exp: 1 year


Currently inactive on forums :(


« Reply #7 - Posted 2014-11-13 17:24:53 »

If your end goal is C++ - start with it.

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.

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

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

"This code works flawlessly first time and exactly how I wanted it"
Said no programmer ever
Offline ra4king

JGO Kernel


Medals: 508
Projects: 3
Exp: 5 years


I'm the King!


« Reply #8 - Posted 2014-11-13 19:36:51 »

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

Offline Gibbo3771

JGO Kernel


Medals: 128
Projects: 5
Exp: 1 year


Currently inactive on forums :(


« Reply #9 - Posted 2014-11-13 20:17:35 »

A quick Google and damn, delegates are cool.

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

"This code works flawlessly first time and exactly how I wanted it"
Said no programmer ever
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Slyth2727
« Reply #10 - Posted 2014-11-13 21:30:00 »

C? Please. Learn ASM.
Offline princec

« JGO Spiffy Duke »


Medals: 1060
Projects: 3
Exp: 20 years


Eh? Who? What? ... Me?


« Reply #11 - Posted 2014-11-13 22:26:39 »

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

Cas Smiley

Offline ra4king

JGO Kernel


Medals: 508
Projects: 3
Exp: 5 years


I'm the King!


« Reply #12 - Posted 2014-11-13 22:30:30 »

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!

Offline Phased
« Reply #13 - Posted 2014-11-13 22:52:21 »

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++ 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.
Offline Slyth2727
« Reply #14 - Posted 2014-11-13 23:27:13 »

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

Junior Devvie





« Reply #15 - Posted 2014-11-13 23:29:58 »

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 Smiley

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

JGO Kernel


Medals: 382
Projects: 11
Exp: 4 years


┬─┬ノ(ಠ_ಠノ)(╯°□°)╯︵ ┻━┻


« Reply #16 - Posted 2014-11-14 01:44:26 »

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

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

Offline aldacron

JGO Coder


Medals: 20
Exp: 19 years


Java games rock!


« Reply #17 - Posted 2014-11-14 05:26:48 »

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.
Offline 65K
« Reply #18 - Posted 2014-11-14 06:51:56 »

is there any real purpose to learn C?
Why not, some people learn Old Greek just for fun. Grin
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...

Lethal Running - a RPG about a deadly game show held in a futuristic dystopian society.
Offline Roquen

JGO Kernel


Medals: 518



« Reply #19 - Posted 2014-11-14 08:27:50 »

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

JGO Kernel


Medals: 508
Projects: 3
Exp: 5 years


I'm the King!


« Reply #20 - Posted 2014-11-14 08:57:42 »

Roquen: I disagree. C++ has many more concepts that Java doesn't have that I believe are invaluable to learn!

Offline Roquen

JGO Kernel


Medals: 518



« Reply #21 - Posted 2014-11-14 09:37:15 »

They're just details.  If you write an OOP style and only know one of (say) java,c++,c#,etc.  You learn a new one and you'll just write in an OOP style.  If you learn C, well you still can, but you'll have to lower the abstraction your self and you'll end up realizing that it's not really buying yourself that much that's useful in the general case.
Offline Gibbo3771

JGO Kernel


Medals: 128
Projects: 5
Exp: 1 year


Currently inactive on forums :(


« Reply #22 - Posted 2014-11-14 10:00:27 »

Thanks for every ones input! This has been great, I got CrunchBang setup on VirtualBox and I am checking out C as we speak. So far it has been pretty straight forward and I have been following this guide, which seems ok. Anyone got recommendations?

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. 

So are you basically saying that since I understand Java, moving to another OOP based language is well, easy?

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

I have been meaning to study algorithms, data structures and all that jazz. The problem is that all the credible books are hella expensive, usually span 1000 pages or so and with a job, college and a high maintenance wife; not easy to dedicate vast amounts of time to encyclopaedia sized books. Which really upsets me, for example this website for design patterns is short, concise and gets to the point. It leaves plenty of questions that can be answered by further reading, if necessary.

I managed to get about 150-200 pages in to Introduction to Artificial Intelligence which was highly recommended by my cousin, who has a PHD in Robotics and a Master degree in Computer Science, so had to believe it was good.

I am currently studying HND Games Development myself, and first year we learn C# and Unreal Engine 4. Second we do pure C# and Scripting + AI and data structures. Third year, for some reason we move right over to Java and C++ (like wtf?), start to learn more about software architecture and design patterns. Not actually looked into 4th and 5th year yet.

So yeah, whatever helps me get a head start in that is golden.

"This code works flawlessly first time and exactly how I wanted it"
Said no programmer ever
Offline pjt33

« JGO Spiffy Duke »


Medals: 40
Projects: 4
Exp: 7 years



« Reply #23 - Posted 2014-11-14 10:28:43 »

C is just a portable assembly language.

I would say more that C is a high-level assembly language which allows you to use a portable style, but no-one ever does. Just at the basic level of types: stdint.h / inttypes.h are 15 years old, but still terribly underused even in new projects.
Offline Roquen

JGO Kernel


Medals: 518



« Reply #24 - Posted 2014-11-14 10:30:03 »

Quote
So are you basically saying that since I understand Java, moving to another OOP based language is well, easy?
Knowing a language from a given major family and learning a second, third, etc. gives you less mileage than learning something that requires you to think differently when (and more importantly about) programming.  Learning how to think differently is useful regardless of what languages you end up using.
Offline SHC
« Reply #25 - Posted 2014-11-14 13:02:47 »

Learn any language, but don't deviate from the logical thinking of OOP style. C Programs are written Top-Down, they focus more on the procedural paradigms. While high level programs are written with a focus on the data. The thinking is different for C style, C++ style and Java/C# style.

Offline princec

« JGO Spiffy Duke »


Medals: 1060
Projects: 3
Exp: 20 years


Eh? Who? What? ... Me?


« Reply #26 - Posted 2014-11-14 13:32:54 »

hmm I'd say that was not the case. C, C++, and Java all largely think about data and the operations on that data in the same way: they are in the family of "imperative programming" languages, differing only by the levels of abstraction over the operations and storage of that data. If you want to learn something truly alien have a go at a functional language such as a Lisp derivative.

Cas Smiley

Offline Roquen

JGO Kernel


Medals: 518



« Reply #27 - Posted 2014-11-14 13:50:29 »

Quote
but don't deviate from the logical thinking of OOP style
I'd say the opposite.  There's nothing particularity interesting about OOP style.  Well structured code is dictated by the data.  The details of the structure are related to the language.
Offline Gibbo3771

JGO Kernel


Medals: 128
Projects: 5
Exp: 1 year


Currently inactive on forums :(


« Reply #28 - Posted 2014-11-18 17:13:49 »

Right I would like to update you guys on what I have chosen to do.

I first attempted (not saying I failed) to learn C on this website, I enjoyed it but as I got more and more into it and started to question wither I should just go for C++, after all it is widely used in the industry and we get taught it at University year 4.

I done some Google foo and got myself a copy of C++ Primer and well I was at it I picked up all 3 volumes of "The Art of Computer Programming" as recommended by many people (even although it is older than me 3 fold).

I am using OpenBlocks IDE, if anyone has a better recommendation that is just as lightweight let me know, I un-installed VS for the simple fact I only have a 60GB SSD and it HAS to be installed on the same drive as Windows.

Also, after some more Google foo I found this framework that looks nice, has anyone ever used it? Much like Java, when I am creating a game, as in properly and not purely for learning it would be nice to have abstraction from the low-level GPU code and such.

Thanks for every ones input! I do intend to learn C as well, I am currently watching the stream by this guy pointed out by Roquen in this thread.

"This code works flawlessly first time and exactly how I wanted it"
Said no programmer ever
Offline SwampChicken
« Reply #29 - Posted 2014-11-19 04:53:32 »

OP, definately learn C. Chasing rouge pointers teaches you to keep your house in order (which is something you tend to keep as you move onto other languages)



Pages: [1] 2
  ignore  |  Print  
 
 

 
hadezbladez (290 views)
2018-11-16 13:46:03

hadezbladez (159 views)
2018-11-16 13:41:33

hadezbladez (291 views)
2018-11-16 13:35:35

hadezbladez (72 views)
2018-11-16 13:32:03

EgonOlsen (2151 views)
2018-06-10 19:43:48

EgonOlsen (2177 views)
2018-06-10 19:43:44

EgonOlsen (1366 views)
2018-06-10 19:43:20

DesertCoockie (1984 views)
2018-05-13 18:23:11

nelsongames (1626 views)
2018-04-24 18:15:36

nelsongames (2273 views)
2018-04-24 18:14:32
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!