From owner-freebsd-questions@freebsd.org Fri Jul 1 08:10:51 2016 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 70B84B87104 for ; Fri, 1 Jul 2016 08:10:51 +0000 (UTC) (envelope-from bsd@bontempi.net) Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 415C12674 for ; Fri, 1 Jul 2016 08:10:50 +0000 (UTC) (envelope-from bsd@bontempi.net) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id E3F7820290; Fri, 1 Jul 2016 04:10:49 -0400 (EDT) Received: from web2 ([10.202.2.212]) by compute4.internal (MEProxy); Fri, 01 Jul 2016 04:10:49 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=bontempi.net; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=szQKDGKWqu7fon0OJFcorQA4rAk=; b=0MAupi TBtoZ9PdearvCBSQ0fo+uqyVyiIBlxXMNt8/1ACPjd+Uvhlu8DX+UsFQkLRWKUGE lvR864RQmcgCZthkQ9zeBmRUNrMIVglP6JKARTu23OyrXv5w21xE7Is4grBe1FzY gqhOd5GMmiscnmU1nGWtQG4QN1wW4HiCZpLhI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=szQKDGKWqu7fon0 OJFcorQA4rAk=; b=NGHnUaTLDBpu60chgGn8r04m6Ypu44j+M2ImVuPX2PgO2Jp OvQq5kdse7UjkKUf1IeYAepUioDgFn3bOECbyIdlb8J8yEgYMER0Ypx+gAkbmvSA 7Z3z44v2ryJTk2U3vPLR9BK0EP/WPp3BemF36GVru/olFdhjHn1DJPg9j+E4= Received: by mailuser.nyi.internal (Postfix, from userid 99) id A4E04D033E; Fri, 1 Jul 2016 04:10:49 -0400 (EDT) Message-Id: <1467360649.3751988.653960161.06009D74@webmail.messagingengine.com> X-Sasl-Enc: U03OJDu1GGN8WrPeJ2V49n+m344tpL8jotrL2cIdmmMn 1467360649 From: Priyadarshan To: Dimitri Minaev , Allen , freebsd-questions@freebsd.org MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" X-Mailer: MessagingEngine.com Webmail Interface - ajax-15e5213e In-Reply-To: <57762256.7070106@gmail.com> References: <20160630175243.063e07a7@KoggyBSD.org> <57762256.7070106@gmail.com> Subject: Re: "Simple" Languages in FreeBSD Date: Fri, 01 Jul 2016 08:10:49 +0000 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Jul 2016 08:10:51 -0000 On Fri, 1 Jul 2016, at 07:57, Dimitri Minaev wrote: > On 07/01/2016 01:52 AM, Allen wrote: >=20 > > Literally anyone who responds with an opinion, I'm interested. Being > > easy to learn for someone who isn't great with Math but does understand > > Unix is a plus but not a requirement. I was starting to teach myself > > Ruby on a Linux box I was using for a while and Ruby did seem to be > > going OK, but a lot of the FreeBSD Books I've bought recommend Perl, > > and I've also had just as many reasons from people saying to try > > Python, so basically any Language and what reasons would be great. >=20 > A huge part of my job is automation in UNIX and 99% of it is done in=20 > Bash. IMHO, shell is a must for anyone working with UNIX, even though=20 > it's not really a programming language in the common sense. About 15=20 > years ago I used Perl often and I remember it as a very natural language= =20 > very similar to shell, but better. The syntax may sometimes look=20 > strange, but most of the time Perl by default does exactly what you want= =20 > it to do. >=20 > The Python is in fashion these days. They say it's easy to learn and has= =20 > a clean syntax. Perhaps, I'm getting too old to learn new languages, but= =20 > I found Python verbose and awkward. The trend introduced by the=20 > object-oriented languages of the last decades makes the programmer use=20 > various helpers, wrappers, proxy objects, singletons and other=20 > doubtlessly useful but clumsy contraptions. For example, let's write a=20 > simple script that runs a program, reads its output and feeds it to the=20 > stdin of another program. In Perl, it's as straightforward as this: >=20 > open(P1, "ls -la |"); > open(P2, "|grep ^d"); > while (my $l =3D ) { > print P2 $l; > } >=20 > Quite natural, eh? Now, Python: >=20 > import subprocess > a =3D subprocess.Popen(["ls", "-la"], stdout=3Dsubprocess.PIPE) > b =3D subprocess.Popen(["grep", "^d"], stdin=3Dsubprocess.PIPE,=20 > stdout=3Dsubprocess.PIPE) > ls =3D a.communicate()[0] > r =3D b.communicate(input=3Dls)[0] > print(r.decode()) >=20 > I'm sure there are other ways to do the same in a more concise way using= =20 > external Python modules like 'sh', but the idiomatic way, AFAIK, is the=20 > one used above. >=20 > Besides, Python, however logical it is, may be unpredictable. For > example: >=20 > In [1]: a=3D99 > In [2]: b=3D999 > In [3]: a is 99 > Out[3]: True > In [4]: b is 999 > Out[4]: False >=20 > I found Ruby to be more like Perl. Even though it is an object-oriented=20 > language, it has many shortcuts that make things simpler, like using $_=20 > variable to store the last read string. But I never liked OOP and put=20 > Ruby away. >=20 > So, from the practical point of view I would vote for Perl. Some would=20 > say it's too old, but hey, it's still more popular than Ruby, according=20 > to TIOBE index: http://www.tiobe.com/tiobe_index >=20 > But the popularity shouldn't be crucial in the language choice. If=20 > you're going to learn programming languages for fun, have a look at some= =20 > less popular alternatives. One of them is my favorite Tcl. It's a=20 > language with very simple syntax, underestimated but powerful. Many=20 > utilities used in other languages, were born in Tcl: Sqlite, Expect and=20 > Tk GUI, to name a few. It's still very popular as a built-in language in= =20 > network hardware. It may lack some libraries supporting modern protocols= =20 > (AMQP, for example), but programming in Tcl just feels great. >=20 > Another interesting language is Scheme. There are many dialects of this=20 > uncommon but beautiful language. Racket has one of the largest=20 > libraries, but it's rather a language for students and teachers than for= =20 > the real world applications. Chicken Scheme and Guile are way more=20 > practical and just as rich. >=20 > Other options include Erlang and Haskell. Go language is also=20 > interesting, but it is IMHO a language for real programmers. Thanks for this. Python, Ruby, Haskell, Julia, even PHP, they have all something to offer. One should really try to feel what is closer to one=E2=80=99s way of thinking about problems, since the language can really help, or really be a hindrance. Our company uses mainly Common Lisp, but we are also a Perl shop. It is interesting to see new employees using so-called =C2=ABnew=C2=BB languages, slowly but surely getting interested in the =C2=ABold=C2=BB Perl 5 (aka Perl Raptor), and ultimately adopting it as main language to =C2=ABthink=C2=BB about problems.