Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411423 Posts in 69363 Topics- by 58416 Members - Latest Member: JamesAGreen

April 19, 2024, 03:47:35 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)C-based languages - Where should I start?
Pages: 1 [2]
Print
Author Topic: C-based languages - Where should I start?  (Read 2574 times)
Gregg Williams
Level 10
*****


Retromite code daemon


View Profile WWW
« Reply #20 on: February 21, 2013, 03:26:59 PM »

Yeah lets also remember that there wasn't even a C++ standard until like 98. I've actually never worked at someplace that used STL let alone boost in their C++ projects.

I don't know that game developers have traditionally been big on it either.

I'm admittedly a C with Classes coder though, and I like to keep classes very flat.

I've only started using the STL lightly in the last two years or so. So far it has worked well enough to not need to be ripped out, but that might change if I started doing more work with custom memory allocators. As to boost, it maybe my C roots, but I really can't stand looking at any of that code and its syntax.
Logged

Klaim
Level 10
*****



View Profile WWW
« Reply #21 on: February 21, 2013, 03:47:36 PM »

The main problem with learning C first is that you have to understand pointers and const char arrays to do something useful, while in C++ you have to avoid them as much as possible.
I don't recall C++ needing you to avoid pointers and char arrays.  Many of us never used the STL, and still don't.

I didn't say C++ needs you to avoid pointers and char arrays, I said you have to avoid them as much as possible. You should not use them until you have no alternative, which is far less common than someone exposed first and too long to C would recognize, which is why it's recommanded to take these languages totally separately as in C++ the important tool you should use in preference order is RAII-based constructs, references, maybe smart pointers (I'm talking about any kind of smart pointer, not just reference counting ones) and sometime (for building abstractions over lower level code or sometimes because it's really the right tool) pointers.  Someone thinking in C writing C++ would to to pointers too quickly.

Same thing with raw arrays. Both constructs are just making things too complex to manage, because you have to write tons of code around them to manage them. Knowing when they are useful is not C++ beginners concern in early steps in the language, but it is important in C as they are the main useful abstractions available.

So, really, chose one, and understand that they are really different languages. Then understand that C++ have more useful (but complex) abstractions for you to use, but it cost time to learn each one and more time to really understand them (like inheritance being not a good choice most of the time).

Mixing C way of thinking and C++ way of thinking in the same code, in particular in C++ as it's often said that C is a super set of C++, which is wrong as already pointed, is the best way to make the code impossible to work with later.

I actually learnt a mix of C and C++ initially and was really stuck for years and didn't understand how you could manage to have code that just work, until I started to recommanded read books on C++, which opened my eyes on the fact that I was really doing "C with object". Since then, no problem. The hard part is that it takes more time getting efficient in C++ than in C. But you don't really build the same size of systems with both languages.

Yeah lets also remember that there wasn't even a C++ standard until like 98. I've actually never worked at someplace that used STL let alone boost in their C++ projects.

I don't know that game developers have traditionally been big on it either.

I'm admittedly a C with Classes coder though, and I like to keep classes very flat.

I've only started using the STL lightly in the last two years or so. So far it has worked well enough to not need to be ripped out, but that might change if I started doing more work with custom memory allocators. As to boost, it maybe my C roots, but I really can't stand looking at any of that code and its syntax.

Yeah things have changed. I'll give some data here:

 - http://gamedev.stackexchange.com/questions/268/stl-for-games-yea-or-nay see the most voted answer that sums correctly that STL should be your default toolbox, use other stuffs if you don't have what you need in it (like concurrent containers or very specific performance containers etc.)
 - I worked 5 years ago in a company that was very new, we didn't have any engine and we had to make NDS games from nothing, so we used the STL, and we made 6 games published with just STL and custom code;
 - In all my recent C++ jobs (game and not) using boost was a requirement, which was helful.  Note that it's not a good idea for all development contexts, it's just a sign a lot of companies understand that custom libs are not as good quality as libs that had a lot of expert eyeballs looking at them;
 - AFAIK All console developers provide C++ recent compilers with up to date C++03 standard library, sometime with C++11 features (NDS compiler did);

There is also good signs that now compiler writers are more willing to quickly implement the standard instead of their own language extension (Microsoft being always the exception, but at least they provide some features) which means it's easier to write code that works with different compilers and compilers versions than it was around 2000 for example.

That being said, it's understanding that C and C++ are different languages that is key here.
Logged

Gregg Williams
Level 10
*****


Retromite code daemon


View Profile WWW
« Reply #22 on: February 21, 2013, 04:03:31 PM »

@Klaim lots of good points, and while things have certainly evolved, it doesn't make things in the past methods and styles invalid either.

Yet I do suppose as time goes on, the complete C++/STL/Boost style will become more and more the standard way.
Logged

impulse9
Guest
« Reply #23 on: February 21, 2013, 04:03:56 PM »

If you're going to use both C and C++, then you will need to learn the coding standards for both C and C++. Cross-referencing them by thinking in terms of anecdotes and generalisations won't get you very far.

Subjectively speaking, C is extremely beautiful. It's down to the point and it doesn't abstract things away from you. Knowing it is pretty much a prerequisite to understanding how computers work.

If you code C-style in C++, that simply means that you probably don't understand either.
Logged
Gregg Williams
Level 10
*****


Retromite code daemon


View Profile WWW
« Reply #24 on: February 21, 2013, 04:16:24 PM »

If you're going to use both C and C++, then you will need to learn the coding standards for both C and C++. Cross-referencing them by thinking in terms of anecdotes and generalisations won't get you very far.

If you code C-style in C++, that simply means that you probably don't understand either.

Talk about generalizations Smiley
Logged

impulse9
Guest
« Reply #25 on: February 21, 2013, 04:18:07 PM »

The key word is probably.
Logged
TomHunt
Level 3
***



View Profile WWW
« Reply #26 on: February 21, 2013, 07:33:41 PM »

Relatively new to programming, however I want to learn a bit about C-based languages, could anyone tell me where I should start? Panda I just want your opinions on which are relatively easier to get a grasp of for beginners? I hope this question isn't too vague and causes any anger towards me  Giggle

A question for you:

Why do you want to learn a C-based language as your first language?

C was one of the first languages that I learned waaay back in the day, and I learned it because QBASIC was just too slow for what I wanted to do. Nowadays, you could probably get away with using a higher level language for most beginner-level applications, although with these you do need to be kinda selective as some are more hand-holdy than others and may lead to "bad habits". I commonly hear Python as a recommended first programming language.

..but if you have a particular interest in C, then by all means learn C. You can't get more C-based than C. Smiley
Logged

~tom | □³ | kRYSTLR
rosholger
Level 1
*



View Profile
« Reply #27 on: February 22, 2013, 04:05:58 AM »

just want to chip in and say that, yes python is a good first language BUT its not a good first language to make games in, pygames is a pretty low level framework that is kinda hard to work with, i would suggest java + slick2d instead, even thou it does not have a lot of tutorials .
ofc if you are not planing to make games or want to learn a C-based language feel free to ignore this! Smiley

EDIT: forgot to say that pygames is very slow too, so you have to make a lot of optimization if you want many sprites on the screen at the same time, which ends up making the game harder to make than with something like java
Logged
rivon
Level 10
*****



View Profile
« Reply #28 on: February 22, 2013, 08:25:47 AM »

