[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]

Tips for C Programming

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: 232
Thread images: 19

File: screenFetch-2017-04-14_08-56-18.png (199KB, 1366x768px) Image search: [Google]
screenFetch-2017-04-14_08-56-18.png
199KB, 1366x768px
Do you guys use C for systems that require lots of complex structures? If so, what's your approach for that? Do you guys create personal libraries for generic structures (lists, heaps, etc) and use them often during the process? I'm asking it because usually people recommend higher-level languages for me whenever they assign me tasks requiring a lot of abstraction. And although those languages do make things easier, I usually find myself confused because I don't understand what's going on on the inside. And that's why I feel comfortable with C: I know its behavior in memory and how it deals with complex structures. Also, as I have to build everything from scratch most of the time, I end up having a good understanding of the system as well.
>>
>>59886315
>Tips for C Programming
1. Don't use C. No one uses C anymore and people that are paid to write C only maintains legacy system until companies get rid of it
>>
>>59886315
HEY WHITTBOI WHT DA FUC IS DIS SHITE
>>
>>59886555
idiot
>>
>>59886555
I don't use C for work tasks, only academic works.
>>
>>59886555
idiotic webdev fag
>>
>>59886695
Worse, probably a rustfag.
>>
File: 1488943260665.png (339KB, 387x550px) Image search: [Google]
1488943260665.png
339KB, 387x550px
>C Programming

Stop
>>
>>59886858
valgrind faggot
>>
>>59886858
wow, many webdev fags here
>>
>>59886878
Valgrind is obsolete, just use ASAN.
>>
>>59886555
trips of truth
>>
>>59887027
>waiting for runtime to detect memory error
Why don't you just use a proper programming language?
>>
>>59887044
Because I get paid to write C.
>>
>>59886555
Exactly, legacy as in "this only works with C"
HTML5 won't work in a Motorola 80030 for example.
>>
>>59886315
No when I use C I mostly use arrays
>>
You should use Rust or ELisp if you need to go really low-level.
>>
>>59887135
The point is not using C to go low-level. The point is using C for higher-level purposes. There are lots of languages that already have a good amount of complex structures built in, but C is the language I feel comfortable with. And often see myself using it in place of higher-level languages.
>>
>>59887464
So basically you're some C pajeet.
>>
>>59887480
You just made C programming sound so gross now.
>>
>>59887552
>You just made X sound so gross now.
That's something I'd sure like to be paid for.
>>
>>59886555

People still use C

the current stable release is C11 and I think the next is C19 or something

you see micro controllers that come with a standard library in C
>>
>>59886555
> No one uses C anymore
> Never heard about embedded systems, system kernels and multimedia libraries.
>>
>>59887781
> embedded systems, system kernels and multimedia libraries.
That's C++.
>>
>>59887811
They use C for those things as well.
>>
>>59887890
Not anymore.
>>
>>59887979
No, C is still most used programming language to program microcontrollers. When you have 2K of ROM and 128 bytes of ram you don't want to waste it with C++.
>>
Don't typedef pointers, structs, anything really.
>>
>>59887979
I work in embedded systems and come across C ALL THE TIME. In fact, for contrained systems it's even recommended to use C instead of C++ since it makes managing it's memory footprint much easier, and idiomatic C generally runs faster on embedded systems than idiomatic C++.
>>
>>59886315
C has its uses, but complex structures is not one of them imo. I'll just stick to C++ and the STL for things like that.
>>
>>59886315
Most people here on /g/ who hate C don't actually program, just ignore them. C is perfectly capable of being used in programs with complex structures, obviously see the Linux kernel as an example.

If you're writing a program for scholarly reasons, I say you should try to implement as much as possible yourself, for the experience. You'll learn a lot, and find a much better understanding of the efficiency of various data structures and algorithms. In a real job, although you'll probably never need to know how to implement hash maps, sorting algorithms, or the like, you'll need to know which is best for every situation.

Also, keep in mind the C programming language was invented alongside Unix, and reflects the design of that system. If you learn C, you'll probably learn a little about Unix as well, which can't hurt.

The abstractions that higher level languages provide nowadays, while definitely positive, don't make C irrelevant. Learning a language like C makes you understand and appreciate those abstractions, and understand their purpose. Honestly, I think C should be one of the first languages taught to programmers. Maybe introduce the concepts with something like python first?
>>
>>59888217
>>59888264
That's even less 'programming' than JS tho, it's more like a branch of EE. We are talking about actually programming.
>>
>>59888289
> (Embedded) systems programming is not programming

How can you call something like that not programming? It's one of the few fields where you're actually required to know what happens behind the curtains and where badly written software doesn't fly.
>>
>>59888289
What do you think "programming" is?
>>
File: recdean.jpg (8KB, 233x216px) Image search: [Google]
recdean.jpg
8KB, 233x216px
>>59888352
Being a supa h@X0r that only uses kali and pen test , and maybe game and android development
>>
>>59888332
>>59888352
Well ok, embedded programming is programming, but it's not the kind of programming where the language matters, you can as well use asm without any visible problems. When comparing programming languages the focus is on large projects with complex abstractions.
>>
>>59888275
This , everybody else is a webdev hipster or a javalet
>>
>>59888436
>embedded programming is programming, but it's not the kind of programming where the language matters

Embedded programming is basically just like any other programming, except you have very tight resource constraints, and usually a specific purpose. The biggest difference is usually fault tolerance: in an embedded application you can't just let the program crash and restart it, like a web browser. You may also need to be able to guarantee how long a certain process will take, and how much of the system's resources. Think stuff like the software controlling an airplane.

Do you not understand why we invented programming languages in the first place? The point of a programming language is to speed up development, provide abstraction, and reduce errors. This is still relevant in embedded programming, which is why we usually don't use assembly.

If anything, language matters WAY more in embedded. Some languages can be completely unusable, like JVM languages or languages with a garbage collector.

