Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to run? #5

Open
pflagerd opened this issue Dec 4, 2022 · 7 comments
Open

How to run? #5

pflagerd opened this issue Dec 4, 2022 · 7 comments

Comments

@pflagerd
Copy link

pflagerd commented Dec 4, 2022

Would love an example or two to explain how you run your tool on java code to produce d. I gather you're not sure this is ready for a standalone tool on its own?

I have several java projects that I'd like to port to d.

@jacob-carlborg
Copy link
Member

Would love an example or two to explain how you run your tool on java code to produce d

Wow, it was almost seven years since lasts time I worked on this project. Not sure if I remember how. Most of the time I was running the tests. But I found this file which looks like an entry point [1]. As you can see, it has some hardcoded values. portFromFile is implemented here [2], which also contains some hardcoded paths, but you can override those in the call to portFromFile.

I gather you're not sure this is ready for a standalone tool on its own?

It's intended to be a standalone tool, but it's far from ready. IIRC translation of the syntax is complete, for the target seven years ago, which was Java 7. What's remaining is most of the work: translating the semantics. Which you can see I've just started with [3].

[1] https://github.com/d-widget-toolkit/jport/blob/d03b1f247fad7ddb54bfec8eb6d7c599a47bf92b/src/main/scala/dwt/jport/driver/Application.scala

[2] https://github.com/d-widget-toolkit/jport/blob/d03b1f247fad7ddb54bfec8eb6d7c599a47bf92b/src/main/scala/dwt/jport/JPorter.scala

[3] https://github.com/d-widget-toolkit/jport/commits/master

@pflagerd
Copy link
Author

pflagerd commented Dec 5, 2022

Excellent. May I ask how you chose Scala? (I don't know it, but am interested in learning).

@jacob-carlborg
Copy link
Member

Excellent. May I ask how you chose Scala? (I don't know it, but am interested in learning).

Well, ideally a tool for D should be written in D. But I needed a Java compiler that was usable as a library. If you look at all the big Java IDEs that have great language support (Eclipse, Netbeans, IntelliJ) they are all implemented in Java. They also have Java compilers implemented in Java. I didn't want to use JNI to access a compiler from D, seems too complicated. Using Java after using D for almost 10 years feel a bit limiting. Therefore I chose Scala, because it works on the JVM and can easily integrate with existing Java code.

In hindsight it might have been better to use Java anyway. If JPort is ever finished then I could have used JPort to port the Java compiler and then JPort itself to D. Then we would both have a Java compiler and a tool that can convert Java code to D code implemented in D 😃.

@pflagerd
Copy link
Author

pflagerd commented Dec 8, 2022

Awesome. I agree. I have worked with JNI and SWIG and they're not much fun. It seems you based JPort on Eclipse's compiler. That's clever. I never thought to look at the Java code for that.

Do you have an opinion on Scala vs Groovy?

@jacob-carlborg
Copy link
Member

jacob-carlborg commented Dec 8, 2022

Do you have an opinion on Scala vs Groovy?

I don't know much about Groovy. IIRC it's more of a scripting language than Java or Scala. But if I would translate JPort to another language it would probably be Java. Because that would allow to run JPort on itself. Another alternative would be Kotlin. Seems to be more popular than Scala these days.

@pflagerd
Copy link
Author

pflagerd commented Dec 9, 2022

There's still some life in Java I would say. Have you been able to use Scala for anything else?

@jacob-carlborg
Copy link
Member

There's still some life in Java I would say.

Yes, definitely. It's Scala that I think is less popular.

Have you been able to use Scala for anything else?

No, this is my first any only project in Scala.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants