Hacker News new | ask | show | jobs
by steipete 4113 days ago
Ruby people discovering algorithms ducks
6 comments

> Ruby people discovering algorithms ducks

This was not a good comment to post to HN. When you toss a Molotov cocktail into an HN thread and "duck", here is what we are going to get:

  web programming people aren't familiar with even basic CS

  I stand before you as a counterpoint to your foolish generalisation

  Oh cute, a web dev. You've just reinvented 1975 [...] 
  Would you like a pat on the head?

  Stop whining

  your comment is bullshit

  you deserve a slap
For any large group like "Ruby people" or "web programming people", HN has many users who either identify with being part of that group or identify with not being part of it. Given the numbers, there will always be a few who are having a bad day or feeling defensive or what have you, enough to respond angrily when someone posts a slur. Then their counterparts feel attacked, and down the whole thing goes.

Social padding prevents disputes like this from turning ugly, but we don't have that on HN. Even when you know another user from their comment history, that's not much information. Imagination fills in the gaps and then we imagine the other in the worst light. That's why the community here is fragile.

To be a good community member, please don't post things that could easily set the thread on fire. If after editing them out, your comment has nothing substantive left, please don't post it.

Thank you.
Java had the same kind of issue for years.

In Java and Ruby, the standard library uses an object `+` operator to mean concatenation (not numeric addition), and the implementation did immediate data copies, rather than doing reference linking and copy-on-write (or immutability).

But in Java this happens only with strings doesn't it?
Sort of... technically only the '+' operator only applies to strings... however it is essentially the same issue as the pull request, from what I can gather (I assume the issue comes from allocating a new array with size length+1 and copying the original each time a record is added). Same thing happens with java.util.ArrayList.add() and its cousins though, and from my experience people rarely use the constructor specifying an initial capacity, so the default gets used even if it is would obviously be woefully small (default is 10 BTW, in case you're curious & lazy :).

Also one might argue that the problem is actually much worse with strings, because string concatenation is so common and the syntactic sugar of the '+' operator for strings encourages the "wrong" way.

Java's JIT compiler optimises string concatenation by substituting a StringBuilder and has been doing so for a while.

As to using the wrong data type, that's really the programmer's fault. If you don't allocate enough capacity or use another data type (e.g. LinkedList) if you don't know the required capacity, you are doing a bad job.

To nitpick, Java's JIT compiler compiles Java bytecodes to machine code, but I know that javac does to the type of optimization that you are describing. There are plenty of scenarios though where it can't/won't do that optimization ... and if you are using the binary version of a library compiled without that optimization I'm pretty sure you're out of luck, especially if the method you're calling is not JIT'd.

I'm not really trying to knock any particular language or runtime here, the point I was trying to make is that nearly every language I've used has quirks that encourage convenience over optimization, and that just because you're coding in language foo, it doesn't mean you're off the hook when it comes to being intentional about the choice between them.

Just to clarify, java.util.ArrayList.add() grows the backing array by 50%, not just by length()+1.
Um... isn't this a data structure not an algorithm?
Programs = Data Structures + Algorithms, and it is often the case that there are deep relationships between the data structures and the algorithms.

For example, any linear recursive algorithm that deals with the head of a list and the tail/rest/butHead of a list is optimized for a linked list implementation. So... to understand a linked list, you really need to be familiar with algorithms that bisect list sin this manner, and the reverse: To understand algorithms that bisect lists in this manner, you have to be familiar with a linked list.

So... Yes it’s a data structure, but it’s joined at the hip to the algorithms that operate best on it.

I know, I was intentionally curt in my reply because snark is best solved with more snark </snark>
Except the linked list implementation was added to the project in 2013[1], and is presumably used elsewhere in the program. This only fixes a couple of bugs using that same mechanism.

https://github.com/rubygems/rubygems/blob/800f2e63bc6174b5b4...

Really. Every time I whine publicly how web programming people aren't familiar with even basic CS, I get a slap.

But really, I should move to web programming. I'll be an expert computer scientist there, probably.

Annnndddd.... what reaction do you expect? "Oh, please come and do web development so we can bask in the glow of your self-righteousness and infinite knowledge of computers."

/snark (apologies for being offensive, but good lord, what a silly statement - unless I missed the joke)

I stand before you as a counterpoint to your foolish generalisation, and guess what, I know plenty of other people that don't fit your stereotype either.

I'm not saying there's not an element of truth to your statement. See, here's the thing. People throughout the software (or any) industry have different collections of knowledge. There are an endless number of things to learn and each one of us is different and brings a different set of skills to the table.

To be great at web development you spend years learning the subtleties of developing for a vast domain of different platforms. There are bugs in the platforms decades old that I know the intimate details of and have workarounds for especially constructed to fit in with the other bugs in the other platforms we deal with. And that's a tiny facet of what you need to know.

You know what would really happen when you came over to web development? You'd find that a lot of the skills as a computer scientist aren't altogether useful.

You wouldn't be an expert computer scientist. You'd be a junior developer, probably.

The statement was a little strong, but in my experience it contains some truth. People who has never used a lower-level programming language can't often recognize these performance issues.
I've often found the opposite; people who use C get excited about using >> rather than / because it saved a few cycles on very old compilers, but fail to notice where they could've made it a million times faster by using a hash table rather than a linked list.
Unless a senior developer / a "wise" developer reviews the artifact created and allows him/herself to state: "This is not effective code. Refactor it by x y z".

The problem is, I think, this is NOT happening or at least to seldom because it "does not pay off", because "the aws boxes are sooo cheap!"

I'd say: the aws boxes are way too cheap and effectively misused. What should have been a way to scale up apps with reasonable effort turned into an energy and resources burning landfill. Granted, at least it is a shared landfill which really helps with from the resources/energy point of view.

(Juniors) Coders should be able to power the machines by driving a bicycle ergometer ... as a way to make the homo-sapience grasp the effects of their "mental work" ;)

I completely agree that software development is such a vast field that it is completely impossible to be proficient in everything. I am kind of a lamer in web development, for example.

But fundamental CS is a different thing.

"Annnndddd.... what reaction do you expect?"

Admitting your shortcomings and try to fix them is not an option at all?

When some central web frameworks do lamest mistakes like making an O(n^2) queue, it is frightening. And instead of deflecting any critique, one may try to fix this situation somehow.

Almost everyone does do lamest mistakes at some point, e.g.:

goto:fail - https://news.ycombinator.com/item?id=7281378

shellshock - https://news.ycombinator.com/item?id=8365110

I'm sure whoever wrote this would feel a little chagrin when coming back to their code and seeing how inefficient it was (though it got the job done when the lists were small), and they probably would admit their shortcomings, why wouldn't they?

Condescending snark is really easy, and it's easy to say in retrospect and with time to reflect that most useful code has flaws and point them out - software is never finished, and there are a lot of different levels of experience and requirements. If rubygems had never become popular, this wouldn't even be an issue.

PS Rubygems isn't a web framework, it's a package management tool, so the straw man you're hacking away at is the wrong one.

Mistakes come for different reasons: the human brain's limitations; carelessness; bad methodologies; ignorance.

I was talking about the last one here.

"PS Rubygems isn't a web framework, it's a package management tool, so the straw man you're hacking away at is the wrong one."

My statement about web frameworks was not about RubyGems, it was about web frameworks, and it was an example of the state of affairs in web development.

You think the original authors (Chad Fowler, Rich Kilmer, Jim Weirich) were ignorant of linked lists? What hubris.

The story is about rubygems, not web dev.

"Oh cute, a web dev. You've just reinvented 1975, but this time without algorithmic analysis. Would you like a pat on the head?"

/snark

Bluntly, web devs often screw up in the fundamentals of algorithmic operations and data. Web dev comes out of the horrific slap-it-up-i-tude of the HTML/Perl days of the mid-90s, and its tooling is still incredibly shoddy compared to desktop development. And the really fun part is? Web devs don't even get it. They often think they are the top of the food chain, with the best tools ever built. I still can't even find a tool to match VB 5's capabilities.

I think you over-estimate the average skill of non-Web devs, and over-estimate the attention paid to performance even by groups who probably know what they're doing.

One example, from Chrome: https://groups.google.com/a/chromium.org/forum/#!msg/chromiu...

It's less about skill and more about culture, knowledge, and the valuation of wisdom/knowledge within that culture.

but, yeah, I've seen some awful non-web code. :)

I'm a senior dev in both domains and I can safely say that your comment is bullshit.
What does any of that even mean?

Edit Could you clarify? Which part of what I said is "bullshit"?

I keep repeating myself on Hacker News, but once more, we've found the difference between Software Engineer and Computer Scientist. One makes things work, the other is a mathematician.

Why do we keep conflating the two?

You should be careful with the term engineer. By definition, engineering is the application of scientific and mathematical knowledge to solving practical problems. Without knowing and understanding the science and math behind computing and software, one can hardly claim to be a software engineer.
The title is cheap in the US and in some companies (cough) they slap it on every position that directly touches the product.
So many programmers have this weird inferiority complex when it comes to the term "engineer". Not you, but those who think that most programming can never be called "engineering" because people don't die if you introduce a software bug[1] (as if the only kinds of modern "engineers" have to do with immediately safety-critical things). I prefer the plain "programmer" myself, but I don't see the big deal unless "engineer" is a protected title wherever that person lives.

[1] Note that I said "most programming".

I'm a little sheepish about using it around the engineers in my life because I know I'm not legally liable and held accountable to the same standards they are when I make a mistake in the software I ship.

I like to think I take a certain amount of rigor in the choices of tools and processes and design philosophy that reduces the amount and impact of bugs... but if we get a customer complaint about our product we don't generally issue a recall and lose millions of dollars.

It's not that I spend any less time learning theory and application and it's certainly no less challenging in some cases than even mechanical engineering but... it's a liability thing.

Also, I don't write software for aerospace control systems.

I've seen companies advertise "software engineer," positions whose primary responsibilities included running a fleet of Wordpress blogs.

Just a matter of perspective I guess.

For me it's not a matter of severity of consequences, but rather in all other professional fields to be called an engineer you need to pass a PE exam. Having not taken that exam, it just feels like taking a cheap shortcut because it's not widely regulated.
My position on "computer science is math": http://www.scott-a-s.com/cs-is-not-math/ HN discussion: https://news.ycombinator.com/item?id=3928276
I'd argue that it's really a distinction between an engineer, who should understand this stuff, and a technician, who doesn't need to to do a job.

Certain segments of our industry are currently engineer heavy, such as embedded, and some appear to be technician heavy. I don't see that as a problem per se but it clearly causes friction occasionally as we tend to conflate them.

Because you cant be good at either without having an element of the other.

Ideally, they overlap.

Ideally they do overlap. But we don't call people who design bridges physicists even though they know a shitload of physics.

Our field is maturing. These difference are only going to become more important.

> You wouldn't be an expert computer scientist. You'd be a junior developer, probably.

+1

When I was in my early teenage years I was already making some development efforts on Pascal, VisualBasic and later on I switched to linux and started doing Perl CGI web apps.

Back in time when I had to choose if I want to do CS degree I was already paid as a web developer and doing what I was going to study for. Then I asked some friends that were actually studying CS and they told me that they have a very tight schedule with work in the following disciplines : FORTRAN, ASM, C, C++ . I told them that's too low-level for me and probably I will not use it for my work so I decided to go into completely different sphere ( I graduated law ).

Now I'm not the best programmer lived on the planet, but certainly I still do what I love and I'm paid for web development as high as a senior person, because of my experience - not CS degree.

So... If you think you can make benefit to web development, why don't you start with a simple open source contribution to any of the existing projects and reduce Wirth's law [1] a bit with some low-level skills. But for something more complicated, please consider some experience first in that specific area.

[1] http://en.wikipedia.org/wiki/Wirth%27s_law

Good, you deserve a slap for being self-satisfied about it. There are loads of fully competent and skilled web developers out there with great, in-depth CS knowledge, and publicly berating them achieves nothing.

Web development is interesting, because it tends to mix in people from a lot of different backgrounds — in particular, some of them come through the design side, and move down the stack. That's good, because it demonstrates the accessibility and flexibility of the stack; it's bad because it can result in suboptimal solutions to common problems.

You probably wouldn't do that well in web development, because it's too different from embedded or systems programming.

You probably have the luxury of specializing in one particular language, and maybe a handful of processor architectures. You probably rely on one or a few libraries, and know them backwards and forwards. You probably have your own personal repository of code and tactics that you go back to often. In other words, your knowledge of programming is probably narrow and deep.

Web developers usually don't get that luxury. Top web developers today have to be fluent in a minimum of two programming languages (javascript and a backend language like Python, Ruby, PHP...), use several different fast prototyping approaches (css compilers and wacky templating systems), have a good working general knowledge of everything from the web browser to the web server, and cope with an environment in which at least one of those parts is changing on almost a daily basis. Web development is shallow and very, very broad.

I prefer systems programming but I've worked as a web developer off and on for several years now. I have a lot of respect for any web developer that's really good at it. They aren't lesser programmers at all, and I suspect a lot of them, if they decided to do it, could kick the pants off of most systems programmers.

I'm a web dev who has a degree in CS. Do you think I'm a unicorn?

Of course not. Stop generalising.

I was going to post the photoshopped joke, but this gets more to the gist of it

http://stackoverflow.com/questions/3811678/add-two-variables...

Edit: found it https://plus.google.com/u/0/+DougTyrrell/posts/br3kqg6Vet6

That's a bit strongly worded, but I also see the pattern of people who came into computing from the Web direction rediscovering basic principles of computing and computer science. Similarly, the NoSQL community seems to slowly be discovering why traditional relational databases work the way they do, why supplying correct and durable replicated storage with high performance is difficult, and why some of the features that NoSQL threw out along side SQL itself in the name of simplicity and performance are actually quite useful and occasionally important.
Slap. Stop whining.
Not sure why parent is getting downvoted, there is a serious problem in the Ruby community that very few of them have read GoF, TAoCP, and/or K&R.
Stop jumping to conclusions, and stop throwing around buzzwords.

GoF is a (somewhat C++-centric) book about design patterns that's completely unrelated to the discussion at hand, may not be the best resource to learn about design patterns and has nothing to do with CS.

TAoCP is more like an encyclopedia; actually reading through even one chapter takes a significant amount of effort (if you want to get anything out of it). Try it. (Yes, I've worked with it.)

K&R is a 27 years old, thoroughly outdated book about C. There are better options[1].

[1] Try the 16 years old book "Expert C Programming" by Peter van Linden, which is excellent, even though outdated too.

+10 if I could, re "Expert C Programming"; excellent read, even if you aren't a C programmer
Because it's smug and adds nothing to the conversation.

I don't see any evidence that the Ruby community suffers more than any other development community from this sort of thing — that is, the ones where high performance is not the biggest concern, of course.