You need to understand that we have so many tools in programming because they all solve different problems in different areas. And none of us are familiar with all of them. When comparing programming languages, the focus is on how well they will help us solve the problem at hand, and nothing more.
>>
>>59888436
From this perspective high level languages are just complex abstractions.

There is no pure programming.
>>
>>59888596
This is exactly right, especially with Security, where a wrong check can mean validation gets circumvented.
>>
>>59886555
fpbp. Literally /thrad
>>
>>59888275
C is a disservice to intelligent programmers. It has almost 0 features that a modern and intelligent programmer uses to be productive. Since C is such a timesink, it's popularity is falling more than any other languages in the market.
C is dying and it should die ASAP. C programmers are actually retards in general. C is a small language to grasp, exactly the kind of shit that makes things retard friendly.
C has no advanced features like C++ does.

But as a newfag you are kinda in the right direction. C is for newbies. Think of it this way:
During ancient times, counting to 10 was a big deal and a person who could count to 10 was considered to be "wise".

Fast forward a few century counting to 10 is so trivial we teach this to toddlers. Now toddlers appreciate the vast "knowledge" of counting to 10 while matured brains are busy with modern technologies.

C is from stone age and the people who still preach it is like overgrown toddlers that can't learn advanced things.
C doesn't have delegates
C doesn't have resizable arrays
C doesn't have strings
C doesn't have string concatenation
C doesn't have namespaces
C doesn't have exception handling
C doesn't have closures in the standard
C doesn't have unit tests
C doesn't have Function overloading
C doesn't have memory safety of any kind
C doesn't prevent memory exploits and has no bounds and runtime checks
C doesn't have dynamic method loading/creatin
C doesn't even have generics and templates
C doesn't have meta programming
C doesn't have mixins
C doesn't have higher order functions
C doesn't have contract programming
C doesn't have inner classes
C doesn't have function literals
C doesn't have array slicing
C has a very limited support for implicit parallelism
C doesn't even have string switches

C is a cancer that plagues the modern software industry. If you want guaranteed memory exploits and security vulnerabilities in your program with timesink development period then use Assembly, not C.
>>
>>59886555
This. Who the fuck uses C these days? C was popular when there was FORTRAN and ASM and C used to be 5 times more productive. This day an age has no use of C unless you have to use a library that's currently only available in C.

So people wrap around those C only libraries and that's all. I've seen people use C++/C# for desktop apps, Java for servers side and C only for writing kernels or in embedded platforms (both of which are very niche).

Java dominates the job market, C doesn't
>>
>>59891019
Whoever made this pasta is extremely ignorant and also doesn't know the difference between language features and libraries that provide pre-built classes/structs and functionality. Not to mention a portion of what you listsd is completely possible in C and libraries exist to give these functionalities already.
>>
>>59891138
>just implement on your own bro
sad
>>
>>59891153
C has been around for half a century, your ideas are not some special snowflake that only you thought of. If you have trouble finding existing libraries that are tested and do it the that's your fault.
>>
File: 1488169244531.jpg (1MB, 2576x1932px) Image search: [Google]
1488169244531.jpg
1MB, 2576x1932px
>>59891173
Library doesn't fix half the lackings mentioned in the pasta, are you dense?

I'd assume you don't know half of them since C doesn't even have 'em
>>
>>59891205
You must have poor reading ability considering I never said a library can fix all of them. I get it, you're panicing and trying to find a way to keep your shitposting act up. Good for you son, too bad it won't save you from being braindead about a good portion of what you wrote.
>>
>>59891227
>I got owned: the post
Ah I see. Next time you try and control damage, try not digging your own hole.
>>
>>59891245
Typical shitposting comeback after you try to make an exaggerated claim to allow you to insult me since that's all you can do.
>>
>>59891227
>I never said a library can fix all of them.
>>59891173
>your ideas are not some special snowflake that only you thought of. If you have trouble finding existing libraries that are tested and do it the that's your fault.
hmmm made me think
>>
>>59891266
You don't really have to reply, just own upto your retardation and move along. It's a quick sand --the more you struggle the more idiotic you look.
>>
>>59891268
Go back one more post friend >>59891138

>>59891289
Its okay if you want to admit already that your pasta is shit and shows your lack of programming knowledge. I will give you a D for atleast mentioning the closure one specifically by official standards only since unoffical ones allow for it which means you did some homework before shitposting.
>>
>>59891320
>>59891266
>>59891227
>that mental gymnastics
Lad, are you upset?
>>
amazing how hostile C++ devs get when C is mentioned
>>
>>59891138
>Not to mention a portion of what you listsd is completely possible in C and libraries exist to give these functionalities already.
>>59891227
>I never said a library can fix all of them.
Hmmmmmmmmmm, made me think again
>>
>>59891339
You're the one freaking out over getting called out.
>>
>>59891364
Ah? I'm not the one who's beckpedaling, c tard.
>>
>>59891354
Do you not understand what 'portion' means? I know english can be hard for ESL pajeets. Just ask if you need help.
>>
>>59891381
see >>59891339
>>
>>59891379
Right, you're just freaking out and trying to avoid the topic by insulting your way out of it.

