LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-13-2011, 08:58 AM   #1
punchy71
Member
 
Registered: Dec 2011
Posts: 172

Rep: Reputation: Disabled
Comparing lines of code side by side


Hi all,
Anyone know of a website or something that allows you to compare a brief paragraph of code with different programming languages side by side so you can compare them to see what they look like?
The exact same program in language "a" looks like this in language "b". The exact same program in language "b" looks like this in language "c" and so on...
If there isn't something like that, there ought to be. =)

Thank you
 
Old 12-13-2011, 09:05 AM   #2
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 244Reputation: 244Reputation: 244
A quick google search lead me in:
http://www.ntecs.de/old-hp/uu9r/lang/html/lang.en.html
 
Old 12-13-2011, 09:24 AM   #3
punchy71
Member
 
Registered: Dec 2011
Posts: 172

Original Poster
Rep: Reputation: Disabled
Uh, sort of, but not quite. I had in mind more of a side-by-side thing.
 
Old 12-13-2011, 09:41 AM   #4
Proud
Senior Member
 
Registered: Dec 2002
Location: England
Distribution: Used to use Mandrake/Mandriva
Posts: 2,794

Rep: Reputation: 116Reputation: 116
You're assuming the same program/function/class would be implemented in same way across different languages, or at least in a way that would be easily comparable. And that there's one 'correct' way to implement something per language. Using that site as an example, what's the benefit of comparing the following?
Code:
quicksort [] = []
quicksort (s:xs) = quicksort [x|x <- xs,x < s] ++ [s] ++ quicksort [x|x <- xs,x >= s]
Code:
def quicksort(arr):
   if len(arr) <= 1: return arr
   m = arr[0]
   return quicksort(filter(lambda i,j=m: i<j, arr)) + \
          filter(lambda i,j=m: i==j, arr) + \
          quicksort(filter(lambda i,j=m: i>j, arr))
Code:
template <class itemType, class indexType=int>
void QuickSort(itemType a[], indexType l, indexType r)
{
  static itemType m;
  static indexType j;
  indexType i;

  if(r > l) {
    m = a[r]; i = l-1; j = r;
    for(;;) {
      while(a[++i] < m);
      while(a[--j] > m);
      if(i >= j) break;
      std::swap(a[i], a[j]);
    }
    std::swap(a[i],a[r]);
    QuickSort(a,l,i-1);
    QuickSort(a,i+1,r);
  }
}
The second (Python) example could equally have been written procedurally/iteratively/imperatively like the third (C++) example, as well as the current recursive functional-like version which is more similar to the first (Haskell) example.

Last edited by Proud; 12-13-2011 at 09:46 AM.
 
Old 12-13-2011, 09:42 AM   #5
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 244Reputation: 244Reputation: 244
Quote:
Originally Posted by punchy71 View Post
Uh, sort of, but not quite. I had in mind more of a side-by-side thing.
Have firefox ? Try using tabs feature

Last edited by Cedrik; 12-13-2011 at 09:43 AM.
 
Old 12-13-2011, 01:29 PM   #6
punchy71
Member
 
Registered: Dec 2011
Posts: 172

Original Poster
Rep: Reputation: Disabled
Okay that works little better, thank you.
 
Old 12-13-2011, 04:03 PM   #7
Laythe
LQ Newbie
 
Registered: Nov 2010
Posts: 18
Blog Entries: 1

Rep: Reputation: 0
For Windows you can try:

Code Compare Website
Cnet Code Compare Download

For Linux you can try:

Meld

Good Luck.
 
Old 12-13-2011, 04:10 PM   #8
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Have you ever heard about Rosetta Code? Take a look at http://rosettacode.org/wiki/Main_Page.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Generate SPECIAL alphanumeric WORDLIST - no repeating characters side-by-side Stanley_212 Programming 33 10-13-2022 06:06 PM
LXer: Create Side by Side or Top-Bottom 3D Video With ffmpeg and Imagemagick or Mencoder by Converti LXer Syndicated Linux News 0 06-14-2011 04:50 PM
LXer: Comparing Kernel Dmesgs: Remove Timing Info and Diff Side by Side LXer Syndicated Linux News 0 08-04-2010 07:31 PM
Installing SUSE 11.1 side by side with Ubuntu already installed on a USB drive jjchavez Linux - Laptop and Netbook 2 09-12-2009 01:39 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:48 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration