Better HN
topnewbestaskshowjobs
Log inSign up

codedokode

9,867 karma · joined Aug 20, 2015 (11y ago) · 5,528 submissions

PHP developer from Russia.
Submissions

comment 10y ago · link · parent

Maybe not to trust the government? Yahoo is not your personal lawyer to defend you from NSA.

comment 10y ago · link · parent

They just made an application to extract an audio track from video file. There is no copyright infringement here.

It is DMCA that makes almost any operation with copyrighted content illegal.

comment 10y ago · link · parent

DMCA works only in US, right? So if website owners move their company to any other country, their service would become 100% legal.

comment 10y ago · link · parent

Stealing money can be robbing, I agree.

But (this is unrelated matter) why is it possible to steal someone's money just by copying several short numbers? We have all kinds of advanced cryptography today but some payment systems still rely on transistor era technologies.

And even worse, companies can track customers using CC numbers. That is wrong too. The shop should not get your name or other unique identifier when you just buy something with a card.

comment 10y ago · link · parent

Hacking is not the same as robbing. Hacker doesn't take anything away from you, except some reputation.

comment 10y ago · link · parent

They have shown who is stronger and probably got some PR for their DDOS services.

comment 10y ago · link · parent

So if someone hosts a site for selling drugs but doesn't sell it himself that is free speech too? It didn't help someone who called himself a Pirate and made a Silk Road.

comment 10y ago · link · parent

Governments can already block traffic on their border and can organize attacks again foreign targets (remember China vs Github case).

Oppressive governments can do even worse things to human rights activists, like banning a person from international travel (like Mr. Snowden or Wikileaks founder) and getting them extradicted from other countries.

comment 10y ago · link · parent

You cannot stop attack because web is decentralized. You cannot tell other Autonomous System to stop sending traffic to you.

> Why do backbones allow it to be carried?

Because they get paid for any traffic passing through. The more traffic they have the more profit they earn.

comment 10y ago · link · parent

Such attacks are possible because Internet is decentralized. There is no way to tell peers that you don't want to get traffic from some AS.

And investigation is difficult because attacking nodes might be in different countries, in some of which DDOS attacks are not illegal.

Maybe it is time to start building international firewalls to protect local infrastructure?

comment 10y ago · link · parent

> helper bots to add relevant content to the mix,

Is not that called an advertisement?

comment 10y ago · link · parent

Chromium might not support H.264 but it supports VP8 and some open source codec Wikipedia uses. So the problem is with developers relying on proprietary codecs.

comment 10y ago · link · parent

The case with Opera is interesting. The web standards became so complicated that Opera was unable to maintain their alternative engine and implement all of new features. Microsoft might have to switch to webkit in the future too.

comment 10y ago · link · parent

The consumers are using different browsers. People who write HTML are often not very competent and cannot make page display properly everywhere.

I use Chromium (because unlike Chrome it is open source). Video playback doesn't work even on twitter and vimeo (who can afford to hire good developers) let alone smaller websites. But it works on Youtube (not always, some videos require flash) and Wikipedia.

UPD: That is why I think people sould learn from Wikipedia developers and not some hipster guys explaining how to connect Redux to Angular2 using ES7.

comment 10y ago · link · parent

It is bad idea to rely on new features anyway. How will your website work in a 5-year-old browser?

comment 10y ago · link · parent

If you say that Google has no idea what it indexes then we can say that the creator of Silk Road had no idea what was sold there, he just made a clone of ebay. Well in the end everything depends on the judge's interpretation of the law. Especially when it allows different interpretations.

In fact google just doesn't want to moderate illegal content. It doesn't even remove the websites with infringing material, only single links.

comment 10y ago · link · parent

They can moderate sites before adding them to a search index. In newspapers usually there is an editor who checks articles before print, why not make google do the same? So there will be no illegal and immoral content and the users will feel safer. Google is very rich and therefore can afford moderation, they just don't want to respect european law.

comment 10y ago · link · parent

Unreadable.

comment 10y ago · link · parent

Maybe they use untyped hashes and arrays just because there is no other data structures in JS?

comment 10y ago · link · parent

In PHP we call it "Array Oriented Programming" ( http://www.epixa.com/2012/04/array-oriented-programming.html ). So looks like Python developers finally discovered this paradigm too. Let's wait for JS developers now.

By the way, PHP has type hints for functions that help to understand what are the types of arguments and the return type.

comment 10y ago · link · parent

They probably only add code and never refactor or delete it (and by the way I don't think it is always bad idea if the code is organized). So a large team can write a lot in several years.

This code might also include HTML templates and CSS or JS files that can easily grow large.

comment 10y ago · link · parent

Also Joel wrote another article where he says that rewriting the code from scratch (removing technical debt or switching to a new popular framework) is generally a bad idea: http://www.joelonsoftware.com/articles/fog0000000069.html

Improving and perfecting the code is a task that can take infinite amount of time.

comment 10y ago · link · parent

Because it is a browser extension which by itself is quite complicated application. I use builtin JS blocking options in Chromium and didn't notice any slowdown.

comment 10y ago · link · parent

As a side effect disabling javascript also makes pages load faster, makes browser use less memory, hides advertisements and protects you from popups.

comment 10y ago · link · parent

I agree, Doctrine has performance problems. I did some microbenchmarks too. But you could try to optimize (or write your own custom) mapping code, or maybe you could load less entities or write a better ORM. Sometimes you have to use SQL queries too (when the result of a query cannot be mapped to entities).

The "SQL and arrays" approach is much worse and doesn't scale. Without ORM and classes you will get undocumented JSON trees (or arrays) passed around.

> http://solnic.eu/2015/09/18/ditch-your-orm.html

It seems to me that author wants to replace complex approach (OOP and ORM) with even more complex one. So instead of having one object representing an entity we can have ten objects representing the entity at different moments in time. So we have to find out which one is the latest. And we will need even more memory to keep them.

He writes:

> There is no User but it’s very likely there is SignupUser.

And soon there will be LoginUser, GuestUser, ProfileEditUser, UserForReport and others. And a bunch of methods to convert between them.

I don't understand what is the problem with mutable entities. They are supposed to be mutable. I never had problems because of functions modifying arguments given to them.

I don't believe functional programming can be use instead of OOP. Can you represent a DOM tree, collection of GUI widgets, a graph of related database entitites, a form with validation rules with functional programming? You will just end up emulating classes and objects.

The author probably just likes the idealized concept and did not try to apply it to a real world application (but if anyone did it would be interesting to see the code).

I also took a look at Ruby Object Mapper he mentions in a post and don't really like it. It uses arrays (that are called ROM::Struct there) a lot and I don't see much functional programming there.

I also have read this article http://seldo.com/weblog/2011/06/15/orm_is_an_antipattern and I partially disagree with the conclusion. Using key-value storage instead of a database is generally bad idea. It doesn't solve "N + 1 queries" problem, it doesn't provide foreign keys (and often transactions), and you have to write messy custom code instead of shorter and better readable SQL query (example: https://www.kchodorow.com/blog/wp-content/uploads/2011/12/SQ... ).

comment 10y ago · link · parent

Good decision. But there are other ways to lose text, for example hitting Ctrl + R instead of Ctrl + T. I am not sure if web standards allow to restore text in this case.

comment 10y ago · link · parent

ORM doesn't save you from understanding how code works. It is not a tool to avoid learning SQL or UnitOfWork pattern.

But it has other advantages: you can use objects for your models, you can use lazy loading and relations between models, you don't have to save modified entities explicitly. So it helps to avoid writing low level code for saving and loading data from a database. You don't have to write routine methods like "get something by id", "get tags for post" or "update a field in a table".

> it encourages the promiscuous mingling of code and behavior, and makes it very difficult to produce code which can be understood without reference to complex interactions among many instances of many classes.

That might be over-engineering. OOP doesn't require you to use every single pattern from a book or build multilevel hierarchies of abstract classes. Abstract classes and interfaces might be necessary when you try to build reusable libraries or components but you don't have to use them inside a monolith application.

But you need to learn things like single responsibility principle so you can divide complex tasks into smaller parts. You have to remember that your code will be maintained by other people so it needs to be easy to understand without searching through all the codebase and hard to break.

And whatever approach you use when you have an application with large codebase written by many people it will be complicated anyway. OOP can help you to organize this code.

> ORM in a typed language

PHP is not statically typed language but you can use type hints for functions. So if you have an argument with a class name specified you can quickly look up what properties and methods the object has (and your IDE will suggest autocomplete options). And you cannot have any such information if the argument is an array.

I used to work with large applications written using "SQL and arrays" approach and they were bad. I had to spend most time figuring out what kind of array is passed to some function and how it is used to display something on a page. And it is hard to check if you don't break something by removing or changing a single element in that array. That is why I think this approach is not scalable beyond small applications written by a single developer. It has no relation to whether mixed arrays are allowed in a language or not. You can get same kind of code if you misuse collections in Java or C# or maybe Go.

You can look at Drupal if you need an example of complex open source application with those problems. It passes a lot of arrays around that are not even documented anywhere. And as an example of OOP application you can see Magento. It is large and very customizable so they had to use different abstractions.

comment 10y ago · link · parent

Twig does not require you to write escape so you can have to write just

    {{ var }}
That is a big difference because beginners always forget about escaping.

> Nevertheless, I used DOM/libxml on the server side in PHP/C,

There used to be XSLT templates but they don't seem to be popular now. Constructing DOM trees in the code without using templates is probably inconvinient and produces bloated code.

comment 10y ago · link · parent

The problem is that many characters look similar but have nothing in common. For example, the article mentions the character 食 meaning "food". So when after reading the article you see similar character like 良 you might think it is somehow related to food. Well, it is not, it just means "good". And another similar character 長 meaning "long" or "leader" also has no relation to previous two.

And when you get to more complicated characters like 感 it becomes even more confusing.

comment 10y ago · link · parent

PHP actually is a bad templating engine for HTML because it doesn't have a feature to convert special characters to HTML entities by default. It is easy to forget a call to htmlspecialchars() (especially for beginners) so the code gets vulnerable to XSS.

That is why you should prefer Twig or other templating engine with autoescaping.

> They all start as an attempt to remove the possibility of writing meaningful code

I don't think so. Twig developers have a large list of reasons on their frontpage: http://twig.sensiolabs.org/

1
180181182
185