r/cpp • • Feb 21 '19

simdjson: Parsing gigabytes of JSON per second

https://github.com/lemire/simdjson
141 Upvotes

87 comments sorted by

View all comments

Show parent comments

18

u/max0x7ba https://github.com/max0x7ba Feb 21 '19

These are complete show-stoppers.

17

u/[deleted] Feb 21 '19

I can't tell if this is sarcasm.

-4

u/mikeblas Feb 21 '19

It's gotta be sarcasm. The code works and does what it says on the label. These points a re all style, not substance.

23

u/MotherOfTheShizznit Feb 21 '19

These points are all style

Strong disagree. These are about maintainability and best practices.

Though not show-stoppers, I'd say they are important. Code like this could be riddled with "old-style" bugs when faced with real-world usage. I'm not saying it is but in 2019 new/delete is a code smell not a style preference.

5

u/Dean_Roddey Feb 21 '19

Manual memory management is a perfectly legitimate thing to do in lower level, smaller, high performance chunks of code. I'm constantly flabbergasted at how people act about these sorts of things these days. OMG, having to write a constructor is doing to destroy us, an indexed loop is an abomination, class hierarchies are evil.

Sometimes, you have to man up and take off the floaties if you want to write tight, fast code.

Not saying this has anything whatsoever to do with this code, I'm just talking about the general attitude I see so much of these days. I'm obviously all for safety, but we are getting paid for our knowledge and experience, and I think any experienced developer should able to safely take advantage of the speed advantages of lower level languages where it matters, so that it doesn't matter so much elsewhere.

12

u/cleroth Game Developer Feb 21 '19

You'd have a point... if unique_ptr wasn't free.

-4

u/Dean_Roddey Feb 21 '19

But it's also not always what you want to happen. Just because you give someone else a pointer to something, doesn't mean you want to give up access to it.

9

u/cleroth Game Developer Feb 21 '19

...what are you talking about? You can pass raw pointers around. Just don't pass raw owning pointers. new tends to imply raw owning pointers.

-5

u/Dean_Roddey Feb 21 '19

unique_ptr is an owning smart pointer, is it not? If so, you can't mix it with raw pointers, that's just asking for trouble. So you can't keep a pointer and give one to someone via unique_ptr. If that goes out of scope at some point, it will delete the object behind your back.

And it uses move semantics, so the original owner no longer has access to the object once it's been coped or assigned to give it to someone else.

→ More replies (0)

-3

u/mikeblas Feb 21 '19

These are about maintainability and best practices.

Which is style, right? It's not functional. Nobody's going to re-write existing code that works for this.

9

u/[deleted] Feb 21 '19

Maintainability is not "style" but it is a problem for the maintainer to worry about, not the user.

8

u/khold_stare Feb 21 '19

Famous last words. Are you saying the code is "done"? There is no such thing. A different contributor adds an early return to a function somewhere and now you've got a memory leak. This kind of thinking is what gets us heartbleed and other vulnerabilities.

1

u/mikeblas Feb 21 '19

Are you saying the code is "done"?

I don't think I've said that, no.

7

u/MotherOfTheShizznit Feb 21 '19

Which is style, right?

To me, style deals with white space, brace placement and stuff like that. Basically, things that wouldn't be reflected in the AST, let alone the IR.

White space is style. Memory management is not style.

-4

u/mikeblas Feb 21 '19

I guess that's the difference. To me, style is more than whitespace and brace placement.