Stop writing C

Stop writing C

Attached: mm.jpg (1920x1080, 84K)

Other urls found in this thread:

godbolt.org/g/ccbaVL
godbolt.org/g/WCvVEH
open-std.org/JTC1/sc22/wg14/www/docs/n1256.pdf
youtube.com/watch?v=KlPC3O1DVcg
github.com/EvilPudding/candle
youtube.com/watch?v=rX0ItVEVjHc
youtube.com/watch?v=qWJpI2adCcs
harmful.cat-v.org/software/c /I_did_it_for_you_all
twitter.com/NSFWRedditVideo

#include
#define TRUE 1

void sage() {
// sage goes in all fields
printf("sage goes in all fields\n");
}

void main() {
int opisafaggot = TRUE;
while (opisafaggot) {
sage();
}
exit (0);
}

No

#include

int main()
{
printf("No");
return 0;
}

#include
int main(int argc, char *argv[])
{
printf("Hello World!\n");
return 0;
}


.file "test.c"
.section .rodata
.LC0:
.string "Hello World!"
.text
.globl main
.type main, @function
main:
.LFB0:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
subq $16, %rsp
movl %edi, -4(%rbp)
movq %rsi, -16(%rbp)
movl $.LC0, %edi
call puts
movl $0, %eax
leave
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE0:
.size main, .-main
.ident "GCC: (Gentoo 7.2.0 p1.1) 7.2.0"
.section .note.GNU-stack,"",@progbits

#include
int main(int argc, char *argv[])
{
std::cout

continuation
_Z41__static_initialization_and_destruction_0ii, .-_Z41__static_initialization_and_destruction_0ii
.type _GLOBAL__sub_I_main, @function
_GLOBAL__sub_I_main:
.LFB1983:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
movl $65535, %esi
movl $1, %edi
call _Z41__static_initialization_and_destruction_0ii
popq %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE1983:
.size _GLOBAL__sub_I_main, .-_GLOBAL__sub_I_main
.section .init_array,"aw"
.align 8
.quad _GLOBAL__sub_I_main
.hidden __dso_handle
.ident "GCC: (Gentoo 7.2.0 p1.1) 7.2.0"
.section .note.GNU-stack,"",@progbits

>using iostreams instead of cstdio

What did you expect?

>cpp
>cstdio
I'm using the standard way you would do it in C++, that's like asking why I'm not using inline assembly in C, cause that wouldn't be showing the strengths of C but asm.

>I'm using the standard way you would do it in C++
cstdio is a C++ header, it's part of the standard library

>that's like asking why I'm not using inline assembly in C, cause that wouldn't be showing the strengths of C but asm.
No, inline assembly leads to unspecified behaviour.

Using cstdio is using the standard library.

>No, inline assembly leads to unspecified behaviour.
What did he mean by this?

Daily reminder C++ is for enterprise code monkeys who need (( smart )) pointers to hold their hand while they shit out enterprise bloat with Qt so that they earn money to buy their soymilk

I didn't say "standard library" I said "standard way of doing it". It makes no fucking sense to use C++ and then use legacy tools. If you go to any C++ forum they'll tell you not to use C style pointers, C style IO, C style anything. They'll tell you to learn and get used to the "new way".

That's another C++ problem, 1000 ways to do the same shit.

Sorry, the correct term would be "non-standard".

>I didn't say "standard library" I said "standard way of doing it"
How can it be a non-standard way of doing it when it is part of the fucking standard library?

>It makes no fucking sense to use C++ and then use legacy tools.
The C++ committee clearly disagrees with that sentiment, otherwise they would have broken C compatibility years ago.

> If you go to any C++ forum they'll tell you not to use C style pointers,
Correct

>C style IO,
Wrong.

Why linux c/c++ community aka GCC haven't started using storage class specifier like __declspec, __syscall used in Microsoft extended C++?
Is this unnecessary for linux machines in the way they are made or what?
I hope you guys are aware of this

>>int opisafaggot= TRUE;

Can you really assign a Boolean value to an int in C?

Because the kernel/userspace ABI doesn't change on NIXes, whereas Microsoft has changed it through the years. That's why they rely on annotations like that.

>says you shouldn't use C style pointers
>says it's ok to use cstdio and just because it's part of the standard
The C++ committee clearly disagrees with that sentiment, otherwise they would have removed C style pointers years ago.

is this bait

>#define TRUE 1

>Can you really assign a Boolean value to an int in C?
Yes, because bools are integers in C.

int i = 3.15f; // you can do this too, it will simply be truncated

>Application Binary Interface.
I am brainlet need to know this.

Write C++ as "C with classes" if you want to, I'm just saying that there are many cases where you need to call write() / read() directly and stream semantics aren't appropriate.

You would have known this if you'd written a program more advanced than fizzbuzz.

What is opaque pointer that comes again and again in Microsoft and directx?

>C with classes
Not that user, but it is actually way more. C++ goes into memory management - not a fan of that.
The exception system is totally broken.

godbolt.org/g/ccbaVL

when writing in a common subset of both languages, both result in the exact same code
godbolt.org/g/WCvVEH

In essence, it defines how you pass parameters and return values from function calls.

For userspace applications it is common to just push arguments to a function (in reverse) on the stack. However, in kernel space this is considered wasteful, so they use a mix of specifying registers and pushing on the stack (for example passing argument 0 in EAX/RAX, argument 1 in EBX/RBX etc).

In C++, it's when you hide class implementation from the header files by using an impl pointer.

Always this fizzbuzz argument, I've made game engine in both languages, I've had to deal with all sorts of quirks from both.

>says C++ is just C with classes
>when asked, says you shouldn't use C style pointers
Which is it? Should we use the C++ way or the C with classes way?

C++ is an unholy abomination, the jack of all trades but master of none. Avoid it at all cost. If you want OPP, use better langs like Java or C#.

You know, it's not like you have to choose either going all in and write deliberately shitty sepples or writing perfect ENTERPRISE QUALITY sepples.

You are allowed to be pragmatic. If your application is IO heavy, you might want to consider calling read and write directly instead of using iostreams.

I don't see why you have to make some kind of autistic limitation on yourself, like you're suggesting.

2 rupees have been deposited to your account sir

Reference variables are a fucking atrocity

>For userspace applications it is common to just push arguments to a function (in reverse) on the stack.
Only on 32-bit. SYSV x64 uses RDI,RSI,RDX,RCX,R8,R9 for args and the stack for the rest. Microsoft x64 uses RCX,RDX,R8,R9 I think and the stack for the rest.

That's probably true, I haven't looked that much into it. Thanks for correcting me.

If I use C++, I would just be inviting people who do use very inefficient ways of developing into fucking it up.

Linus Torvalds, please. Your views of C++ are based on misconceptions about how the language was in the 90s.

Bjarne just shave that shit off man. There's no shame in losing your hair but going full pedophile isn't helping anything. get a beard trimmer and no guard yourself itll take 5 secs and youll look much better

see Iostream is how you're taught today, this and others are things that may be helpful for the programmer, but detrimental to the final product.

He's had this look for quite some time now.

Attached: bjarne3.jpg (300x291, 19K)

This is bait.
Don't fall for it!

GLANCE VALUE
L
A
N
C
E

If I made a silhouette of bjarne, everyone here would recognize him, if I made one of you, no one would know who you are, even if you discovered the cure for cancer.

See the rest of the discussion and the post you even replied to ().

>this and others are things that may be helpful for the programmer, but detrimental to the final product
Wrong. There is code that needs to be correct, and there is code that needs to be quick and dirty. A buggy pointer expression causing your program to crash in during runtime and corrupt all data on disk is obviously also important to the final product.

Explains why all the sepples wizards have such weird hair.

Attached: three.png (1047x517, 1.1M)

Like I said before, C++ has more wrong ways of doing things, in the case I mentioned, you could use cstdio instead of iostream and you would have a better result, but because iostream is what you are taught, it creates an incentive to be inefficient.

>misconceptions about how it was in the 90s
I doubt Linus is misinformed on that. It was really shit back then.
Now it's still as shit it just has a little bit of sugar to cover the taste.

I can't sympathize with the mindset that C++ is good. It should be abandoned in favor of other things if just to clean up the old poor decisions.

>If I made a silhouette of bjarne
Just to underscore the pedo look, or what?

After all these years, why has no one created a viable alternative to C yet?

Attached: C.png (867x812, 1.22M)

If iostream is ever a significant enough part of your program that using it instead of printf makes a noticeable performance difference, then a.) You can always use printf in C++, and b.) Your program is probably doing something stupid.

There's loads more examples.

>I doubt Linus is misinformed on that. It was really shit back then.
Yeah, I worded that wrong. Misconceptions based on how the language was in the 90s.

>but because iostream is what you are taught, it creates an incentive to be inefficient.
That is the most ridiculous thing I've read all day. That's like me arguing that since you learned Java as your first language, you cannot be trusted with writing efficient C code because there is an incentive for you to write Java instead.

You keep repeating that, but somehow we are just supposed to take your word for it, right?

You do not have the same inefficient tools on C to fuck it up by using them, you're forced into using the minimal way. Mostly, I'll agree there's some.

Actually, I would argue the exact opposite.

Since C lacks any form of decent algorithms or data structures that is common in virtually all modern programming languages, it provides the programmer incentives to implement their own poorly thought through and buggy collection libraries.

I've seen this over and over again, people relying on their own in-house linked list implementations for example. This is going to have a far greater impact on performance than some RAII container.

you may be correct, but if bjarne walks up to someone and is in need of some sort of help they are much less likely to help him based on looks alone.

What are the main things you dislike about C++?

Poor Bjarne ;_;

I don't understand it.

>you're forced into using the minimal way
no you're not. You can always screw up an implementation of anything, and make it either incorrect or slower than optimal. In C++ you can just write std::find(thing.start(),thing.end(),something) instead of a for loop, and expect at least the same performance

Imagine how sexually frustrated a man must be in order to write an entire programming language.

legacy semantics, mostly.

So what about multiple men doing it?

Is the C standard "available" somewhere, i.e. at no charge? Preferably ANSI C89 or ISO C90.

