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.
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.
- 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
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.
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?
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.
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.
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-...
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.
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...
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.
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.
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.
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.
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.
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!