Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Show HN: WordCount.is (wordcount.is)
48 points by joelrunyon on Sept 21, 2012 | hide | past | favorite | 55 comments


This is my first ever endeavor into some sort of programming.

I use evernote or textedit to write a lot posts or guest post and there's not always a quick way to check word count before I send them off. In addition, a lot of wordcount sites out there were ugly, hard to use or filled with ads.

I know it fills a really, really small niche need, but I was pretty happy I could put it together in a few hours, solve a small problem and learn something about programming at the same time.

Now, to move on to bigger projects!


This is what I see in case it differs from you: http://imgur.com/jhjSV Im on Windows 7 using Chrome.

Personally I feel as though the gray box explaining what the page is, is taking up most of the page. Any way to make it smaller? This way I feel as though it would remove any scroll bars on the page and prominently show your "WordCount.is is a useful web utility by Joel Runyon"

Other then that, page looks clean and is simple to use.


Thanks for the feedback. I'll see what I can do.


I actually expected the word count to show up in the grey area, I think it would look nice.


Hey Mark,

Went back through and cleaned things up. Thanks for the suggestion!


Great start for a first endeavor. Couple notes:

- Would definitely recommend rethinking the header/banner area. Takes up a lot of vertical space and seems unnecessary for such a simple tool.

- You're loading jQuery twice. Recommend removing that second version (line 14).

- http://wordcount.is/js/jquery.center.js is returning 404 and doesn't seem needed (line 12).

- It's best practice to cache your selectors for re-use in jQuery. Here's a slight rewrite that does that and cleans up your event binding: https://gist.github.com/3764620

Happy hacking!


Hey Josh,

I went ahead and implemented all of your suggestions (I think). Seems to be a little bit faster! Thanks.


Thanks for all the support and suggestions everyone.

I've gone ahead and implemented several of the suggestions. You can check it out here --> http://wordcount.is

Thanks again for the support and programming help!


You should check out Marginalia, my web-based markdown editor with live word counts. We even use the same bootswatch theme :)

https://www.marginalia.io


the text on your buttons isn't centered vertically


Weird, they were fine yesterday. I'll take a look. Thanks!


As a funny little anecdote, I know of a Mac word processor company that, as a tiny update, added a live word count feature to their product.

Sales shot up 30%.

It turns out that a number of people who write for a living need to hit hard word count limits, and were willing to pay for a product that had that feature.

The dev I know who added the feature said he spent all of 15 minutes on it.


I'm surprised at how many people leave this out. It's a simple function that most writers/editors use, but for some reason lots of writing applications leave out.


While already quite clean, your JavaScript can be simplified somewhat. split() will take a regular expression:

    var wordCount = value.trim().split(/\s+/).length
Additionally, JavaScript's regex dialect has a special character of "\W", which matches any non-word character. So if you split on "\W+" instead, you ought to get a more reliable list of words, eliminating cases like "foo -- bar" counting as 3 words.


I was wondering what a word (in a word count) was, thinking like you that "foo -- bar" was only two words, just like "foo-bar" or "foo/bar". So I started two widely used word processors and got surprising results : "foo -- bar" is actually considered 3 words long in both Microsoft Word 2007 and LibreOffice Writer 3.6.1.2, but "foo-bar" and "foo/bar" are 1 word long. There seems to be no standard as to what a word is in this context :

      Different word counting programs may give varying results, 
      depending on the definition of "word", on the text segmentation
      algorithms, and on whether words outside the main text such as
      footnotes or hidden text are counted. [1]
Anyway it seems a consensus to say that "foo -- bar" is 3 words long, so wordcount.is does give a not so wrong answer after all.

[1] http://en.wikipedia.org/wiki/Word_count


Hey Skymt, I implemented the first part of your suggestion and it worked well.

However, when I tried to implement the \W, it gave me a very different count. When I checked it against Microsoft's Word's count for block of lorem ipsum text, the original function matched it exactly. Any thoughts as to what happened?


Thanks Skymt. I'll implement that this weekend.

Thanks for the tips.


Nice first project Joel!

Evernote is one of the rare programs that's very much inferior on the Mac, as the Windows version DOES have a word count feature. I'm really not sure why the team can't include it on the Mac version.


Thanks Thomas.

I love Evernote, but this is one of the minor details that could be improved.


Evernote for Mac has had word count for several months now. Click the "i" button, the popover shows the size of a note, and its word and character counts.


