I am a beginner reading the recently posted "How to be a Programmer" article and there is a section on choosing languages. The author discusses choosing the "best language for the task." That is something I see discussed quite frequently. I know there are languages that are most commonly used for certain tasks, but how do you decide between two similar languages? Like building a web app in Ruby vs. Python? Can anyone give an example like this?
[+] [-] silentbicycle|16 years ago|reply
While people can argue about the relative merits of Ruby and Python for days, the direct impact of language characteristics on a beginner are likely to be overwhelmed by other issues. For example, if a friend knows one of them quite well, go with that one - he/she can probably answer some questions, and in the short term that's far more important.
The same principle holds for Linux/BSD distributions, version control systems, and so on: If there's not a huge consensus and the differences don't mean much to you, just pick one. You'll be in a better position to make an informed decision later, and you're not stuck with it forever. Time spent trying to decide could instead be put toward learning the basics.
Another example that comes to mind is systems for parsing. There's ANTLR, lex + yacc, packrat parsers/PEGs, Prolog's DCGs, etc. While they have different strengths, any deep comparison will also nonchalantly throw around terms like LALR(1).
[+] [-] colbyolson|16 years ago|reply
Had I just picked a language and just ran with it, I would be farther down the road than where I am now. So just grab something, sit down, and play with it.
[+] [-] stefano|16 years ago|reply
One factor that can make the language choice important is the speed of the program: if you need to make a computationally heavy application, you'd better choose a fast language. This would rule out interpreted languages. In such a case, you should choose Common Lisp/C/C++/Java/C# rather than Perl/Python/Ruby.
Another important factor is the platform where your app will be running. If it's on your own server, you can use whatever you prefer. If it's on the iphone, the most abvious choice is Objective-C. If it's a small device with little memory and low computing power, languages with a low memory footprint and manual memory allocation like C and Forth would make a better choice than Python or Ruby.
[+] [-] JDigital|16 years ago|reply
If Python is too slow, use C.
If you don't know C, use Java.
If you don't know any of these, you ought to learn at least one. Use Python.
[+] [-] unknown|16 years ago|reply
[deleted]
[+] [-] silentbicycle|16 years ago|reply
[+] [-] ams6110|16 years ago|reply
Here's what I'd recommend: start off with an interpreted language, maybe Python, and work through a couple of tutorials. If you want to be a little different maybe look at Lua. Then try to build something. Tutorials are good but not as motivating as your own project. I would avoid IDEs like Visual Studio at first, they have a lot of power but for a beginner they might be distracting and keep too much under the covers that you really need to understand.
Then start exploring other stuff. At some point you should try a functional language. Work through a book like the Little LISPer until you "get" recursion, currying, how the Y-combinator works (no not this site). Definitely take the time to learn C and pointers. Even assembly. Learn about object-oriented programming. Exposure to all these perspectives will make you a better programmer, no matter which language ultimately becomes your favorite.
[+] [-] intellectronica|16 years ago|reply
I like Python very much and think that it's a fantastic language for building things and probably the best language for learning programming. But if, say, all your friends use Ruby, or you find that Ruby has better libraries for whatever it is you hope to be doing then I'd recommend you choose Ruby. In fact, I think PHP is an awful language and that learning is is a complete waste of time, but if you're in an environment where using PHP is the best way to get up and running, you should choose that.
All other things being equal, I think Python would be the best choice for you. It's a great, very versatile language, designed from the ground to be easy to learn and understand. It comes with libraries for doing pretty much anything you might want to do with a computer. It has a wonderful community - very mature and very helpful. You'll find it easy to get very high quality help learning Python.
[+] [-] Hexstream|16 years ago|reply
While designing or implementing a worthwhile Turing-complete, general-purpose programming language with a correct and efficient implementation is a huge undertaking and requires vast amounts of knowledge, doing the same for a domain-specific language is much easier because the scope is much more focused and the efficiency requirements are often not as strict.
As long as you focus on semantics, limit the scope of your language, use declarative techniques like pattern-matching that will let you avoid the Turing-completeness trap (Turing-completeness makes your code hard to analyse and process, unlike declarative data) and use a proper general-purpose language for the implementation, designing and implementing a domain-specific language is really not that hard, though proper IDE integration and a debugger are still not so easy to do.
I like to make the right tool for the job, so I use Common Lisp, which makes it almost ridiculously easy to invent new s-expression-based syntaxes via macros and compile through production of trees of closures, among other things.
[+] [-] sid|16 years ago|reply
I know alot of poeple who picked up perl as their first language during uni and wont pickup anything else cause they are so deeply into it and say its the best language. It might be from their point of view which is fine but dont let the first language you learn be the only one you ever use also.
Like the other guys said, if your a beginner pick one, hell pick python for the simple reason that google use it (so it must be good) get used to it and then try to compare with others once you get the swing of things.
Like buying a guitar for the first time, you dont know which one is good cause you dont know what a good guitar is supposed to sounds like so you buy a fender or a les paul cause one of your idols use it !
[+] [-] gruseom|16 years ago|reply
If two languages are truly similar, like Ruby/Python or Java/C#, it doesn't matter much which you start with. If I were you I'd pick one based on gut feeling or a coin flip and get at it.
[+] [-] tommia|16 years ago|reply
There are many things to consider. And most of the issues ar non-technical
- will there be support for the frameworks, language etc long enough?
- are the coders competent with the language / framework
- what limitations exists on deployment
- what limitations the customer imposes
Of course if there's are no non-technical issues to consider, go for the technically "best" solution.
[+] [-] gdp|16 years ago|reply
1) Whether the features and capabilities of the language match the task
2) Your familiarity with using a given language for a type of task.
There might be a third, somewhat less tangible concept of "elegance" mixed in there too, insofar as that some languages might lend themselves to very direct, elegant solutions to a particular problem, while others might require more round-about ways of doing things.
If you wanted to become good at comparing programming languages, the best way would probably be to read up on various classes of programming features. For example, type systems, object systems and other factors that generally influence programming language design. The other way would be to actually use some of the languages in question to get a sense of whether they agree with your preferred manner of problem solving. This might also give you a chance to explore library support and documentation and other related factors are that might influence your decision.
After you've programmed in a bunch of different languages, using a whole lot of different paradigms, you generally start to be able to pick the similarities and differences between languages pretty quickly, hopefully with reference to your past experience about what you do and don't like in a programming language.
[+] [-] jhancock|16 years ago|reply
One of the reasons you see so much disappointment with ruby is people start with rails and that doesn't really help you become a good ruby programmer. It may actually teach you bad habits and keep you from knowing how the language and http requests, and db requests really work (none of which is that complicated).
I use ruby over python. Mainly because I picked it up first and don't have a good reason to switch. I use merb as my framework, which is a fine choice, but if I had to start again, I might go with Sinatra.
If you do go with Ruby, buy this book: The Ruby Programming Language http://www.amazon.com/Ruby-Programming-Language-David-Flanag...
I have seen no text that comes close to this new book in teaching Ruby.
[+] [-] makecheck|16 years ago|reply
The standard library can be a big factor. Not having to download a dependency is a big win, which is why large standard libraries such as Python can often be better than something like a CPAN dependency in Perl. It can be the difference between using C++ or Objective-C, versus C. But more generally, if you need to do X, and you already know how to do it with language Y, you'll need a really good reason to try a different language.
[+] [-] russell|16 years ago|reply
Take a look at the standard libraries and third party packages. If someone else has written it, you dont have to, unless you want the experience. Python, Java, and Perl have lots. Ruby and IO less so.
Look at job listings. If you are starting out, you might as well pick on that you can get money for.
Look at the communities. Are the people ones that you would like to hang around with. If they dont like newbies, look elsewhere. Python seems to be pretty good in that respect.
As for web development, Python has Django (I recommend) and Pylons. Ruby has Rails. Stay away from Java; everything is too damned complicated, but there are a lot of jobs.
[+] [-] megaduck|16 years ago|reply
Java is a wonderful tool for a LOT of systems programming. It's got a nice object model, automatic memory management, and pretty good execution speed. Given the choice between C++ and Java, I'll take Java every time. Remember, Java was originally designed for embedded systems like set-top boxes. It's still one of the best languages out there for those kinds of applications.
It's not a good fit for UI or web work, but neither is C/C++. As always, consider the type of job before selecting a tool.
[+] [-] gdp|16 years ago|reply
Says who? Ignoring the fact that LoC is a terrible metric for measuring anything except the amount of paper it would require to print the program, I think it would be very hard to use it to quantify how much you will accomplish. Your (implied) assertion that you will not just accomplish less, but accomplish between a half and a fifth as much in Java as in Python is even more outlandish. I can't imagine you have any evidence to support this?
> Stay away from Java; everything is too damned complicated
What is this supposed to mean? That the hundreds of thousands of people who make their livings from doing web development with Java and being competent Java programmers are either stupid (for not programming in Python), or super-smart (because they can grok Java)? This is pretty absurd. Java is no better and no worse than pretty much any other language in wide-spread use. To its benefit, it has extensive library support for pretty much everything under the sun, and all the enterprise features which would make it relatively painless to do a whole heap of things that would become very difficult in almost any other language.
Really, I think you should refrain from giving advice on specific programming languages if you are just going to resort to complete and utter nonsense to provide comparisons.
[+] [-] jwecker|16 years ago|reply
So don't spend too much more time thinking about it. If you just need someone to just tell you where to dive in so you can really get going here you go: If you have or plan on growing a beard- Python/Django. If you plan on staying clean shaven and dressing smartly- Ruby/Rails. When you've mastered the current choice and have a nice career going, go ahead and master the other(s).
[+] [-] colbyolson|16 years ago|reply
[+] [-] jacquesm|16 years ago|reply
That way you can sort of ease in to the concepts of syntax (and debugging) in a familiar environment.
Adding some js will give you some client side functionality, from there it is a (relatively) small step to running some code on the server.
Then you can add things like databases and so on.
The language itself is not the most important factor, the method (edit - (compile) - test - evaluate and iterate) is.
You'll learn how to set yourself a goal (say building a website), sketching it out (paper is good), then make a static html mock-up, then expand on that.
This will take you some time!
[+] [-] edw519|16 years ago|reply
1. Unless you use Flash, you'll probably have to use some javascript anyway if you want any logic on your client.
2. You can click View:Source on any web page to see the javascript running that page. You'll have millions of examples of source code along with that code in action right now on your machine. A live example is an excellent learning tool.
You can also use javascript for your server side logic, but that's another debate altogether. If you build some pages that do something first, you can worry about the back end later.
[+] [-] gdp|16 years ago|reply
[+] [-] jhancock|16 years ago|reply
I want this to be the answer, but for right now, I can't afford to cut my teeth on it.