Related
Currently I have listed down learning Unix/Shell Scripting and reading CLR Algo book as the most important priority for me. I was thinking if I could solve the algorithms questions mentioned in CLR using shell scripting. Mind you I'm a complete newbie to Unix/Shell Scripting.
No, it's not. Shell scripting is definitely not designed for writing algorithms. You should use a general-purpose programming language like C, C++, Java, Python, or [insert your favorite general purpose language here].
That's not to say that you couldn't use bash or something for algorithms -- it's Turing-complete AFAIK -- but you really wouldn't want to. It'd be a huge pain, you wouldn't learn a lot of the skills you need (like modeling algorithms in common programming languages or styles), and your solutions would be cryptic. Do yourself a favor and use something else. Shell scripting is for automating tasks, not solving algorithms.
Also, most shell script languages (bash most notably) are weakly typed, which a.) hurts performance and b.) will make your program harder to reason about. Dynamic typing is OK for algorithms, weak typing, not so much. Performance will be abysmal, regardless.
If you're trying to learn both shell scripting and algorithms, you can still do it at the same time. Write scripts to compile and test your programs and write your programs in a general purpose-language.
Shells like Bash are quite powerful but I think you'll find that their limited support for arrays, no support for hashtables, and other limitations would make it tedious to implement anything more than very basic algorithms. Python or Perl would be a much better general scripting language.
(added later) Since learning that Bash 4 has associative arrays, I'd like to add that implementing some algorithms with shell scripts could be done. It wouldn't be fast, and wouldn't be elegant, would be tedious as hell, and limited in its application; but if you want to be forced to learn the intricacies of the shell while you learn to implement algorithms, that is, purely as a mental exercise, this might be a good thing for you.
Not at all. Shell scripting is good when you want a one point stop to perform all your UNIX/Linux system related activities. You can go for C/C++, Python, Java.
Universities usually prefer one of the following (not a complete list, just heard ones):
C
C++
Java
C#
Python
Matlab
Scheme
You should pick a language based on your need (learning programming is not a need, you do it for achieving something). some examples (not a complete list):
You have interest in unix-linux programming at system level: C, C++
You are interested in being a software engineer: Java, C# (maybe C++)
You are interested in web programming: PHP (maybe Python)
You are interested in mathematical/statistical programming, linear algebra etc: Matlab
etc. First: determine your programming aim, then search it on the web to see what people are using, then learn it
I would like to ask you about what formal system could be more interesting to implement from scratch/reverse engineer.
I've looked through some existing and open-source projects of logical/declarative programming systems. I've decided to make up something similar in my free time, or at least to catch the general idea of implementation.
It would be great if some of these systems would provide most of the expressive power and conciseness of modern academic investigations in logic and its relation with computational models.
What would you recommend to study at least at the conceptual level? For example, Lambda-Prolog is interesting particularly because it allows for higher order relations, but AFAIK is based on intuitionist logic and therefore lack the excluded-middle principle; that's generally a disadvantage for me.
I would also welcome any suggestions about modern logical programming systems which are less popular but more expressive/powerful.
Prolog was the first language which changed my point of view at programming. But later I found it to be not so high-level as I'd like to see it.
Curry - I've tried only Munster CC, and found it somewhat inconvenient. Actually, at this point, I decided to stop ignoring Haskell.
Mercury has many things which I wanted to see in Prolog. I have a really good expectation about the possibility to distinguish modes of rules. Programs written in Mercury should inspire compiler to do a lot of optimizations (I guess).
Twelf.
It generalizes lambda-prolog significantly, and it's a logical framework and a metalogical framework as well as a logic programming language. If you need a language with a heavy focus on logic as well as computation, it's the best I know of.
If I were to try to extend a logic based system, I'd choose Prolog Cafe as it is small, open sourced, standards compliant, and can be easily integrated into java based systems.
For the final project in a programming languages course I took, we had to embed a Prolog evaluator in Scheme using continuations and macros. The end result was that you could freely mix Scheme and Prolog code, and even pass arbitrary predicates written in Scheme to the Prolog engine.
It was a very instructive exercise. The first 12 lines of code (and and or) literally took about 6 hours to write and get correct. It was pretty much the search logic, written very concisely using continuations. The rest followed a bit more easily. Then once I added the unification algorithm, it all just worked.
I've been looking at Haskell lately and it seems like a very nice way to watch programming problems from an alternative point of view - alternative to my usual imperative (I have a strong C++ background) view, at least.
However, all the articles I see seem to deal with the same kinds of programming problems:
Parsers
Compilers
Numeric computation problems
I'd like to give Haskell a try myself, by writing some GUI application. Hence, I'm wondering: does it make sense to write event-driven systems like GUIs in a functional programming language like Haskell? Or is that a problem domain at which imperative languages excel? Unfortunately it still takes quite some time for me to switch my mind to 'functional' mode, so I have a hard time deciding argueing against or in favor of using a functional programming language for an event-driven system.
I'd also be interested in examples of GUI applications (or event-driven systems, in general) which are implemented in Haskell.
Here's a couple of Google keywords for you:
Functional Reactive Programming (FRP), a programming paradigm for, well reactive (aka event-driven) programming in purely functional languages,
Leksah, a Haskell IDE written in Haskell,
Yi, an Emacs-like editor which replaces Lisp with Haskell as the implementation, configuration, customization and scripting language,
Super Monao Bros. (yes, you guessed it, a Jump&Run game)
Frag (First-Person Shooter)
Purely Functional Retrogames is a 4-part series of blog articles about how to write games in a purely functional language, explained using Pacman as the example. (Part 2, Part 3, Part 4.)
xmonad is an X11 window manager written in Haskell.
Also, looking at how the various Haskell GUI Libraries are implemented may give some ideas of how interactive programs are made in Haskell.
Here's an example using epoll to implement an event driven web server: http://haskell.org/haskellwiki/Simple_Servers
Take a look at this wikibooks article, it's a basic wxHaskell tutorial. In particular see the Events section.
I recommend spending some quality time with Haskell and FP in general before jumping in to develop a fully-fledged application so you can get more familiarized with Haskell, since it's quite different from C++
xmonad is event-driven -- see the main event handling loop, which takes messages from the X server, and dispatches to purely functional code, which in turn renders state out to the screen.
"Functional reactive programming" was already mentioned, but it may seem complicated if you're looking at it for the first time (and if you're looking at some advanced articles, it will look complicated no matter how long have you studied it :-)). However, there are some very nice articles that will help you understand it:
Composing Reactive Animations by Conal Elliott shows a "combinator library" (a common programming style in functional languages) for describing animations. It starts with very simple examples, but shows also more interesting "reactive" bit in the second part.
Yampa Arcade is a more evolved demo of Functional Reactive Programming. It uses some advanced Haskell features (such as Arrows), but is still very readable. Getting it to actually run may be more complicated, but it is an excellent reading.
Haskell School of Expression by Paul Hudak is a book which teaches Haskell using multimedia and graphics (including some animations etc.). It is an excellent reading, but it takes more time as it is an entire book :-).
I find my way to functional programming through F#, which is a bit less "pure" compared to Haskell, but it gives you a full access to .NET libraries, so it is easy to use "real-world" technologies from a functional language. In case you were interested, there are a couple of examples on my blog.
Dynamic languages are on the rise and there are plenty of them: e.g. Ruby, Groovy, Jython, Scala (static, but has the look and feel of a dynamic language) etc etc.
My background is in Java SE and EE programming and I want to extend my knowledge into one of these dynamic languages to be better prepared for the future.
But which dynamic language should I focus on learning and why? Which of these will be the preferred language in the near future?
Learning Ruby or Python (and Scala to a lesser extent) means you'll have very transferrable skills - you could use the Java version, the native version or the .NET version (IronRuby/IronPython). Groovy is nice but JVM-specific.
Being "better prepared for the future" is tricky unless you envisage specific scenarios. What kind of thing do you want to work on? Do you have a project which you could usefully implement in a dynamic language? Is it small enough to try on a couple of them, to get a feeling of how they differ?
Scala is not a dynamic language at all. Type inference doesn't mean that its untyped. However, Its a very nice language that has nice mixture of OOPs and functional programming. The only problem is some gotchas that you encounter along the way.
Since you are already an experienced Java programmer, it will fit nicely into your skillset. Now, if you want to go all the way dynamic both Ruby or Python are awesome languages. There is demand for both the languages.
I would personally recommend Clojure. Clojure is an awesome new language that is going in popularity faster than anything I've ever seen. Clojure is a powerful, simple, and fast Lisp implemented on the JVM. It has access to all Java libraries of course, just like Scala. It has a book written about it already, it's matured to version 1.0, and it has three IDE plugins in development, with all three very usable.
I would take a look at Scala. Why ?
it's a JVM language, so you can leverage off your current Java skills
it now has a lot of tooling/IDE support (e.g. Intellij will handle Scala projects)
it has a functional aspect to it. Functional languages seem to be getting a lot of traction at the moment, and I think it's a paradigm worth learning for the future
My (entirely subjective) view is that Scala seems to be getting a lot of the attention that Groovy got a year or two ago. I'm not trying to be contentious here, or suggest that makes it a better language, but it seems to be the new JVM language de jour.
As an aside, a language that has some dynamic attributes is Microsoft's F#. I'm currently looking at this (and ignoring my own advice re. points 1 and 2 above!). It's a functional language with objects, built on .Net, and is picking up a lot of attention at the moment.
In the game industry Lua, if you're an Adobe based designer Lua is also good, if you're an embedded programmer Lua is practically the only light-weight solution, but if you are looking into Web development and General tool scripting Python would be more practical
I found Groovy to be a relatively easy jump from an extensive Java background -- it's sort of a more convenient version of Java. It integrates really nicely with existing Java code as well, if you need to do that sort of thing.
I'd recommend Python. It has a huge community and has a mature implementation (along with several promising not-so-mature-just-yet ones). Perl is as far as I've seen loosing a lot of traction compared to the newer languages, presumably due to its "non-intuitiveness" (no, don't get me started on that).
When you've done a project or two in Python, go on to something else to get some broader perspective. If you've done a few non-trivial things in two different dynamic languages, you won't have any problems assimilating any other language.
JScript is quite usefull, and its certainly a dynamic language...
If you want a language with a good number of modules (for almost anything!), go for Perl. With its CPAN, you will always find what you want without reinventing the wheel.
Well keeping in mind your background, i would recommend a language where the semantics are similar to what you are aware of. Hence a language like Scala, Fan, Groovy would be a good starting point.Once you get a hang of the basic semantics of using a functional language(as well as start loving it), you can move onto a language like Ruby. The turn around time for you in this way gets reduced as well as the fact that you can move towards being a polyglot programmer.
i would vote +1 for Groovy (and Grails). You can type with Java style or Groovy still (you can also mix both and have no worry about that). Also you can use Java libs.
As a general rule, avoid dynamically typed languages. The loss of compile time checking and the self-documenting nature of strong, static typing is well worth the necessity of putting type information into your source code. If the extra typing you need to do when writing your code is too great an effort, then a language with type inference (Scala, Haskell) might be of interest.
Having type information makes code much more readable, and readability should be your #1 criteria in coding. It is expensive for a person to read code, anything that inhibits clear, accurate understanding by the reader is a bad thing. In OO languages it is even worse, because you are always making new types. A reader just getting familiar will flounder because they do not know the types that are being passed around and modified. In Groovy, for example, the following is legal def accountHistoryReport(in, out) Reading that, I have no idea what in and out are. When you are looking at 20 different report methods that look just like that, you can quickly go completely homicidal.
If you really think you have to have non-static typing, then a language like Clojure is a good compromise. Lisp-like languages are built on a small set of key abstractions and massive amount of capability on each of the abstractions. So in Clojure, I will create a map (hash) that has the attributes of my object. It is a bit reductionalist, but I will not have to look through the whole code base for the implementation of some un-named class.
My rule of thumb is that I write scripts in dynamic languages, and systems in compiled, statically typed languages.
Does anyone know if Google uses Ruby for application development?
What are the general job prospects of Ruby compared to other languages like Perl or Python?
Aaron's roughly right. We use C only for kernel work (and other maintenance on 3rd party stuff written in C) so I wouldn't count that as "application development", and Objective C for the very specific case of apps running client-side on Apple gear, etc.
Ruby is the embedded scripting language for Google Sketchup, see http://code.google.com/apis/sketchup/docs/gsrubyapi_examples.html -- that decision was made before Google acquired "#Last Software", Sketchup's makers.
Regarding Nishant's second question, in the wider job market, Ruby's kind of OK: still low absolute numbers but good growth, see http://duartes.org/gustavo/blog/post/programming-language-jobs-and-trends and http://blog.timbunce.org/2008/02/12/comparative-language-job-trend-graphs/ -- the data are getting a bit long in the tooth, but it's really hard to do these assessments in a very up-to-the-minute fashion;-).
Does anyone know ig google uses Ruby for any application development?
Nope: they use C/C++/Java/Python/JavaScript (I'll go find a reference).
Here's a post by Steve Yegge that makes it pretty clear they don't do Ruby.
About job prospects: If you want to work for Google, it doesn't matter which of Python, Perl and Ruby you are fluent at: Python hackers don't have an advantage over Ruby hackers etc. when applying for a job as a Software Engineer. If you want to do Perl or Ruby programming a lot, Google is not the place for you.
To get an approximation about programming language popularity in job openings, try searching for programming languages on job offer sites. For example, http://www.itpinoy.com/search/ says Java is more popular than PHP, which is more popular than Ruby.
I've been programming Perl for several years before I started using Ruby. Again, a few years later, I started using Python, while still doing Perl and Ruby as well. In general, I tend to be more productive in Ruby and Python than in Perl, so I don't do much Perl anymore. I like Python because it feels like mature, well-designed and clean for me (compared to Ruby, which I feel a little bit hackier), and I like Ruby because I can do powerful operations by typing only a little (in contrast, Python doesn't support assignment in the middle of an expression, blocks, regexps as first-class objects, mutable strings; and the standard library of Python is not so versatile, e.g. the list and dict types have less methods than in Ruby).
So for someone new to Perl, Ruby and Python, I'd recommend spending a day with Ruby, one more day with Python, and choose which of these two to concentrate on learning.