HNHacker News
TopNewBestAskShowJobs

mden

570 karma · joined August 28, 2013

email: mdenchev'-'gmail.com
submissionscomments
mden··on Additional C/C++ Tooling
Our team has had a decent compile time improvement by switching to ninja[1] from gmake.

[1] https://martine.github.io/ninja/manual.html

mden··on Interview: Larry Wall
For the ease of others (your link is broken): http://www.wall.org/~larry/
mden··on Less is more: language features
If a function receives immutable state, returns immutable state, and does not depend or modify outside mutable state, then that function has no side effects. Mutating state within the function itself will not affect anything outside it and so mutations are not side effects, at least by default.

About your two situations, I am guessing you mean that the functions rely on state not being passed in, but rather on state referenced from the outer scope? I agree that that complicates both reasoning and testing, and so it should be avoided. In C/C++ this type of design (i.e. relying on static scope state) is practically always avoided as there's rarely any need for it.

If instead you mean that mutable references are being passed in as parameters then logic wise isn't this similar to assignment/binding in a functional language as long as you avoid propagating the side effect to other functions?

I am personally a great fan of immutability, just not functional languages. I can see the justification for limiting the tools at your disposable to guarantee certain things, it's just that in this case I think they are not sufficient.

---

For those downvoting, gee thanks. I see how trying to have a discussion is hurting your feelings.

mden··on Less is more: language features
"[They] break referential equality and equational reasoning"

Please explain?

Mutations can cause side-effects but don't have to. You seem to think that limiting program behavior _necessarily_ alleviates informal reasoning, but that's not the case. Your argument is also highly hyperbolic in terms of testing. A properly designed system with immutability needs to be tested no less than properly designed system with mutability.

mden··on Less is more: language features
To me this is a weird list. It's a bit like removing the personality of a person and then claiming that made the person better.

Also a lot of the things he lists are not at all as clearly harmful as he makes them out to be.

GOTO: Used in some of the cleanest code bases. For example the lua programming language, redis db, and linux kernel OS. Yes the use is limited, but it's there not because of mistakes but rather because it is sometimes the most clean way.

Numbers: I don't understand this one. In the very least having different types of numbers seems to be a necessity for anything performance oriented such as graphics. JS not having them (they seem to have been added for WebGL as an extension, no?) is not a good reason for all new languages to do the same.

Mutations: I am personally of the view that mutation often simplifies the informal reasoning complexity of a program. There's a reason functional programming hasn't caught on and it likely never will. A hybrid approach of having both immutability and mutability like Rust seems most sensible.

Reference equality (Referential transparency?): If you have immutability do you not get this for free? How can you be sure about getting rid of mutations but not be sure you want objects to be equal based on data?

Each language has it's own quirks that make it special and that's part of the reason programming is fun. There's never a single right way.

mden··on Meteor 1.1 Released – Now Supporting Microsoft Windows and MongoDB 3.0
Isomorphic means "same shape". In this case the code running on the client and on the server is the same. Not that terrible of a choice for a word.
mden··on The OWebl Cookbook
I'll give what I consider to be reasons why the language isn't more popular, but it seems most people that use the language don't share these views. Please don't flame me for the excessive rant below and keep in mind these are subjective reasons (that may be badly worded, (it is 2am) or even worse simply misinformed).

- The compiler error messages are awful, especially for newer programmers. By awful I really do mean awful. "Syntax error" is not a very meaningful message, but at least it tells you the location right? Except due to the poor grammar of the language (I did say these objections are subjective) a small mistake like a missing in or semi-colon results in a wild chase trying to figure why you are getting a "syntax error" in a perfectly valid piece of code.

- Unpolished language grammar. There are just a lot of small things that bug me about the language like the existence of "in" for let statements (Rust's approach feels much cleaner), having multiple ways to create blocks (begin..end, and parenthesis), having to type rec for recursive functions, difference between declaration of functions in mli and ml, argument sigs and function sigs use the same delimeter, let is used for binding functions, imperative mode using refs is just plain ugly. These are minor and almost entirely subjective objections, but the real issue isn't just a lack of polish, it's that the language is too unrestricted.

- Language is too unrestricted. 1) It's often very difficult to read other people's code because there are many ways to accomplish the same thing. 2) The language almost invites you to have high levels of nested logic (something considered a cardinal sin in imperative programming) to the extent that it's not uncommon to see (or be tempted to write) 6 or even more levels of depth. 3) Easy abuse of lambda functions (fun and function) can make it difficult to even know how many parameters a function really expects. I mean this in the sense that you need to carefully read the code to get an idea of even whether a let binding is a data binding or a function binding. Of course these are all things you learn to handle and manage with some experience, but they really don't make the language an easy pick-up.

