Hacker Newsnew | past | comments | ask | show | jobs | submit | srssays's commentslogin

The US hardly lacks collectivism, it is merely on an incomprehensibly grand scale. Pay your taxes and the state will help you, evade them and the state will punish you.

Certain African countries are strongly individualistic. The state is too weak to help or punish anybody. Infrastructure crumbles, crime and slavery abounds.

You seriously don't want to visit let alone live in a country that lacks collectivism.


Collectivism != cooperation. The comment to which you replied also says the US has heavily collectivism. But due to its coercive nature, it killed the cooperation that existed before it.


Except for Vietnam!


> Linked lists are a very convenient and surprisingly universal data structure, but they really shine wherever you have a recursive algorithm. Which is, in the languages mentioned, almost all the time.

Linked lists were way ahead of their time. Nowadays everything is so fast that we can probably use them without guilt, but there is still a sense of disgust associated them.


Linked lists are indeed wasteful in terms of memory usage, compared to simple arrays. There are ways of optimizing this, but you won't get away from having an additional pointer to the next element.

However, linked lists offer many advantages that arrays do not. The length of a list need not be known at compile time, for one. It's trivial and very fast to insert a new element in the middle of the list. They are not optimized for random access, but they pose no performance penalty (over arrays) if you need to traverse them from start to end.

But the most important advantage of linked lists is that they are their own iterators (in C++ parlance). You don't need an additional state for iterating over a list - you don't need to store and update the index, for example. Each element of a list is the beginning of the rest of the list, so if you hold a reference to one, you can stop and restart iteration without problems. Moreover, you can add elements to the list and still be able to use the previously captured element as a start of new iteration: no need to invalidate the iterator.

In other words, Linked List has some very desirable properties and it makes sense to use it for almost anything other than a fixed-length, random-access collection. All Lisps provide vectors and hashes for the latter use-case.

I think the problem with Linked Lists is that they are not hard to implement and taught on the entry-level courses, with C as an implementation language. This makes it very hard to see their usefulness. With a bit of tooling (library functions) and language support, they really shine.


> but you won't get away from having an additional pointer to the next element

It was done on some Lisp Machines with CDR-coding. newly allocated lists did not have any CDR pointers. Optimizing lists that way could also be done by the garbage collector, when it needed to copy lists or in optimization runs before saving an image.

Most other implementations did not implement it.

http://www.faqs.org/faqs/lisp-faq/part2/section-9.html


!! is an extremely common idiom, across multiple different programming languages.

Code should be written so that it is understandable by other professional programmers, not people who started programming two weeks ago.


As a professional programmer, I've come to prefer code written to be understood by someone who started two weeks ago.


In that case, don't write any code. Don't use function. Don't use React. Don't use lodash. Don't use third party library.

People who only start coding for two weeks can't understand any code.

People who start has enough experience to work, but only start in this project for two weeks, will understand "!!" idiom.


Then by that principle you'd want to use !! since casting via function or constructor differs more between languages.


What it looks like in other languages is only minorly relevant to its obviousness and readability.


I don't see the argument that Boolean(val) "reads easier" than !! as long as you know what !! does.


Wouldn't any programmer recognize that Boolean(val) is a cast to a True/False value that's most likely an object, given the uppercase?


Perhaps, but it's a primitive, not an object.


I'm curious, which languages? I've never seen any of my colleagues write !!, ever, in C/C++, Java, Python, or Swift. I've also not seen it C# or Go, but my exposure is limited.


I've been paid to write code in Perl, PHP, Ruby, JS, Go, ObjC, and Java, plus a little C and Python, for going on 15 years. I'm pretty sure I've never written "!!" and I think I could count the times I've seen it used on one hand (maybe never in any codebase I've worked on, but I'm not entirely sure)


I feel sorry that they paid you then



It's one of the earliest things I can remember learning in my intro to programming classes in college. Those were in Java.


I spend chunks of every day looking at a C/C++ codebase and have never seen this. Taught Java for a year in college, I have never seen this. I would leave a note to a student for using this to be honest - too unclear, and (as this thread denotes) not well known enough to put in production worthy code.


I'm pretty surprised to hear this from someone who taught a programming course. It actually makes a ton of sense when you evaluate what is happening: it's the negative unary value and then the negative unary result of that value - there's no possible way it could be anything other than true or false. It's more of a side affect of the unary operator ! than it is a language feature, which I believe is why it sees such ubiquitous implementation.