>>59891408
Pajeet it's okay if you need help understanding simple words. I know your java training didnt prepare you for logic in the real world.
>>
>>59891381
>backpedals to "portion" once he realizes there are no closures in standard C
Next thing you will admit is the fact that C has no exception handling (try..catch..finally blocks)
>>
>>59891019
oh luk dis agian
>>
>C tard getting shredded
Every time
>>
>>59891426
>makes a false claim
>lul use libraries, your ideas aren't special
>gets BTFO
>I-I never said all the problems can be fixed
C people are mentally ill
>>
>>59891432
top kek
>>
>>59891432
Or the fact that C has no meta programming
>>
>>59891514
Or the fact that C has no mixins
>>
>>59891531
Or the fact that C has no namespaces
>>
>>59891552
Or the fact that C has no string switches
>>
>>59891467
You see, when you are busy with writing malloc() and free for each line of codes instead of doing actual works, people tend to become more autistic. That's why no one uses C anymore. C programmers are either contained in mental institutions or mailing lists and IRC where they can feel safe
>>
File: L9v9JXq[1].jpg (12KB, 258x245px) Image search: [Google]
L9v9JXq[1].jpg
12KB, 258x245px
>>59891205
Holy kek lmao I've never actually seen that outdated book in print form. That's not a fucking reference that's an issue of Cosmopolitan.

When will C cucks learn and switch to a *real* programming language?
>>
>>59891780
C tards like to contain themselves into lesser programming language like C
>>
>>59891866
>C is a lesser programming language since you have to actually be a programmer to use it
>>
>>59891937
That's like saying "hurr durr I made a 6x6 integer multiplication manually because I use maths"

No one cares you waste time on trivial garbage
>>
>>59891976
This. C cucks literally cannot stop doing textbook exercises. Real programmers use the libraries and utilities of modern programming languages to actually create products.
>>
>>59892073
In that case, Dreamweaver fags must be the perfect programmers.
>>
>>59892109
Competent dreamweaver users are in greater demand than competent C cucks.

https://www.indeed.com/m/jobs?q=Dreamweaver

https://www.indeed.com/m/jobs?q=C+Programmer
>>
>>59892219
C tard rekt again
>>
>>59892219
Sure, because job demands has really something to do with being a real programmer.
>>
>>59892266
No one wants self entitled real programmers too
>>
you can learn the entire C language by reading a 120 page book in one sitting
people only prefer it over cpp because they're too retarded and lazy to learn the later

1% of /g/ actually does embedded programming, and that doesn't matter anyway because you can get a 250mhz dual core chip with dozens megabbytes of memory that runs a real time OS for $2 now lol
>>
>>59892281
Is that even the point of this whole thread, you autistic fuck? The point is how C programmers deal with complex systems. Fags like yourself were the ones who came up talking shit about the language.
>>
>>59891019
>C doesn't have exception handling

I can only barely code C#, but holy shit, doesn't it really?
>>
>>59892609
C doesn't not need exception.
>>
>Rust shills shitting on C because nobody cares about their shit language
Pathetic
>>
>>59886315
enjoy your thread OP?
>>
>>59892634

>returning errors the same way you return values
shiggy diggy
>>
>>59886555
>t. Pajeet
C isn't going any where street shiter.

>>59888275
This right here.

>>59886315
If you look at old APIs before Cocoa and .NET (i.e. Toolbox, Win32, or UNIX even today) you'll see libraries that combine relevant structures and the functions that operate on them. I tend to do the same thing in C. I'll break a project down almost as if I was using C++ or another OOP language, with the caveat (of course) that I don't have things like inheritance or data hiding. Instead of a class I have a header file that presents the related structures/functions as if they were bound in a class.

As an example, in the old Apple Macintosh Toolbox API you had a Window Manager which was all the functions and structures related to creating and manipulating Windows. Same thing for the File Manager, Resource Manager, etc, etc.

Sometimes your code will be generic and applicable across projects (heaps; lists). Sometimes you optimize for a project, which is where low level C can be really great.
>>
>>59892955
Exceptions are convenient but expensive in every language where I've used them.

If you're using C you're probably worried about execution time and returning a result code is better. The return can always be a result code, 0 for success, with actual results returned via pointers passed as parameters. You don't have to mix the two.
>>
>>59892325
>people only prefer it over cpp because they're too retarded and lazy to learn the later

I prefer it where performance is critical. In those cases using Python, Java, or even sometimes C++ is the lazy option.
>>
>>59892955
exceptions language poorly document exceptions. C document correctly return value.
>>
>>59893166

what did he mean by this?
>>
>>59892957
There there. Everytime a /g/ toddler spews memes like "le pajeet xD", "le sjw xD" you can be assured they ran out of arguments --hence resorts to ad hominem.

>C isn't going anywhere
That's the problem. No one is using C anymore. The legacy C libraries is why C is being used and most of the times those jobs last untill they get ported to C++ or something. Try having a job instead of screeching autistically in your basement. NEET C tard. Or are you just too underage to find a job?
>>
>>59893889
>There there. Everytime a /g/ toddler spews memes like "le pajeet xD", "le sjw xD" you can be assured they ran out of arguments --hence resorts to ad hominem.
Or we're just tired of your shit.

>UNIX
>Linux
>embedded
>drivers
>performance critical
>"That's the problem. No one is using C anymore."
Your mom finished your PB&J. She even cut the crusts off. Go have lunch now.
>>
>>59894167
You basically dodged his question and repeated *nix and drivers a few times followed by a buzzword "performance critical" as your counter argument.

Why do you try so hard to fit in?
>>
>>59888596
>Some languages can be completely unusable, like JVM languages or languages with a garbage collector.
https://en.wikipedia.org/wiki/Embedded_Java
>>
>>59892798
Tbh, yeah. I always have fun watching how cancerous /g/ can be with the most trivial things.
>>
>>59886315
>C
>2017
Enjoy your 43 memory leaks, 12 dangling pointers and 99 data races in one single commit. Please don't publish your shit so people won't suffer.
>>
>>59897437
brainlet detected
>>
>>59897454
Oh I'm sorry. I'm not a turbo (((expert))) 'c' super karnel hacker master who doesn't know how to produce bugs
>>
>>59897482
so shut the fuck up
>>
C apologists are NSA shills plain and simple. Rust makes it harder to produce vulnerable programs as it actually implements safety precautions like Bounds checking, dangling pointer prevention, data race prevention, lifetimes etc. This is against the interest of the NSA and so they are shilling C so that people continue to produce exploit prone, unsafe and vulnerable programs.