I was going to suggest making a browser extension out of this, but after some searching see that it has been done before. (On Chrome: https://chrome.google.com/webstore/detail/kmndjoipobjfjbhocp...).

This seems useful for people who 1) are not programmers, and 2) either are running a browser where there is no such extension, aren't interested in installing extensions, or have a one-off need.


Very clean design and targets the niche nicely. One of my pet peeves is broken wordcounts though. A single space registers on your site as 1 word. Can I suggest checking out my post about javascript wordcounts? http://drewschrauf.com/blog/2012/06/13/javascript-wordcount-...


Congrats on your first project. Useful features: 1. Detect whitespaces in count 2. Count of a specific word/character in the text


Good ideas. I'll see if I can figure that out!


For a first venture into programming, this was nicely done!

One thing, I thought the definition of a "word" is something like 6 characters, so a really long word could be considered 2+ "words". It seems like your definition of a word is a set of strings separated by a space. Is this intentional?


LOL it looks like we have a lot of pre-typewriter peeps in the house :)

I'm old school, so when I learned to type, I learned it on an actual typewriter. When we had to fix mistakes, we needed to use good old fashioned liquid paper.

So doing things like calculating your typing speed in words per minute was done where 5 characters was considered a "word". So when I was in school, when the teacher or prof said to hand in a 2000 word essay, it would be based on where a word was considered 5 or 6 characters, regardless of how many actual words there were.

http://www.speedtypingonline.com/typing-equations

Interestingly, I just checked on MS Word, and they consider a word to be anything with a space inbetween, so I guess the definition has changed since the Mesozoic era!


I don't mean to be condescending, but you're not thinking of a 'word' as in, a 'word' in computer architecture are you? I'm pretty sure a word doesn't have to be six characters, but i could be wrong...


You're thinking of calculating touch typing speed in WPM, where the standard is to consider a "word" to be 5 characters.


Hey Steve, I'm not aware of that definition. Hmm...Would have to have a link to that definition? I guess tweak the script pretty simply if that's the case.

But yes, to answer your question, this is a word count as defined by spaces between words.


Off-the-cuff thoughts: is a number (say "12") a word? Is a hyphen -- used, say, like this -- a word? They count as 'em in your webapp, but I'd be curious what the official definition of word actually entails.


I think it depends on your definition, but broadly, yes, I would say most would count "12" as a word.


since when did words of more than 6 characters become two words!!!!!

That is so bizarre.


Nice but I think it is a little bit lacking on the feature side even for a pet project. As others point out there are already a ton of ways to obtain a word count. Maybe you add value by providing a frequency chart of words?


It's not really supposed to have a lot of "features." It's a single-purpose site – find your basic word count.

It took me a few hours and taught me a little about programming. I view it much more as a stepping stone to understanding development and programming than as a full-time business project.


wc(1) to the rescue! :)


If you're on OS X: copy the text to the clipboard and run pbpaste | wc


If you're on Linux: Select text and run xclip -o | wc


or "wc" <enter> <ctrl-v> <ctrl-d>


Or switch to new Vim buffer, then pg<C-g>


Pretty cool. Congrats on releasing!


Thanks zrail!


Good stuff Joel! This is clean.


Thanks man! :)


For whatever reason, this counts prefixed whitespace as a single word.


Why is this a service and not a .js file?


The TLD is .is, in case you thought it was .js.


I think he's asking why this is a website, and not just a simple javascript library that others can use.


I figured, for people like me with no coding or programming background, a single-use website would be more useful than a library that people would have to set up themselves.

Plus, while I know about GitHub, I haven't really spent too much time on it to really know how it works.


It's pretty easy to do in javascript. Made a Gist with a simple example https://gist.github.com/3764261


The gist isn't quite as interactive.


I have to agree. I mean, it's nice and all but really it's a function you can write in a few minutes. I don't think it needs a website and a submission to HN.


Thanks peacemaker. Maybe as I get better I'll get faster at programming.

In the meantime, it was fun to be able to solve a problem I had by learning something I didn't know before.


I agree it's good to get out and learn things like this, I'm just not sure you needed to post it here?

*Thanks for the downvotes too...


1. It's his first venture into a programming project 2. "var wordCount = value.trim().split(/\s+/).length" isn't much of a library. The benefit of a project like this for user's is so they can avoid building the scaffolding and deployment.


For a first venture, well done. I'm just questioning why it should be a post on the front page of HN for such a simple (sorry if that offends?!) piece of code.

I'm truly not trying to discourage and probably sound like a grumpy old man but I just don't think the OP needed to post something so simple here.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: