Better HN
topnewbestaskshowjobs
Log inSign up

hellofunk

9,428 karma · joined Jul 10, 2015 (11y ago) · 3,276 submissions

John Bellick, Mexico City
Submissions

comment 10y ago · link · parent

What a superficial thing to say. Is social media all you can think of? Every generation is born into a context out of its control and contributes what it can to what it was dealt. If you think social media is the pinnacle of the Generation X,Y,Z group, you aren't looking very far.

comment 10y ago · link · parent

There is an interesting TED lecture about the gradual rise in intelligence, how children are usually smarter than their parents.

comment 10y ago · link · parent

Actually if I recall correctly, an absurd law was passed that would seem impossible to enforce, and it stated that it was illegal to walk around your own house in the nude. I don't know if that law is still around, but it was active a few years ago when I lived there.

comment 10y ago · link · parent

Yes, but prostitution is legal in Singapore.

comment 10y ago · link · parent

... and no freedom of speech

comment 10y ago · link · parent

>of all the fluff phrases

You're forgetting "it is worth noting", "it is important to note," "it should be noted that," "I should note," and their many derivatives which serve no purpose and are nothing but filler. [0]

[0] https://en.wikipedia.org/wiki/Wikipedia:It_should_be_noted

comment 10y ago · link · parent

Objective-C has nothing to do with it, actually (despite that Objective-C technically is C with a superset of features -- all C is compatible Objective-C).

The issue is the build/compilation process for the different platform architecture via cross-compilation. Tends to be rather tricky, regardless of the actual language you choose to write your app with (this build process is entirely separate from any code you write yourself in any supported iOS language).

comment 10y ago · link · parent

>The basic idea is that specs are nothing more than a logical composition of predicates.

This reminds me of this technique:

https://github.com/astoeckley/Eat-Static#going-further

comment 10y ago · link · parent

building libwebsockets on iOS can be quite a chore for many, however, and the authors of the library are not shy to express their distaste for Apple products, which I find inappropriate.

comment 10y ago · link · parent

JIT compilation opens up a lot of new features and workflows in a language, from interactive development at a REPL to in some cases very powerful abilities to generate, compile and run code all at runtime (i.e. "eval" in lisps).

2471.

Interactive Vim Tutorial(openvim.com ↗)

2 points · by hellofunk · 10y ago · discuss

comment 10y ago · link · parent

Related: "it is important to note", "it is worth noting", and derivatives. [0]

[0] https://en.wikipedia.org/wiki/Wikipedia:It_should_be_noted

2473.

“It should be noted” and its cousins are the new wasteful phrase of the decade(google.com ↗)

1 points · by hellofunk · 10y ago · 1 comment

2474.

Tobacco, caffeine, alcohol, and carpal tunnel syndrome in American industry(ncbi.nlm.nih.gov ↗)

3 points · by hellofunk · 10y ago · 1 comment

comment 10y ago · link · parent

Say more! I'd like to know what you mean.

comment 10y ago · link · parent

I'm inclined to agree that for objects that are going to be created and destroyed very often, especially in tight loops, PIMPL is not an ideal idiom. I wouldn't use it to generate fleeting effects in graphics, for example.

For objects that are used in setting up parts of a system and that will persist for long periods of time, maybe even the lifetime of the app, PIMPL is particularly well-suited for such classes. Classes that might manage networking, or encompass an entire part of app's running architecture, etc.

comment 10y ago · link · parent

With the use of link-time optimization, most of the overhead of using pimpl idiom is removed. Both the outter wrapper functions as well as the implementation functions can be inlined, making the function calls effectively like a normal class implemented inside a header.

comment 10y ago · link · parent

The bogus part is 10 minutes vs a few seconds just because you change to the latest standard.

comment 10y ago · link · parent

PIMPL means "pointer to implementation" and the reason you and your colleagues are having difficulty with it is because you don't understand it, and therefore should not be using it, or, investing the time to understand it before trying to use it.

>every class has its own .cpp and .h file

Wrong. There are so many high-quality and widely-used libraries that are "header only".

>When I do any of these tricks, find that someone else later comes and makes a changes that introduces the extra #includes after all.

It is possible to write sloppy code in any language, and also to receive low-quality contributions from anyone else to your code. This is not unique to C++. That's why it is important that everyone in a team be on the same page about how code is organized.

>I am referring to writing a base class in the header and then doing the actual implementation in a derived class visible only inside one .cpp file.

This is not the PIMPL idiom, though it is halfway right.

comment 10y ago · link · parent

This article is not very general. Much of what it tries to convince us is not going to matter for most developers, and has the cost of suggesting modern features are not good for any developers. For example:

>It is not rare to see Modern C++ applications taking 10 minutes to compile. With traditional C++, this number is counted in low seconds for a simple change.

This is simply a bogus statement with respect to what at least 90% of c++ developers do on a daily basis.

