LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 03-30-2023, 05:36 PM   #1
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,681
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
writing a few lines of comments that work in most languages


i want to write some reasonably arbitrary text as comments to be prepended and/or appended to source code for most languages or all major languages used in BSD or Linux the code that will write this commented text will not know which language it is, or get to even see the code that the comments will be attached to for to guess the language. the comments will not be inserted in the middle of the code so multi-line code (such as multi line triple quotes in python) will not be affected.

the language i will be coding this in needs to not matter. i will prototype it in one language and finalize it in another. others may translate it to the language they use, maybe FOSS, maybe not.
 
Old 03-30-2023, 06:04 PM   #2
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,263
Blog Entries: 24

Rep: Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194
Quote:
Originally Posted by Skaperen View Post
i want to write some reasonably arbitrary text as comments to be prepended and/or appended to source code for most languages or all major languages used in BSD or Linux the code that will write this commented text will not know which language it is, or get to even see the code that the comments will be attached to for to guess the language. the comments will not be inserted in the middle of the code so multi-line code (such as multi line triple quotes in python) will not be affected.

the language i will be coding this in needs to not matter. i will prototype it in one language and finalize it in another. others may translate it to the language they use, maybe FOSS, maybe not.
[humor-sarcasm]
Could you be a little more vague please?
[/humor-sarcasm]

Asking for a near universal generated markup syntax, originating from an application defined by language independent source is a bit of a stretch for my tired old brain cell.

Even a UML transform direct from model to source will require knowledge of the target language. You seem to be asking for a single comment syntax which will be recognized by any arbitrary language compiler or interpreter... and I cannot easily parse what you mean by a generating application which is itself language independent (i.e. a universal executable model).

A clear description of your ultimate use case would probably help others, certainly myself to understand what you are asking.

Last edited by astrogeek; 03-30-2023 at 08:46 PM.
 
2 members found this post helpful.
Old 03-30-2023, 06:41 PM   #3
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,220

Rep: Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309
As is the case with many of your questions, the answer is that there is no such thing.
 
Old 03-30-2023, 11:39 PM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,811

Rep: Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306
would be nice to show an example, but maybe not
 
Old 03-30-2023, 11:53 PM   #5
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,859
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Maybe you could use emojis, they are language-independent.
 
1 members found this post helpful.
Old 03-31-2023, 07:16 AM   #6
Michael Uplawski
Senior Member
 
Registered: Dec 2015
Posts: 1,620
Blog Entries: 40

Rep: Reputation: Disabled
Quote:
Originally Posted by NevemTeve View Post
Maybe you could use emojis, they are language-independent.
... Darn... ascii art. Wait, I have to check out a few things ...
 
1 members found this post helpful.
Old 03-31-2023, 07:48 PM   #7
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,681

Original Poster
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
Quote:
Originally Posted by dugan View Post
As is the case with many of your questions, the answer is that there is no such thing.
i was afraid of that.

i remember my college days when a friend wrote a mainframe program that took in source code, detected the language, and invoked the compiler for that language feeding it the whole original file. i then created a file that could be fed to either the Fortran compiler or the PL/1 compiler with each producing different binaries that did the same thing (copied input to output). i ran it both ways and showed him the results (printed job output back in those days) and asked him which language his program would choose. he tried his program on my source code. his program hung in a loop.

of course that was a limited scope of just two specific languages. i later tried to do the same thing with COBOL but was unsuccessful.
 
Old 04-01-2023, 02:04 AM   #8
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,811

Rep: Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306
still not understand what are you looking for. Usually we have flowcharts, which means we have some kind of input data and would like to process it and finally produce some kind of output. The flowchart will explain the process itself, step by step, but it is not executable. It should be translated to something which can really do the job. That's why we have programming languages. But you can almost never translate a real source code from one language to another, there is no such tool. And because of the complexity (and incompatibility) of the existing languages it will never exist.
(even moving from python2 to python3 or perl5 to perl6 are not that trivial and works only in one direction)

So what are you really looking for? a general pseudo-language, which can be used to generate real source code on different languages? No, that does not exist and never will.
More than 25 years ago there was a c++ -> c cross compiler (translator?) (because that time we did not have real c++ environment), but the result was terrible.
 
Old 04-01-2023, 05:33 AM   #9
Michael Uplawski
Senior Member
 
Registered: Dec 2015
Posts: 1,620
Blog Entries: 40

Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
More than 25 years ago there was a c++ -> c cross compiler (translator?) (because that time we did not have real c++ environment), but the result was terrible.
Was not the very first C++ environment dependent of a meta-compiler that created C-code from C++ ? I really mean Bjarne-C++.

On-Topic: one of my (2) ingenuous bosses developed a generic code generator, based on XML and some pipeline-architecture, similar to a big XML-munging Java-framework the name of which I cannot remember right now (began with a 'C' *) ). The first version and the only one I was involved with, spit out C++ code for GUI-elements that were drawn in a vector-graphics editor with the capacity to parameterize “actions”. You draw, you push button, you include, compile and link => Your military submarine-simulator. Enjoy.

When the customers had become too fearsome, it all came to a halt, but in the meantime, the thing has evolved into a payed online-application. In a version I saw, it could produce Java as well.

This is not something very revolutionary, the guy had simply been too early with the idea (to “never having to program anything at all”).

Code-comments were – of course – coming with the XML-code, as well.

Edit: *) Cocoon !
The similarities were though accidental.

Last edited by Michael Uplawski; 04-01-2023 at 08:09 AM. Reason: Cocoon
 
Old 04-01-2023, 11:25 AM   #10
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,220

Rep: Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309
So your boss built an in-house CASE application? Impressive.
 
Old 04-01-2023, 11:31 AM   #11
Michael Uplawski
Senior Member
 
Registered: Dec 2015
Posts: 1,620
Blog Entries: 40

Rep: Reputation: Disabled
Quote:
Originally Posted by dugan View Post
So your boss built an in-house CASE application? Impressive.
Maybe, but the demands were fewer: make projects quickly and let customers do their adaptations and fixes themselves, while we advance towards other things, as coding takes too long.
 
Old 04-03-2023, 01:48 PM   #12
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,681

Original Poster
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
Quote:
Originally Posted by astrogeek View Post
[humor-sarcasm]
Could you be a little more vague please?
[/humor-sarcasm]
if you have something with only one language class, then maybe you can list some of the languages it can handle and some that it cannot. you seem to expect only things that are limited, such as supporting only one language. i've see things that can go beyond that. may you see as being vague things that can deal with a great many situations. would a development requirement that let the developer choose certain things to be supported be vague enough?
 
Old 04-03-2023, 01:50 PM   #13
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,681

Original Poster
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
Quote:
Originally Posted by dugan View Post
As is the case with many of your questions, the answer is that there is no such thing.
ah! you have figured out why i ask them.
 
Old 04-03-2023, 01:53 PM   #14
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,681

Original Poster
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
Quote:
Originally Posted by NevemTeve View Post
Maybe you could use emojis, they are language-independent.
good idea! i'll look for that feature if any exist.
 
Old 04-03-2023, 06:13 PM   #15
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,649
Blog Entries: 4

Rep: Reputation: 3935Reputation: 3935Reputation: 3935Reputation: 3935Reputation: 3935Reputation: 3935Reputation: 3935Reputation: 3935Reputation: 3935Reputation: 3935Reputation: 3935
I recommend that you implement some kind of template-driven system. First detect the language, then invoke the appropriate template for that language.
 
  


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
What are the top few most human-readable programming languages? punchy71 Programming 46 01-11-2023 02:17 PM
LXer: How To Print Files Without Comments And Empty Lines In Linux LXer Syndicated Linux News 0 07-01-2020 02:57 AM
Request: Slackware Info-Zip ZipNote be patched to support writing back comments ruario Slackware 0 04-24-2014 12:44 PM
[SOLVED] Add lines end of file above the end comments bkone Programming 2 02-27-2012 09:58 AM
languages of linux: which languages can be choosen in suse and red-hat distributions? Klaus Schnorr Linux - Software 3 09-10-2005 02:19 AM

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

All times are GMT -5. The time now is 07:19 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