Date: Fri, 01 Jul 2016 08:10:49 +0000 From: Priyadarshan <bsd@bontempi.net> To: Dimitri Minaev <minaev@gmail.com>, Allen <bsd_atog@comcast.net>, freebsd-questions@freebsd.org Subject: Re: "Simple" Languages in FreeBSD Message-ID: <1467360649.3751988.653960161.06009D74@webmail.messagingengine.com> In-Reply-To: <57762256.7070106@gmail.com> References: <20160630175243.063e07a7@KoggyBSD.org> <57762256.7070106@gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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 <P1>) { > 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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1467360649.3751988.653960161.06009D74>