Ignore the NSA/C shills. Programming in C should be banned and outlawed.
Say no to security exploits, say no to the NSA. Your data and your privacy is worth preserving.
>>
>>59897555
>>59897482
>>59897437
Ever heard of unit testing, asserts, valgrind, static analysis, address sanitizer, coverity?


I know it's not taught in academia so for some basic knowledge of debugging and testing is a void, especially for pajeets who think the JVM will save them from every producing bugs.
>>
>>59897688
C doesn't have unit testing, you can't use valgrind for kernels, Rust's cargo already has a static analyzing tool built in and C doesn't have smart pointers

C cuck status = BTFO
>>
>>59897717
Okay so you're just a Rust troll and my god I hope you honestly don't believe you can't unit test in C or any language for that matter just because it didnt dedicate a keyword for it.
>>
>>59897741
Your half assed shitty libraries won't do the job, that's why threre are so many security bugs in Linux
>>
>>59897762
You're just digging yourself a hole. Do you even know what unit testing means because I'm really starting to doubt it and your programming ability in general.
>>
>>59897790
C cuck BTFO once again
long square_root(long x)
in
{
assert(x >= 0);
}
out (result)
{
assert((result * result) <= x && (result+1) * (result+1) > x);
}
body
{
return cast(long)std.math.sqrt(cast(real)x);
}
..
/// add function
int add(int x, int y) { return x + y; }

/// code sample generated
unittest
{
assert(add(1, 1) == 2);
}

/// code sample not generated because the unittest is private
private unittest
{
assert(add(2, 2) == 4);
}

unittest
{
/// code sample not generated because the unittest isn't documented
assert(add(3, 3) == 6);
}

/// code sample generated, even if it only includes comments (or is empty)
unittest
{
/** assert(add(4, 4) == 8); */
}
..
void myFunc(T)(T[] data)
{
if (data.length > 2)
data[0] = data[1];
}

@safe nothrow unittest
{
auto arr = [1,2,3];
myFunc(arr);
assert(arr == [2,2,3]);
}


How will they ever rocever?
>>
>>59897825
Are you just pretending to be retarded and act like you can't unit test in any language or do you really not know how to write unit tests without it being built into the language?

This really shows how poorly students are educated these days.
>>
you can create any data type you want in C or find a library/standard library function that does it efficiently
>>
>>59886315
only things I've had to use C for lately has been pretty close-to-the-metal sort of things

Like right now, I'm writing a stupid little game for the SG-1000 in C right now, there's 1kB of work RAM, 16kB of VRAM (not memory mapped, you access through a port) and a 48kB cartridge address space, all my data structures are static, most of my shit is just a bunch of arrays of unsigned chars.
I honestly should have just targeted the MSX so I'd have at least 8kB of the stuff, I don't have enough memory for a full-screen display buffer while doing anything remotely complicated so my game runs in a smallish window. Most emulators map some additional RAM to support the game "The Castle," which has some onboard RAM on the cartridge, but I'm going for stock limits.
On the plus side, I don't have to even think about memory leaks since you're not going to do malloc on a single-tasking machine with 1k RAM.

I could do it in asm, but honestly, that's more work than I can be arsed to deal with for a stupid little project like this, and the sheer lack of typing required for complex array addressing and the lot (sdcc is an optimizing compiler too, so I can write fairly simple code and it'll clean it up to be fast, often faster than what I'd have written) is more than worth it.
>>
>>59886315
Check out:
https://www.youtube.com/watch?v=443UNeGrFoM
https://www.youtube.com/watch?v=lCtALewoFjc
And the Handmade Hero crowd. TLDW: Metaprogramming and Unions.
>>
What is it with Sepples fags and sperging out over missing "features" that exist to solve issues that Sepples introduced in the first place?
>>
>>59892073
>use the libraries and utilities of modern programming languages
And C programmers are the ones writing those libraries and utilities.
>>
>>59892325
>and that doesn't matter anyway because you can get a 250mhz dual core chip with dozens megabbytes of memory that runs a real time OS for $2 now lol
Which uses orders of magnitude more power than an 8-bit mcu, and is less reliable, and when you manufacture thousands of pcbs, those $2 adds up.
>>
>>59886315
+1 for the Arc GTK theme OP. Heil Gnome! Linux Master Race!
>>
>>59886315

Do you implement your own automatic garbage collection and heap defragmenter?

I'm trying to learn bare metal arm programming, it's cool - I like embedded programming way more then the java script trash most programmers get hired to do.
>>
>>59897555

>rust.

Try saying that when you attempt to get a job as an embedded developer.
>>
>>59891019
even if someone actually took this shit seriously they would surely stop doing so at
>C doesn't have resizable arrays
or
>C doesn't even have string switches
>>
>>59897825
>>
>>59899548

Check out dmalloc. It's a malloc debugging library that you can link to any C project you build. I use a Makefile flag to enable or disable dmalloc for debugging or production code. When your code is tight, you don't need garbage collection.

Heap defragmentation isn't really needed in C, once you allocate a block, you have a pointer to it and it doesn't change till you release it. I've rarely had a problem with fragmentation, but I also like to use valgrind to profile the memory performance of any program I write that is intended to run for days/months/years at a time.
>>
>>59891019
You have trouble writing c code, but consider those who can use c properly idiots. Yes, c is a stupidly simple language. It's also an extremely productive language. Shouldn't your difficulty with understanding c reflect more on your stupidity than everyone elses?
>>
>>59894972
You basically just hand waved important categories of software engineering as your counter argument. Why do you try so hard to shit on the highest performing language out there? Is it because you can't code in it?
>>
>>59897555
>this fucking meme

