-1

I'm trying to create a kind of "shorthand" syntax for Java that replaces verbose keywords with less verbose ones, so that I can write Java code with fewer keystrokes. Is there any way to replace keywords such as "public" and "static" with abbreviations of those keywords, and then translate that to "normal" Java code?

//would it be possible to convert this to "normal" Java code?
pu cl ModifiedSyntaxExample{
    pu st void main(){
        System.out.println("Hello World!")
    }
}

This would be equivalent to:

//would it be possible to convert this to "normal" Java code?
public class ModifiedSyntaxExample{
    public static void main(){
        System.out.println("Hello World!")
    }
}

The first version is less verbose (and therefore easier to type), because "public" and "class" are replaced with the abbreviations "pu" and "st".

Anderson Green
  • 30,230
  • 67
  • 195
  • 328
  • Is typing really that hard for you? – jahroy Dec 18 '12 at 05:56
  • @jahroy No, but function definitions in Java are more verbose than in some other languages (such as Javascript). I want to make them slightly less verbose, if possible. – Anderson Green Dec 18 '12 at 06:02
  • @jahroy Typing isn't difficult at all, but I don't like writing "public static void" (or some variation of this) next to every single function definition. I'd prefer to use some kind of shorthand notation. – Anderson Green Dec 18 '12 at 06:06
  • @jahroy I now realize that it would probably be better to use an auto-complete feature of some IDE instead of creating a new dialect of a programming language (which seems like overkill). – Anderson Green Dec 20 '12 at 02:49
  • I agree. I don't think you should try to change the syntax of a language to fit your personal preferences. It's important to appreciate the differences between various programming languages. Each one is suited to solve different problems and is designed with this in mind. You also should consider that someday you're likely to work on a team, in which case a "_custom dialect_" will not work at all. I would also argue that _public static void_ all have specific, valuable meaning that is **not** verbose. – jahroy Dec 20 '12 at 03:06
  • Fortunately for you, all IDEs probably have some notion of _auto-complete shortcuts_ that will hopefully suit your needs. Best of luck! – jahroy Dec 20 '12 at 03:07

1 Answers1

3

If you are using any IDE than yes, its possible. For example in eclipse you have one code snippets which you can configure in such a way that, you will make your code less verbose. I hope I have understood your question correctly. for ex - sysout will print System.out.println(); for you.

Ved
  • 8,577
  • 7
  • 36
  • 69
  • http://viralpatel.net/blogs/20-useful-java-code-snippets-for-java-developers/ its a bunch of sample snippets. – Ved Dec 18 '12 at 06:05
  • Specifically, how can I use "code snippets" to automatically replace one keyword with another keyword? – Anderson Green Dec 18 '12 at 06:08
  • Which of these snippets would be the most relevant? I haven't yet found any that can automatically replace one keyword (such as "st") with another keyword (such as "static"). – Anderson Green Dec 18 '12 at 06:23
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/21302/discussion-between-blue-and-anderson-green) – Ved Dec 18 '12 at 06:41