I have benchmarked unique_ptr, auto, brace initialization, lambdas, range-based-for and other modern idioms and found them all to be at least as fast, and often faster, than their older counterparts. Now, if I were to instead go off and write template-heavy code using new features, that would be different. But in reality, the vast majority of c++ developers -- I'd wager at least 95% -- are not writing variadic templates on a daily basis (nor should they be).

The memory safety and many benefits from unique_ptr [0] is one of many modern tools that is a non-brainer to use in nearly all contexts. No, not nearly all contexts, allow me to rephrase: all contexts. It just is, and if you compare its use to manual new/delete code, the benefits are solid and faster.

The author further claims that modern C++ is less maintainable and more complex. The absolute opposite is true in nearly all cases. Using unique_ptr again as an example, it leads to less code, less complex code, more clear code, and better maintainability and code readability. Uniform brace initialization is another example that prevents many common older problems in the language.

FYI the author keeps talking about high frequency trading as an example of why modern c++ is a bad choice. Well, I worked at a HFT firm for a long time until last year, the firm places millions of trades per day and is among the most successful in the markets it trades. And what did we use? Only modern features. Lambdas, auto, unique_ptr, range-fors, even std::async -- everywhere in our code. This author is either naive or political.

I think the title of this article is highly misleading, and the contents are not relevant. Overall, this article is just bad advice for most of us.

[0] https://news.ycombinator.com/item?id=11699954

comment 10y ago · link · parent

One more to add to the list: J.S. Bach who walked some 200 miles to hear an organist play once. One of many legendary anecdotes about the man.

comment 10y ago · link · parent

I'd also be curious about the run-time costs (performance) of an exception-ready system that doesn't actually ever handle exceptions vs one that doesn't consider exceptions a possibility.

comment 10y ago · link · parent

Run time type checks in my experience mean a few things:

1) You can compile or run the program fine even if there are type errors.

2) An existing type error may never be caught if that particular block of execution never runs. Then you can have unexpected surprised later when you finally do something to trigger that block.

3) They are slower than static type checking due to the runtime costs of checking types. Statically-typed compilers can do enormous optimizations once they know exactly what the types are.

comment 10y ago · link · parent

The OP asked for examples of lisp being used anywhere that is relevant, and I gave some.

comment 10y ago · link · parent

To be clear, I was not referring to references at all but rather to naked pointers you get by calling get() on a unique_ptr, and passing those to non-owning classes/functions that need them (including third-party APIs).

comment 10y ago · link · parent

I completely agree and I wish we could have the best of both worlds. I love Clojure and I love the compiler support with static typing in other languages.

Clojure attempted to add static typing with the core.typed projects, but high-profile exits [0] from that framework have made clear that this is a problem that can only properly be implemented at the language level.

If I could have a lisp with static types, I might not use anything else again.

[0] https://circleci.com/blog/why-were-no-longer-using-core-type...

comment 10y ago · link · parent

>instead of having clear memory ownership contracts

You have a good point for shared_ptr, but unique_ptr offers the best clarity for ownership, much better than raw pointers, since owning and non-owning pointers all look the same, but a unique_ptr that hands out regular pointers to its memory makes it clear in the code who owns what.

comment 10y ago · link · parent

Unique_ptr offers many advantages:

1) Exception safety: what if you throw between your new and delete? Unique_ptr will clean up for you anyway and leave you in a stable state.

2) What if you forget to delete or your delete code never runs? Any of the many problems associated with explicitly writing delete can be non-issues with unique_ptr.

3) Clarity. When you see regular pointers in C or C++, it is never immediately clear who owns them. With unique_ptr, you don't have this problem because it doesn't look like a pointer. If you therefore see pointers, you know immediately they are non-owning.

4) Convenience functions like reset() on unique_ptr handle the release of the old and allocation of the new simultaneously. In general, the less code you have to write is often the better path to safety and maintainability.

5) Unique_ptr handle resources other than memory. It can be used to handle file streams, DB connections, etc and automatically close those also, if you provide a custom deleter function (which can just be a lambda, for elegance).

6) Unique_ptr is not copyable. This is important: if you own resources, it force you to consider this when you copy objects, and the compiler will force you to write your own copy constructor. Without this, it is easy to get into trouble if you forget these things with raw pointers.

7) Many syntactic improvements: i.e. unique_ptr will automatically call delete or delete[] based on what needs to happen, you can't accidentally get it wrong.

This is just a start list. The value of unique_ptr is considerable.

comment 10y ago · link · parent

I agree, and I frequently use unique_ptr only, and then pass naked pointers to non-owning objects who need a reference. In this way, the code is clear: if it is a regular pointer, it is non-owning always.

Some might argue that using shared pointers is better for this application, but then you must also deal with potential reference cycles and add weak pointers to the mix eventually, and in addition to these concerns, handle any runtime hits for the reference counting.

1
828384
110