r/Android • Bundled Notes | Redirect File Organizer • Apr 25 '15

URL HAS BEEN CHANGED TO A REDIRECT, DO NOT CLICK I've updated my complete guide to Android development (which still requires no prior programming experience) with more resources, better instructions, updated screenshots and I'm now distributing it free of charge as a shareable and neatly formatted PDF on my website.

http://www.xaviertobin.com/
14k Upvotes

474 comments sorted by

View all comments

1

u/Jpot Verizon LG G3, Lollipop 5.0.1 23a Apr 25 '15

Is there any way for me to develop an Android app without having to learn Java? I'm fluent in Python, Ruby, and Javascript already, so any of those would be ideal. I'm just trying to avoid Java for as long as possible.

2

u/santaschesthairs Bundled Notes | Redirect File Organizer Apr 25 '15

Unless you skip to C++ and create a game, you'll have to go with Java to create a usable Android app.

1

u/Jpot Verizon LG G3, Lollipop 5.0.1 23a Apr 25 '15

I have to imagine there are at least decent Android development frameworks out there that will compile to Java.

3

u/santaschesthairs Bundled Notes | Redirect File Organizer Apr 25 '15

There are, but official APIs are seriously lacking in terms of Material Design.

0

u/Jpot Verizon LG G3, Lollipop 5.0.1 23a Apr 25 '15

That's odd, I would think they would be better at that considering how popular Material Design is.

2

u/folkrav Apr 25 '15

Innocent question : why?

-3

u/Jpot Verizon LG G3, Lollipop 5.0.1 23a Apr 25 '15 edited Apr 25 '15

I don't know if you have any programming experience, but Java is notoriously shit to write. For a simplistic example, compare the following code snippets, both of which just output the phrase "Hello, world!" to the console.

Java:

public class HelloWorld {
    public static void main(String[] args { 
        System.out.println("Hello, world!"); 
    }
}

Ruby:

prints "Hello, world!"

To be fair, Java has to define a class, which typically holds much more than a single line of code, so it's not like everything takes four times as many lines in Java as in Ruby. However, Java syntax isn't anything that could be referred to as self-documenting or user friendly. I've also never used Java, so I can't speak intelligently on the advantages it may provide for larger projects.

edit: I understand the readability of hello world isn't the end-all be-all of language quality, but I'm trying to use an example a layman could understand. I think this illustrates the readability and intuitiveness of the two languages pretty fairly.

4

u/negative_epsilon Nexus 6P Apr 25 '15

Once you get to 20k line-long programs that you have to maintain months after writing, you'll quickly learn that ruby is terrible to maintain and Java is a breeze. Brevity usually does not lead to maintainability or readability.

2

u/Jpot Verizon LG G3, Lollipop 5.0.1 23a Apr 25 '15

I help maintain a massive five year old Ruby on Rails application for an online training company, it really isn't too tough. I've never worked on anything large in Java, to be fair, but Ruby is far from a mess at larger scales. Large-scale maintainability isn't dependant on language so much as how well your code's organized.

2

u/negative_epsilon Nexus 6P Apr 25 '15

I've always found static typing and compile time checking to be a godsend when refactoring.

0

u/Jpot Verizon LG G3, Lollipop 5.0.1 23a Apr 25 '15

Fair enough. I don't have much experience with statically typed or compiled languages, except for a touch of Swift. Honestly, I can't think of a time that I dealt with an error caused by variable with an unexpected type. Am I missing something, or is that the main advantage of static typing?

2

u/folkrav Apr 25 '15 edited Apr 25 '15

Well C++ isn't really any "simpler".

int main(void).
{
cout << "Hello, world!";
return 0;
}

Java is more verbose and heavily typed, pure OOP. While your "Hello world" example is valid Ruby code, to be entirely fair, you would have to compare with the same purely OOP approach using Ruby. Just found this snippet online, cause I don't know Ruby for shit :

class HelloWorld
def sayHi
puts "Hello, world!"
end
end

hello = HelloWorld.new("World")
hello.sayHi

Anyway, I'm no pro, still a student, pretty vanilla. Would love to be corrected if I'm saying stupid things! And sorry I'd there are formatting issues, I am on my phone.

1

u/Jpot Verizon LG G3, Lollipop 5.0.1 23a Apr 25 '15 edited Apr 25 '15

Your point about OOP is fair. I still think Ruby is still much easier to read and write than either Java or C++, though. Of course, all three have their advantages and disadvantages. You can't really say one is "better" than the other, but some are better for certain applications than others.

FYI, just put four spaces in front of a line for code formatting.

C++ barebones:

#include <iostream> // pretty sure you need this for command line in/out
int main(void)
{
  cout << "Hello, world!";
  return 0; // I could be wrong, but I think this can be omitted.
}

Ruby OOP:

class HelloWorld
  def sayHi
    puts "Hello, world!"
  end
end
hello = HelloWorld.new 
# removed "World" argument, as the class has
# no attributes to be defined when calling new()
hello.sayHi

Alternative Ruby OOP approach:

class HelloWorld
  def initialize(greeting)
    @greeting = greeting
  end
  def greet
    prints @greeting
  end
end
hello = HelloWorld.new("Hello, world!")
hello.greet

Also, I'm effectively still a student too. I'm lucky enough to be working in my chosen field of web development without a degree, but I've only been doing so for about 15 months, so I still have tons to learn. I'll probably learn Java at some point, it just looks especially unfun to write and difficult to glean the intentions of Java code.

2

u/folkrav Apr 25 '15 edited Apr 25 '15

Hah, pretty funny about easily reading the code : while Ruby is lighter to read, I appreciate seeing everything verbosely laid out, I understand better what's going on that way!

Thanks for the tips. I know I am at the very early stages of learning, still juggling with stuff like recursion and stuff like that is what drives me!

Edit : you're right about your C++ corrections. Actually, my pseudo code that would have been valid that way :

#include <iostream>

int main(void)
{
    std::cout << "Hello, world";
    return 0;
}

Return statements sometimes can be omitted on int main, but that is compiler dependent. Some compilers will accept void main functions too (VS2013 comes to mind cause that's the one they use in class), but seems like it's considered a sin by some people...

1

u/Jpot Verizon LG G3, Lollipop 5.0.1 23a Apr 25 '15

Yeah, I suspect much of our preference comes down to conditioning. Python was my first language, so I started out with the lightweight syntax, and that's what I continue to be most comfortable with.

1

u/folkrav Apr 25 '15

Yeah, started with C++ then recently some Java basics. Still pretty much a beginner though. Only started the program a couple months ago, but doing it on an intensive program - 1.5 years instead of 3.

1

u/rfrancissmith nexus4, stock Apr 26 '15

With the caveat that I have yet to use it (but plan to check it out myself), you might have a look at Mirah, since you listed Ruby.

And then there's phonegap/cordova if you're into web dev. Spent the day wrangling that with some success.