Car* car = new Car();

Car* car = new Car();

Attached: 1542039436882.jpg (750x724, 60K)

Other urls found in this thread:

youtube.com/watch?v=a0YrCABCOEY
twitter.com/NSFWRedditImage

OOP was a mistake

it's as if Autism was a language

And multicore CPUs were a "mistake"
5 years ago

Car car;

low quality bait

(lol captcha)

Car *car = (Car *)malloc(sizeof(Car));

Attached: mfw.png (445x148, 27K)

auto car = std::make_unique();

>tfw google is tracking you in realtime

Attached: bp.jpg (620x400, 26K)

>Wählen Sie alle Bilder aus, die
>ein Geschäft von vorne zeigen
????

no

Attached: 1556057057133.jpg (306x306, 36K)

malloc returns a void pointer, you need to cast it to the right type

What's so hard to understand

object 'car'
make 'car'

Attached: 12321.png (126x196, 45K)

The C Programming Language

Attached: thecprogramminglanguage.jpg (379x499, 27K)

stop speaking nazi you wurst swallower

CDR

old new = new old(New, Old:New);

Attached: 1534612207788.jpg (372x471, 39K)

import car

nvm fucked up

MyString.setString((new String("My String")).toString());

>casting malloc
yikes

Attached: 1435515581122.png (653x716, 482K)

>sepples

Attached: 1556165500755.jpg (1280x720, 380K)

struct Car* car = (struct Car*)malloc(sizeof(struct Car));

Initialize_Car(car);

Is this considered bad form in C?
#include
#include

#define new(t,v) t v = malloc(sizeof(*v))

struct Point
{
int x;
int y;
};

typedef struct Point *Point;

int main(void)
{
new(Point, p);
p->x = 10;
p->y = 20;
printf("%dx%d\n", p->x, p->y);
new(struct Point *, r);
r->x = 5;
r->y = 15;
printf("%dx%d\n", r->x, r->y);
new(int *, n);
*n = 25;
printf("%d\n", *n);
return 0;
}

based C++

How hard is it to write malloc? "new" implies different semantics

#define MALLOC(x) malloc(x)

I use it for allocating data structures.
new(ListNode, list->next);
seems more expressive to me than
list->next = malloc(sizeof(*(list->next)));

Car *car = new Car();

there

i dont like that because it obfuscates the declaration. just write malloc you lazy nigger

good thread

Attached: me.jpg (1920x1080, 200K)

>Using typedef for this
I hate this OOP way of thinking

>C++

You have never seen then a big project then, that has more than 15 years of work in it and everything was written procedurally.
Those things are full of magic

Attached: 23456789.png (839x627, 856K)

>var car = new Car

Based C#

var car
prove me wrong

>forcing oop into C
stop

Attached: 39989514_1670742956386210_5813449294123892736_n.jpg (960x540, 33K)

>casting malloc

Attached: 1501848126422.png (728x546, 409K)

Yeah, I agree if you need any sort of decent abstraction in C you may as well just use C++ instead

youtube.com/watch?v=a0YrCABCOEY

try
malloc(sizeof *ListNode)

instead

CarFactory carFactory = new CarModule.CarFactory();
CarBuilder carBuilder = new CarModule.CarBuilder(carFactory);
Car car = new CarBuilder.Car();
car.Drive();
car.Exit();

I love when Ctards do this and then can't seem to write an equivilent in C because it's a massive strawman argument and writing the equivilent in C would show it.

Fucking japshit, buy domestics

Attached: pepe-transparent-laugh-1.png (250x242, 103K)

Jokes on you, I use Python :^)

>equivalent
why the fuck would anyone want the equivalent of that abortion

No they weren't paralellism was always gonna happen sooner or later.

>auto car
heh

Attached: 1552550607654.jpg (400x399, 24K)

You either are using C, in which case it's normal to cast malloc, or you're using C++, in which case you probably shouldn't be using malloc in the first place.

Dumb pedantic bullshit that nobody cares about IRL

A) why would you ever want to
B) you can do that very easily with function pointers, but see A

Why so hostile??

Attached: 1554954486419.png (1278x720, 765K)

I guess I've just been exposed to too many people masturbating to the C language spec and thinking that knowing syntax trivia automatically makes them better programmers. IRL I don't care whether people leave the parens out of their sizeof's, as long as they don't act like it's somehow incorrect to include them

malloc(sizeof *ListNode)

is way fucking better than

malloc(sizeof(*(list->next)));

u fucking brainlet. would hate to share a code base with your primitive ass

The fact it's behind a macro means that isn't a problem at all. Any extensive C codebase is going to have a fuckhuge EDSL in use.

val car = Car()

