It is a well known joke that "C programmers can write C in any programming language", though we can abstract this joke away to "$LANGUAGE programmers can write $LANGUAGE in any programming language".
This is usually language snobbery, poking fun at newcomers with a background in a different programming paradigm.
As well as being rude, unhelpful, insular and likely to drive newcomers away, it's wrong in suggesting that it's a bad thing.
Yes, there may be better ways of accomplishing what the newcomer seeks to do, but the important part is that it's a learning experience, which they may bootstrap themselves up from to a proper understanding of the language; a process which you can assist.
Ranting aside, I have been trying to teach myself Haskell. I come from an imperative and object-oriented programming background, with mutable objects and strict evaluation, so Haskell is somewhat of a culture shock, being functional, immutable and lazily evaluated.
A refuge in the storm of unfamiliarity is that the syntax resembles that of shell, so I'm starting from being able to plug existing shell commands together, until I can understand the equivalent native operation.
This is not a bad idea since it allows you to be more productive while learning; and since one advantage of shell is that you have a lot of commands available to re-use, these are applicable to many programming environments after you work out how to execute subprocesses.
One of the nice ways you can do this in Haskell is the Shelly package.
In this example, we have a git foreach
command, that runs a git command
in every git repository under the current directory.
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ExtendedDefaultRules #-}
{-# OPTIONS_GHC -fno-warn-type-defaults #-}
import Control.Monad
import System.Environment
import Shelly
import Data.Text as T
default (T.Text)
git_foreach args = shelly $ do
contents <- ls "."
forM_ contents $ \entry -> do
isDir <- test_d $ entry </> ".git"
if isDir
then do
chdir entry $ cmd "git" args
else return ()
main = getArgs >>= git_foreach
More detail on how this works can be found in the excellent article by the author.