- Language is difficult to reason about internally. Let me give an example. OCaml can be very clever sometimes, like when you prepend to a list, that's an O(1) prepend with no copy of the initial list even though it's immutable. To write better OCaml code you need to become familiar with such things (though I suppose that's true of any language) and sometimes it's not easy (for me at least) to guess internal behavior. For example, does "let t = {t with x} in" modify t in place even though t is immutable (assuming we are the same level where t is first declared, i.e. initial t is no longer reachable) or does it create a new copy of t and then modify the x in that new copy? I guess a fair counter is, who cares?, and I get that, but at the same time I have some underlying drive that makes me want to know (the answer is the second one, the data is copied) at least things such as when I am allocating new memory.

The last big one and the most controversial of all - (purely) functional programming is not worth the trouble. It is inherently more complicated than imperative regardless of all the functional people claiming otherwise. It's not as simple as "you learned one first and that's why it's easier", an argument I've heard repeated many times, one that probably has merit, but also one that cannot account for the difference in difficulty. I can write an entire paper on why functional is more difficult (essentially it will use most of the reasoning as Out of the Tar Pit - which argues that functional is great - but with some changes in the argument to result in an opposing conclusion). In terms of informal reasoning, the benefits of lack of internal (to a function) mutable state are essentially zero, or better worded, lack of local mutable state increases the complexity of a function. It's not like your state doesn't change if you use recursion and immutability... it certainly does, it just mutates transiently while you are building up your result. That's often more difficult to reason about than a typical imperative solution with mutability. Okay, fine, perhaps I am a shit developer who simple isn't smart enough or lacks the experience, but the reality is when you are working on a team, the chances are that you will have a very difficult time gathering 20, 30, or more solid functional developers let alone that many OCaml developers. Ideally, you want your team to all be at least competent in the language you are using and that's harder to achieve with OCaml.

I think OCaml is a lovely language that brings a lot to the table, but I simply can't see it becoming mainstream (or really any other functional language either). The thing that makes sense to me is to merge imperative and functional into some sort of hybrid language, which is one of the main reasons Rust is so exciting. Reduce global mutable state to as low as reasonable while making allowances for local mutable state. Also Rust fixes the three sections of complaints above - great errors and warnings, feels more polished when writing, and forces a much higher rigidity - though it introduces some other issues.

At this point I am not even sure what I'm talking about so I'll end it here hoping the above made any sense at all.

mden··on Ask HN: The rising “Hackathon Hackers” culture
And out of curiosity, how do you resolve your statements with the fact that you have over 5k karma and over 1k posts on this site alone?
mden··on On Secretly Terrible Engineers
Fyi, there's a mistake in your second solution - consider a strictly increasing list.
mden··on Google Earth Pro is now free
This sounds really awesome, but does anyone have an explanation as to why they are doing it? Building something like Google Earth Pro must take many millions of dollars, so why would a company release it for free?
mden··on Main is usually a function – when is it not?
It does not. It just moves what "the problem" is.

An example of that is the article itself which leverages the gained information from SO to solve the real problem.

Also arcane knowledge is not the same thing as problem solving.

mden··on Prosecute Torturers and Their Bosses
Yup, thanks!
mden··on Prosecute Torturers and Their Bosses
So you are saying we shouldn't prosecute the executive branch even though they clearly broke and sanctioned breaking existing laws. When should we prosecute them? What makes them different from tyrants?

Also your example doesn't make any sense. Creating a law for abortion is not even in the same category as breaking current laws. This is not purely an issue of morality, it's about the rule of law as well.

mden··on Streem – a new programming language from Matz
In some languages you can hide the extra check:

for i in range(1,100):print("Fizz"(i%3==0) + "Buzz"(i%5==0) or i)

mden··on RMS on why Emacs lisp doesn't have namespaces
http://aws.amazon.com/s3/
mden··on Human running speed of 35-40 mph may be biologically possible
That's my understanding as well. The title makes no sense and seems very click-baity.

"Our simple projections indicate that muscle contractile speeds that would allow for maximal or near-maximal forces would permit running speeds of 35 to 40 miles per hour and conceivably faster"

So essentially if human physiology worked differently than it did, we could theoretically run much faster. Not a useless result, but not really anything as exciting as they make it sound.

mden··on You could have invented Parser Combinators
This is an aside, but I really liked the presentation of this article. It starts from the right place, builds at the right speed, and relates to the reader in a fun way. The format of statement followed by the same statement but expressed in code was great. Thanks for writing/linking it.
mden··on Ask HN: How do I learn C and C++ when I love high-level languages?
What can I say, C++ isn't easy to learn :)
mden··on Ask HN: How do I learn C and C++ when I love high-level languages?
Assembly didn't really click for me until I learned computer architecture :p

You can always go one level down, but I would hardly say you need assembly for c or c++.

mden··on Ask HN: How do I learn C and C++ when I love high-level languages?
Go to a code practice site like hackerrank or oj.leetcode (personal favorite but I suggest using an external compiler for it) and solve problems. Start from the simplest ones and make your way up. Once you solve a problem, go back the following day or week and without using a reference solve it from scratch. After solving a problem look at the solutions provided in the forums. A lot of the time they will be a lot more elegant and contain things you haven't considered or seen before.

This is only half of it. The second half is to choose a mid size project, write yourself something that resembles a spec, and code it up from scratch. It could be some sys util or perhaps a video game (this will require you to learn library linking).

The third half is to read online articles and tutorials while you do the two things above.

The fourth and final half is to get yourself a book once you have a grasp on the language(s) and learn some of their more complicated idioms and pitfalls.

Also as a side note, at this point in time I don't think the "C/C++" conglomerate make much sense any more as modern C++ looks very different from C. Unless you explicitly need C, I would suggest learning C++ first as it's higher level (and also much larger). Though, idk, maybe learning C first is better as it's the foundation for C++... I guess either is fine, just not both simultaneously.

mden··on Navdy
I agree with what you are saying and you shouldn't be reading messages or w/e when driving, but surely looking away from the road is more dangerous than not? In the very least it takes more time. Again I'm not encouraging the behavior, just saying not all distraction are equivalent...
mden··on Navdy
Hmm. I think I took Yxven's comment out of context which in turn made my comment out of context. I agree that interruptions like reading a text message are dangerous regardless of how they are done. They are obviously more dangerous if you have to take your eyes off the road to do it is what I was saying.

In regards to long trips, I still maintain that having a distraction like music, audio books, or company to talk to is actually safer than not having them. Your brain getting tired of monotonous activity and scenery is a real thing as anyone who's done a 10 hour drive can tell you. But again my comment wasn't really in the same context as the parent I guess, so there's that.

mden··on Navdy
"Cell phones are not dangerous because the driver was looking at his phone or playing with the buttons when he had an accident. They are dangerous because they encourage your mind to wander."

So you are claiming that having to look away from the road for possibly whole seconds to deal with a phone is not really dangerous, but what is dangerous is your mind wandering? I'm sorry but experience and common sense says otherwise.

I would also argue that your second point is not as not clear cut either. Having some sort of distraction is definitely helpful most of the time when driving long distances. I personally find audio books very greatly help to fight off monotony, which in turn keeps my attention higher than if I was not being distracted.

mden··on Project Euler Returns
Ah of course. Thanks.
mden··on Project Euler Returns
A noob question I suppose, but couldn't the salt be generated deterministically from the email and still serve it's purpose?
mden··on GCC 4.9 is doing “some seriously crazy shit” according to Linus Torvalds
That's not a tautology. There's a non-circular flow to the reasoning.
mden··on Too Much Power For One Man
Isn't it nice how you can make most things sound evil if you just use the right wording. What you wrote reminds me of cases where law enforcement takes terms like "subversion" used by an engineer and extrapolates evil plots out of them.
mden··on Beautiful web type – typefaces from the Google web fonts directory
Partially off topic, but page layouts like the one you linked to really come off as unnatural to me. Specifically the way the margin for annotations is used in the centering of the main content is distracting. It's like you are giving equal relevance to sporadic notes as to the main article. I'm surprised to see it in a typography book.
mden··on The new VirginAmerica.com
Why? I find it absolutely horrendous personally and would avoid any webpage that used it (got to the end of the presentation on my second try as I literally rage quit the first time).

Some reasons as to why I severely dislike it: 1) When it scrolls the background changes color. There's multiple transitions going on. It's sort of like going to a different website. I lose my entire concentration and interest. 2) No scroll bar. I can't get to the final slide without painfully going slide by slide. 3) When scrolling with the mouse, I lose control of the webpage for about a second. I can keep spinning the mouse wheel but nothing is happening. It's infuriating.

mden··on The Truth on OpenGL Driver Quality
I don't think production quality is the only reason. Sometime it's cheaper to design one product and sell it as multiple products to capture more value. For example, some people are willing to pay 1k for a graphics card while others are only willing to pay 300. So you sell the same graphics card to both groups but for one you artificially lower it's capability. This allows you to capitalize on the market a lot more efficiently than selling your product either at a low price or a high price.
← PreviousPage 5 of 7Next →