When comparing Lua vs Pharo, the Slant community recommends Lua for most people. In the question“What is the best programming language to learn first?” Lua is ranked 16th while Pharo is ranked 20th. The most important reason people chose Lua is:
One of the best features of Lua is its very well designed C API. This is very useful if you have an existing C library you need to integrate with Lua or quickly get a Lua script running on the C side of the game. Finally Lua plays so nice with C that if you need to optimise for speed you can re-write it in C a lot easier than other languages.
Specs
Ranked in these QuestionsQuestion Ranking
Pros
Pro Very easy to integrate with C and C++
One of the best features of Lua is its very well designed C API. This is very useful if you have an existing C library you need to integrate with Lua or quickly get a Lua script running on the C side of the game.
Finally Lua plays so nice with C that if you need to optimise for speed you can re-write it in C a lot easier than other languages.
Pro Great documentation
The official Lua documentation is very helpful and thorough. There are also a large number of online resources or books with lots of helpful information for beginners and advanced users alike.
Pro Portable
Lua can be built on any platform with a ANSI C compiler.
Other than that, Lua is extremely small. For example, the tarball for Lua 5.2.1 is only 245K compressed and 960K uncompressed (including documentation).
When built on Linux, the Lua interpreter built with the standard libraries takes 182K and the Lua library takes 243K.
The small size and the ability to build with a C compiler make Lua an extremely portable language that can run on a lot of different systems and computers.
Pro Simple
Easy to learn.
Pro Fast
Lua's performance compares very well to other languages, If performance needs to be further improved you can:
- Implement critical parts in C
- Use the LuaJIT compiler. The LuaJIT compiler is a drop in replacement for the stock compiler and provides significant performance improvements. From the overview page:
LuaJIT speeds can rival code written in C.
Pro Embeddable
Many different game engines (e.g. Elder Scrolls series, ToME) use Lua for scripting, and it's runtime is designed for embedded use.
Pro Clean and simple syntax suitable for beginners
The Lua syntax is modeled from Modula, a language known for being a fantastic introduction to programming.
The Lua syntax also has the following key characteristics:
- Semicolon as a statement separator is optional (mostly used to resolve ambiguous cases as in a = f; (g).x(a)).
- Syntactic sugar for function calls (f'string', f"string", f[[string]], and f{table}) and method calls (obj:m()).
Pro Helpful community
Due to the growing popularity, Lua has a rather large and helpful community surrounding it.
Pro Object-Oriented
In Pharo everything is an object. Compiler - object, network - object, method - also an object. And objects communicate with messages. No operators, no control-flow statements. Just objects and messages. Few things to learn, but you can learn OOP well.
Pro Easily learnt
There is good, free documentation including several books written by experts with extensive examples. There is an online MOOC. There are many tutorial videos. Supportive conferences and community. Even a professional support option if desired.
Pro Live updates
The nature of Pharo being a "live" environment allows you to perform live updates to your system without requiring to restart it. You can upgrade/modify classes while serving requests at the same time.
Pro Highly productive
Pro Seaside
The framework for developing sophisticated web applications in Smalltalk is developed in Pharo. Seaside lets you build highly interactive web applications quickly, reusably and maintainably.
Pro Remote debugging
Pro Beautiful coding patterns in your IDE
No need to search google for compact beautiful examples of how to do things, your live environment source is available and you can easily live search, see how it works and copy how the masters would do it (examples most languages still copy too).
Pro Glamorous toolkit & GTInspector
Most languages are still copying the Smalltalk tools of yesterday - GTInspector (written in Glamorous) takes live exploration of code/running objects to a new level. It's really slick, and better yet, you can easily write your own inspectors in 10 lines of code.
Pro Code can be run on rock solid GemStone environment
Pro 64 bit support as of Pharo 7
Use 32 bit or 64 bit versions of Pharo on Windows, Mac & Linux.
Pro Advanced code analysis tools
MOOSE environment provides extensive, easily leveraged and class leading tools for code analysis and improvement.
Pro Can run headless for production
Pro Really simple networking and REST with Zinc
Pro Graphics, graphing and visualisation framework - Roassal
Roassal and Mondrian provide fantastic and easily used frameworks for graphics, graphing and advanced visualisations (comparable to D3.js) but with much less code. Visualisations can be rendered into web friendly graphics (SVG, .png etc.) without additional work.
Cons
Con Easy to make mistakes when declaring variables
When writing a function, if a programmer forgets to declare a variable, that variable will be declared at global scope. The code will seem to run fine at first, but if another function uses a variable with the same name, but fails to declare it, it will create subtle, incredibly difficult to find bugs.
Con Some concepts may not be applied to other "mainstream" programming languages
Lua features a prototye-based inheritance model. While this is also used by Javascript, it's not used by many other mainstream languages, and so some of the concepts learned while learning Lua won't be very applicable to other languages.
Another thing that makes Lua different from other programming languages, is the fact that Arrays start at 1 instead of 0. While helpful for beginners, it can complicate logic and make it very confusing when switching languages.
Con Batteries not included
Lua is so small mainly due to many of the components not being included in the core package. A lot of people need the functionality provided by the Lua module management system LuaRocks and libraries such as Penlight.
Con Small community
But they are very friendly and supportive. Best help comes through the mailing lists so not always easily googlable. There is also a Slack community where help is nearly instantaneous.
Con Odd language
Requires a different mindset. Much harder to apply what you know from popular or conventional languages . Switching over from or between other languages is more difficult.
Con Single threaded
Pharo's VM only ever uses one CPU core. If you want to write code that uses more than one CPU core, you need to jump through hoops such as running multiple VMs and synchronising your data.