8 ms·
I couldn't agree more with this article. I did some Go a year ago and liked it. Then coming back to it a year later after having done some functional programmi
by tarikjn 12y ago
I couldn't agree more with this article.
I did some Go a year ago and liked it. Then coming back to it a year later after having done some functional programming in Clojure, it's not just the lack of generics that disrupt my flow but also having to think about all sorts of imperative programming details like naming and creating variables and scope placements in cases that would otherwise be unnecessary in a functional language.
I feel like I have been tainted by functional programming, and now Go feel like a joyless programming language which inevitably affect productivity.
I am looking for a replacement programming language to solve small problems for which Python/Ruby would have traditionally been used, good file system, stream and networking APIs, but concurrency as a first class citizen, garbage collected, fast startup time. Doesn't need to be good at long running programs, but it would be great if it can evolve to play a repeat role in a large system/process without the hassles of having to duplicate every written line of code into tests to prevent small changes from breaking things.
I am considering giving Haskell a try, but wondering if it might be overkill.
Any suggestions?
- felipehummel 12y agoYou may try out using Scala as script language like this: "scala myScript.scala". The first startup times are slower, and even after that it may be slower than Python/Ruby but it still may be sufficient for your use case. Using "sbt ~run" (re-runs your program automatically at every file change) may also be an option.
- tarikjn 12y agoI don't see a reason why Clojure couldn't achieve the same startup time? I am trying to avoid the JVM startup time itself so that leaves out Scala/Clojure. I'd like to be able to have a fast startup time when, say, running a script with its containerized environnement, when it is done the container exits, so I can't leave a vm running. So I believe that leaves out JVM languages. Independently from that, I did try Scala before Clojure and found its grammar to be overkill and unintuitive so it wouldn't be my first choice.
- chrismccord 12y agoElixir sounds like it might be worth a look. Nice for scripting and as good as it gets for concurrent programming. Some of its design is inspired by clojure so you might feel right at home. http://elixir-lang.org http://elixir-lang.org
- rcarmo 12y agoHave a go at Hy (hylang.org). You can have your cake and eat it too. :) Other than that, I'm fiddling with LISP Flavored Erlang (lfe.io), but I've had previous Erlang exposure.
- tarikjn 12y agoThat looks pretty interesting, but I don't have that much experience with Python, so the benefits are diminished. I am looking for a runtime which can take full advantage of multiple cores for a single program, something I believe Python would fall short at.
- Cyther606 12y agoNim. http://nim-lang.org/tut1.html http://nim-lang.org/tut1.html
- friendly_chap 12y agoThis question is not easy. Most languages I consider well designed do not become mainstream - which comes with a host of problems. Nowadays I think if having no type system at all is better than having a broken type system, thus I am considering picking up a mainstream dynamic language (JS being an obvious candidate - but the runtime puts me off).
- tarikjn 12y agoJS could fill the role but both the runtime and language are unideal, we end up dealing with a lot of browser baggage. JS is still my tool of choice for building web apps. Just as for long running services, Clojure is a no brainer for me. I am pretty open to ML or LISP based syntaxes, not necessarily looking for something Clojure-like.
- jbooth 12y agoGo has first-class functions, if it had generics it'd be trivial to put together libraries for most of the functional-collection goodies, while still having imperative style available for when you care about performance or when it's just simpler for the problem.
- nine_k 12y agoThis, and using something like `Either` / `Result` instead of the `result, error := MethodCall()`. (Alas, the authors of Go seem to consider notions like 'monad' or 'Kleisli category', both pretty simple, impractical.)
- jbooth 12y agoWords like 'monad' and 'kleisli category' (which I've never heard of) absolutely REEK of impracticality to me, regardless of the concepts. There's a rule for academic papers where if the author is writing in clear language, he has something interesting to say, and if he's writing in fancy academese, he's probably saying absolutely nothing. I don't really see a huge additional value for your proposed method call semantics, can you explain more? Some(Result) can make nil go away, but you've still got the error to deal with. So you're talking some type system where a single value encapsulates Result/Nil/Error?
- nine_k 12y agoThese words are merely unfamiliar. Do you think that 'pointer arithmetic', or 'open-closed principle', or 'abstract class', or 'exception propagation' sound less intimidating for a layman? But in reality none of these are complex after you've put a small effort to comprehend the notions behind them. Specifically, try reading these completely un-academic un-papers. 'Either' monad, with nice kid-friendly pictures: http://fsharpforfunandprofit.com/posts/recipe-part2/ http://fsharpforfunandprofit.com/posts/recipe-part2/ Bonus: Martin Fowler, of all men, endorses the above approach, in Java, of all languages: http://martinfowler.com/articles/replaceThrowWithNotification.html http://martinfowler.com/articles/replaceThrowWithNotificatio... A Kleisli category, with examples in down-to-earth, compact, un-hairy C++: http://bartoszmilewski.com/2014/12/23/kleisli-categories/ http://bartoszmilewski.com/2014/12/23/kleisli-categories/ This stuff is not hard and is utterly practical. It can very well be used in current industrial languages. The worst service you can render to yourself is to start thinking that you already know all what is worth knowing, and close your mind to new concepts. Guys that thought that Fortran and Cobol are enough to get by for foreseeable future were technically correct — both are still in some demand! Unfortunately, their market share has dramatically shrunk, deservedly, as have employment opportunities.
- wtf_is_up 12y ago> I am looking for a replacement programming language to solve small problems for which Python/Ruby would have traditionally been used, good file system, stream and networking APIs, but concurrency as a first class citizen, garbage collected, fast startup time. You just described Go, mostly. I can't think of a more fitting language given your stated requirements. To your first point: I don't know what Go has to do with your preference of functional programming to imperative. Go doesn't claim to be a functional language so I just am not seeing the connection.
- tarikjn 12y agoYes, I did describe what Go is good at, that's because I am trying to find something to put it against for what I use it for currently. Let's say I prefer Haskell's syntax/approach. Coming from Go, what could I be missing in Haskell?
- xasos 12y ago> solve small problems for which Python/Ruby would have traditionally been used, good file system, stream and networking APIs, but concurrency as a first class citizen, garbage collected, fast startup time I think for the most part, you won't be missing a lot in Haskell. If you are looking for what you say above, Go should satisfy your needs greatly. Haskell is amazing for functional programming needs - fast prototyping and great at doing mathematical calculations. It helps you think in another way, but I certainly wouldn't use it for building something like an API or networking.
- nine_k 12y agoWhile it's kind of off-topic, let me still ask: what are the problems you see in using Haskell for networking? I see that building a library with the C calling convention might be hard, but a web service must be pretty language-agnostic.
- codygman 12y agoI'm not sure why the xasos says that. For me Haskell has been great for apis. Regarding calling C, the Haskell ffi is very easy to use. Try Nim, Ocaml, or Haskell to replace Go in that order. I order it in terms of probable familiarity.
- deleted 12y ago[deleted]
- jramnani 12y agoYou may want to take a look at Pixie. "Pixie is a lightweight lisp suitable for both general use as well as shell scripting." https://github.com/pixie-lang/pixie https://github.com/pixie-lang/pixie
- stonemetal 12y agoIf you don't need windows support, O'Caml with Jane Street's Core is pretty good. The Async module handles the concurrency bits, and the Pipe module handles the streaming parts.
- ufo 12y agoNote that for now Ocaml is still single threaded so the concurrency is cooperative, similar to how it is in Python or Nodejs. BTW, I'd recommend Lwt instead of Async because its more popular (kind of sad that there are two competing concurrency libs though)
- frowaway001 12y agoScala is pretty nice. Concerning the JVM startup time: It's usually in the range of milliseconds for your use-case. What gave the JVM a bad name regarding startup time are large JavaEE application servers which had dependencies to hundreds of MBs of libraries. In this case, startup is slow, otherwise: not so much.
- danidiaz 12y agoI think Haskell is a possible alternative to Go/Python/Ruby for these kinds of tasks. But nothing's perfect. Some possible annoyances you might encounter: * Much of the functionality required to be a valid "Python alternative" is not on the base packages. You'll have to install extra packages much sooner than with Python. And you'll have to know what packages to install. * Despite having proper sum types, most I/O libraries in Haskell rely on exceptions for signalling errors. And Haskell has no proper stack traces. If you are not careful, you might find yourself pining for Go's multiple return values. (Some would add "having to use the IO monad" to the list of annoyances, but I think it actually helps.)
- bstpierre 12y agoI found ocaml to be a more flexible alternative -- I can sprinkle printf for quick debugging without having to alter types. (I think this is what you mean by "having to use the IO monad". I didn't work with haskell much, so it's possible there's an easy way around this there.) And stack traces in ocaml are reasonable, though not quite as verbose as python's. But your point about needing to install extra packages stands for either language.
- kxs 12y agoYou should look into Debug.Trace for quick printf-like debugging. Usage: trace ("error occurs here") (f x)
- gnuvince 12y agoOCaml is currently my language of choice. I love functional programming, been doing it for a while now, but it's nice to know that if I read an algorithm in a textbook, I can just implement it as-is instead of doing a translation to be purely functional (and sometimes having to fight to get back the asymptotic complexity). The module system is also absolutely great, and should be copied shamelessly by more languages.
- Peaker 12y agoHaskell doesn't ban imperative programming, it simply distinguishes it in the types.
- llambda 12y ago> I am looking for a replacement programming language to solve small problems for which Python/Ruby would have traditionally been used, good file system, stream and networking APIs, but concurrency as a first class citizen, garbage collected, fast startup time. You may want to have a look at ClojureScript, which has come a long way in the last few years. While the tooling is still not as nice as Clojure-on-the-JVM in my opinion, it continues to get better everyday--this week support for a better REPL via NodeJS[1] was introduced, for instance. A lot of smart people are putting good effort into the compiler and ecosystem and I suspect we'll see a continued uptrend in cljs adoption. Anyway, it may be just what you want: an elegant, productive, pragmatic language with first-class support for concurrency (atoms, core.async) and well-suited to short-lived and scripting-domain problems. (Bonus you can write your frontend and backend in the same language if you want!) [1] http://swannodette.github.io/2014/12/29/nodejs-of-my-dreams/ http://swannodette.github.io/2014/12/29/nodejs-of-my-dreams/
- oahziur 12y agoThe "REPL via NodeJS" is amazing!!! I want to try ClojureScript on NodeJS for a long time. Now I can play with the REPL.
- dominotw 12y agoF# ?
- zodiakzz 12y agoDart. https://www.dartlang.org https://www.dartlang.org