> I would leave a note to a student for using this to be honest - too unclear, and (as this thread denotes) not well known enough to put in production worthy code.

You've done a total disservice to your students that understood negative unary operations then. Given how many upvotes my initial post on this thread has (currently 38) I don't think the thread denotes what you think it does at all.


You're kidding, right? "!!foo" is a complete no-op in Java. It is never needed and never correct.


You're basically wrong on every single point. It's a syntactic hack in JS to get a guaranteed boolean coersion, but for anything else it's an absolutely pointless abomination. (Maybe PHP has a similar thing, but I haven't programmed in PHP, so I wouldn't know.)


In Java? What purpose would it serve there?


What? I've been coding in multiple languages for multiple platforms for almost 30 years and have never come across it. It seems rather unlikely that it's 'extremely common'


It is very common in C code, where for most of its history you hadn't any explicit boolean data type but used int, following the rule that zero is false and anything else is true.

The '!!expr' is the idiom most people use whenever the need for a canonical 0/1 representation arises.


C++ is somewhat of a low bar, because of the state of the art in package management in C++ land is "download a header-only library". C++ does have sum types in the form of boost::variant, but boost is an abomination.

The danger to Rust is that for many projects it wins by default because the alternative languages are immature, rather than because its performance/security capabilities are actually worth the productivity trade-off compared to other languages.

Once Swift matures a bit, it will take a lot of the lustre from Rust.


People who change their religion are often disowned by their family, their spouse might divorce them, etc. It can in no way be considered a choice.


I suppose you haven't heard of the "Trump voter divorce" yet, have you?

Political views are sometimes similar in character to religious views, such that expressing contrary opinions results in shunning and being ostracized by one's family and community.

It's one of the major reasons why free and fair elections have to use secret ballots, aside from vote-buying. Around here, it's risky to even participate in partisan primary elections, because employers can look up your name in the voting records and determine which party's ballot you used, then engage in party-based discrimination at work that ranges from subtle to blatantly overt.

While this area seems to have more than its fair share of petty and bigoted persons, it can basically happen anywhere that requires a declaration of party affiliation during the primary.

My own spouse has turned a bit more left over the years, even as my siblings-in-law have gone more to the right. It has resulted in some rancor, as those four gratuitously post replies on Facebook for each other's posts and summarily delete replies by my spouse. They're really being a bunch of a-holes.

If you don't conform to the views of your local community, you're going to have a hard time. And the more homogenous it is, the more you can be punished for your non-conformity.


It's still a choice to remain with your religion. It's not a simple one, granted, but if you stick with a religion that requires you to hate or be intolerant to other people, you don't deserve that others are tolerant of your religion. Hence they can choose not to engage with you. Why would hey have to bear the burden of you picking the easy path.


Lolwut are you serious?


Software is written better.

In the past, computational complexity was lowered by arbitrary size limits. e.g. if you had a O(n^2) algorithm you might cap n at 10 and now you have a O(1) algorithm. Job done.

Now, computational complexity is lowered by aggressive use of indexing, so you might lower your O(n^2) algorithm by putting a hash table in somewhere, and now you have an O(n) algorithm. Job also done.

The practice of putting arbitrary size limits on everything has almost died out as a result.


Nope. Fruit juice is mostly water. Even raw sugar is only 380 kcal/g, just a bit more than French fries (310 kcal/g).

If you're underweight, you should eat food.


Something about your numbers seem way, way off (by two orders of magnitude, actually). Could you explain better or point to references?


I think it's per 100g, not per g.

Edit: yeah. That's how dietary references are done lots of non-US places. https://www.wolframalpha.com/input/?i=calories+in+100g+of+su...


Apple is $750b company built on one product (iPhone). Their business hangs on a thread. What happens if they have a big recall like Samsung had?


> What happens if they have a big recall like Samsung had?

They have enough cash reserves to keep going for a long time, as well as other product lines that were successful enough to get them to where they are.


It is written by PR people, wire services and politicos. The journalist simply assembles the ready-made components into the lowest energy configuration.


A lot of the time, it's not even sent to the journalist in question. It's just 'someone else reported on something, so every site in the same niche rewrites the story in their own words'.

That's why every single 'controversy' and news story ends up on every media site under the sun.


Love this comment, and based on my experience with tech journalists this is actually the case.


Yes, it's definitely the case for a large amount of stories. Paul Graham has written on the phenomenon and how taking advantage of it helped ViaWeb. [0]

[0] http://www.paulgraham.com/submarine.html


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: