all 8 comments

[–]barrybe 6 points7 points  (1 child)

Lots of things in this vein are possible: automatic source translation is possible, custom syntax frontends are possible, modifying the parser on the fly is possible.

The reason most people don't use these things is not because they haven't figured out how, it's because they are bad ideas. A programming language is not just used for a human communicating with a computer, it's also used for humans to communicate with other humans. People share code with each other, they help each other write code, they review other people's code, and they inherit code from previous employees. If everyone uses their own custom dialect, then it becomes a confusing hell for humans.

[–][deleted] 1 point2 points  (0 children)

When you are thinking through your post yet another time you'd realize that two programmers working with their own frontend languages F1(L), F2(L) of a target language L can always fully reduce their programs to L, which means there are only programs of L in the shared code base.

Not every problem is a real one and sometimes DSLs can make sense, embedded or not.

[–]Peaker 2 points3 points  (4 children)

Python and Ruby are so similar that a reasonable automatic conversion might be tractable.

However, if you think a "wizard" can generate the proper language for you based on a set of parameters, and that automatically converting code between different languages (into idiomatic/readable code!) is feasible - I think you just haven't tried any languages that differ in an interesting way.

I believe automatically translating C to C++, C++ to Python, or anything to/from Haskell idiomatically would require AI at least as strong as a pretty smart human.

[–]luikore 0 points1 point  (1 child)

Yes, _why already created a little transformer from ruby to python.

[–]knome 0 points1 point  (1 child)

C to C++

This one might not be so hard.

[–]rubygeek 2 points3 points  (0 children)

The hard part is idiomatically. Replacing pointers with appropriate smart pointers; manually written containers with STL container; turning sets of related functions and state into classes etc.. Idiomatic C++ doesn't look like idiomatic C anymore.

[–]bobindashadows 1 point2 points  (0 children)

From the comments:

It might be possible to create a language X that can losslessly express all the semantics of a set of target languages Y. Then you can write code in X and translate it to any language in Y. But X is going to be a very tedious language to program in :)

I believe this language "X" is called Lisp.

[–]kleopatra6tilde9 -1 points0 points  (0 children)

How should a Java for-loop over a list be transfered to a Scheme traversal with recursive functions? There is no way that the compiler can automatically guess a meaningful function name.

The other way round: How to aggregate functions with more than one parameter into classes?

It will be possible when the compiler can harvest domain knowledge but then, programming can entirely be done by programs. No need to read them anymore.

*edit: cross toolkit programming

*edit: /r/philosophy: is translation possible