[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

/gcc/ - General C Circlejerk

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 62
Thread images: 9

File: 1486335370525.png (769KB, 1052x1342px) Image search: [Google]
1486335370525.png
769KB, 1052x1342px
Welcome to the first official /gcc/.
Talk about C and stuff.

>I want to learn C
Read:
C Programming: A modern approach
The C Programming Language 2 (aka K&R)
GNU C Reference Manual
Avoid like the plague: Learn C the Hard Way

>I'm ready for more!
Expert C Programming: Deep C Secrets
Computer Systems: A Programmer's Perspective

> How to write readable code
Linux style
OpenBSD style
Avoid like the plague: GNU style

C programmers please help me add to this list.

What are you working on?
What do you use C for?


To foster some discussion:
One major complaint about C is it not having separate namespaces. How do you work with this? Do you use any sort of file organization or segregation schemes to keep symbol collisions in big projects?
C is a very low level language that is best suited for groundwork, do you use any layering on top for more "high-level" programming? eg. embedded languages such as lua/guile
>>
Is K&R the best way to learn C for someone who only knows OOP concepts?
>>
>>58822782
I'd suggest A Modern Approach instead.

Unless you learned OOP through Smalltalk, what you know as OOP is probably built upon the procedural model.
I think the main difference is that in the C model, you do not have different agents to which you "ask" to do things, but just the main program logic, which performs actions on objects.
so instead of something like
array.sortyourself();

you
sort(array);

For the rest it's pretty similar, you just have to "unlearn" some of the methodologies of OOP, eg stop expecting different agents to have their own logic.

If I'm not being helpful ask away and I'll try to make myself clearer
>>
File: ching chong nip nong.png (128KB, 581x443px) Image search: [Google]
ching chong nip nong.png
128KB, 581x443px
Is this Modern Approach book that people keep recommending available as a PDF from anywhere? Most books you don't even need to pirate; a PDF is usually the second or third search result anyway from some university's website.

Also, if I find an old edition, is it okay to read that one instead? I am exactly the sort of Pajeet hobbyist who only wants to learn programming until it becomes difficult and only look for a programming job if it turns out I can do it with no effort. With that in mind, if more recent editions of these books only include changes that are for very advanced programmers, I probably won't bother, same as I don't want to just start with C++.
>>
>>58822753
Do you have similar guide for C++?
>>
>>58823665
"Accelerated C++: Practical Programming By Example" is a book, and some anon here made videos of himself reading and learning each chapter, so if you want some videos to help you learn, that's a good place to start.
>>
>>58822753
>One major complaint about C is it not having separate namespaces. How do you work with this? Do you use any sort of file organization or segregation schemes to keep symbol collisions in big projects?
>C is a very low level language that is best suited for groundwork, do you use any layering on top for more "high-level" programming? eg. embedded languages such as lua/guile
>>
How much time do you need between learning the language properly, building a respectable portfolio and getting a job. Above average intelligence guy, but not gifted. 4 hours a day.

I know, estimates, of course.
>>
>>58823609
there are a few downloads at libgen.io

But if you want to pajeet, you probably don't want C, you probably want either of ruby, python or javascript.
>>
>>58824274
Thanks, but I've done Python. I want to learn C so I can pick up hardware stuff too and learn actual computer facts about memory and whatever the fuck a socket is.
>>
Does anyone have any experience writing 3D game software in C?

If i wanted to be a C zealot all the way, how long would it take me to actually put out a game if I only use SDL2 and OpenGL?
>>
>>58824353
A socket is a UNIX object (though the winsock api somehow implements this on windows) which is pretty much:
A buffer stored in kernel for which a process has a handle and to which it can read or write
That's all a socket is really. But it's very flexible, a process can create a socket and bind it to a port (essentially: a unique number) to communicate to another process that has a socket bound to the same port.
The other process can be in another computer, in which case they communicate over a network (notably, the internet). This is handled by the underlying network stack. The rest of the process is done transparently.
After you learn your basic C, read beej's guide to network programming with sockets to learn more about this.
However, although sockets are simple, programming them is not quite so, because there are many types of sockets and several parameters you can use on them, so they look more complicated than they really are in C code.
Also I'm very sure python has socket support as well.
But yes indeed with C you understand things at a lower level indeed
>>
>>58824486
probably 200 hours
>>
File: kuruminha_render.png (137KB, 1024x770px) Image search: [Google]
kuruminha_render.png
137KB, 1024x770px
What attracts you to C++
>>
http://icube-icps.unistra.fr/img_auth.php/d/db/ModernC.pdf
Is this a good startpoint for beginners ?
>>
>>58825024
Any start point is a good start point, you can always find something else later.
>>
>>58824974
The ability to waste my time by optimizing the memory usage and cpu of programs even though they already perform pretty good.

Oh yeah I shaved off another 10 microseconds off that function that only gets called every 10 seconds. That feeling never gets old.
>>
>>58822753
>What are you working on?
Java
>What do you use C for?
Maintaining old programs. Getting real tired of faggot """contributors""" fucking up my code because they don't know C properly.
>>
>>58822753
>Avoid like the plague: GNU style
definitely
>>
Should I learn C++ or C?
>>
>>58825389
If you learn C, you'll hate C++.
If you learn C++, you'll hate C.
>>
>>58825396
I already have java experience an am learning C++

Oh well
>>
>>58825406
I still think you should give it a try.
Idiomatic C is very different from C++.
You won't ever have to "avoid" features because C has very few, and you'll end up using all of them if your projects balloon past 1000 loc.
>>
>>58825389
>>58825406
Don't listen to him. Yes they are kind of represent two different approaches to programming, in the field of simplicity vs complexity
Start with C, because that's the foundation on which C++ is built.
You don't need to learn much about the standard library though, C++ has it's own STL, but be sure you understand the core concepts of C well and C++ will be a lot easier.

And yes I always say "Learn C then C++"
>>
>>58825024
Looks good, it even touches assembly, which any self-respecting C programmer should know.
I'll add it to the next OP
>>
File: 1482464371365.jpg (156KB, 430x720px) Image search: [Google]
1482464371365.jpg
156KB, 430x720px
>>58822753
>GCC also includes a go compiler
Loving it.

C+Go master race
>>
>>58826327
What makes go worth using when it's literally a neutered C?
>>
>>58826354
If I am building an application, I'd build the core engine written on C.

However for plugin system etc has to be written in an easily maintainable and much more productive language.

So the option is lua, python, perl etc but Go has a better performance.

C is yet to be replaced though. It has the best performance of almost all languages. However, scaling and implementing a large application without causing undetected memory leaks, overflows are a major pain in the ass.
Better option would be Rust (C++ done better) but learning Rust is hard, even for C++ devs. So for now I am stuck with C+Go, although I intend to be shifted to Rust+Go for a better and safer code base.
>>
>>58822753
What's the problem with Learn C the Hard Way?
>>
>>58826687
the author has his head up his ass and can't teach worth a damn

keep reading it if you want, you'll come to a brick wall about 20 chapters in because his teaching style is "copy all this code that i wont explain and then try to break it and tell me why it did that :^)"
>>
>>58826687
As >>58826748 said, the author is a prick but more importantly, it doesn't really teach you, it just gives you a tour of what it's like but you end up with no solid foundation. You don't end up knowing the language or knowing how to solve a problem on your own.
>>
>>58826327
Silly bratposter
>>
File: .jpg (138KB, 620x620px) Image search: [Google]
.jpg
138KB, 620x620px
if I know the syntax and basic programming logic to make a few hundred line projects with just the standard libraries
how the heck can i learn these giant libraries you seem to need for anything
its so much more complicated with like 1 million ''''objects''' and functions
>>
c is like basketball with the hoops at pro height
>>
>>58827090
you just hope the library has good documentation
>>
File: kuruminha sip.png (74KB, 618x618px) Image search: [Google]
kuruminha sip.png
74KB, 618x618px
>>58827126
What
>>
>K&R

absolutely deprecated
use 21st century C (the 2nd edition)
>>
>>58827359
Nope.
>>
File: 52352353513414.png (4KB, 236x213px) Image search: [Google]
52352353513414.png
4KB, 236x213px
SAME SHOW
>>
>>58827661
Kill yourself, my mate.
>>
>>58825396
I'm fine with both
>>
>>58825396
Both languages are completely different and there is no point in comparing it.
Learning C++ as C with classes is mistake.

If you want to learn C++, learn C++
>>
>>58828600
>If you want to learn C++, learn C++
If you want to learn C++, don't.*
FTFY
>>
>>58826428
>Rust (C++ done better)
Common Lisp is C++ done better
>>
>>58828638
Why?
>>
File: cpp.jpg (14KB, 242x320px) Image search: [Google]
cpp.jpg
14KB, 242x320px
Is C Primer Plus a good book as well?
>>
>>58828656
C++ is a terrible language, and should not be used for any purpose.
>>
>>58822753
>One major complaint about C is it not having separate namespaces. How do you work with this? Do you use any sort of file organization or segregation schemes to keep symbol collisions in big projects?
To avoid collision between different functions you can use static and wrap all the functions in your .c file in an extern'd struct (basically a vtable). You end up with something like List.append(list, thingToAppend); You can also just choose to prefix things.

>C is a very low level language that is best suited for groundwork, do you use any layering on top for more "high-level" programming? eg. embedded languages such as lua/guile
Common Lisp has excellent FFI capabilities through CFFI on SBCL. There's also ECL which can also compile to C (Chicken Scheme can do this also).
>>
>>58828698
Do you have any experience with C++11?

Have you been working on larger c++ project?
>>
>>58825389
Learn C and write a lot of C first.

After you make large enough systems, such that you've started implementing your own object mechanisms, learn C++, preferably C++11 or later.

You'll understand much better when and why to use C++.
>>
>>58828782
>To avoid collision between different functions you can use static and wrap all the functions in your .c file in an extern'd struct (basically a vtable). You end up with something like List.append(list, thingToAppend);
That's acutally a pretty good idea anon! I'll implement it next time when it makes sense.

As for the low-level/high-level stuff, I am more inclined to use something like tinyscheme, which is a very small embedded language, as opposed to embedding perl or ruby.
>>
>>58824131
Do you have anything to say about either of those things or are you just here to abuse the quoting system?
>>
>>58829011
As an example of when it makes sense to use it, you can use it for API versioning by externing multiple structs with the same interface but links to different functions. You can also use it in the context dynamically loaded libs where you export the same interface through their structs so you only have to load the struct instead of loading all the symbols individually. This lets you reload and change functionality on the fly and you can combine that with another language through FFI to test your new rebuilt code.
>>
Sometimes I get inspired to write very nice and very systemically correct C code, but then I actually try to do it and it becomes cumbersome and boilerplate.
How do you have fun writing C?
>>
op is a qt girl
>>
>>58828648
There are actually many interesting ways that C++ and Lisp are very similar. They share a similar view for what a language should be. Unfortunately C++ just executes it all very badly. Sometimes I dream of a language with the homiconicity of lisp and the low-level unsafety of C++
>>
>>58829253
In Common Lisp on SBCL you can turn down the safety if you want and restrict the types so that it'll generate more efficient assembly. You can also do standard mallocs and frees.
>>
>>58829222
I've found that the fun is clumpy. When I write C, the best parts are refactoring and watching how fast it goes. To me, the sense of accomplishment at the end is the feel-good funness.

Writing it is kind of a pain.
>>
>>58822753
>Linux style
>OpenBSD style
>Avoid like the plague: GNU style
Is there a specific comparison between the three?
>>
Practical C Programming is pretty good. Although I'm coming from java.
>>
*general C++ circlejerk
>>
>>58823400
Thanks anon
Thread posts: 62
Thread images: 9


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.