There are no "safe" languages. In a "safe" language you are just relying on an abstraction built by someone else. The processor doesn't know about bounds checking or pointer safety or any other such fucking thing. At some level your precious Rust / Java / Meme language is no more "safe" than C or assembler. That's because C operates in pretty much the same manner as the fucking silicon.

Don't get me wrong. I'm fine with high level languages and their features. But sometimes you have to write code that is performance or memory critical. And you need to manipulate memory and work with addresses in a way the "safe" languages do not allow.

So C is going no where. Because some of us need to work closer to the cpu.

If you ever move beyond Mommy Koder Kamp, maybe you'll learn why.
>>
>all those replies to obvious baits
This thread was going to be a good thread, but you've chosen to not ignore baits and shit this thread up to bumplimit.
>>
>>59886315
For speed you should write all functions in assembly and simply call them from your main loop.
>>
>>59897900
>sg-1000
>C
bloat
>>
>>59901939
you could tell which old cart games were written in assembly and which were written in c or other higher level languages because they always ended up being slow
>>
>>59901643
>That's because C operates in pretty much the same manner as the fucking silicon.
>>
>>59897869
>That damage control
Just sad
>>
>>59886315
So, what's wrong with C++ exactly and why aren't you using that?
>>
>>59902147
it's barely object oriented and carries all the baggage of c
>>
>>59886555
this desu
>>
>>59901975
hey it was true back when the pdp was in down the hall from ken and denny
>>
>>59886315
I personally use C++, but your questions are not limited to a specific language.
>Do you guys create personal libraries for generic structures (lists, heaps, etc) and use them often during the process?
Some times, but I will always refrain if I can afford to use something preexisting.
You can easily trim down a lot of fat by having your own simple libraries for these things, but you can also introduce a lot of errors and waste a lot of time reinventing every wheel possible.
There is no reason to optimize a problem before it is a problem. That is just a waste of time.
>Also, as I have to build everything from scratch most of the time, I end up having a good understanding of the system as well.
Exactly, you start with these projects because you don't know exactly what is going on. This is why students are told to implement them while they are learning.
It is a great exercise where you can learn about the language you should know about data structures anyway.
But once you know how to make applications, you find that simply reading about how it works and then read how the api is made, you know all the things you need in order to use it.
It is too easy to get bogged down in details you never need to worry about.

Regardless of what project you are making, learn the methods people are using. It helps giving you perspective and keep you focused on how to complete advanced projects.
>complex structures? If so, what's your approach for that?
I really like agile development, there you build a very basic system as fast as possible and then iterate over and over to make the system more complete.
The beginning is always hard, you have to make a lot of plans and nothing works.

I don't want you to stop implementing anything yourself, some things gets implemented in a better way or gives you the understanding needed to optimize the system in the special way you need.
I made the same mistakes too.
>>
>>59886555
>what are all major gamedev companies
>>
File: 1492243292674.jpg (137KB, 462x534px) Image search: [Google]
1492243292674.jpg
137KB, 462x534px
>>59886315
>low level programming

fucking disgusting dude
>>
File: ugly-shepard3.jpg (46KB, 465x391px) Image search: [Google]
ugly-shepard3.jpg
46KB, 465x391px
>>59902978
about 0.002% of the total programming market combined
>>
>>59902978
Actually, that's C++
>>
>>59902997
>>59903005
>c++ written in c style
>still c++
>>
File: 1492253029484.png (176KB, 392x391px) Image search: [Google]
1492253029484.png
176KB, 392x391px
>>59903031
>Language X written like language Y is not language X

The fuck am I reading?
>>
>>59901975
In terms of memory it does.
>>
i started reading the c programming language book. looks like a really good book, but there are some topics that i already know. can you guys recommend other good and professional resources for studying C?
also, C is still used in embedded systems, SOs, compilers, HPC(which is why i am studying it) and others types of applications. but a bunch of webdevs fags like you guys wouldn't understand...
>>
>>59903095
not really, it did in the old DEC PDP days but those have long since passed
>>
File: 1491940442841.png (330KB, 552x714px) Image search: [Google]
1491940442841.png
330KB, 552x714px
>>59903095
One of the only abstractions in C is that all of memory is treated as a series of bytes. You don't explicitly fill a cache line and pass it to L2 to operate on as happens in reality.
>>
>And although those languages do make things easier, I usually find myself confused because I don't understand what's going on on the inside
you just described most C purists in a nutshell
>>
>>59903049
>write in subset language because of compiler support
>LMAO YOU'RE STILL WRITING IN THE SUPERSET LANGUAGE EVEN THOUGH YOU USE NONE OF ITS FEATURES
>>
All you "programmers" bashing C for memory safety, bounds checking, dangling pointers, data races and other C "problems" need to ask themselves if language is really at the fault of your problems. Computers are dumb devices, they will do exactly what you tell them to do. If you access data out of array bounds it's your problem for doing so. In reality if you design your system correctly before you implement it you can avoid all of the "problems" of C. Real problem is that developers just don't care about software architecture and just design system as they go - in other terms they do what is called "code pissing". Have any of you even looked at any C coding standard? Take a look at NASA coding standard http://homepages.inf.ed.ac.uk/dts/pm/Papers/nasa-c-style.pdf Do you even write your algorithms in PLD first? C is used in a lot of safety critical applications. Guess what programming language is your car's ECU programmed in. It doesn't matter what new hip cool language will come along tomorrow. If developers don't take system design seriously we will always have software bugs and no amount of language innovation can prevent this.
>>
>>59886611
Yo, cockney rebel nigger! Anything on the old telly?
>>
>>59903326
>GOTO not considered harmful!
>Nigger programmers the real hazard!

