9,867 karma · joined Aug 20, 2015 (11y ago) · 5,528 submissions
comment 10y ago · link · parent
Maybe there should be some international agreements on how to deal with such cross-border crimes but they should be discussed and agreed upon by many countries.
And I don't like this anyway. I would rather prefer having american or russian systems disconnected from other countries than extraditing people into a foreign country to judge them by foreign laws.
comment 10y ago · link · parent
Obviously this person's rights for a fair trial are violated.
If he is a Russian citizen, shouldn't he be judged in Russia?
Or should we apply the same rules to American citizens? For example, everyone working is NSA or its contractors can probably be prosecuted for taking part in a conspiracy to break into computer systems and intercepting private communications. Should muslim countries arrest any US tourist that have earlier posted pictures with Allah in Facebook and extradite them to Iran for fair trial by Sharia law? And what about people who develop software to bypass Great Chinese Firewall? Should they be extradited to China? US wanted to get Julian Assange, should not China get its enemies too?
comment 10y ago · link · parent
They also lack privacy: your name is written on a card and in every transaction you use the same card number so merchants can collect person's shoppping history (and using a name they can find customer's page in social networks). And maybe they even share this information among themselves.
Not in every country there are laws protecting clients. In US there is a law, but in other countries if your card number got stolen you might never get the money back and even be left with a debt if it was a credit card (because it is client's responsibility to keep his card info secure).
When you are buying something online with a card there is no way to check whether it is a real shop or just a fake site to collect card numbers.
As a result merchants make their own sophisticated antifraud system and you never know whether your card would work or not. For example once I was unable to pay for a Digital Ocean server with virtual prepaid card (of course I would never pay with a real card on the Internet) so I chose another cloud hosting and they lost a customer.
comment 10y ago · link · parent
Idiomatic doesn't mean maintainable and scalable. Imagine you are working on a project in a team, not alone. How do you understand what kind of "lightweight" object you should pass to this function:
function foo(data) { .. }
When you have thousands of such functions you'll spend most time reading through their code to understand what type of argument they need. This means "idiomatic" javascript code works only when it is small in size. Once it gets larger you'll have to resort to old school non-idiomatic Java-like classes and a static typing system.Regarding prototypal inheritance I don't understand how it is supposed to be used. Let's say we have constructors for objects User(name) and SuperUser(name, privileges). I understand if `SuperUser` is inherited from `User` (class-based ineritance), but I don't understand what is the meaning of SuperUser being inherited from some user charlie. Why `charlie` and not `john`? Why do I need an instance of common `User` to create a `SuperUser`? And as I haven't seen the explanation in above comments I guess you don't understand it too yet evangelize about it.
I think JS was supposed not to have any inheritance at all. The objects were supposed to be created with constructors and that is all. As an argument I can say that a helper method `Object.create()` that is required for object inheritance was only added in ES5 [1] and haven't existed in earlier versions. This is how you create objects from objects without classes and even without constructors:
var person = { name: null, greet: function () { ... } };
var john = Object.create(person, { name: 'John' });
var charlie = Object.create(person, { name: 'Charlie' });
var superCharlie = Object.create(charlie, { isSuperUser: true });
I also guess JS doesn't have classes because it was designed for writing simple form validation scripts and not large applications.[1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
comment 10y ago · link · parent
def __call__(self, request):
client_ip = request.META['REMOTE_ADDR']
self.last_visitors.append(client_ip)
...
This code follows your scoping rules but still leaks memory. So it looks like you don't understand why memory leaks occur. I explained somewhere in ancestor comment that to prevent leaks you either need a language with pure functions or reset environment on each request, none of which is possible in Python yet the latter is available for PHP users.With Django processing model any array can become the source of a memory leak. I have heard that Ruby and NodeJS developers often have to restart their applications every several hours because they even have no tools to find the source of a leak. The problem that does not exist in PHP by design.
comment 10y ago · link · parent
And I am not only person who needs classes in JS: https://github.com/search?l=JavaScript&q=class&type=Reposito...
I do not see any benefit in prototypes. It just makes code more complicated and buggy. I would happily use them if I knew a way to do it while keeping code simple.
> When we have distinct structures, signatures and functors we can easily understand how they are supposed to be used
Yet Javascript has neither of those.
> If you mean that mutating values should be avoided
No, I am ok with mutable values.
comment 10y ago · link · parent
With PHP you can see your program as a pure function whose result depends only on arguments. You don't have to care about memory leaks like you don't have to do memory management when you have a GC. And if you want more performance and less convenience you can always opt into running your own web server.
> Don't use global variables
If you have an object that is persisted between requests you already have some state that is saved.
comment 10y ago · link · parent
That is true only for low quality legacy code. I have always developed with all kinds of errors enabled and converted to exceptions (that means single E_NOTICE terminates the program with exception as it is done in Java).
Modern frameworks like Symfony 3 or Slim use the same approach. If you write a project using Symfony you won't miss a notice.
I think default PHP error handling system is wrong - there should be no warnings or notices, only exceptions. Sadly OOP was not very popular among PHP devs in the beginning.
comment 10y ago · link · parent
console.log([] * {})
and be surprised. At least in PHP you cannot multiply array by object.Type casting in PHP gets fixed gradually: https://wiki.php.net/rfc/invalid_strings_in_arithmetic .
comment 10y ago · link · parent
No. This code causes an error in PHP:
$name = 'John';
echo $nmea; // error
class A { public $name; }
$a = new A;
echo $a->nmea; // error
This code doesn't raise an error in JS: var a = { name: 'John'; };
doSomething(a.nmea); // no error
So with JS you learn about errors later and spend more time on debugging.comment 10y ago · link · parent
When we have distinct functions, classes and objects we can easily understand how they are supposed to be used: you can call a function, create an instance of a class, call a method of an object. With Javascript you cannot easily see whether you have a plain function or a constructor and how you should use it. And interpreter won't tell you anything if you forget to put a `new` keyword.
(And by the way why do you write 'var Person = function' instead of just 'function Person'? The latter is shorter and more readable)
Your code can easily cause a bug. Imagine Person's constructor looks like this:
function Person() {
this.friends = [];
}
...
var NewPerson = function() {};
NewPerson.prototype = charlie;
Do you see the problem here? To fix the problem you have to rewrite the code using Object.create() and call parent constructor with Person.call(...).I have written applications in Javascript and I think that Java-style classes are the best for readable and maintainable code. All these tricks with prototypes and dynamic objects (where you can add or patch properties in objects in runtime) might look good in short samples of code but they are only the source of bugs and cause waste of time to understand what the author meant in real world applications. Your code example proves that because adding a single field to a Person's constructor requires you to find and modify all of the objects inherited from it and this task is not easy too.
comment 10y ago · link · parent
And JS is too forgiving, even more forgiving than PHP. In JS you can misspell object fields's name and learn about it only when undefined value will cause an error somewhere in another module.
comment 10y ago · link · parent
comment 10y ago · link · parent
comment 10y ago · link · parent
And why would a device need full Internet access? Shouldn't it be only accessible in home network with maybe some (user selected) servers from Internet it is allowed to connect to?
We could use some sort of VPN (from device to other owner's devices) so that even if it is connected to Internet directly it doesn't accept any packets coming not from its owner. VPN also provides encryption while allowing user to examine traffic in clear text.
I think we need some type of easyly deployed, ubiquitous, simple, snandartised VPN type protocol so that the users can build protected networks over public insecure infrastructure.
Today if you connect your device to Internet you connect it directly to NSA and chinese hackers.
And if your device is disconnected from public network hackers cannot break into it even if they have exploits.