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

News needs sensationalism.

Thanks for posting another side of this.

What you're saying makes a lot of sense.


"all functions are pure, there is no data mutation, and entities are represented by data structures instead of objects."

God i love to see this


In javascript, what data structure can you implement without objects? Pretty much nothing. Even arrays are objects.


They're using objects, including arrays [1], so I think they would have been more precise to say that they're using objects and arrays as simple data structures rather than using OO features like inheritance and mutation.

[1] https://github.com/tonaljs/tonal/blob/main/packages/chord/in...


This is just semantics then. If you're implementing a linked list or a tree without a class (or at the very least a function that behaves like a class), it's going to be awkward and clumsy.

Data-structures beyond what the standard lib gives you (string and array) are the main reason the addition of classes to JS was so helpful.


This isn't quite right, linked lists and trees in functional languages can be represented extremely succintly, i.e.

  data List a = Nil | Node a (List a)
  data Tree a = Leaf a | Node (Tree a) (Tree a)
there is nothing stopping you from writing something like this in JS

  const list = { kind: 'node', val: 3, next: { kind: 'nil' } };
And then using a switch case to navigate the list/tree matching on the kind field.


Absolutely. The navigation behaviors will have to be in functions though. And from an application code developer's perspective, the connection between these objects and functions may not be obvious. If only there were some way to associate behavior with state.


The whole point of the top comment is that they appreciate how this library chose not to associate behavior with state, and instead organized things as functions and data structures.

With the latter approach, the user is not limited to the bahaviors that the library author wrote. The data (not state) can be used freely. Similarly, the functions are not tied to any particular state - the data can come from anywhere, as long as it has the right shape.


Uh… what? It’s quite the opposite; why would you need a class for linked lists and trees?


To provide an easy place to find the behaviors that are included with those data structures.


You definitely need generic node objects to define the nodes.

You could have a completely stateless class/object that would manipulate those nodes and add them and remove them from the data structure.


Well, in principle you could have the node objects be created with an object literal in an outside builder function, and the manipulation also be done by outside functions. That's how it's done in languages without OOP. The question is how far are you willing to go to avoid doing anything that looks like OOP.


Very far


What they mean is functions and data are separate, emulating a more functional paradigm and less mutable state.

The functions are kept pure and the data is kept pure.

As opposed to an object oriented programming style in which data and functions share the same object and create bug ridden state machines thats not as easy to reason about.

Some further explanation about this:

https://www.goodreads.com/quotes/702062-immutable-objects-ar...

a semi-nuanced discussion:

https://www.reddit.com/r/scala/comments/ejwsp1/is_mutability...

you can just Google mutable state to find more info.

separating your data structures and functions in many cases will make your code cleaner and more bug free.


I'm well aware of the pros and cons of mutability. I object (hah!) to this novel new use of the word "object". The concept is well defined by the ECMAScript spec.

Your first link's first sentence's first two words are "Immutable objects". No problem there. It doesn't conflate objects with mutability.


you know how unsufferable it is when people bog a conversation down with semantics instead of ideas.

the point is obvious.

Being that every single language on Earth uses objects for non-primitive data structures that should be inferrable to a reasonable person.

a data structure in that context is clearly an ordered grouping of objects versus an unordered/loose grouping of objects.


I mean some languages don't.

I have ideas but I don't think I'm getting them through. Most of the problems functional proselytizers have with objects come from inheritance and mutability. Instance methods from classes don't seem to conflict with any of the functional tenets.

As for mutability, I think it's good sometimes. Dates should have been immutable, but Maps are a good fit for mutation. Immutable maps might make sense too sometimes.

But I find it difficult to communicate about any of this when fundamental terminology is used in novel ways.


what languages don't use objects to implement non-primitive data structures?

like a binary tree for example


C# allows you to implement some data structures using `struct`s instead of `object`s. Probably not binary tree though.

I honestly still don't understand what you're getting at.

> a data structure in that context is clearly an ordered grouping of objects versus an unordered/loose grouping of objects.

What's an "ordered grouping"? What does "loose" mean? These are not gotchas. I'm trying my best here.

For me, if I were implementing a data structure, I would probably use objects. In fact, I'd probably use a class. I'm not trying to argue that data structures shouldn't be implemented in terms of objects or anything. My point is just that the tonal.js description is kind of nonsensical. Or at least hard to understand.


What languages on Earth implement non-primitive data structures without objects?

I guess maybe low level c and assembly where you implement everything as bits in physical memory?


It's mostly a question of what the language considers to be an object.

There's often a stack-/heap-allocated dichotomy. Some languages consider stack-allocated structs not to be objects. They have no reference identity. Assignment has copy semantics. C# is one such language.


The problem is you don't know if it's a blunder until after.


Blunders are things you _could_ or _should_ have avoided, had you only taken a moment to pause and think.


By "blunders", the author includes both those which can be prevented (see section "Preventable blunders") and those which can't. This is one of the reasons this article is silly.

Next in the series is, "Avoid accidents: 80% of being a good driver."


To be fair, you could stop calling them accidents. "Avoiding collisions" does sound like it will get you to 80% of being a good driver.

Like the author, I also play chess, and I could have written the same advice. Maybe the charitable take here is "Don't worry about long term plans so much, at least until you manage to stop making trivial mistakes, evaluated looking retro-actively at decisions you made."


Driving accidents are largely avoidable though.

If you avoid the wheel while tired or with alcohol in your system, you'll slash a big part of the risk. Avoid conversations in the car, on the phone or with your passenger(s), that's even more risk reduced. Keep your tires in good shape, your windshield clean, that's even better. Finally, if if you practice defensive driving, situational awareness, more still accidents can be avoided.

