Maybe you've seen it already, but maybe you haven't. If you haven't, then maybe you should read Arthur Liao's article entitled "A Quick Comparison of Nim vs. Rust":
https://arthurtw.github.io/2015/01/12/quick-comparison-nim-vs-rust.html
What are your thoughts?
FWIW, there were discussions about the blog post on both Hacker News and Reddit.
https://news.ycombinator.com/item?id=8883791
http://www.reddit.com/r/programming/comments/2scodb/a_quick_comparison_of_nim_vs_rust/
@Nikki The people here are much more civilized. Not only have we actually used Nim here, but we've also used Rust, so we can offer an informed comparison of the two, without the zealotry and ignorance of Nim that the Rust users at HN and Reddit so often display
Well, you're not being more civilized. You've accused Rust users of being zealots and fanatics with no supporting argument. When I look at the threads linked, I don't see any evidence of that. Rather, I see intelligent, well behaved Rust developers shooting down arguments against Nim, as in
http://www.reddit.com/r/programming/comments/2scodb/a_quick_comparison_of_nim_vs_rust/cnqkmch
Why don't you provide a specific example of Rust fanaticism in one of those threads? Right now, it appears that you're just making stuff up.
Did you even read any of the discussion you're linking to, brianrogoff? How did you miss these ones:
https://www.reddit.com/r/programming/comments/2scodb/a_quick_comparison_of_nim_vs_rust/cnoldn8
https://www.reddit.com/r/programming/comments/2scodb/a_quick_comparison_of_nim_vs_rust/cnqlij3
I was wondering if it was possible to speed up the nimrod code by processing the file in parallel. I took a quick stab at it, but soon found I don't understand "parallel:" blocks at all. This code doesn't compile, it errs out with:
lib/system.nim(2986, 6) Error: cannot prove: i <= len(chunks) + -1
can someone take this ball of confusion and make it do its thing in parallel? I'm curious if it would give a speed up (I note that the original version keeps a cpu core pegged...)
# ball of confusion...
import parseopt2, os, streams, tables, pegs, strutils, threadpool
# return a list of start and endpoints of a file
# broken into numparts. sizes should be approximately
# the same
proc split(fname:string,numparts:int): seq[tuple[s,e:int]] =
result = @[]
var
line:string
pos = 0
newpos = 0
let size = (int)getFileSize(fname)
let fs = newFileStream(fname,fmRead)
let nb = (int)(size/numparts)
for n in 1..numparts:
if pos+nb > size:
echo "breaking " & $(pos+nb)
result.add( (s:pos,e:size) )
break
fs.setPosition(pos+nb)
line = fs.readLine()
newpos = fs.getPosition()
result.add( (s:pos,e:newpos-1) )
pos = newpos
# process a chunk of a file and return a count
# of each word for that chunk.
proc doit(fname:string,s,e:int): CountTable[string] =
result = initCountTable[string]()
let fs = newFileStream(fname,fmRead)
var line = ""
var ignoreCase = true
fs.setPosition(s)
while fs.readLine(line):
let input = if ignoreCase: line.tolower() else: line
let words = try: input.findAll(peg"\w+") except: @[]
for word in words:
result.inc(word)
if fs.getPosition() > e:
break
# TODO: XXX I have no idea what I'm doing here...
# want to process all chunks of file at same time
proc stitchfun(fname:string, chunks: seq[tuple[s,e:int]]) =
var
res: seq[CountTable[string]] = @[]
chunk: tuple[s,e:int]
parallel:
for chunk in chunks:
# XXX: how do I call this??
discard spawn doit(fname,chunk.s,chunk.e)
for k in 0..res.high:
# coalesce the CountTables and print final results.
echo res[k]
proc main() =
let fn = "count2.nim"
let chunks = split(fn,8)
echo chunks
stitchfun(fn,chunks)
when isMainModule:
main()
Quoting Varriount:
"While Rust does have it's faults, this forum isn't really meant for such discussion. I would rather see discussion about how to program effectively in Nim, than criticisms for another programming language."