News for hackers. Stuff that matters.
Re:My experience rewriting Enjarify in Rust by the_duke on Monday September 19, 2016 @05:20AM (#12530005)
Good write up.

I can agree with him on a couple of points.

I've found Rust code to become terribly verbose and unreadable for certain tasks. You have to be careful to not end up with messy and hard to read code. Lifetimes of course make it even worse. Some common patterns are hard / awkward to implement. The stdlib is (intentionally) very small, and throwing together various crates adds a considerable maintenance overhead. Overall I find Rust really promising though. It might need a few more years to mature.

I totally agree on Go: I intially really loved it and used it all the time. The more code, and especially the more reusable libraries I wrote, I started hating it more and more, to the point where I only touch Go if I have to, or for small, one-off, self contained projects that need a bit more perf than Python or where Haskell is not appropriate (team, problem space).

The only thing that's a plus for go is it's dead-easy concurrency.

Re:My experience rewriting Enjarify in Rust by sethammons on Monday September 19, 2016 @11:32AM (#12532179)
I've not looked at Rust, but I've been using Go in production now for years at this point with non-trivial code bases. In our cases, they are mostly SMTP and HTTP servers. Sometimes the boiler plate gets in the way (and I think Go should almost never be used for simple CRUD stuff, there are better options), but I find the readability fantastic. It really dawned on my how readable it can be when I had to fix a missed condition in clean up on shutdown. It was fixed in an hour. For the perl version that the Go one replaced, it would have been a day before I even understood what would have needed fixing.
Re:My experience rewriting Enjarify in Rust by stormcrowsx on Monday September 19, 2016 @12:51PM (#12532791)
Really not a property of Go. Any codebase can be hard to follow if the designer wants it to be. It just happened that the Perl community went off the deep end and decided that tiny unreadable code was better than big readable code.
Re:My experience rewriting Enjarify in Rust by kbenson on Monday September 19, 2016 @01:19PM (#12533004)
> It just happened that the Perl community went off the deep end and decided that tiny unreadable code was better than big readable code.

That's one way to look at it. The other is that they embedded more syntax which makes the learning curve longer, but yields more more efficient writing and reading of code once you've fully internalized that syntax. The big mistake, IMO, was that they also made the language easily usable to get something done before you've fully internalized those rules, which leads to subtly wrong or weird programs that just work most of the time.

Perl is fundamentally different than most languages in how it uses context, but you can get away with not really understanding that at all by just learning a few rules-of-thumb. This, predictably, results in frustration in the writer, as they run up against what look like rough edges and weird idiosyncrasies in the language but are often just places where they've never actually learned how Perl really works.

That's not to say Perl doesn't have actual rough points and problems (what language doesn't after almost 30 years?), but contrary to popular belief, Perl is actually highly designed, and usually conforms to a few core principles (even it those principles are not what many other languages emphasize).

Re:My experience rewriting Enjarify in Rust by mbrock on Monday September 19, 2016 @05:27PM (#12534891)
It's worth keeping in mind that Perl, like its predecessors sed and awk, was intended among other things to be useful and convenient as an embedded language in shell scripts.
Re:My experience rewriting Enjarify in Rust by ngrilly on Monday September 19, 2016 @12:53PM (#12532799)
> I think Go should almost never be used for simple CRUD stuff

Why?

> there are better options

Which ones?

Re:My experience rewriting Enjarify in Rust by goatlover on Monday September 19, 2016 @03:29PM (#12534022)
PHP, Ruby, Javascript, Python - pick one.
Re:My experience rewriting Enjarify in Rust by duaneb on Monday September 19, 2016 @04:24PM (#12534400)
Why are they better? Dynamic languages are orthogonal to creating CRUD apps and come with massive runtime and reading overhead.
Re:My experience rewriting Enjarify in Rust by goatlover on Monday September 19, 2016 @05:48PM (#12535045)
The overhead doesn't matter for simple CRUD stuff. The developer's time is what matters. The dynamic language are more productive.
Re:My experience rewriting Enjarify in Rust by duaneb on Monday September 19, 2016 @06:32PM (#12535321)
> The dynamic language are more productive.

Do you have a source for that? I hear it a lot and I just don't buy it.

Re:My experience rewriting Enjarify in Rust by goatlover on Monday September 19, 2016 @07:01PM (#12535498)
If dynamic languages require less code and less hoops to jump through with more high level abstractions available to express yourself with, then chances are they will be more productive. There is a price to pay for this expressivity in terms of performance, overhead and potential bugs not caught at compile time. This is well understood, which is why you hear it a lot.

Now like most things having to do with programming, there is little empirical research backing up any language claim. As such, your anecdotal experiences might be different than the what you hear a lot. Maybe you are more productive in a statically compiled language. Maybe the metaprogramming features in a Ruby or Lisp don't make you more productive. Perhaps a more restrictive language fits your coding style and thought processes better.

Or maybe you're a Haskell programmer, at which point I would defer.

Re:My experience rewriting Enjarify in Rust by data_hope on Tuesday September 20, 2016 @02:54AM (#12537668)
There are basically not many conclusive and reliable studies out there that would show empirical evidence for or against dynamic or static languages (software engineering is not even a social science in this respect, i.e. psychology and sociology are more empiric than us).

From my personal and anecdotal evidence, I would say that dynamical languages are on average a good choice in terms of productivity. More or less, Smalltalk and Lisp have explored that design space and we have a fairly solid understanding of what a good dynamic language looks like (basically, most of them really look all the same if you look beyond the syntax). There are established practices and resources. I would even go so far and say that with dynamical languages - even though they are highly flexible - we have a pretty homogeneous situation. The most important differences between let's say Ruby, Python, Javascript and Clojure is in the ecosystem (libraries, etc). So I say: So dynamic languages are this robust and reliable family van.

With statically typed languages the situation is not so homogeneous. The selling point of statically-typed languages is that they can give you compile-time guarantees. Yet we have expressive and non expressive type systems. Languages that only allow for simpler types (golang), for complex types (ML/Haskell, and Rust which is simpler in terms of polymorphism yet more complex because it has these lifetimes). What I am trying to say is that already when speaking about expressivity, there are differences in statiically typed languages that are pretty huge. Yet they don't map 1:1 to productivity. I don't think there is a language better suited for compiler-writing than Haskell, yet it will be an unproductive language when I use it as a replacement for shell-scripts (or Python scripts that do shell script tasks). And I frankly don't know if Golang would be the right tool for this (if I had the choice between Golang and Python for writing a compiler ,I would probably choose Python).

When it comes to a CRUD application, it probably is not so much a question of which language you pick for implementing it, but for how well you understand the patterns (MVC, etc) established for CRUD applications, how nice the ecosystem supports you (libraries, frameworks, etc) and how well you write your tests.

Re:My experience rewriting Enjarify in Rust by slmyers on Monday September 19, 2016 @08:01PM (#12535787)
Isn't it more of an opinion than an objective truth? ie, it doesn't really need a source.
Re:My experience rewriting Enjarify in Rust by duaneb on Tuesday September 20, 2016 @11:42AM (#12540364)
That is what I was angling toward.
Re:My experience rewriting Enjarify in Rust by cm3 on Monday September 19, 2016 @07:32AM (#12530486)
> The only thing that's a plus for go is it's dead-easy concurrency.

Since you mention Haskell, I would like to say that Haskell's concurrency support is more diverse and at least as easy as Go's.

Re:My experience rewriting Enjarify in Rust by masklinn on Monday September 19, 2016 @08:26AM (#12530823)
> I would like to say that Haskell's concurrency support is more diverse and at least as easy as Go's.

More diverse is easy, Go is opinionated about its concurrency.

"At least as easy" is a flaming lie. The diversity alone makes it impossible but beyond that:

* when you look for concurrent go you're introduced to 3 constructs (`go`, channels and `select`) and you're off to the race having barely learned the language

* when you look for concurrent haskell you're directed towards the corresponding paper, "tackling the awkward squad" and a world of Async, MVar, ThreadId, STM and various types of Chan, and at that point you still can't write a line of concurrent haskell

Like the_duke I don't enjoy Go, but with respect to dead-easy concurrency the only language that's in the same ballpark is Erlang (and it's similarly boiled down to a complete lack of diversity — though a different model than Go's — and three basic constructs: `spawn`, `receive` and `!`).

Re:My experience rewriting Enjarify in Rust by mitchty on Monday September 19, 2016 @08:46AM (#12530969)
> * when you look for concurrent haskell you're directed towards the corresponding paper, "tackling the awkward squad" and a world of Async, MVar, ThreadId, STM and various types of Chan, and at that point you still can't write a line of concurrent haskell

I was directed here: http://community.haskell.org/~simonmar/pcph/

And after reading the first few chapters, I'd place go's options under the Rich Hickey quote of simple versus easy. Additionally I sped up a simulated annealing program with the accelerate framework in Haskell by typing "Acc " twice. From 1 000 iterations/minute to about 500 000. I'd call that an easy win. Haskell also allows for more than simply concurrent programming. I always ended up with locks in go and wondering why I was using it over c with an event loop and threads at that point.

Re:My experience rewriting Enjarify in Rust by jerf on Monday September 19, 2016 @01:25PM (#12533048)
Haskell's concurrency advantage is that the answer to the question "Does Haskell have X concurrency construct?" is "yes", and additionally, it's generally safe to use because everything is immutable. It even has support for things that have proved difficult or impossible in almost every other context because of that immutability, most notably STM.

Haskell's concurrency disadvantage is the same set of answers to the same question. It intrinsically has a big toolbox to start with, and a bigger one once you get into the libraries that implement further things on top of it (the pipe libraries, for instance), and that intrinsically makes it harder.

So, for instance, yes, you certainly sped up your program very easily, but new users often have a hard time finding their way to the best resources, and if their problem is not a trivially parallelizable algorithm, which it sounds like you had, there can still be some trouble in figuring out which concurrency construct they need.

Re:My experience rewriting Enjarify in Rust by dbaupp on Monday September 19, 2016 @02:02PM (#12533337)
STM is useless with full immutability: it is safe in Haskell because effects (including mutation) can be controlled/packaged into contained areas, via abstractions like monads.

That said, one downside of STM is that it isn't as efficient as some other schemes especially with high contention, as everything gets serialized through the metadata for tracking transactions. It's an awesome tool, but not a panacea (like with any other technology).

(I'm sure you know this, but others reading the thread may not.)

Re:My experience rewriting Enjarify in Rust by cm3 on Monday September 19, 2016 @08:51AM (#12530996)
Yeah, also the STM support is often overlooked and is a good fit for some tasks where everything else is much harder.
Re:My experience rewriting Enjarify in Rust by duaneb on Monday September 19, 2016 @04:26PM (#12534407)
You can't even write a generic pmap in go. Right there haskell wins.