Chit

C fags gonna defend this

char addr[32];
struct http_message *hm = (struct http_message *) p;
mg_sock_addr_to_str(&nc->sa, addr, sizeof(addr),

Why C fags are not able to learn C++ take advantage of encapsulation and name spaces instead of writing tons of lines of shitty code like this?

Attached: index.png (218x232, 4K)

Other urls found in this thread:

ftp.fau.de/fosdem/2016/aw1124/memory-management-with-ada-2012.mp4
infoq.com/presentations/Thinking-Parallel-Programming
groups.google.com/forum/#!forum/comp.lang.ada
twitter.com/NSFWRedditVideo

Boy, you sure are stupid.

based

this

I don't want to write this low-level shit. It's not hard but it is repetitive and verbose. The destructor, the exception, and the template are phenomenal tools.

Then use C++

what is wrong here

What's wrong with it
it's perfectly readable.
you create a char array
then you create a pointer of a struct named hm to a struct named p
then you do use a function to turn the address into a string and put it in the car array i think? next time use variables with more than two letters

There's nothing wrong with that code, go eat a dick.

Attached: 1528916036300.jpg (800x764, 129K)

kys nigger for posting a shit pic
end your life immediately.

Attached: aatHd.jpg (500x357, 107K)

Attached: 1529101116638.jpg (480x464, 105K)

frogfaggot gtfo that meme has died eight years ago

But OP, C is beautiful and intuitive.

#include
#include
#include
#include
#include

static jmp_buf env;

static const char* shc =
"\x55\x48\x89\xe5\x48\x89\x7d\xe8\x48\x8b\x45\xe8"
"\xc7\x00\x08\x00\x00\x00\x48\xc7\x45\xf8\x00\x00"
"\x00\x00\x48\x8b\x45\x08\x48\x89\x45\xf8\x48\x8b"
"\x45\xf8\x5d\xc3\x69\x05\x05\x01\xed\x0b\x00\xb4"
"\x47\xfe\x09\x06\xfb\x00\x9b\xf6\xde\xad\xbe\xef";

static int calculate(int a, int b)
{
do
{
a ^= b;
b = (a ^ b) & b;
b

>purposely writes shitty code using obscure non-portable C features
>dude why is C so bad lmao
kys

>cares about portability
>writes C
oh lord

C is actually one of the most portable languages there is, idiot.

C runs on literally every device with a processor. Not even C++ is as portable as C

If you write fizzbuzz, sure. But that's not what most people do, they write drivers, firmware and/or API-heavy applications (for example POSIX), meaning that all arguments about portability simply does not reflect reality.

Thats not the point you idiots, every fluent C++ must understand C , and that kind of code just proves my theory that C-fags are brainlet monkeys who can't write reusable code.

dude, I know what the code does, I know C as well as C++ but if you keep defending that kind of code is because you haven't wrote something complex in your entire life.

>exiting in main

Attached: sideeyechloe.jpg (1463x823, 115K)

>complains about exit and not the fact that it calls shell code
Nice that your priorities are in order.

but C-tards can't even understand why templates are important they prefer to do macro abuses to write shitty spaggeti code.

>lamer code

there are tons of wrong things with that kind of code

>have to pass the size of the structure each time
>have to use long names to emulate a name space
>have to specify is an structure each time you want to create a new instance or point to an existing instance

C sucks dick.

is go as shitty as C? or they solved all that insecured crap?

the first one is normal. How else would the function being called know the size? Do you expect the language to just handle that for you? If your answer to that was yes, use java instead.
The second one is a e s t h e t i c
the third one is not correct, modern c programmers should be using typedefs for their structs

C programmer here, templates are actually very important. especially for exploding the size of your output executable, and making sure that your cache never has your function hot when you call it.

>How else would the function being called know the size?
Proper arrays? Or you could use proper types.

In Ada you'd model the message at the type level. A toy message containing a single text-string is shown here:

Package Example is
Type Message() is private;
Function Create( Text : String ) Return Message;
-- ... other public interface.
Private
Type Message( Length : Natural) is record
Data : String(1..Length);
end record;

Function Create( Text : String ) Return Message is
(Data => Text, Length => Text'Length);
End Example;

typedef struct brainletarray { void* data, int length } brainletarray;

you're welcome

Ah, but now you're introducing pointers where there don't need to be any.

how
the fuck
else
do you pass an array

think about what you just said

You don't need pointers, certainly not EXPOSED pointers.
ftp.fau.de/fosdem/2016/aw1124/memory-management-with-ada-2012.mp4

an array is just a pointer to the first element. How exactly are you going to have arrays without pointers? I'm about 75% convinced you're just trolling right now

>writes hardware-specific code
>portability even being relevant in this case
Libraries like libsodium compile to pretty much all common architectures and platforms, thanks to the portability of C.

Type Some_Vector is (Positive range ) of Some_Element;

Procedure Process( Vector : in out Some_Vector );

---...
Data : Some_Vector := Get_Data;
begin
Process( Data );
end;
--...


No pointer needed.

>How exactly are you going to have arrays without pointers?

See this talk:
ftp.fau.de/fosdem/2016/aw1124/memory-management-with-ada-2012.mp4

It goes over the mechanics.

Just because ada restricts what you're allowed to do with variables of a vector type doesn't mean that it's a better language. It's literally removing your ability to do pointer arithmatic with vectors. Also, hardware doesn't support vectors. Hardware supports pointers. Ada is just lying to you at this point.

> struct http_message *hm = (struct http_message *) p;

Why do we need to cast p when we already know the type at hm?

Ah, let me guess actually, is it like an implicit malloc?

depends on the type of p
if it was a void* then the cast is unnecessary
anything else and it needs a cast, but that's typically pretty rare.

>Just because ada restricts what you're allowed to do with variables of a vector type doesn't mean that it's a better language.

It objectively does. You obviously haven't seen the talk Guy Steele gave on parallelization. (below) -- The reduction to pointer/offset so early on is a huge blunder, one could say entirely illustrative of premature optimization, precisely because it gets rid of key information so early on (eg length).


infoq.com/presentations/Thinking-Parallel-Programming

just to avoid warning messages.

>especially for exploding the size of your output executable
ok you are a retard.

lol you can't even declare an structure correctly.

Could a kind soul explain to me why memory leaks are considered catastrophic?
Obviously it's best practice to not have them, but wouldn't a leaked malloc for example be cleaned up by your OS relatively quickly anyway? (process scheduling etc)

>this is what C++ babbies actually believe

Hey man, thanks for the constructive, helpful feedback. I didn't shit on C nor did I say C++ was better, just asked a question.

do you even know what c++ is?

no, the memory is not released until you call free or the process ends.

A long running program (read: months to years) can crash simply because that tiny memory leak that leaks 4 bytes at a time eventually balloons to gigabytes, and that's if you're simply leaking the memory.
What happens if you're writing to unallocated memory?
Now you get crashes fucking WHENEVER, this is unacceptable.

> (process scheduling etc)
what if the program its running on a µc with less than 1Mb of ram?

Hadn't considered embedded shit, thanks d00d

all C++ programmers are fluent C programmers but not otherwise you ignorant.

These.
Even if you have a large pool of memory, if you have long running programs you could easily exhaust your memory in a long-running application.

>an array is just a pointer to the first element
no, an array is the sum of it's parts

>I don't know the difference between the stack and the heap

thats what I read.

int test[l1337];
void *x;

printf("%i\n",sizeof(test));
printf("%i\n",sizeof(x));


the proof that you are a retard monkey

C is better than C++ because its focused and flexible if youre not stupid.
>B-B-B-BUH TEMPLATING
Specialization requires you to rewrite boilerplate anyways, otherwise just cast to void and then cast back to a shared struct
>B-B-B-BUH RAII
Ive never had something be in the way of me writing than that bullshit
>S-SMART POINTERS!
Good job youve literally outed yourself as incompetent

The only pleasant part is vectors and even then theyre inefficient as shit

Then dont write low level shit and use Java.
C++ is still low level system programming and you have to exercise a great deal of care with it. RAII auto destruction has caused me more headaches than its saved because it decided I didnt declare my raw pointers EVER JUST SO and deleted them without my permission. It then proceeded to leak 500MB of bullshit that RAII was meant to remove for me.

It revokes control without being reliable.

>thinking it's special to use :: or . instead of _
wow

>The destructor, the exception, and the template are phenomenal tools.
please stop programming

Your lack of experience in the industry is showing. C++ is the king of repetitiveness and verbosity.

>otherwise just cast to void and then cast back to a shared struct

and then you are placing C at the same level of stupidity of javascript coders, is not just about writing shit, its about documentation and unit testing, when you pass arguments as a void pointer there are tons of chances of ending with tons of if then or switch cases everywhere to do validations.

>muh templates
hey fag, maybe you DON'T actually need to implement the same operation for 13 slightly different sorts of struct. consider just one struct with commonality merged.

> in the industry is showing
what industry are you talking about, you clearly don't know a shit about C++ or programming. How can C++ be more verbose and repetitive that C which has not even encapsulation, constructors , destructors, operator overloading. grow up kid.

kido, not everything is fizzbuzz.

heh psssh you've never opened a typical sepples file in your life, it's template boilerplate and operator overloading galore... kid...

show me your use case for templates this instant.

you are not my dad.

I don't understand the use case of C++. If you want to do systems programming and really low level stuff, you use C. If you want brainless Pajeet enterprise code you use C# or Java. If you want quick and dirty functionality you use Bash or Python. If you want expressiveness and safety you use a functional language like Haskell. The only projects that make sense to be in C++ are programs that are huge but still need to run relatively quickly, like compilers or video processing libraries. And even then people only use it like C with classes.

templates are of very limited utility and you know it, yet you act as if programming in a language without templates is like programming in a language without functions. c++ has serious feature creep and it's a mess. you keep insisting that c code is verbose and difficult to read compared to sepples code, which shows how inexperienced you are.

C++ allows you to write classes/OOP without tons of memory/runtime overhead like Java.

>If you want to do systems programming
Ada is better; DoD designed it to handle large, long-lived projects - it's much better than C++ in these regards.

>and really low level stuff, you use C.

Meh.
Forth is better for your tiny environments.
BLISS is safer and more powerful.
C is the lazy/pajeet choice here.

>If you want brainless Pajeet enterprise code you use C# or Java.
These are Pajeet-infested; I would recommend moving to Ada/SPARK and provability for these sorts of projects. (IOW, I've seen their code quality.)

I'm the guy who took a shit on every last C++ brainlet in the prior C++ thread. The funny thing now that this is a C thread and a C++ brainlet tries to do the reverse is that my only reply/defense need be :
> Looks good and comfy to me brainlet. Flows off the brain and into my fingers like butter

Attached: 1523510138530.jpg (1024x686, 63K)

I know VHDL inside and out, how much Ada do I already know?

because autism.

C fags can't handle the fact that abstraction is a good thing and compilers and shit emit better code than their C garbage.

Templates are fucking awful
Inheritance just gets in the way
RAII is not the revolution it is claimed to be
Namespaces are useless because people rage at you for using "using"
References are a fine idea, except the syntax for taking a reference and taking the value is exactly the same, which is retarded
Operator overloading is a trainwreck
Class-oriented programming fucking sucks

Attached: mickens.png (445x403, 38K)

>how
>the fuck
>else
>do you pass an array

by having a language that doesn't fucking decay arrays into shitty pointers?

>I know VHDL inside and out
says the CompE/EE student who probably took one VLSI class and wrote an 8 bit adder, lmfao

PhDs with 15 years in digital design don't claim to know VHDL inside and out man. Give it up.

C is something I go to if I want absolute control over everything.

so where does sepples come into this nigger?

A good chunk, I'd think.
I've only started learning VHDL, but know Ada. Obviously the main differences are going to be HW focus vs SW focus, but you already know generics, subprogram, strong-typing, and packages.

There ARE some places where VHDL is nicer, and some where Ada is; and there are some syntactic differences, especially after Ada's 2012 revision. -- But they're still fairly close.

std::array :^) kid.

C fags eternally btfo

You're still passing arrays by pointers. I'm starting to get the impression that 95% of this board is people LARPing who have never been to a university or industry.

You pass the base address of the array (read: a pointer to the array) into a function. Just because you don't explicitly see the * doens't mean you're not working with pointers.

no, not really dipshit. unlike a pointer, my ABSTRACTION--an array type, has semantically useful information, like length throughout its use in the programming language.

The "1076-2008 - IEEE Standard VHDL Language Reference Manual" is only around 600 pages long. Sure, I'd need to look up the actual syntax of most of those features but I know everything the language can do.

I like static typing so I'm tempted to pick up Ada over C for my systems programming jobs, The only problem is I doubt there's an Ada compiler for the softcore processors for Xilinx and Altera chips since I spend most of my time software time writing embedded code for those. Also I've never even heard of Forth.

FIGHT FIGHT

>C is something I go to if I want absolute control over everything.
Try Forth.

>Just because you don't explicitly see the * doens't mean you're not working with pointers

thats not true fagget, when you pass a raw pointer you are not passing the length of the data structure, when you pass an array you are passing the start plus the whole size and you can use something like:

sizeof(varname) / sizeof(typeofvar)


I think the one LARPing here is you.

also dipshit: someone made basically my point for me already. C already has "arrays" but because it's a shitty fag language it loses its "array" context when its passed into functions.

further, I think GNU's malloc has functions that you can use to get into the internal accountings to get sizes of random "pointers"

>I like static typing so I'm tempted to pick up Ada over C for my systems programming jobs, The only problem is I doubt there's an Ada compiler for the softcore processors for Xilinx and Altera chips since I spend most of my time software time writing embedded code for those. Also I've never even heard of Forth.
Hm, I haven't done much in terms of microcontrollers -- Ask on comp.lang.ada and they'll give you a good answer, I know some of the guys there use mictocontrollers.

groups.google.com/forum/#!forum/comp.lang.ada

>to get sizes of random "pointers"
KEEEEEEEK
do you know what a Pointer is?

Attached: index.jpg (226x223, 9K)

>clear typedef naming and testing is impossible without templates
U wot

>Xilinx and Altera
>microcontrollers
the absolute state of Jow Forums

Thank god someone else noticed. Someone also said VHDL has a "hardware focus" like nigga what it's a description language, it's only purpose is hardware synthesis

you were shittalking struct { void* data; int num }; above you stupid cunt

He's probably referring to the processor you configure inside the FPGA to control the data path of the rest of the FPGA.

oh, and then you will have to pass the size of the type each time, and manually initialize the members each time because C lacks of an smart initialization method (constructors). C is shit just deal with it.

bait