Better HN
topnewbestaskshowjobs
Log inSign up

hellofunk

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

John Bellick, Mexico City
Submissions

2221.

Nissan creates self driving chairs for people who can't stand queuing(designboom.com ↗)

1 points · by hellofunk · 10y ago · discuss

comment 10y ago · link · parent

I'm not a big fan of Facebook, but I'll admit that React was a real game-changer for my own development life. I don't use JS any more but all the idioms I learned using it I now adopt to other languages. I heard once that React actually came out of the Instagram team, which Facebook acquired. Regardless of the history, it's an amazing tool.

2223.

Unsafe Air-Pollution Levels Affect 9 in 10 People Globally(time.com ↗)

5 points · by hellofunk · 10y ago · discuss

comment 10y ago · link · parent

What? C++ has a gigantic ecosystem for high quality libraries in a huge number of fields.

comment 10y ago · link · parent

I didn't say it was hard to understand; but it does scare me to depend on any C-style macro like that in a C++ project.

comment 10y ago · link · parent

You don't need in/out params to get references; in Swift, anything defined with "class" is always passed by reference.

comment 10y ago · link · parent

> The standard does not guarantee order is preserved

Are you sure about that? The standard does not guarantee which order transform will actually run and apply the function, but that is a different matter than the order of the final result. I'm pretty sure the standard guarantees that. If you have side effects and require application order guarantees, for_each is the one to use.

edit: this SO answer from a Google engineer suggests I am correct: http://stackoverflow.com/questions/34167638/stdtransform-ord...

comment 10y ago · link · parent

Well, technically Swift's memory management is the same as what C++ offers via smart pointers, the only difference is that in C++ it is opt-in (and still very popular). Swift is quite unlike Go or Java's memory management; it is not a GC in the sense that they use it.

comment 10y ago · link · parent

Fair enough. The point I was (trying) to make is that Swift doesn't have a traditional GC like Java, or Javascript, etc.

comment 10y ago · link · parent

For the curious, there are many other stabs at doing functional programming in C++:

https://github.com/beark/ftl

https://github.com/BartoszMilewski/Okasaki

https://github.com/fons/functional-cpp

https://cat.github.io/

There is a lot of interest in making this happen in C++, which is awesome.

comment 10y ago · link · parent

Yes, but I thought the question you replied to was about IBM's implementation, and thus their github page for it.

comment 10y ago · link · parent

The author of the first STL has famously said that, even after all these decades, he has never written any C++ code that uses OO inheritance, because he hasn't found a use for it.

The STL is mainly a generic library, not an OO library.

comment 10y ago · link · parent

take a look at one of the macros this library depends on:

https://github.com/kennytm/utils/blob/master/traits.hpp#L47-...

Wow that scares the heck out of me to do that!

comment 10y ago · link · parent

Cool, but I'm left with some observations:

1) C++ already provides a transform and accumulate (just for starters) which are much like map and fold. Isn't it better to learn to use the built-in tools rather than rely on a library? There is quite a lot of functional-style stuff in the standard already.

2) The cost of these abstractions is not clear. You can do a lot of functional idioms in C++, but often a tremendous amount of copying is happening compared to an imperative solution, because C++ lacks functional data structures under the hood.

3) Points 1) and 2) above are largely addressed by proposals for C++20 specification, such as the Range library.

comment 10y ago · link · parent

The post is about IBM's Swift implementation.

comment 10y ago · link · parent

I think the pitch is that despite static typing, it offers a lot of multi-paradigm high-level features while remaining elegant with fairly minimal syntax compared to other native static languages like Rust or C++. It automatically manages memory but without a stop-the-world garbage collector and goes a long way to opening a lot of flexible design options to any developer: it has great support for generic programming, object orientation, and functional programming.

The downsides? Well, I find some of its syntax choices a bit odd and inconsistent; I think the pursuit of elegance could have gone much further. And, while I celebrate its pervasive use of closures/lambdas and functional idioms in my many contexts, it lacks true functional data structures that would be necessary to really write in a proper functional style with confidence that the runtime wouldn't suffer.

Also, the implementation of its high-level features is somewhat magical and hidden. You can't depend on performance when using them until you really study them. So much so, that WWDC had a big talk about how to choose language features depending on the type of performance you need, and none of it was intuitive.

Additionally, at least on the Apple platforms, its Objective-C heritage can be a bit annoying. In particular, you can't mix and match closures with "selectors", which is a real shame and missed opportunity for flexibility and elegance.

comment 10y ago · link · parent

> your pension payments and so on

It's no big deal. An accountant easily handles all that, and accountants are plentiful in the Netherlands.

comment 10y ago · link · parent

In fact, in my tests, unique_ptr with make_unique was faster than a raw pointer with new.

comment 10y ago · link · parent

C++ training is a big industry, yes. Not sure about other languages.

comment 10y ago · link · parent

The official C++ FAQ is good:

https://isocpp.org/faq

Scroll down to the sections on C++11/14.

comment 10y ago · link · parent

You forgot option 3), which I use myself: Write in a high-performance language that also has high-level features, and write 90% of your code without concern for the language's cool optimization features.

That's what I do and it's great. I don't use move semantics or think about them, I avoid heavy templates, and I focus a lot of my work on the functional tools in C++ now and the more elegant ways of doing stuff at a high level. For when I need those extra optimizations, no need to change languages, I'm already there.

comment 10y ago · link · parent

There are other C++11/14 features that improve performance even further that are not mentioned here. For example, automatic type deduction often finds a more correct type for a variable or iterator than you'd guess on your own, since your guess might require an implicit conversion which might be costly in some cases. Brace initialization can also avoid costly implicit conversions. And using lambdas rather than named functions often leads to automatic inlining, an additional performance benefit.

C++ is a changing language and is doing a good job keeping up the with times, adding high-level features while increasing performance at the same time.

comment 10y ago · link · parent

A bizarre problem I have had on SO is that, after years of gaining reputation into the 5 digits, now if I ask a question on a topic that is new to me, I often get the response that I should know better if I have a high reputation. It's weird. If I have my colleague ask the same question, a guy with much less reputation, the answers are helpful. It's as if the quality of the question is judged by how much the asker must already know. Which is ridiculous if you explore a lot of different technologies.

Then there are genuine trolls who, despite massive reputation, seem to have the sole goal of proving everyone wrong. It's also weird.

This image has never rung more true to me then when interacting with so many "power" users: http://i.imgur.com/Oy6mA.jpg?fb

comment 10y ago · link · parent

I fail to understand why his discussion of the words "merry, marry, Mary" and photos of him with Biden and Obama had any relevance to this discussion. That was a very odd interlude in an otherwise fairly interesting talk.

comment 10y ago · link · parent

Sorry, but this is just simply not true. If you've never done functional programming before, then I could see why you think doing it in C++ is not complicated. Here is an example of just how large the can of worms gets when attempting to bring functional programming to C++:

https://bartoszmilewski.com/2013/11/13/functional-data-struc...

and:

https://bartoszmilewski.com/2013/11/25/functional-data-struc...

And, I disagree that you can change the definition of a particular programming paradigm when discussing a particular language. Functional programming means something that is not really possible in C++. For starters, the fundamental underlying data structures for functional programming do not exist in C++ and there is no third-party implementation of them worth mentioning; the above experiment is admitted by the author to fall flat when doing anything idiomatic.

As I mentioned before, C++20 might turn the tide on this front a little bit, thanks to the Range library.

2246.

How Big Would Your Social Security Check Be If You Wait Until Age 70?(host.madison.com ↗)

1 points · by hellofunk · 10y ago · discuss

comment 10y ago · link · parent

> functional programming (which is not that complicated at all in C++)

> I think most C++ programmers have a reasonable command of all of these

These gave me a bit of a chuckle. It's true only if you've never done proper functional programming using a genuinely functional language.

It's true that you can now pass lambdas around as first-class values easily, store and manipulate them as you might in a functional language, and that's a fantastic convenience.

But that's not what functional programming is. None of the idioms you'd use in Clojure or Haskell are wise to use (yet) in C++ (although Niebler's Range library will make a big step in the right direction... in C++20, where it's currently slated for specification).

If you try to do real functional programming in C++, you'll end up with a very inefficient program that pales to writing an algorithm with a more procedural or OO idiom.

And, in my experience interacting with lots of C++ developers, most do not know what actual functional programming is all about.

comment 10y ago · link · parent

you can't have too much security, ever. especially not when loads of personal files and potential sensitive data are getting stored under said security.

comment 10y ago · link · parent

This is an extraordinary achievement for the industry and is something all of us should be proud of. It's the reason I became a developer and now I know I made the right decision. What fantastic news!
1
747576
110