Congrats on being a retard
>>
>>59903418
>use tens of goto statements to make spagetti code nobody can reasonably follow
>blame the language
Guess we should remove the JMP instruction from assembly language as well.
>>
File: notamused.jpg (846KB, 1200x1600px) Image search: [Google]
notamused.jpg
846KB, 1200x1600px
>>59903439
>BASIC literally did nothing wrong
>>
File: knuth.jpg (12KB, 250x250px) Image search: [Google]
knuth.jpg
12KB, 250x250px
>>59903418
Goto is not harmful if used correctly. Problems arise when people abuse it.
http://web.archive.org/web/20130731202547/http://pplab.snu.ac.kr/courses/adv_pl05/papers/p261-knuth.pdf
>>
Why haven't you learned Rust yet, /g/? It's like you don't even care about safety or concurrency.
>>
>>59903439
I would have never figured out something like javascript if it wasn't for the embedded systems I did in assembler.
Goto statements is something every programmer should learn, even if they never use it.
>>
>>59903326
do i really need a nasa standard to make my C programs werk? LOL
>>
>>59903611
https://internals.rust-lang.org/t/diversity-on-the-governance-teams/2048
When they will focus more on the language and not other "issues" I might consider learning it. Show me a production application written in rust with complexity of a Linux kernel.
>>
File: 1491580808366.jpg (120KB, 600x600px) Image search: [Google]
1491580808366.jpg
120KB, 600x600px
>>59892325
>1% of /g/ actually does embedded programming, and that doesn't matter anyway because you can get a 250mhz dual core chip with dozens megabbytes of memory that runs a real time OS for $2 now lol
Let's have your 250mhz dual core cpu running an OS handle someone's pacemaker for 10 years with 100% guaranteed no crashes. Yeah, I didn't think so faggot.
>>
>>59903640
You should be following standards regardless of what programming language you use. Code should be well structured and readable for other people to be able to work on it. That's why standards are necessary.

>Programs must be written for people to read, and only incidentally for machines to execute.
t. Harold Abelson
>>
>>59903644
>staying at brainlet level over trivial issues
Good. You're not ready.
>>
>>59892325
>you can learn the entire C language by reading a 120 page book in one sitting
This is true in the sense that you will understand all the keywords C can offer

but you won't know all the design patterns and idiosyncrasies of the language
>>
>>59903644
You know what? It's actually quite nice to have at least one woman on a team. Have you tried working with only guys? It gets tiresome pretty fast...
>>
>>59903326
"Just code better" isn't really a sufficient response for large codebases maintained by dozens of programmers of all varying ability and style.

C is like saying "forget seat belts, child seats, anti-lock breaks, and adaptive steering! How can I power-slide? I want full control; I need to pump the breaks. People should just drive better, then we'd have fewer accidents".

We've been trying to "drive better" for decades (Valgrind, lint, code reviews, static analysis tools, education, ASLR, NX protection, et al). We still regularly see massive security-smashing epic failures.
>>
I just started to learn C as my first programming language (EE student), so far I've been programming microcontrollers only, and made a few tests in the computer, my question is how can I make a program with a GUI in C? let's say I make a calculator with buttons and stuff instead of using the command line.
>>
>>59903745
>car analogy
>>
>>59903772
Whomst are you quoting?
>>
>>59903777
ur mum lol
>>
>>59903818
But I don't think my mom has ever said that.

Moreover, I'm not entirely convinced you've even met my mother, so how would you be able to quote her?
>>
>>59903745
All valid points If you want to race.
>>
>>59903818
are you 11?
>>
>>59903745
>C is like saying "forget seat belts, child seats, anti-lock breaks, and adaptive steering! How can I power-slide? I want full control; I need to pump the breaks. People should just drive better, then we'd have fewer accidents".

This, this right here is how sjws, liberals, do-gooders, know-it-alls and women take the fun out of anything and emasculate & sissify men. How am I ever going to enjoy the thrill of just doing something kick ass or plain fun with all your neurotic rules? It's just a fucking car, with or without safety belts, just drive it, have some balls. Pic related: THAT is programming. Not your sjw-approved, safe and secure meme language.
>>
>>59903871
Forgot pic
>>
>>59903777
You with your "programming is like driving a car" retardation.
>>
>>59903871
>SJWs
filtered
>>
>>59903674
Programming community is not an trivial issue, especially if language is developed by that community. What will they do when they can't find any more developers that fit their requirements? Will language just die? Focus should be only on technology and technology only. They are creating non-existing problems. Programming communities worked just fine in the past, no one complained about diversity issues. Why do they need to bring that up? But setting this aside, you still haven't fulfilled my other request. I ask you again. Show me a production application written in Rust with complexity of a Linux kernel. Until rust proves itself as industry strength programming language no one will consider using it over C or C++.
>>
>>59903871
>gun safeties are emasculating! If I want to shoot myself in the foot I will and I don't want no SJW installing safeties in my muh gun
dumbass
>>
>>59888228
Why not
>>
>>59888228
Fuck you I won't do what you tell me.
>>
>>59903915
>What will they do when they can't find any more developers that fit their requirements? Will language just die?
That is the situation they have now from link posted earlier. They just soldier on while trying to attract recruits who will diversify their team.
If there arent any, there arent any.
>They are creating non-existing problems. Programming communities worked just fine in the past, no one complained about diversity issues. Why do they need to bring that up?
Having a couple of women in the workplace, even on tech projects, is *just nice*. I've yet to work with a woman who was the star of the project, but also I've yet to work with a woman who thought she was the star, or demanded she be treated as one. Would you have chosen to go to strictly all-boys schools if you had the chance? Is it cooties you're worried about?
>>
File: 1435753289282.jpg (827KB, 2404x1260px) Image search: [Google]
1435753289282.jpg
827KB, 2404x1260px
>>59904059
I don't mind what shape of genitalia person that I work or attend school with has. Said that I would probably still pick boys only schools. Why you ask me? Am I perhaps gay? The answer to that will be no. The problem is that women in school environments encourage bad rivalry between males which often results in broken friendships and hatred between peers. Males in school environments often focus more on getting attention of females instead of focusing on their studies, although by the time they reach university they find out that women aren't everything and perhaps learning things is of greater value.
>>
>>59904380
From the woman's side having an all-female environment is fucking awful, everyone is nasty cliquey and backstabby. When a man is in the office it's a calming agent.
>>
>>59904380
Topkek, thank you fine anon. Hopefully later in life you will move beyond this, meaning you will move into circles and circumstances where professional concerns overrule peoples dicks and shit. Some might call that a pillar of (white) civilization and sheet.
>>
If you hate C, you're a pussy ass nigga who can't handle dealing with knowledge about the system you're programming on.
>>
>>59888217
>waste it with C++
C++ has no overhead compared to C, if you know what you're doing.

