views:

205

answers:

9

Hi

This is a problem I constantly face. I know how to execute a certain task in one enviroment / framework / language but I am a complete stranger in another.

What's more, sometimes the gap between languages / enviroments is really too big to be simply adapted (like porting a prolog application to C#)

So, I guess the question is: how to cope with solving a problem you know is easy to solve in one language but, due to an "environment" restriction you have to program in another?

+1  A: 

In my experience, an 'environment restriction' is really just another term for "I haven't figured it out yet". Thus, I figure out how to do it in that particular language, and I'm that much smarter.

Rarely will you find a problem that absolutely cannot be solved in a different language (so long as the language switch was lateral (ie, not Python -> JavaScript))

Nick Sergeant
Python to JavaScript is a lot less of a change than Prolog to C#. :)
Jason Baker
+3  A: 

I find the system() call useful in these cases. I'm only half-kidding here - if there's a simple solution that requires the use of another tool, just use that other tool.

Mark Bessey
+1  A: 

Other than a few instances where it was mandated by contract that I write it in X language on Y platform, I've found that I've had significant latitude to use whatever language was the best fit for the job.

Where there have been instances ("must use Ada" comes to mind) that I had to write code in a particular language or on some platform that brought with it particular challenges, I just had to figure it out. I'm generally of the opinion that anything is solvable in any language once you've had enough exposure to that language.

itsmatt
+1  A: 

I don't think there is a quick way out of this one. I usually pick up the most well-known book on that language and spend a few days reading the chapters and trying to pick up on the "philosophy" of that language. Then look at how some well-known problems are solved in that language - which gives you a good hang of how things are done in it. As time goes by, you naturally become stronger in the language as well.

If a problem that is easy to solve in one language becomes difficult to solve in another, usually the problems needs to be rephrased for the new language i.e. the question needs to be either asked or answered in a different way.

alps123
+1  A: 

There is no easy button. Pseudocode the solution. Do a little, and I do mean little, research then put some music on and just start coding.

Coding is coding regardless of the language that it's done it. You simply need to learn, or understand, the way the language is intended to be used, i.e. procedural or object oriented and you need to find a good resource for assisting you with syntax and functional issues that you'll encounter. The best way to learn all of that is to just do it.

DL Redden
My bad, I was pretending to be on a Linux box at the time.
DL Redden
+3  A: 

First, I find some "good" reference for the language and its basic library and skim through it. No need to learn everything at once, I just need to have a notion of what tools are available, so that I know what to search for and what to write on my own.

Then, I dig in. There are various mini-projects that I have worked on over the years (puzzle solving mostly, and a couple of mini-games, like hangman (both playing against a computer chosen word and the computer playing against a possibly unknown to it word) ) that I am very familiar with their logic, so that I only need to adjust (perhaps) the algorithm and start coding.

That's it. A general idea of the language first, then start coding, preferably familiar miniprojects.

ΤΖΩΤΖΙΟΥ
+1  A: 

I google it, read books, wikipedia etc... just get cracking!

Jacob T. Nielsen
+1  A: 

When I was younger I'd just grab some source code, strap on my helmet and dive in (and by this I mean start working on bugs in existing code)--Except for basic and assembly I've learned every language on the job.

I tried this recently with Ruby and found my brain less flexible than it used to be, the language scared the living crap out of me, and I just couldn't enjoy all the neat tricks the way I should. Guess I'm not extreme enough any more.

These days I've decided to settle down and pick a language I like enough, with the speed and versatility to do what I want and wide-enough usage that I can always get a job in it. For me it's Java, but your mileage may vary.

Bill K
+2  A: 

Solve some questions at Project Euler. It is the only site I know of that lets you jump right into the language syntax & constructs while sharpening your computer-science/math/algorithm skills.

The problems focus on traditional computer-science concepts that most languages support, like recursion/iteration, string manipulation, working with date/time, and standard constructs from arrays to trees.

Also, they have a very active forum with answers (spoilers) already posted for many languages.

gHeidenreich