Learnt C++, need assistance with Java

comp@ddict

Well-Known Member
Adept
Apr 25, 2009
6,384
128
127
25
Manipal
about.me
Learnt C++ till OOPS.

Havn't done any real world applications yet. But wanna move on to Java and android app development. Best resource/book? Paid/Free both
 

Gryph0n

Active Member
Adept
Dec 7, 2007
348
14
33
Bangalore
You didn't have a look at Sun's Java Tutorial ?

Trail: Learning the Java Language (The Javaâ„¢ Tutorials)

BTW, it looks to me like you're language hopping. I'd suggest that you really understand the basic concepts of programming first and then you can easily pick up any language. Ensure that you understand things like debugging, looping, arrays, linked lists etc.

IMO, C++ & Java are not oriented towards learning programming. May I suggest learning programming using Python, as it should be easier for newbie programmers ? Mind you, Python is also used professionally, but being a scripting languague, it should be easier than C++ or Java.

Here's a open source book that teaches programming, using Python.
How to Think Like a Computer Scientist — How to Think Like a Computer Scientist: Learning with Python 3

Download Python for Windows from the site below. Pick 3.2.2.3 as the book uses Python3.
http://www.activestate.com/activepython/downloads
 
  • Like
Reactions: 2 people

Rogues

Active Member
Disciple
Jul 26, 2010
190
1
28
28
Hyderabad, Andhra Pradesh
I second what #Gryphon said. Python is a pretty awesome. One more important thing is to work on projects. Learning numerous languages will not make you a good programmer.
 

comp@ddict

Well-Known Member
Adept
Apr 25, 2009
6,384
128
127
25
Manipal
about.me
No no I dont want to learn numerous languages. Isn't Android App Development base on the Java language? Hence Java(correct me if I'm wrong)
 

Gryph0n

Active Member
Adept
Dec 7, 2007
348
14
33
Bangalore
No no I dont want to learn numerous languages. Isn't Android App Development base on the Java language? Hence Java(correct me if I'm wrong)
You're correct in the sense that Java is the 'native' language for Android. But Python also will work on Android via SL4A. C/C++ is also supported via the NDK, but only performance oriented apps (typically games) use it.

android-scripting - Scripting Layer for Android brings scripting languages to Android. - Google Project Hosting

I haven't used the SL4A layer on Android, so I can't speak for how good/bad it is. However it should help you take tentative steps into Android using Python.

BTW, there's nothing wrong with learning/using multiple languages; it can help expand your horizons. But IMO doing it when you're just starting out isn't too good an idea. Ideally you want to get grounded in programming basics rather than having superficial knowledge of multiple languages. Once you have mastered the basics, you can easily move between languages.
 

comp@ddict

Well-Known Member
Adept
Apr 25, 2009
6,384
128
127
25
Manipal
about.me
So you mean to say I can make an entire app using Python instead of Java?

No I intend to make Java a proper base actually.

But I'll be doing HTML and CSS simultaneously
 

avi

Well-Known Member
Elite
Nov 23, 2010
4,178
1,737
202
So you mean to say I can make an entire app using Python instead of Java?
Yes, you can do.

You can build apps just with HTML & no java.

If you still want to learn Java, go with Head First Series. nothing beats them. Once you know the concepts & libraries, head to Sun Java's Online Resources.

For python :


Python 2 - http://www.ibiblio.org/swaroopch/byteofpython/files/120/byteofpython_120.pdf


Pyhton 3 - http://www.swaroopch.com/files/byteofpython/byte_of_python_v192.pdf

Few more FREE awesome python books :


1. Dive into python - http://diveintopython.nfshost.com/toc/index.html


2. How to think like a computer scientist - http://www.greenteapress.com/thinkpython/thinkCSpy/thinkCSpy.pdf


3. Python 101 - Python 101 -- Introduction to Python


4. Learn python the hard way - Learn Python The Hard Way, 2nd Edition — Learn Python The Hard Way, 2nd Edition


5. The python tutorial - The Python Tutorial — Python v2.7.3 documentation


6. Think python - http://www.greenteapress.com/thinkpython/thinkpython.pdf


Any interested guy should start with the first links I'd given. #1 book, would be next. Books #2, #4 & #7 have the best examples / problems.


And I agree with @Gryph0n, go with Python :)
 
Last edited by a moderator:
  • Like
Reactions: 2 people

comp@ddict

Well-Known Member
Adept
Apr 25, 2009
6,384
128
127
25
Manipal
about.me
Okay I'll learn python with the "Head Start" series as I've heard again and again that it's very good.

But can you tell me what's different between Python and Java?

Python is a scripting language. Elaborate please
 

avi

Well-Known Member
Elite
Nov 23, 2010
4,178
1,737
202
Nope, I said learn Java with Head First. Head First python is okayish book.

Here is the difference :

[h=1]Comparing Python to Other Languages[/h]Python is often compared to other interpreted languages such as Java, JavaScript, Perl, Tcl, or Smalltalk. Comparisons to C++, Common Lisp and Scheme can also be enlightening. In this section I will briefly compare Python to each of these languages. These comparisons concentrate on language issues only. In practice, the choice of a programming language is often dictated by other real-world constraints such as cost, availability, training, and prior investment, or even emotional attachment. Since these aspects are highly variable, it seems a waste of time to consider them much for this comparison.
[h=2]Java[/h]Python programs are generally expected to run slower than Java programs, but they also take much less time to develop. Python programs are typically 3-5 times shorter than equivalent Java programs. This difference can be attributed to Python's built-in high-level data types and its dynamic typing. For example, a Python programmer wastes no time declaring the types of arguments or variables, and Python's powerful polymorphic list and dictionary types, for which rich syntactic support is built straight into the language, find a use in almost every Python program. Because of the run-time typing, Python's run time must work harder than Java's. For example, when evaluating the expression a+b, it must first inspect the objects a and b to find out their type, which is not known at compile time. It then invokes the appropriate addition operation, which may be an overloaded user-defined method. Java, on the other hand, can perform an efficient integer or floating point addition, but requires variable declarations for a and b, and does not allow overloading of the + operator for instances of user-defined classes.
For these reasons, Python is much better suited as a "glue" language, while Java is better characterized as a low-level implementation language. In fact, the two together make an excellent combination. Components can be developed in Java and combined to form applications in Python; Python can also be used to prototype components until their design can be "hardened" in a Java implementation. To support this type of development, a Python implementation written in Java is under development, which allows calling Python code from Java and vice versa. In this implementation, Python source code is translated to Java bytecode (with help from a run-time library to support Python's dynamic semantics).
[h=2]Javascript[/h]Python's "object-based" subset is roughly equivalent to JavaScript. Like JavaScript (and unlike Java), Python supports a programming style that uses simple functions and variables without engaging in class definitions. However, for JavaScript, that's all there is. Python, on the other hand, supports writing much larger programs and better code reuse through a true object-oriented programming style, where classes and inheritance play an important role.
[h=2]Perl[/h]Python and Perl come from a similar background (Unix scripting, which both have long outgrown), and sport many similar features, but have a different philosophy. Perl emphasizes support for common application-oriented tasks, e.g. by having built-in regular expressions, file scanning and report generating features. Python emphasizes support for common programming methodologies such as data structure design and object-oriented programming, and encourages programmers to write readable (and thus maintainable) code by providing an elegant but not overly cryptic notation. As a consequence, Python comes close to Perl but rarely beats it in its original application domain; however Python has an applicability well beyond Perl's niche.
[h=2]Tcl[/h]Like Python, Tcl is usable as an application extension language, as well as a stand-alone programming language. However, Tcl, which traditionally stores all data as strings, is weak on data structures, and executes typical code much slower than Python. Tcl also lacks features needed for writing large programs, such as modular namespaces. Thus, while a "typical" large application using Tcl usually contains Tcl extensions written in C or C++ that are specific to that application, an equivalent Python application can often be written in "pure Python". Of course, pure Python development is much quicker than having to write and debug a C or C++ component. It has been said that Tcl's one redeeming quality is the Tk toolkit. Python has adopted an interface to Tk as its standard GUI component library.
Tcl 8.0 addresses the speed issuse by providing a bytecode compiler with limited data type support, and adds namespaces. However, it is still a much more cumbersome programming language.
[h=2]Smalltalk[/h]Perhaps the biggest difference between Python and Smalltalk is Python's more "mainstream" syntax, which gives it a leg up on programmer training. Like Smalltalk, Python has dynamic typing and binding, and everything in Python is an object. However, Python distinguishes built-in object types from user-defined classes, and currently doesn't allow inheritance from built-in types. Smalltalk's standard library of collection data types is more refined, while Python's library has more facilities for dealing with Internet and WWW realities such as email, HTML and FTP.
Python has a different philosophy regarding the development environment and distribution of code. Where Smalltalk traditionally has a monolithic "system image" which comprises both the environment and the user's program, Python stores both standard modules and user modules in individual files which can easily be rearranged or distributed outside the system. One consequence is that there is more than one option for attaching a Graphical User Interface (GUI) to a Python program, since the GUI is not built into the system.
[h=2]C++[/h]Almost everything said for Java also applies for C++, just more so: where Python code is typically 3-5 times shorter than equivalent Java code, it is often 5-10 times shorter than equivalent C++ code! Anecdotal evidence suggests that one Python programmer can finish in two months what two C++ programmers can't complete in a year. Python shines as a glue language, used to combine components written in C++.
[h=2]Common Lisp and Scheme[/h]These languages are close to Python in their dynamic semantics, but so different in their approach to syntax that a comparison becomes almost a religious argument: is Lisp's lack of syntax an advantage or a disadvantage? It should be noted that Python has introspective capabilities similar to those of Lisp, and Python programs can construct and execute program fragments on the fly. Usually, real-world properties are decisive: Common Lisp is big (in every sense), and the Scheme world is fragmented between many incompatible versions, where Python has a single, free, compact implementation.
Comparing Python to Other Languages
 

Rogues

Active Member
Disciple
Jul 26, 2010
190
1
28
28
Hyderabad, Andhra Pradesh
You can't choose a single language for everything. I simply recommended python because it's easy to learn and use. I would suggest you stop comparing one language to another, and just choose one that you are comfortable with and one that allows you to do what you want to do effectively.
Disclaimer: This essay was written sometime in 1997. It shows its age. It is retained here merely as a historical artifact. --Guido van Rossum
 

Gryph0n

Active Member
Adept
Dec 7, 2007
348
14
33
Bangalore
Python is a scripting language. Elaborate please
If I use an example of an expression like:
"a=b+c"


  • Python
You don't have to declare the types of a,b,&c (Integer, character, floating pt., etc). The runtime has to determine the types of b & c, and then apply the correct operation (+) or give error if the operation is not allowed. Basically, it should lead to smaller code, but more time in running the program.


  • Java & C++
You have to declare the types of a,b,&c (Integer, character, floating pt., etc). So the compiler knows whether the operation (+) is allowed or not, for the declared types. As a result, runtime's load is much lighter. Basically, you write more code, but the program should spend lesser time running.



PS, my post is actually about static & dynamic typing. Practically however, all scripting languages are dynamically typed.
 

Arv90

Well-Known Member
Adept
Sep 9, 2011
307
118
82
29
/home/Work
i think java would be an appropriate upgrade from C++ as it is done in the engineering syllabus'
Where as python would be a downgrade in terms of coding experience.Because coding is pretty simple in pyhton.
Multi threading,applet and other interesting concepts in java,tough though,working in java would give a proper insight on how variables,loops work within a program.
 

Gryph0n

Active Member
Adept
Dec 7, 2007
348
14
33
Bangalore
i think java would be an appropriate upgrade from C++ as it is done in the engineering syllabus'
Where as python would be a downgrade in terms of coding experience.Because coding is pretty simple in pyhton.
Multi threading,applet and other interesting concepts in java,tough though,working in java would give a proper insight on how variables,loops work within a program.
Real programmers use Assembly :bleh:

http://www.pbm.com/~lindahl/mel.html

 

Gryph0n

Active Member
Adept
Dec 7, 2007
348
14
33
Bangalore
Anyways the link gives a 404 page not found error.
Thanks for pointing that out. vBulletin seems to have sanitized the tilde(~) in the URL.

I just made it plain text, and now vBulletin seems to have auto-converted it to URL, correctly this time.
 

Rogues

Active Member
Disciple
Jul 26, 2010
190
1
28
28
Hyderabad, Andhra Pradesh
C++ is probably a very hard language to grasp once you go into the nooks and cranny. It's not very well designed, but it's a very powerful tool.The syntax of python will be a little difficult to grasp coming from C++, but once you get it, it allows you to just code away rather than think what kind of variable to declare. Dive into python will be a good start for you since you already know C++. It's available for free. Just google it. If you want to be a good programmer, I suggest you register at StackOverflow and check out stuff that interests you.Cheers.
 

comp@ddict

Well-Known Member
Adept
Apr 25, 2009
6,384
128
127
25
Manipal
about.me
I read each and every point. I'm still inclined to Java, it seems similar to C++ in many aspects so it would actually be a bit faster for me.

Python, I start from 0.
 

Rahul++

SuperUser
Adept
Aug 27, 2007
3,142
175
152
27
Pune
www.wrapcode.com
I would recommend you to learn Java first. It's always better to continue the flow (i.e. OOP and similar syntax in your case). You can learn python in like 10-15 days.

In my case, My learning phase was like C -> C++ -> Java -> Python -> C# -> and so on :p

Python can really be your first language to learn. Reason, it is damn simple scripting language. Very easy to learn.