>>59888264
Managing memory footprint is harder in C. In fact, pretty much everything is harder in C. You have less tools at your disposal.

If you wanted, you could just write C code but compile it with a C++ compiler. It would work the same and have the same memory footprint.

But C++ gives you tons of tools on top of C that helps you organize your code.

C++ makes it much easier to encapsulate the implementation of complex data structures. This makes it much easier to manage the memory footprint. Equivalent C code would be much more opaque.
>>
>>59903418

rasterman had an easily digestible post on properly using goto recently you might check out if you think it's all bad http://www.rasterman.com/
>>
>>59892955
You can return structs that contain success/fail flag or enum along with the data.

I prefer this to exceptions, even in C++. The interfaces are easier to understand because you can see what kind of failures a function might have.
>>
>>59891344
C++ devs need to work with C pajeets that assume any language feature of C++ is "too confusing" and therefore useless. It's pure lazyness and unwillingness to learn anything new.
>>
>>59904619
Similar story for an all male environment although not malicious.
>>
>>59905762
>Managing memory footprint is harder in C.
what ?
>If you wanted, you could just write C code but compile it with a C++ compiler.
no you can't ? but judging from the rest of you post you don't even know what malloc is.
>>
>>59905796
really? i thought it's the other way because c++ devs seem to have problems grasping memory management and pointers
>>
>>59905838
>no you can't ?

Yes you can, and malloc is available in C++ but nobody uses it because it's harder to use with very little gain

>>59905859
C++ has manual memory management and pointers, so I'm not sure what you're talking about.

Basically: "Hurr, I made things hard for myself, look how smart I am"

Typical C mindset
>>
Where are the tips you pieces of shit?

Holy fuck, rustfags are pathetic.
>>
>>59905884
>Yes you can, and malloc is available in C++ but nobody uses it because it's harder to use with very little gain
no you can't because you need to cast malloc in c++ which no one does in C because the standard guarantees that void pointers it will be casted automatically
>>
>>59903662
Also - power requirements
>>
>>59905930
Why would you even want to use malloc in C++? lol

Ok, so you're pointing out a slight difference in the language because you're autistic?

The point is that you can write C++ code that looks and acts exactly like C code. Maybe you have a few extra casts thrown in, but it is otherwise the same.

I'm only saying that to prove the C++ isn't slower than C.

Most of the abstractions have no overhead...
>>
>>59905973
>Why would you even want to use malloc in C++? lol
thats not the point. the point is that you can't just compile c code with a c++ compiler

>The point is that you can write C++ code that looks and acts exactly like C code.
yes you can do that, and until a few years ago c++ was just c code clued together with c++ features. but within the last years c++ code became something completely different.
so what you are talking about isn't really c++.
>>
Its just normies vs edgelords.
Edgelords know far more than normies.
C haters of /g are normies.
Its like some people can't understand mechanics from Landau books and instead want colorful modern era sjw book.
>>
>>59905973
Does C++ new internally calls C's malloc or C++ has its own assembly language implementation of new?
Hope u understand what I asked.
>>
>>59886555

This. You should use a reasonable subset of C++ instead of plain C. It will make your life a lot easier.
>>
>>59906059
Yes, I understand there are many reasons why you can't just use a C compiler. I was just pointing out that C++ is a superset of C.

Therefore, it makes no sense to say C++ is "slower" if it has all the C features available.

>>59906094
I believe they both compile to the same assembly code. The difference is that new will automatically call the constructor. If there is no constructor than the performance is the same.

An advantage to malloc is that you can call realloc, so if memory is incredibly tight you might want to go that route in some cases.
>>
>>59905762
>If you wanted, you could just write C code but compile it with a C++ compiler.
No. C++ is not a proper superset of C. Any malloc calls will not compile (unless you are casting them like a fucking moron) and that is just one example.
>>
>>59906873
It's not a proper superset, but it is effectively one.

For the sake of the argument it is irrelevant whether it is a perfect superset or not.

I'm just pointing it out to show C++ is not slower than C.
>>
>>59886555
you are a fucking retard and everyone who thinks this is probably some fat ass fucking retarded gaming neckbeard.

C is not going anywhere because no fucking language can do the same shit. Pointers and malloc, until your hand-holding Visual Studio programming languages can do this shit then you can just shut the fuck up and let the experts make $200,000 while you cap out at $70,000 making shitty web apps until you get replaced by pajeet

>inb4 c++
shit's so much of a clusterfuck that it's actually more intuitive to use c
>>
>>59906873

>Write a cast whenever you malloc
Oh dear, what a fucking struggle.
Almost everything that can be done in C can be done in almost exactly the same way in C++. Having to write a few extra characters to make your intention explicit does not change functionality one bit and it doesn't make your "muh not proper subset" argument any less autistic.
At least talk something that's actually missing in C++ like flexible array members.
>>
>>59907093
>shit's so much of a clusterfuck that it's actually more intuitive to use c
Classic C programmer.

Thanks for the keks, mate

Next you'll tell me a rock is better than a hammer because you don't understand what the handle on the hammer is for.
>>
>>59907123

C++ is the original kitchen sink programming language, he kind of has a point.

But if you know what you're doing your C++ will almost always end up looking better than C, simply because any solution you write in C will work almost unchanged in C++.
>>
>>59903210
>Implying you can manipulate the cache replacement algorithms with software
>>
So you can use C for almost anything right? But are there things it would be weird or overkill to use C for? What are some things strangely made with C but ended up working well?
>>
Here you go
https://doc.rust-lang.org/book/getting-started.html
>>
File: 1491619022917.jpg (44KB, 282x341px) Image search: [Google]
1491619022917.jpg
44KB, 282x341px
>>59907146
>C++ will almost always end up looking better than C
>because if you just write C code it'll work
>>
>>59907564
thanks I found just what I was looking for

>rustup self uninstall
>>
>>59907582
The point, which you and tons of other C-fags don't seem to understand, is that you can write C++ code that looks like C code.

The C++ features are generally optional.

BUT, if you use some of the features your code will look better than the C code.

You don't have to use the features, so C++ code can look pretty much the same as C code. Yet, the features have the opportunity to improve it.

Makes sense?
>>
>>59886555
He's right though.

C is great but we have Go / D / Rust / Nim to serve as modern safe equally fast equivalents. Nobody should be starting new C projects now.
>>
>>59907662

Cfags have to use every single feature a language offers, whether it's appropriate or not.
It's because they're used to a language only having the bare minimum of features you need to get anything done.
If it's there, they have to use it impulsively so they can proceed to complain about it.
>>
File: 1491108368213.jpg (47KB, 558x564px) Image search: [Google]
1491108368213.jpg
47KB, 558x564px
>>59907662
>C++ code is better because you can avoid all the C++ features
>>
>>59907764

>C++ code is better because you can choose the best way to do thins instead of the only way to do things
>>
>>59907885
>the best way to do things
the C way?
>>
>>59908019

70% of the time.
>>
>>59907764
Fuck, are you trolling me or are you autistic?

C++ = C + extra stuff

Since the extra stuff is OPTIONAL, you don't have to use it.

So how could C possibly be better than C++? C++ has everything that C has, in addition to some very useful features.

That's the point, you autistic moron
>>
>>59886555
why do we even need to know C to maintain code can't we just rename them to .cpp files and then add in all the cool c++ features?
>>
>>59908078

Gotta be those radical array members senpai
>>
>>59908078
C++ is a horrible language. It's made more horrible by the fact that a lot
of substandard programmers use it, to the point where it's much much
easier to generate total and utter crap with it. Quite frankly, even if
the choice of C were to do *nothing* but keep the C++ programmers out,
that in itself would be a huge reason to use C.

In other words: the choice of C is the only sane choice. I know Miles
Bader jokingly said "to piss you off", but it's actually true. I've come
to the conclusion that any programmer that would prefer the project to be
in C++ over C is likely a programmer that I really *would* prefer to piss
off, so that he doesn't come and screw up any project I'm involved with.

C++ leads to really really bad design choices. You invariably start using
the "nice" library features of the language like STL and Boost and other
total and utter crap, that may "help" you program, but causes:

- infinite amounts of pain when they don't work (and anybody who tells me
that STL and especially Boost are stable and portable is just so full
of BS that it's not even funny)

- inefficient abstracted programming models where two years down the road
you notice that some abstraction wasn't very efficient, but now all
your code depends on all the nice object models around it, and you
cannot fix it without rewriting your app.

In other words, the only way to do good, efficient, and system-level and
portable C++ ends up to limit yourself to all the things that are
basically available in C. And limiting your project to C means that people
don't screw that up, and also means that you get a lot of programmers that
do actually understand low-level issues and don't screw things up with any
idiotic "object model" crap.

t. Linus
>>
>>59886555

oh hi. embedded systems programmer here. C is still the tits.
>>
>>59892955
Gb2r
>>
>>59886315
yes, building from scratch, unit-testing every branch, integration tests and fudge testing, no surprises here.
Most free c-libraries are junk in this regard but good enough for the majority.
>>
>>59903767
With X11, you usually create a windows, create a 'picture' that you can modify using a pointer (its kinda stored like a bmp file, all pixels stored in 0xAARRGGBB, putt it on the window, use another image to do your modification and swap them when its computed, to avoid tearing. Its a bit tedious at first but when you've wrote some function to add a bit more abstraction, print form etc, you can do nice stuff
>>
>>59891019
>C doesn't have delegates
>C doesn't have resizable arrays
calloc
>C doesn't have strings
it allows to implement different coding standars
>C doesn't have string concatenation
strcat
>C doesn't have namespaces
only real issue
>C doesn't have exception handling
write it yourself
>C doesn't have closures in the standard
>C doesn't have unit tests
literally what
>C doesn't have Function overloading
useless shit that only causes more indirection
>C doesn't have memory safety of any kind
Annex K was virtually withdrawn from C11
>C doesn't have dynamic method loading/creatin
>C doesn't even have generics and
added in C11
>templates
useless
>C doesn't have meta programming
>C doesn't have mixins
>C doesn't have higher order functions
>C doesn't have contract programming
>C doesn't have inner classes
>C doesn't have function literals
>C doesn't have array slicing
write it yourself
>C has a very limited support for implicit parallelism
>C doesn't even have string switches
strcmp
>>
>>59910613

>C programmers don't know what unit tests are
No wonder you end up with millions of buffer overflow exploits!
>>
>>59904619
>be in all female office
>just found out that stacy has been buying me full-fat frapuchinos on the daily starbucks run instead of fat-free to spite me, that skank
>>
>>59910613
>templates are useless
how_to_spot_the_brainlet.txt
>>
>>59911386
>full-fat frapuchinos on the daily starbucks run instead of fat-free to spite me
2% difference in fat content is really going to kill you.
Thread posts: 232
Thread images: 19


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