When comparing Java vs Smalltalk, the Slant community recommends Smalltalk for most people. In the question“What is the best programming language to learn first?” Smalltalk is ranked 2nd while Java is ranked 22nd. The most important reason people chose Smalltalk is:
You can modify the system as it's running. You're "swimming with the fish", instead of probing a black box by remote control.
Ranked in these QuestionsQuestion Ranking
Pro Fantastic IDEs
Because Java is statically typed, integrated development environments (IDEs) for Java can provide a lot more feedback on errors you will encounter. Java IDEs can give you specific errors in the location where they occur without having to run the code every time. This makes is faster to debug and learn from your mistakes.
IDEs also have extensive auto complete capabilities that can help you learn the programming libraries you are using faster and tell you what functions are available.
Pro Most commonly used language in industry
Pro Consistent programming standards
Most Java code follows very standardized coding styles. This means that when you're starting out, there are fewer questions about how you should implement something as the programming styles and patterns are well established and consistent. This consistent style means that it's often easier to follow others' example code, and that it's more likely to meet at least a certain minimum standard of quality. This discipline with consistent stylistic standards also becomes useful later, when collaborating on projects with larger teams.
Pro Best introduction to "C style" languages
The Java syntax is very similar to other C style languages. Learning the fundamentals of Java will port over well to other languages so you can apply what you've leaned to other languages afterwards.
Pro Introduces you to object oriented languages
Object Oriented Programming (OOP) is a paradigm that teaches you to split your problem into simpler modules with few connections between them; it's the most common paradigm used in industry. Java is the best choice as an introduction to object oriented languages because, as a statically-typed OOP-only language, it very clearly highlights core OOP principles such as encapsulation, access control, data abstraction, and inheritance.
While a scripting language provides more flexibility and terseness, learning a scripting language first would not instill these fundamental concepts as well, as they tend to obscure details such as how types work, and are less encouraging of an object oriented style.
Pro Platform Independent
Because of the Java Virtual Machine, the Java programming language is supported wherever a JVM is installed.
Pro Massive amount of libraries and APIs
Java has been around for such a long time that there have been tens of thousands of APIs and libraries written for almost anything you want to do.
Pro Environment of live objects
You can modify the system as it's running. You're "swimming with the fish", instead of probing a black box by remote control.
Pro Easy to learn and experiment
Pro Inspector makes objects transparent
Programmers must make detailed mental models of the system they are developing. Bugs usually happen when the mental model does not match the actual system. This is one of the greatest difficulties beginners have because most systems are so opaque. It takes a lot of effort to see what's really going on. But in Smalltalk this is much easier, thanks to the powerful tools included in the environment, like the object inspector.
Pro Internal source code and documentation
You can explore how everything works easily.
Pro Superb Integrated Development Environment (IDE)
All tools (Inspector, Browser, Debugger etc.) are written in Smalltalk and are live objects in the environment. All sources are present, so that the tools can easily be studied, changed and experimented with.
The same goes for the other components like the compiler, OS-Integration etc.
Pro Pure and easy object orientation
Smalltalk is one of few languages that are purely object oriented. This provides a solid and easy to understand base on which to learn object oriented programming, the most popular approach to programming.
Pro Agile "interactive" test-driven development
Smalltalk had the original (and still the best) unit test system that inspired it in many other languages (like Java's JUnit). Working with interactive live objects in Smalltalk style TDD makes it easy to teach and learn TDD.
Pro Incremental compilation
Provides an extremely fast code-compile-run-debug cycle. This is great for beginners to experiment and prototype ideas.
Pro Inspired many other languages' object systems
Pro Save and restore virtual machine image
A Smalltalk environment can save the state of a running program and later restore and resume execution. This includes the internal state of live objects, multiple thread stacks, and debugging sessions, making it easier for beginners to take the exact problem to an expert for assistance.
Pro Powerful integrated debugger
You can edit code and swap it in while the your program is still running after an exception has already been signaled, or restart from anywhere in the call stack. You can inspect and modify the state of any object. Some Smalltalkers write unit tests and then program exclusively in the debugger.
Pro Elegant syntax fits on a postcard
The syntax was designed to be easy enough for children to learn. Beginners can learn the language rules very quickly and then focus on programming without fighting the syntax at the same time. Things that have to be baked into the grammar in other languages are simple message sends with block arguments in Smalltalk. Expressions have only three precedence levels to worry about.
Pro Open source
MIT licensed implementations Pharo, Squeak, Cuis & Dolphin
and GPL licensed GnuSmalltalk.
Pro Graphical user interface
Beginners are usually stuck making command-line applications in other languages, because GUIs are too hard. Smalltalk GUIs are easy enough to start with.
Pro Language uniformity
This leads to a very simple programming model (pure OO) that is still very powerful. A lot of stuff that is hard to implement in other languages is easier in Smalltalk.
Pro First-class functions with lexical closures
Pro Provides a functional way to interact with objects
Many languages today use object orientation, while the most of them stock on the half way in that perspective.
Smalltalk sees literally everything as an object and this includes things like the classes and primitive data types. There is are zero control structures such as selection and iteration, since all is done by sending messages to objects.
It use a lot of concepts from Lisp in order to provide a nice experience for this pure kind of object orientation.
It provides immutable data structures, closures, anonymous functions and higher order functions, while all those functions are objects. This is what makes Smalltalk so simple, elegant, and easy.
All this counts for Pharo, while other implementations as Amber are probably feature complete to it.
Pro It invented a lot of stuff
Smalltalk is the inventor of Just-in-Time compilation and the MVC concept, refactoring through their so-called refactoring browser and it was also one of the first adopters of a language virtual machine, closures, live programming, test driven development, an IDE and the development of GUI`s.
Con Worst-of-both-worlds static type system
It's just barely good enough to make decent IDEs, but it's not at the level of Idris or even Haskell. For large enterprise projects, the IDE support is important, but the static typing in Java just gets in the way for the smaller projects beginners would start with.
Python is duck typed and this makes small programs easy to develop quickly, but the price is that you have to write unit tests to avoid breaking larger programs. In contrast, you can be reasonably certain that a program that actually compiles in Idris does what you want, because assertions are built into the powerful type system. Java can't make that claim and still requires unit tests. Java has the worst of both worlds because of its poor static type system.
Con Lacks modern features
Java evolves very slowly - lambda expressions weren't available until Java 8 (which is not available on Android), and despite getters/setters being a long-time convention, the language still doesn't have native accessor syntax (a la C#'s properties). It's unlikely newer, popular features like list comprehensions or disjoint union types will be available anytime soon. While not strictly required for novice programmers, these make problems more complicated and tedious than they need to be - for example, when a simple local function would do, (portable) Java demands anonymous inner classes, an interface and a class, or worse, no abstraction at all.
Con Confusing mis-features
Some features in Java can be quite confusing for beginners.
Encapsulation is needlessly obfuscated with a confusing access control model. As an example, the "protected" keyword not only grants access to child classes, but to the entire package. Since small programs are written as one package, it becomes functionally equivalent to "public".
In OOP, everything is supposed to be an object, but, in Java, primitive types such as integers, booleans and characters are not, and must be handled as special cases.
Java continues to lack many high-level features, and, particularly prior to Java 7, compensated by adding confusing Java-only features, such as anonymous subclasses. Some example code is unreadable without knowing a special-case feature, libraries differ in style based on when they were released or what platform they target(e.g., Android vs. Desktop), and some solutions just aren't available on some platforms.
Con Too verbose
- A Hello world needs package, class, static method and the actual
- Reading a line from input requires instatiating 5 objects in the right order.
- Exceptions are everywhere, particularly since all values are nullable.
- Java has a getter/setter culture, but without native syntax support.
- portable Java code lacks anonymous functions, and continues to lack good support for partial application, compensating instead with verbose design patterns, kludges like anonymous inner classes, or just inline code.
- It is statically typed without type inference, with a culture that promotes long class names.
- Poor support for sum-types and pattern matching leads to overuse of inheritance for dynamic dispatch and chains of nested conditionals
Especially for beginners, this can make reading Java code feel overwhelming; most Java courses tell students to simply copy, paste, and ignore a significant percentage of the code until they've learned enough to understand what it means.
For experienced programmers, this makes Java feel tedious, especially without an IDE, and actively discourages some solutions and some forms of abstraction.
Con Locks you into the static OOP mindset
Con Half-baked generics
Type erasure means it doesn't even exist at runtime. The whole generics system is confusing for beginners.
Con Garbage collection may teach bad habits
Java is a garbage collected language and it does not force programmers to think about memory allocation and management for their programs. This is fine most of the time. However, it may cause some difficulties in adjusting to a non-GC language (such as C for example), where memory management needs to be done manually. But if good coding practices and habits are followed, this shouldn't be much of a problem.
Con Enforces some misguided principles
Java utilizes principles that organize code into "classes" as the central concept, instead of more familiar organizational methods.
Con Long learning curve
Con Static typing but no type inference
The type system gets in your way more than it helps. Heavy IDE support is absolutely required for reasonable productivity. This means beginners have to learn not just the language, but eventually a complex, heavyweight IDE too.
Con Checked exceptions
Catch blocks can be a frequent source of mistakes.
Con Not common
Smalltalk and its implementations are no longer popular languages to use. Available jobs are scarce (but do exist), and online communities are relatively small. There is little to no modern books or resources made for the language, although older, very good books do exist.
Con Virtual machine in its own isolated world
Smalltalk wants to be the whole OS. While this has tremendous advantages internally, interacting with the world outside the VM is not so easy.
Con Non-standard arithmetic ordering
Since every operation is considered a message sent sent is a specific order, all arithmetic operators have the same precedence. E.g. 2 + 3 x 4 translates to 2 + 3, and the result is multiplied by 4, giving an answer of 24 (instead of the correct answer - 14). Once you are learn this, it can easily handled using brackets, e.g. 2 + (3 x 4), but still a momentary suprise for beginners.