Pygame is great and it isn't that slow. You can't draw tilemaps by individual tiles every frame, yes. But otherwise it's pretty much ok.
What I would suggest though is maybe to try PySFML. That way you would get the awesomeness of Python + speed of SFML (as it's HW accelerated).
Logged
rosholger
Level 1
*



View Profile
« Reply #29 on: February 22, 2013, 10:54:45 AM »

well it might have been my old super crappy computer
Logged
zalzane
Level 5
*****


View Profile
« Reply #30 on: February 25, 2013, 06:04:08 PM »

Even though there's a bunch of languages that use the letter "C" in them, theyre each very different from each other.

C - One of the first "high level" languages, but very low level by todays standards. This language is unsafe in that you can perform lots of black magic using pointers and arrays. This means there's lots of opportunities for ugly bugs to manifest. Because of how barebones and how close to the metal the language is, its popular with embedded programmers. Not recommended for desktop applications.

C++ - Some guy decided he wanted a mainstream OOP language, so he copied C's syntax and tacked on OOP abstractions like classes, lists, and inheritance. He decided that instead of having the language focus on a single paradigm, it would be filled with features so that anyone could do any sort of black magic they wanted, structure wise. What this means is that the language is extremely messy, bloated, and hard to parse. You can't really trust the compiler to perform any specific kinds of optimizations or shortcuts because it's too busy dealing with a horrific syntax tree. Because of how expansive the language is, theres probably only a handful of programmers out there who could claim to actually know the entire language. The only reason this language is still popular is because "industry standard" is an excellent buzzword.

C# - This started off as microsoft's idea of a java clone. Unfortunately for oracle, microsoft's research department is very sharp, which means that after a few years C# turned from a java clone into a potential java successor. It has absolutely nothing to do with C or C++ with the exception of some of the syntax. While C and C++ compilers generate native machine code, the C# compiler generates CLR bytecode which is compiled by the end user's computer, which requires the .NET or Mono runtimes to be installed on the end user's computer.
Logged
ThemsAllTook
Administrator
Level 10
******



View Profile WWW
« Reply #31 on: February 25, 2013, 06:40:22 PM »

C - One of the first "high level" languages, but very low level by todays standards. This language is unsafe in that you can perform lots of black magic using pointers and arrays. This means there's lots of opportunities for ugly bugs to manifest.

Lots of power too, once you learn how to use these things to your advantage!

Not recommended for desktop applications.

Always worked great for me. If it fits your style, there's nothing fundamental about C that makes it unsuited for desktop applications. If C++ or C# fit your style better, they'll likely be better choices, of course.
Logged

Xienen
Level 3
***


Greater Good Games


View Profile WWW
« Reply #32 on: February 26, 2013, 03:27:13 AM »

C - One of the first "high level" languages, but very low level by todays standards. This language is unsafe in that you can perform lots of black magic using pointers and arrays. This means there's lots of opportunities for ugly bugs to manifest.

Lots of power too, once you learn how to use these things to your advantage!

Not recommended for desktop applications.

Always worked great for me. If it fits your style, there's nothing fundamental about C that makes it unsuited for desktop applications. If C++ or C# fit your style better, they'll likely be better choices, of course.

Agreed entirely.  The presumption that it is "not recommended for desktop applications" is just crazy to me.  It is definitely about style, because C++ has the ability to do all of the same pointer "black magic", but developers tend to not use them because C++ often has more elegant ways of accomplishing the desired effect.  In general, I also tend to agree with those that say C is not well suited for a multi(5+) programmer environment, even though it has been done and done well at places like Cryptic Studios because they are extremely selective when hiring programmers.
Logged

TomHunt
Level 3
***



View Profile WWW
« Reply #33 on: February 26, 2013, 05:39:43 AM »

C# - This started off as microsoft's idea of a java clone. Unfortunately for oracle, microsoft's research department is very sharp, which means that after a few years C# turned from a java clone into a potential java successor. It has absolutely nothing to do with C or C++ with the exception of some of the syntax. While C and C++ compilers generate native machine code, the C# compiler generates CLR bytecode which is compiled by the end user's computer, which requires the .NET or Mono runtimes to be installed on the end user's computer.

The C# language is developed and maintained by a product team in Microsoft's Developer Division (the one that makes Visual Studio, the compilers, and all that stuff) that receives technical direction from Anders Hejlsberg, who wrote Borland Turbo Pascal way way way back in the day.

They did make a "java clone" of sorts with J# back in the 90s (which I think Anders also might have had a hand in), but they dropped that after awhile as it wasn't really catching on all that well compared to Java proper.

What makes C# pretty interesting is that it is built to be able to leverage COM objects in DLLs built using C/C++, so things don't have to be converted or recompiled to use with C#. The C# program can just add a little compatibility layer for accessing the C/C++ stuff. This, along with the fact that it is dead simple to learn if you already know C/C++ or Java, has made it rather popular, especially in Microsofty circles - although things like Mono have taken it well beyond the Microsoftsphere.
Logged

~tom | □³ | kRYSTLR
Muz
Level 10
*****


View Profile
« Reply #34 on: February 26, 2013, 08:42:45 AM »

C - One of the first "high level" languages, but very low level by todays standards. This language is unsafe in that you can perform lots of black magic using pointers and arrays. This means there's lots of opportunities for ugly bugs to manifest.

Lots of power too, once you learn how to use these things to your advantage!

Enough power to run an operating system.

Kinda agree with zalzane's summary. Though I'd say "not recommended" is more that it's a low level language and isn't designed for object oriented. like... how do you guys make games without strings?

However, if you're going solo... you don't really need object oriented. OO is awesome when you want someone to pick up where you left off, but replaceable otherwise.

If you're just learning programming, the differences are probably going to be way over your head and you'll just want to start to learn to make dice rolling stuff or something. Which you can do in all languages, and pick up a different one once you've decided on a style you like.
Logged
zalzane
Level 5
*****


View Profile
« Reply #35 on: February 26, 2013, 09:14:28 AM »

Although C is a wonderful language, I don't recommend it for desktop applications because there's typically a better tool for the job in that kind of environment. Being such a barebones language, you're going to have to reinvent the wheel/scrounge for libraries quite a bit before the language is even comparable to some of the higher level alternatives. On top of that, I can only think of a handful of situations in which C's greatest strengths (small binaries/predictable compiler) really could come into play in the context of a desktop application.
Logged
Pages: 1 [2]
Print
Jump to:  

Theme orange-lt created by panic