new is redundant. Why would you want the concept of something that is both an object and a method?

Mandatory semicolons are just superstition at this point. They're artifacts from a time when people had no idea how to format code and were just experimenting.

Explicit typing when type can be implied is also an artifact from when compilers and editors were pretty dumb and type-inferring was somewhat costly.

95% of the time your variables should be immutable. Improves parallel processing performance both in multi-threaded code and in processor misses. Syntax should reflect that.

And while I'm at it, pointers are a bit of an artifact too. In embedded it still very much matters where known/predetermined register locations are a thing, but the 99% of the rest of the code gains zero benefit from using pointers over references. There's a myth that pointers improve data density, but that's not true at all. Reference bloat in languages/environments like Java are pretty much just historical baggage. If you wanted a dense array of plain-old-data of whatever format you wished, you could easily make it work without ever being able to see a number associated with the reference.

LMAO your fucking syntax is still wrong, pretentious ass nigger

>you need to cast
no

>avoiding addressing the fact that one way is clearly superior

idiot monkies

Yep, the superior way is the one that doesn't dereference a FUCKING STRUCT lol, check your code before you fuck up a simple example while trying to act superior

auto *car = new Car()

I've taught you well son.

Attached: complete-java-online-training-by-durgasoft-2-638.jpg (638x479, 112K)

return new Car.Builder().build();

from vehicles import Car

car = Car()

Python is best

nigga if that wasn't main then exit I would have slapped you for not deallocating those points

You dont actually program for a living

object oriented programming makes designing efficient software impossible. just because your employer doesn't care doesn't make it untrue. :)
I do understand why people love OOP though it's because it makes designing software easy it gives bad programmers an intuition easy rules to follow.

If you were an employed software dev you would know that designing efficient software will not be even remotely as successful towards your business and product goals as efficiently designing software.

It's all about adaptability and towards that end modern design practices are entirely revolved around automation and modularity. If it means writing 1000 lines of boiler plate for every console app then so be it as long as you can respond to a problem in and implement high priority fixes in hours and days rather than months.

Also it's very cheap to throw more memory and processors at a problem. Throwing more domain experts at a problem on the other hand? Good luck with that.

Car myCar = new Car();

is that supposed to be C#?

for (var currentCarBrandIndex = 0; currentCarBrandIndex < carBrands.length; currentCarBrandIndex += 1) {

Attached: 1530485639391.jpg (647x435, 44K)

List farts = null;

var car = new()

Functional designs are often significantly slower than object oriented designs due to all the memory copying, or rather the lack of it in OO.

only sensible syntax itt

Based

It's sad that you think the only alternative is functional programming.

car_t *car = new car_t;

The more I use java at work the more I hate it. I fucking wish we could use kotlin or scala instead holy hell. Doesnt help we are stuck using java 7 still lol

>designing efficient software will not be even remotely as successful towards your business and product goals as efficiently designing software
breath of fresh air, let me just repeat that to drive that in to people's minds

like the fact we dont even have
>Car car = new();
inferred type is proof this language is deisgned to harm you when you use it

>(E[]) new Object[size];
may g*d have mercy

#define harm_planet struct car *new_car = malloc(sizeof(car))
harm_planet;

based

At least it's not ham planet
Fat "people" should be starved

OOP predates multicore processors by over 50 years you fucking retard

Attached: 757.jpg (1022x547, 57K)

Procedural doesn't scale well without strong organization (OO, anyone?). Other declarative sub-paradigms outside functional tend to only work in specific problem domains.
If you think you have the silver bullet, then post it instead of being intentionally vague in an effort to look smart on an anonymous imageboard.

>Java 7
That's literally all of your problem. Well, that and working with devs who have been poisoned by old Java.
I'm a smug C# programmer, but I'll admit that 8 is actually decent. Well, if you mentally blank out all the old cruft and just write idiomatic Java 8.

class Truck extends Car {
// A truck uses no functions that relate to a car, but we can kind of think about it as a sort of car so this is the right way to code

kek

Attached: lol.gif (290x189, 1014K)

The samefag is strong in this one.

I had a "select street signs" a while back where the sign was like two blocks from my house. Was really trippy.

Attached: Screenshot_20190427-030237_Clover.png (1440x2560, 345K)

This pajeet pasta is fucking golden.
I shall take this into work on Monday and laugh at it with other programmers.

Attached: fuckinglol.jpg (474x590, 29K)

abstract class TransportDevice {
...

class Car implements TransportDevice {
...

class Truck extends Car {


University was a mistake desu, This was half a course.

class SixWheelTruck extends HeavyDutyTruck {


I actually worked in a project that had multiple inheritance chains of length 7 and no clear roles of each "level".

>not using Java 9
var car = new Car();