When writing shell scripts or other types of executables, you often put a directive at the top of the file to indicate which kind of interpreter to use.
Oh wait, that didn’t work?
Okay, that worked on my Mac. But why all the guesswork? There is another command that is better.
env. Use it as a directive like so:
And if it’s a
env is kinda like
which. It takes the first argument and figures out the full path of that, and uses it as the directive
man env to read more about it.
#!/usr/bin/env INTERPRETER makes your script more portable
the ability to run your script anywhere, on any OS/platform
The holy grail goal of programming/CS = write once, run everywhere
It is somewhat circular in that it depends on
env living inside of
/usr/bin/, but I believe it is a convention that is much more rarely broken than where
another CS vocab word.
The quality of being predictable, doing expected things.
e.g you walk into a dark room, you expect the light switch to be near the doorway opposite of the door hinge, not a mousetrap clamping down on your fingers when you reach along the wall.
Originally posted on Quora: Jonathan Tsai’s answer to What is the most valuable programming language to know for the future and why?
I will have to agree with Michael Hanson’s answer as well as some of the other ones that suggest learning multiple programming languages is more beneficial than picking just one.
I myself am a multi-linguist of both human and programming languages. If you randomly survey a large body of people living within various civilizations in the world on what the most valuable human languages are, the answers you’ll get back are likely to be English, Chinese, French, Spanish (not necessarily, but roughly, in that order).
When you know multiple languages, learning additional ones become much easier, because through immersion/osmosis, you are made aware of the different types of parts of speech, recognize the cognates and influences of one language to another, etc. That’s why you will frequently come across Europeans who speak at least 3 languages (English, French, and the language of their country), and Indians who speak 3-5 languages or more (English, Hindi, the language of their state/region, + neighboring state/region).
Programming languages actually have a much simpler syntax than human languages. The more you know, the easier it is to learn more.
I would rephrase the question as plural instead of asking for a singular response: What are the most valuable programming languages to know for the future and why?
If you like lists, this section is for you, but not in any particular order:
- Python - frequently used by scientific and statistics communities and data science; it’s a fairly easy language to learn and remember with libraries for just about everything you would need, and a very active development community who can whip up a library if one doesn’t exist already. Personally, Python is really easy to me and reads and writes just like pseudocode. I’ve written as many as 100-200 lines on a whiteboard or a text editor in one sitting and was able to execute the code in the interpreter without any syntax errors.
- Ruby - I am not a regular practitioner, but Ruby is also very powerful in that it is an interpreted language like Python, which means that it doesn’t need to be compiled before it’s run. A lot of famous websites are built on, and many of my friends who are paid handsomely, use Ruby, due to the popularity of the Rails framework (Ruby on Rails)
- Java - This one is nice because it’s a compiled language and the compiler can optimize the heck out of the code, and it runs really fast. There are lots of Java practitioners, and the majority of financial websites (banks, stock trading platforms, etc), will use Java because of its outstanding speed and performance characteristics. Incidentally, Java is also the language used by the Android operating systems, so if you want to learn to write for something like 79-80% of the world’s mobile users, this is the way to go. (Source: 2014: The iPhone 6 Had Better Be Amazing And Cheap, Because Apple Is Losing The War To Android; 2015: Apple iOS And Google Android Smartphone Market Share Flattening: IDC)
- Shell Scripting / Bash - Unix utilities are awesome. They are lightweight, fast, and often times, you can just use an existing Unix utility for doing common but advanced tasks like searching and sorting on a single machine, and additional various things.
- C++ / C - it still powers lots of high performance systems, but is a bit more cumbersome to write than Java, hence the reason that Java is the language of choice when building such systems. However, this is a very low-level language, and the thing about programming languages is that their interpreters and compilers are quite meta–if you chase it up/down the stack far enough, you’ll find that some/most of them are inevitably implemented in C. Not much daily use, but if you like learning the nitty gritty or really knowing what’s under the hood (analogous to learning Greek / Latin to having a better grasp on English), then this is something you have to learn.
I would be hard-pressed to give you a ranked list since I don’t know the statistics off the top of my head, but my impression is that the above are your programming language lingua francas, and most likely the highest value in terms of popularity/ubiquity, economic value, and utility.
Tonight, I was doing some research and maintenance on a couple of my open-source projects. In particular, I had recently learned about EditorConfig (which BTW, is a great idea! and a standard EVERYONE should adopt), and wanted to add it to most of my projects.
That brought me to my GitHub homepage, and I caught a glimpse of my GitHub streak. Only 2 days! I was on a roll for a few days, and then a few days of working on private projects reset my streak.
Not that it matters, anyways, but I was slightly bothered, and being the fan of automation that I am, I quickly thought up how to automate my GitHub contributions to keep my streak alive, artificially.
30 minutes later,
github-streak is born and released to the world. I call that being diligent at slacking off.
It’s a fairly straightforward project that had a few requirements/constraints as I designed it:
- Had to be portable, modular
- Had to be cross-platform, as much as possible
- Had to be really simple technology and minimal dependencies–don’t overthink it
- Written in BASH/shell script (my favorite shell)
- Even uses the conscientious
#!/usr/bin/env bashshebang directive
- Creates a symlink in
/etc/cron.daily– probably won’t work for every system, but at least was available on my webserver and others that I’ve used in the past
- The script just appends a date string to a
.streakfile (hey, a new convention!) and
- Added in the
- MIT licensed (my favorite open-source license)
So, here you go internet, have at it:
Show some star/fork love. Plz thx kbye.
Edit: Here are some other GitHub projects worth checking out that manipulate commit history as art:
It’s 2015, and from time to time I still see a lot of
== peppered throughout codebases that I work with, and just wanted to share a few posts that might change your mind =)
=== and its complement
!== and should be used like 99% of the time because it is faster and more accurate.
> 0 == "0" < true > 0 === "0" < false > 0 == false < true > "0" == false // really? < true > !!"0" < true > !"0" < false > "0" === false < false
There are more perverse and mind-bending examples that are out there, but I’ll leave you with those for now.
As you can see, the former
== does type coercion, which is lazy way of doing comparisons without casting data explicitly, and can find yourself in hot water down the line. The latter
=== does type checking first, and then checks equality of the values.
Protip #1: If you want to test a JS expression or figure out some syntax really quickly, just open your JS console in the browser inspect tool.
Protip #2: If testing for something truthy or falsy, a nice trick is to just do use the
! operator twice (
!!). As can be seen above, JS treats non-empty strings as a truthy (yet, strangely,
"0" == false)
The JetPacks 3.3 upgrade that allows you to manage and administer multiple WordPress sites from one WordPress.com account is a breeze to use!
I’m not quite used to it yet and still getting acclimated, but I think it’s a great time-saver and will grow on me more over time.
I can see it as a great feature to use once a site for daily workflows in updating content once a site’s major structural and design work has been done.
Cheers to the WordPress team for this great feature!
Read all about it in the original post.