Nothing will of course mitigate all accidents, but there are definitely things that make you more or less accident prone in traffic.


That's not applicable to chess. Some blunders are deep and neither player sees mate in 10.

The computer immediately sees mate in 10 and calls the last move a blunder. The opponent misses the mate in 10 and moves elsewhere, the computer puts it as a blunder.

Both players blundered without even seeing a clear win, and it would take them an hour of analysis to see the exact sequence and prove there's no way to escape it even though there are a hundred variations


So success is more likely by not being an idiot. Not exactly helpful advice.


don't know what you're getting downvoted it is true


Wait but the dollar has a higher exchange rate than Chinese currency as well.


I wonder if kids on social media is going to be looked at in a hundred years like we look at kids smoking cigarettes from 100 years ago.


Here's sort of a non-legalese take on it.

Its a bit sensational but I couldn't find anything with a nonsensational balanced take on it.

https://www.skynews.com.au/insights-and-analysis/labors-intr...


for context, Sky News Australia is approximately as mad as the US Fox News.


Might have something to do with both being owned by Rupert Murdoch?


My thoughts exactly.

What if the left has been destroying their country through unchecked spending and immigration and the right are the only people awake enough to see it?


"What if the left has been destroying their country through unchecked spending and immigration and the right are the only people awake enough to see it?"

We had no left government in ages ;)

The ÖVP is moderate to right and is part of EVERY government since 1987 (!!!)

Also see https://en.wikipedia.org/wiki/List_of_ministers_of_finance_(...


But the left wasn't in power the last 7 years. The center-right and the Greens were and are in power. It requires some mental gymnastics to frame this coalition as left.

But to be frank, I'm not following Austrian politics closely. If the FPÖ is anything like the German AfD they are actually a very pro free-market. anti-social and worker-hostile party. I don't know why struggling people would vote for them, but they do.


> I don't know why struggling people would vote for them, but they do.

In stark contrast to many, I know a lot of people voting for the FPÖ, although all my close friends are far more left than right.

I have family that votes for the FPÖ, I have acquaintances and I know them, because I talk to them, uncondescending and am very interested in their motives.

And quite frankly: Most of the time it's simply not logical.

I can point them to laws the FPÖ enacted (because, you know, stuff like that is public), laws that DIRECTLY hurt them and they still vote for them, because "the foreigners, they will take everything we have!"

And even foreigners vote for them. People that are not Austrian citizens but already living in Austria feel like they belong here but now the gates should be closed.

It all boils down to emotions and the good ol' divide et impera, which has worked for millenia all around the world.

Some have their reasons, e.g. because they like what the FPÖ is doing at local levels.


The founding fathers would think that allowing the government to have a database on ANYTHING is a bad idea.

Plus dog poop is ecologically good for the environment and fertilizes nature.


It is absolutely not good for the environment. Your dog does not eat a local, natural diet. There are more dogs than could be locally and naturally sustained.



DONT EAT THE POOP.

and you won't get that disease.

Problem solved.

And dont let your kids eat any animal poop


Children often touch things in the grass and then touch their faces or put their fingers in their mouth


Concrete and asphalt don't need fertilizer.


Most dogs are extremely particular about where they poop and don't poop on concrete and asphalt if they have any other choice.


I guess we walk through different alleyways.


Apparently, dog poop is not an effective fertilizer and is considered harmful for grass?

Was news to me as a dog owner who allows our dog to do her business in the back yard (but would never allow it on a public walkway/area).

https://lawnlove.com/blog/is-dog-poop-bad-for-grass/


That blows my mind. I had two dogs as a kid, and if we didn't pick up the poop fast it destroyed the grass underneath. Their corner of the yard was all dead grass.


My dog has pooped in my backyard for years and nothing but thick quality grass everywhere.

probably because most kibble is vegetable based and vegetable based poop is good for the grass.

maybe you fed your dog more meat?

if your dog's poop is killing the grass you're doing something seriously wrong with its diet.


> most kibble is vegetable based

Most cheap kibble maybe.

> if your dog's poop is killing the grass you're doing something seriously wrong with its diet.

If yours isn't, I think _you_ might be doing something wrong with its diet. https://lawnlove.com/blog/is-dog-poop-bad-for-grass/


lawnlove.com

"Dont believe everything you read on the internet"

- Abraham Lincoln


Do your dogs urinate in your yard as well?


I think any poop from a carnivore is bad for grass, and everything else. You can compost it and it will be usable after about 1.5 years.


dogs are omnivores.

most kibble is vegetable based


Sorry, misspoke. I meant any animal that eats meat, including humans, dogs, chickens, etc. If they eat meat, there are toxins in the poop that make it inappropriate as a fertilizer, but you can compost it and kill off most of the bad stuff.


Using an A.I. article from lawnlove.com as a source....okayyyy

This country has really gone downhill with education

My teachers would have yelled at me for having a source like that.


Fair point. Was my first Google hit on "is dog poop bad for a lawn" which was probably lazy on my part.


how do you share CSS between pages?


I'm guessing they use a build process to embed it inline in a <style> element.


Yeah, for the CSS I don't even have a handler because it just goes right in the head.

I don't usually have more than a few lines.

Perhaps my use case is unusual though, I work on simple web apps, games, interactive simulations. I'm about to get into writing, and I expect a small amount of CSS will be sufficient for that too. Though that would probably expand over time, heh. You want to add a quote, and then a floating image...


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

Search: