HNHacker News
TopNewBestAskShowJobs

zohebv

435 karma · joined October 26, 2010

submissionscomments
zohebv··on Roy — small functional language that compiles to JavaScript
> In what world is initiating a productive discussion about an important issue

A toy example is not an important issue. As for initiating productive discussions, I will let your comments speak for themselves

1. This is cargo cult programming at its worst

2. What drove you to unleash this horror on the programming masses, Moggi?

3. Why have you cursed us so?

4. It makes me sad that having monad sugar ....

5. .... stripped of all utility and sense.

zohebv··on Roy — small functional language that compiles to JavaScript
So, his example monad is bad. Indulging in hyperbole and invoking Moggi can at best be seen as attention-seeking behavior and at worst as an underhanded FUD tactic to turn people off the project. Peaker has pointed out the problem with the example monad without indulging in antics. There are better ways to communicate the mistake made in the example program. There is nothing irrecoverably terrible with Roy, but your comment conveys a false impression to the uninformed reader.
zohebv··on Roy — small functional language that compiles to JavaScript
Monads are not simply a tool for managing side-effects. Why would you consider parser combinator/List Monads useless in a language with unrestricted side effects? Writing monads without sugar becomes clumsy very quickly and monads have been demonstrated to be useful innumerable times, why wouldn't you support some syntactic sugar for it?
zohebv··on Scala as EJB 2: feedback (incl. Fantom comparison,funny comments
These operators such as ++ (concatenation) etc are uniformly available in all collections. It has inherited these operators from base sequence classes/traits specifically TraversableLike.

http://www.scala-lang.org/api/rc/scala/collection/Traversabl...

If you write a fancy skiplist and add a TraversableLike trait you will get these operators and the associated methods for free!

Check the source code for NodeSeq. https://lampsvn.epfl.ch/trac/scala/browser/scala/tags/R_2_9_...

It does not implement any of these operators. It just inherits some features extends immutable.Seq[Node] with SeqLike[Node, NodeSeq] with Equality

provides an equality operator and a builder and gets all the other collection operators for free. These operators have the same semantics and implementation across all collection classes unless you specifically override them.

zohebv··on Scala as EJB 2: feedback (incl. Fantom comparison,funny comments
In scala the use of : changes the associativity of the operator, so a ++ b ++ c is equivalent to (a.++ b).++ c while a ++: b ++: c is equivalent to (c.++: b).++: a However fear not :-) the arguments are always evaluated left to right i.e. a,b,c and never c,b,a. It might be useful to think of (c.++: b).++: a as a ++ (b ++ c) except that ++ has c as the "this" parameter in the inner expression and not b.
zohebv··on If you want to get rich, stop being a fucking joker
I think, this is in part a consequence of the deification of Steve Jobs, who might have adopted a similar stance towards his partners/employees. Such behavior is now automatically assumed to be acceptable by some subset of people. The No Asshole principle is passé. The author may have written such an email irrespective of Steve Jobs influence. But the audacity to post it on his own blog for everyone to "admire" certainly has to do with the publicity around the Jobs' supposed douchiness.
zohebv··on Richard Stallman on Steve Jobs: correction
> 1. How do we make a software distribution system that simultaneously keeps malware off but allows developers and users liberty without a third party policing the content?

Android lets you install alternative marketplaces. In effect, the user now has to trust only a couple of marketplaces and this should help keep away malware while preserving freedom.

> 3. How do we workaround the fact that most people do not and will never have an interest in the technical workings of devices

Regulation :-( Ford is not allowed by law to build cars that can only be serviced by Ford. It should be the same for computing devices.

zohebv··on Robot walks like a human, no power required
So it does use a power source. The title should read - "Robot walks downhill without additional power source".
zohebv··on Will Dropouts Save America?
Not everyone becomes a successful startup founder. Most people work as employees and not graduating will put a sever dent on their career prospects.
zohebv··on From C to C++: A quick reference for aging programmers
This is my personal style. I don't really use the OOP much. I get as much work done as possible via STL. Use RAII for resource cleanup. Completely avoid new/malloc/throw etc. If forced to use pointers use smart_ptr (possible use case - polymorphism) and don't forget about enable_shared_from_this.

http://www.boost.org/doc/libs/1_47_0/libs/smart_ptr/enable_s...

My C++ code is typically 3X shorter than corresponding C with fewer bugs and faster performance. The main issue is avoiding memory corruptions and getting away from pointers and memory leaks by leveraging the STL heavily.

I do use objects and make sure the members are C++ types rather than some C-style pointers, so that the copy and equality semantics are well defined. The key thing for me is avoiding pointers at all costs as pointers complicate memory management immensely. Use STL vector, set etc and in the worst case smart_ptr.

zohebv··on U.S. Government Compels Google To Hand Over Wikileaks Volunteer's Gmail Data
> Electronic Communications Privacy Act

Orwellian naming conventions are all the rage these days :-) Jerry Yang faced a lot of heat for doing pretty much the same thing in China. Google seems to reluctant to criticize the US government now, unlike, for e.g., the Chinese government.

zohebv··on Dart language
This http://www.dartlang.org/docs/technical-overview/index.html

A delightfully blank page :-) Yes it mentions classes, interfaces, optional types, libraries, tools, structured yet flexible language. But all of these are a given. Is there nothing else?

What about Generics, Covariance/Contravariance ? Type inference? Odersky thinks type inference in the presence of subtyping is untenable. Is it the same here? Are interfaces linearized as in Scala? What about immutability? It might be too much to ask for rank-2 polymorphism and Haskellish Type Classes but what about support for delimited continuations? Let me guess, these aren't "design goals". All I am saying is this isn't 1990 either.

zohebv··on Dart language
From whatever little I see, I am already hating it :-) This looks like Java for Javascript, if that makes any kind of sense. We are in the year 2011, PL design has progressed so much since 1990 that such an anachronism is unpardonable. I sincerely wish that companies like Google focus on hiring the right kind of person for designing programming languages.

What is frustrating is that there are so many people who can do this job right, yet we are stuck with amateurish programming languages designed by companies like Google. Please try and hire people like Oleg Kiselyov, Simon Marlow, Erik Meijer or some one from the possible hundreds who have worked deep in PL theory for literally decades. On the face of it Gilad Bracha has great credentials, credentials that would make the HR folk happy but one look at some of the stuff he writes and we know things are not going to be good.

http://gbracha.blogspot.com/2011/06/types-are-anti-modular.h...

I think Phil Wadler gave him more respect than was due in the comments :-) Microsoft hired Anders Hejlsberg for .Net which I don't think was a good idea, he is a great engineer but not a PL theory expert. They however "rectified" the situation by hiring Erik Meijer later and his impact via LINQ and F# and improvements in C# is obvious. Not to say that Hejlsberg is not good, but Meijer is better. Getting back on track, I may be wrong but Dart makes me groan. It is one thing to design such a language in 1990, but quite another thing to do it in 2011.

zohebv··on Node.js cures cancer
As it so happens, I am now implementing a load balancing solution on the JVM using the hybrid technique you recommend, lots of threads and some asio coming soon. However asio support on the JVM is poor. You are correct, in that using asio does not preclude you from using threads and viceversa; while node.js does not let you use threads. Your argument is valid, but this is very different from the argument ted is making viz. a CPU bound task will make the server useless. This is demonstrably false, and ignores the fact that typical web workloads are io bound.

The C++ solution you posted is probably a hybrid solution as you described, but it has its own set of restrictions. The environment does not guarantee run time safety, functional programming support is poor and coroutine support is non-existent or weak(I noticed there is an unfinished Boost.coroutine library that must heavily depend on #include <functional>). While node shuts out threads it enables other solutions more suitable for a heavily I/O bound server. I only want to draw attention to the fact that almost all solutions available today involve some kind of compromise and hybrid solutions are possible in almost all of them.

As for the "deductions", I thought that they were obvious. You need threads rather than processes, so that you can share memory and avoid the serialization/deserialization complexity when communicating between threads. Or less often, you need a more elaborate synchronization mechanism such as reader/writer locks. As for asio extracting maximum performance, I think I will be better off writing a blog post about it.

zohebv··on Why Startup Hubs Work
Interesting, this reads like an anecdotal description of the New Trade Theory.

http://en.wikipedia.org/wiki/Paul_Krugman#New_trade_theory http://en.wikipedia.org/wiki/New_Trade_Theory

zohebv··on Node.js cures cancer
> @zohebv there are several errors in deduction here:

@ajd I would disagree with this statement very easily and very confidently.

> really

yes

> multi-threading and non blocking io are two separate tools

asio is a way of minimizing the number of threads in a system and extracting maximum performance.

> i don't think anyone's asserting that

It follows by logical deduction. There are only 3 possible criticisms of node.js 1. I need shared memory 2. I dislike Javascript 3. I dislike asio

Given that the cancer post doesn't make a big deal of 1 and 2. you are left with 3. And if you read his follow up post he is again complaining about "event-loop" programming. Yes he is indeed complaining about asio. asio necessarily introduces event loops.

There is only one reason to use multiple threads over multiple pre-started processes. You need the shared memory. You should still be able to pull off shared memory in node but it can be cumbersome. I am yet to see anyone complain about needing shared memory and hence disliking nodejs. Its either

1. "threads are robust for cpu bound workloads"

- which can be solved by simply launching as many nodejs processes as Python processes, though you only need to launch as many nodejs instances as cores if you are not interested in winning this argument.

2. "Don't force this programming model on me"

It is not forcing any programming model on you except that shared memory is harder. And yes you cannot acquire a lock and go off and do io. If you want to do that then you can, by piling up pending events in a queue, but the ugliness of the code will stick out easily. You might as well switch to Python/Java threads or whatsoever.

> of course, you can spawn 40 other process - but i don't like a model where that's your /only/ option

Can you describe the other options you want to try?

Check this out http://teddziuba.com/2011/10/straight-talk-on-event-loops.ht... He has broken down his own defense with his fancifully named "Theorem 2". If you do more IO than CPU then "use more threads". Except he doesn't give you the number of threads because he doesn't know how many. In fact, he cannot know. And this is why asio is a win.

Fact is on an n-core system if you launch n nodejs processes you are guaranteed one of the 4 hold true 1. You service all requests thrown at the system 2. You maximize the CPU utilization 3. You maximize I/O utilization 4. You maximize RAM utilization - "4. is some what pedantic"

i.e. it will extract the maximum possible performance from the hardware you throw at it. It is just a consequence of making sure all io is non blocking. With a threaded solution you will never get the number of threads right and you will end up with a server that cannot serve all requests even when it has spare CPU, spare I/O capacity and spare RAM. Maximizing CPU utilization implicitly assumes the absence of locks. If you use asio as well as locks CPU utilization will not be maximized. This is something that most of the "nodejs" critics don't understand or fail to appreciate.

Yes shared memory is harder to do in node, but erlang doesn't do shared memory, Python cannot do threads sensibly, Java cannot do coroutines, why dump hate on nodejs because it isn't an ideal environment for a solution that requires shared memory? Sure there are many problems that require shared memory. However 95% of webservers don't fall into this category.

Lastly ted's inexperience really shows here, he is only 27 years old and has a lot left to learn. To start with he can stop trying to school Ryan Dahl, who is someone who certainly knows his Computer Science and is making a valuable contribution to the community.

Lastly as a practical exercise, try to build (at least as a thought experiment) some web service that outperforms node using respected platforms such as Python and Ruby. asio is a technique for IO bound loads but node will do better than Ruby/Python even on CPU bound loads thanks to V8. An order of magnitude faster. I have said that you need to have n processes for n cores, but in practice it seems just one process turns out to be enough as loads tend to be io bound and V8 is typically 10 times faster than Ruby. And if you have coroutines event based programming is not hard at all. So yes people have discovered that one nodejs process has replaced their two dozen Ruby processes and is serving out twice as many requests from the same box and they are impressed. And they don't care about what Ted thinks.

As a footnote, of course, you can do shared memory within a single nodejs process(trivially true), but for pure CPU workloads Java/C++ would probably be a better option.

zohebv··on Node.js cures cancer
> How is running 40 instances of node processes different from running 40 instances of a single threaded web server?

40 Instances of a single threaded webserver can block for I/O. If your webserver is 50% CPU bound this means that your CPU utilization is lower than in the case of a perfectly async system. You will serve fewer requests per second than an async framework. This is where the rule of thumb "no of threads = 2X no of cores" originates. Of course this rule wont work well for heavily I/O bound servers with high latency I/O. With node.js latency/IO percentage etc won't matter.

> If you had a choice would you not rather have light-weight processes (threads) rather than actual processes because of lighter memory requirements?

It would be great to have a multithreaded async framework. However a multithreaded environment eventually ends up introducing several blocking I/O functions which Dahl wanted to avoid. Hence the choice of Javascript.

node.js is one of a 100 possible solutions. Nobody insists that you use it. In fact I haven't even written a single line of node code. However I have done enough systems work to know the benefits of async programming.

> Threads are too hard to program to? Try STM?

STM can only handle scenarios that do not involve I/O. One of my colleagues was in the group at Microsoft tried STM with I/O that fell hard on their faces. Sure there are plenty of approaches - threads, actors, STM. Async programming is one such approach. If you want to write an async web server, right now node.js is the only solution. I think it might be possible to do a pure async web server in Haskell, as any IO gets captured in the type signature but I don't know of any async Haskell webserver framework.

> I'm not buying the notion that node's event model has any advantage over anything whatsoever.

You are basically asserting that async programming has no advantage over any other approach whatsoever. Having dug into hard disk device drivers, filesystems and caching for the Windows CE kernel, I would have killed to have a proper async I/O framework in CE from the ground up. We had a gazillion locks in the kernel modules, for gazillion data structures when all we really wanted to do was perform I/O without grabbing a lock. The Linux epoll, BSD kqueue and Windows IO completion ports are all async APIs added for high performance systems. These APIs are, strictly speaking, not required if you have threads but when you get into sufficiently advanced systems programming you cannot live without these. Trying to say that async programming is useless is equivalent to claiming that APIs such as epoll/kqueues are useless.

zohebv··on Node.js cures cancer
Node is an asynchronous programming framework bundled with a largely async library. If you have 40 cores on your system, you would presumably run 40 instances of node for a CPU intensive webserver(using multinode etc). So the event handler won't get stuck as long as there are available cores.

What about a single core system? Well I guess a threaded/multi-process solution would time slice the fibonacci requests between two threads so that both requests are served in 10 seconds, instead of one request in 5 seconds and the next one in 10 seconds like the node.js solution. Does not sound much better.

If you have done any kind of systems programming, you would know that availability of asynchronous I/O is a life saver, and can simplify your locking model greatly. 90% of the issues you face when building such systems is that some module deep inside grabbed a lock and issued a blocking I/O request and now the rest of the system is bottle necked behind it. Node.js is basically trying to eliminate the possibility of the existence of such a module. This complicates the issue of I/O calls, but simplifies locking in the sense that you don't really need all those locks in your system. In node.js of course there are no locks. The complexity moves from reasoning about locks to reasoning about correctly handling I/O calls and responses. IMO, this is the correct place to move the complexity to, because locks are simply an abstraction the programmer built. When debugging the system, we have to deal with - "How to get rid of this monolithic lock", when the real problem is - "This IO is taking too long we shouldn't be blocking on it". An async programming framework tackles this problem head on.

If you use Python/Perl you will never really know the number of instances of the process to run, Too many and you time slice requests, slow down all of them, increase your queueing buffers instead of just dropping the extra requests. Too few processes and you start dropping requests that you could have served. With a framework like node.js the number of instances you want is equal to the number of cores on the server.

Of course node.js can be an inappropriate solution for a wide variety of reasons, but I could not find anything really relevant regarding that in your post. Alex Payne discusses some issues here. You may want to read it. http://al3x.net/2010/07/27/node.html

zohebv··on Hey CS Paper writers, please show your code
Most often they don't have any code. Most of the action takes place inside the head and not inside the computer. What they have are proofs of correctness, invariant enforcement, complexity bounds etc. I doubt that reading the code will improve understanding of the algorithm anymore than a thorough description of the algorithm.
zohebv··on Ask PG: What has changed since you wrote Hackers and Painters in 2004?
> Actually, Bill Gates has simply built gates and extracted a toll for using them. His products were rarely acceptable alternatives if evaluated on their own merits and sold largely because of strong-arm deals with the OEMs.

While I have cited Bill Gates as a weaker contributor than Einstein/Gandhi, I think you are being far too critical here and missing a few key things. The fundamental insight that Bill Gates had was that software is king and the hardware is the add on. Even Steve Jobs credited Bill for the insight at D5. All other competing OSes at the time were a hardware and software bundle. Bill realized that what was of essence was the software and the hardware wasn't as important. He licensed the software and commoditized the hardware industry into a fierce race to the bottom that saw PC prices dropping every month. If Apple/Amiga had won that round we would be spending a couple of grand on a PC even to this day and poorer economies wouldn't have been able to afford computers as freely as they do now.

zohebv··on Ask PG: What has changed since you wrote Hackers and Painters in 2004?
> This is an urban legend

This is true, I stand corrected. However outside of Hilbert and Einstein no one was looking at Reimannian Geometry for answers.

> The physics community was already converging on the special theory of relativity

They had the Lorentz equations for decades but were not getting anywhere close to the final result apart from Poincare. And even Poincare inspite of getting almost all equations lined up, seemed to miss the fact that there is no absolute time and that time is only partially and not totally ordered. Einstein hit the nail on the head inspite of the fact that Lorentz/Poincare had been working on the problem for possibly decades. It still seems likely that Poincare could have arrived at the result.

This is the reason I cited GR. As far as I know, no one apart from Einstein/Hilbert seemed to ave been working on it.

In hindsight special relativity was "obvious", but Maxwell's equations had been around for decades and the Lorentz transforms emerged in 1887 and yet no one was able to make the mental leap required to re-interpret the nature of Time. SR could have ended up taking decades more to sort out. Einstein hit the ball out of the park in his 20s when the scientists working on the problem had spent decades on it. And GR could have only followed after SR.

zohebv··on Ask PG: What has changed since you wrote Hackers and Painters in 2004?
I do know about Hilbert, however Einstein and Hilbert were in heavy correspondence in the preceding few months and Hilbert never claimed primacy over Einstein. My conclusion, after seeing many accounts appears to be that Einstein would have arrived at the equations irrespective of Hilbert's inputs but not vice-versa. "Hilbert's treatise was exceedingly involved, or indeed confused—according to Felix Klein."

Also it should be noted that Satyagraha and Gandhi's civil resistance predates the March 1st movement.

zohebv··on Ask PG: What has changed since you wrote Hackers and Painters in 2004?
I should have said most people, rather than noone. Bill Gates helped make the PC cheap by building a hardware independent OS that commoditized hardware. Edison has a fairly colorful commercial history. But the PC/electricity revolution would have happened with or without these individuals, there were enough competitors. The same cannot be said about Einstein. When Einstein published the General Theory only 2 other people were able to understand it. Virtually, all peaceful civil disobedience protests that we see all over the world from American Civil rights to the Tunisian revolution follow a template set up by Gandhi. Peaceful civil resistance is an action that was never really thought of as practical/possible before. Bill Gates is making substantial social difference via vaccines now, but I would not count his work at Microsoft in the same league as Einstein/Gandhi.
zohebv··on Ask PG: What has changed since you wrote Hackers and Painters in 2004?
> I mean this inclination doesn't imply anything about what economic policy should be

Isn't it disingenuous to infer that this inclination should not imply anything about economic policy? I would arrive at the opposite conclusion. Economics are sentiment driven by a huge factor. Robert Shiller's work in behavioral economics and his book Irrational exuberance has established and popularized this idea. Krugman's discussion of the unsuitability of BitCoin as a currency rests largely on the peculiar nature of human sentiment and behavior. Large income gaps are perceived by most people as unfair irrespective of the contributions by the wealthy. No one thinks that Bill Gates/ Edison made a greater contribution to social progress than Einstein/Gandhi. I don't think the association of the net worth of an individual to the contribution that they have made to society is very strong. Economies rewards people largely on the basis of demand/supply with I believe is a weak proxy for social contributions.

Perhaps you want to draw an analogy to say gay marriage where the popular vote might end up denying gay rights, but I don't think a similar argument holds in the case of wealth distribution.

zohebv··on Java languages issues: classfile format, continuation, immutability, TCO
Thank you for the paper reference. It looks like O(1) detection is possible but is possibly expensive. With a periodic deadlock check you end up having to tune the periodicity and be able to write a very robust deadlock handler. For ex: what if one module ends up deadlocking leading to huge buffer overflows in a queuing system. What kind of periodic interval can you recommend that would be generally applicable, how should the deadlock handler react in such a situation etc. periodic detection will make the deadlock handler harder to write.

> Java's Date/Time classes have a broken design

They might be. But none of these are JVM issues per se. These are merely Java library issues. Add a library that fixes the issue. The slide deck is apparently about top 10 issues in the JVM. Deadlock/date are problems that can be solved by a library. Some of the issues in there are Java language issues and not strictly JVM issues. The pauseless GC slide is a ridiculous simplification. The slide deck is an obviously random hodge podge collection of disconnected scraps. It is a waste of time to go read through it. The intention of my comment was to save other people's time as the slide deck does not have anything interesting about Top 10 JVM issues or anything close. It is also somewhat disconcerting to know that the speaker is a VP at Oracle though possibly not in charge of JVM development.

zohebv··on Java languages issues: classfile format, continuation, immutability, TCO
Weird presentation. He has a disclaimer upfront that he doesn't really know much about the JVM. He wants a Decimal class? Fine go ahead and write one. You can easily emulate it using an int with a globally accepted denominator value, but whatever. He wants the class file format to be changed from stack machine to register machines. And exactly why?

He wants deadlock detection on every lock acquisition? So lock acquisition is now O(n) instead of O(1). Fine, go ahead and write your own expensive deadlock detecting lock class. Why does he need the "JVM" to support this?

Also what does - synchronized must die because we have > 2 CPUs- mean. One would think this makes synchronization more important. He is not even proposing an actor model as an alternative.

What does non threadsafe objects not being allowed to escape mean? Escape into a different thread? How does he propose to do the analysis required to identify such objects? Statically/Runtime? Is this even tractable? What level of granularity does he expect the lock on an "escaped" object to be, if the object itself is a graph of of many objects?

I like how he pretends to solve all GC problems in one slide, using "escape" analysis or whatever. Everything will be concurrent and nobody will pause. And there seems to be some persistent obsession with the Date and Time classes. He has also somehow managed to combine immutability with autoboxing.

zohebv··on Scala is for drivers
Well, all these tuples can be represented as a List[Any] object in Scala with no problems and it would be just like any other dynamically typed language. However, if you want static type checking of your code, then yes - it is useful to tell the compiler the constraint on the range of values that are valid for your object. This is generally not possible in dynamic languages and should not be surprising.
zohebv··on [dead]
Many years ago, a couple of my friends got together and planned a vacation. One of our friends who didn't want to come along jumped in and said - "Hey why don't you take the money pooled in and donate it to earthquake victims instead of taking a vacation." He felt really smug about this suggestion and couldn't stop patting himself in the back about his brilliance. I am not making this story up. The two of you should meet and congratulate each other.

Of course, there are several other ways of contributing to charity but I know the itch to scratch when you dreamed up this "awesome" scheme might have been too much to resist.

"make sure he's OK" - so you emailed jonathan before you put your script in action, didn't you?

"I was saddened by his reply" - One would expect someone who is so easily saddened to have some empathy for his own victims .. or maybe not. Maybe next time, when yuppies buy each other coffee you can keep out or do charity on your own dime?

zohebv··on Retiring a Great Interview Problem
How about this, this will compute more than pairs

<pre><code>

let dict = Data.Set.fromList["apple", "pie", "bread", "applepie", "piebread"]

let fn q = concat.Data.List.map (\(x,y) -> if (member x dict) then if y == "" then [[x]] else Data.List.map (x:) (fn y) else [] ) $ tail $ zip (inits q) (tails q)

fn "applepiebread" [["apple","pie","bread"],["apple","piebread"],["applepie","bread"]]

</code></pre>

zohebv··on Ask HN: Desperate Python Hacker Seeking Help and Suggestions
This looks like a variation of the stable marriage problem. http://en.wikipedia.org/wiki/Stable_marriage_problem
← PreviousPage 2 of 4Next →