Because they usually aspire for things other than C.

If you want to make a viable alternative you consider what C is used for and adapt to that. If you look at the ideas behind C++ initially (and most features individually, it's not one language in any realistic sense) it's all about aspiring for other paradigms or features from other languages. It's not about improving the way you write C code.
Compile time introspection is STILL missing from C++ afaik. Which is pretty crazy. I think it's because they don't look at the language and think about how they could make it better. But rather how they can lure in/appease more people.

There's also the backward compatibility issue and inertia behind the language. People will always tell you you've failed to replace C until you've actually succeeded. It's not regarded as a possibility until it's done.

>he doesn't read his children bed time stories from his hard copy of the standard


open-std.org/JTC1/sc22/wg14/www/docs/n1256.pdf

Thats ok

C didn't have bool until C99. Even then, everyone just uses int. 0 is false, everything but 0 is true.

why not use char? I mean int is guaranteed to be at least twice as long as a char isn't it?
>C programmers will defend this unironically

>>>/j/avascript

Attached: leddit.gif (350x232, 461K)

There are books out there with his head and he wants backwards compability

You can use anything to indicate true or false, 0 will evaluate to false and anything else will evaluate to true.

The reason why pre-C99 just uses ints is because every signature defaulted to an int-type before C99.

Ints are the fastest to read on their native machine types. If you want small ints, you can use sized struct members (int x:1) or bit flags, or sometimes you see people declaring something like 'typedef char bool8;'.

>guaranteed to be at least twice as long
only in a struct, in reality it depends on the hardware

C

An int is only guaranteed to be at least 16 bits.

A char represents the smallest addressable unit (and therefore sizeof(char) is always 1).

There may be some requirement that sizeof(int) > 1, I don't know.

OK.
#include
int main(){printlf("Nein");return 0}

>printlf
>lf
>l

Fuck... forgot ';'

#include
int main(){printf("Well, fuck.");return 0;}

>tfw writing games in C
comfy af

When StroodalSoup stops writing his shit-tier language (that he has never fucking used in his entire life on a live enterprise system).

Honestly unless you're making a 3D game just about any language can be used for whatever your task is, just stick to whatever is easiest and best. I pretty much exclusively use JS and node.js for my projects now because it's so fast to develop for, I use C and sometimes Java at my work

2d or 3d?

kek

youtube.com/watch?v=KlPC3O1DVcg

C fags BTFO

>appeal to the authority
kill yourself back to Jow Forums

>C is obsolete because my shitty language with tons of cruft and garbage in it also has C in it
Not only is it a really dumb argument, it isn't even true.

>#define TRUE 1
why not just do this instead?
typedef enum {false,true}bool;

Attached: nope-5.jpg (1280x781, 404K)

thats not a problem its called freedom. most languages prevent it. beauty of c++ is it soley relies on programmer abilities

I don't write C because I'm STUPID!

which is the worst language to program a game in. scope is brutal and opp os shoehorned. only framework for Javascript is canvus

I'm making a 3D game engine. On my repos there's some examples of how to use it.
github.com/EvilPudding/candle

Attached: candle.png (1920x1080, 3.61M)

Not very gay

I had a quick look at it and it just seems terribly overcomplicated and kind of inefficient.
All this crap with signals can just go. It's not necessary and doesn't make things simpler in the end, but just more complicated.
I still can't find where fucking "sig("world_draw")" ends up doing anything at all.
This kind of shit is gay.
You should just get to know your data, and simply do the transforms necessary to get where you want.
This way you get much more power over how everything works, while your code ends up simpler.

Not everything under the sun needs to be an entity. Actually this thinking is completely harmful.
Don't generalize much at all in something like this where you pretty much know everything about your data.
I know you are trying to build an entity component system because all the cool kids do it too, but I don't think you should do it this way.

Whats your end goal with this?
If you want to program a game, pretty much all of the things you are doing are unnecessary.
I don't even understand how you ended up like that.
Anyway, seems like you need a good old dose of mike actons teachings:
youtube.com/watch?v=rX0ItVEVjHc
youtube.com/watch?v=qWJpI2adCcs

harmful.cat-v.org/software/c /I_did_it_for_you_all

sig is a macro which converts the string to a hash compile-time, so it doesn't have to do string comparisons or hashing in runtime. If you notice, that was from my very last commit, before I was using extern global variables with a number for each signal, and you would call the signal by calling those variables. This way is better because you can reference the signal without having registered it yet.

>Not everything under the sun needs to be an entity. Actually this thinking is completely harmful.
What exactly do you have a problem with it being an entity? For example, because of the entity component system, I get a generalized way of having signals and listeners and a GUI, if I want something to have it's own interactive graphical interface, I just register a listener for "component_menu", use the nuklear functions to draw the controls, and it is all displayed in it's proper place, I think if you saw how it runs and how it fits with the GUI you would understand.

>Whats your end goal with this?
>If you want to program a game, pretty much all of the things you are doing are unnecessary.
Like I said, you can check the other repos to get a sense of what I'm using it for. I am also using it for my master thesis. All the tools that are there are there because I needed them at some point.