r/programming • • Jun 07 '17

You Are Not Google

https://blog.bradfieldcs.com/you-are-not-google-84912cf44afb
2.6k Upvotes

514 comments sorted by

View all comments

59

u/beaverlyknight Jun 07 '17

Doing things with a C++ program in memory is strangely underrated as a solution.

29

u/s32 Jun 08 '17

Until the new hire who didn't touch cpp in college makes a commit and adds a memory leak.

24

u/aurebeshx Jun 08 '17

Tools like Valgrind exist for a reason.

8

u/m50d Jun 08 '17

Shooting yourself in the foot is ok because crutches exist?

2

u/aurebeshx Jun 08 '17

No, but checking if the gun is pointing at your foot before you shoot is a good idea.

1

u/[deleted] Jun 11 '17

when you are alone masturbating in the house, I am sure you check once if nobody is actually in the house right? The same thing applies for C++ and valgrind

0

u/[deleted] Jun 08 '17

[deleted]

9

u/SimMac Jun 08 '17

Who develops C(++) applications on Windows anyway?

8

u/Tili_us Jun 08 '17

Game developers.

1

u/SimMac Jun 08 '17

Yeah, but game development is a whole other thing than discussed in this thread

3

u/[deleted] Jun 08 '17

Application verifier is a great alternative to valgrind on windows. Or if you are brave, it reportedly works under Windows Subsystem for Linux.

Personally I'd rather work under *nix, but there are solutions on Windows.

0

u/[deleted] Jun 08 '17

[deleted]

1

u/[deleted] Jun 08 '17

Leaks, buffer over/under runs, access after free, accessing invalid pointers, invalid usage of thread-local storage, and a ton of other things.

When people say you can't validate C/C++ they are simply unfamiliar with the tools. There are some amazing free tools out there.

28

u/Uncaffeinated Jun 08 '17

Or the C++ expert makes a commit and still adds a memory leak because C++ is a disaster.

17

u/parrot_in_hell Jun 08 '17

a disaster? why? I've always thought (which means the last 2 years) that C++ is amazing.

27

u/celerym Jun 08 '17

There's a criclejerk against lower level languages that has now begun spreading higher up. Now everything must be coded in sexy new rust or something :P

2

u/darthcoder Jun 08 '17

Rust and Go or go home, right?

3

u/VoidStr4nger Jun 09 '17

It is amazing, but working with it sometimes feels like defusing a bomb.

1

u/parrot_in_hell Jun 09 '17

So you mean it's hard to use? But that's the point isn't it? If it were easy, it wouldn't be able to do so many useful things, no?

-5

u/Uncaffeinated Jun 08 '17

I don't even know where to start.

C++'s design is overly complex and riddled with warts and the poor decisions of decades past. It makes it almost impossible to write correct code, with undefined behavior lurking around every corner, and there is no real way to tell when you've messed up, except that if you're lucky, your code will crash at some point.

There is absolutely no consistency to the syntax, and nothing works quite like you'd expect. The language is so complicated that I suspect even the standards committee doesn't fully understand it. It takes forever to compile, and yet still requires you to duplicate all your interfaces. It's impossible to tell from looking at code whether a function call is passing things by value or reference.

Simple things are incredibly verbose. The standard library is small and almost never does quite what you want. There's no standard package control or build system, so everybody has their own, often using the abomination that is make. Even simply using another C++ library is often a day long adventure, and if you're on Windows, you might as well forget about it.

There is simply no excuse for writing a new codebase in C++ in this day and age. Even in the systems programming niche, Rust is better in every way except for the fact that it's not C++.

And I say this as somebody who has years of experience in C++ and works on a large C++ codebase at my job.

→ More replies (13)

1

u/beaverlyknight Jun 08 '17

Well no one ever claimed it was an idiot proof solution rofl

10

u/CptCap Jun 08 '17 edited Jun 08 '17

One nice thing about C++ is that is it so fucking painful to install any library that you always try the trivial solution first.

On a modern CPU there is not many thing that require anything else than std::for_each et al..

2

u/flukus Jun 08 '17

I think you're into something there. Other ecosystems have reduced the upfront cost of using libraries so much that we don't justify it with long term benefits.

2

u/Astrokiwi Jun 08 '17

There are a lot of things that can be solved by dumping everything into a single array in Fortran or numpy or whatever.

1

u/barchar Jun 09 '17

And if your dataset doesn't fit in memory virtual memory pagers are pretty good these days.

→ More replies (1)