Proposal: Simplifying the Scala getting started experience

Actually compilation overhead is very important in dynamic evaluation. So, we cannot use groovy for that purpose either.
But groovy is very good in some web framework in the area where dynamic is more important than runtime speed.

We also have areas where I would prefer to use groovy if I had no scala controllers.

IMHO

Really I do not understand the desire to advertise scala in the area where scala is really weak. I think it is a bad publicity stunt

It is not.

@AMatveev I think you have sufficiently made your point. Yet apparently most other participants in this thread disagree with you. Please respect that take that into account.

To everyone: this discussion needs to be refocused on the initial topic of how to improve the getting started experience, instead of whether we should even care about the getting started experience.

1 Like

Ok, may be I have used bad terms, but it is over javascript so it should use “dynamic invocation”.

It seems you are right and I have made some off topic. I am sorry.

I’m not sure what is a casual beginner. I have had team mates over time with very little coding experience who often asked me for help. Does that count?

1 Like

So let’s define one low-experience, casual coding group as people who can write an excel formula. They can enter numbers into cells, and enter formulas in other cells to compute derived values. But perhaps haven’t yet done any excel macros.

Let’s define another group as undergraduate students with no prior coding experience on day 1 of their programming practical. This first prac will inform their view of if coding is for them or not, and if that language in the lab is difficult or not.

And lastly, lets’s think of somebody who once a month or so has to generate a report from some data, and for that day writes some throw-away python scripts small enough to fit on a screen without scrolling. They forget most of what they know between each scripting day, and have to in effect mostly relearn it each time.

Let’s see how a hello-world looks like in the most popular programming languages.

I’m not an expert in judging what are popular languages, but I’ve heard people referring to the TIOBE index in the past, which currently starts with (1) Java (2) C (3) Python (4) C++ (5) Visual Basic .NET (6) C# (7) JavaScript (8) PHP (9) SQL (10) Objective-C

It doesn’t exactly confirm the hypothesis that short hello world programs make a language popular.

= = = (1) Java = = =

public class HelloWorld {
public static void main(String[] args) {
System.out.println(“Hello, World”);
}
}

= = = (2) C = = =

#include <stdio.h>
int main()
{
printf(“Hello, World!”);
return 0;
}

= = = (3) Python = = =

print(“Hello, World!”)

= = = (4) C++ = = =

#include

using namespace std;
int main()

{

** cout << “Hello World!”;
return 0;**

}

= = = (5) Visual Basic .NET = = =

Imports System
Public Module Hello
Public Sub Main( )
Console.WriteLine(“hello, world”)
End Sub
End Module

= = = (6) C# = = =

using System;
namespace HelloWorld
{
class Hello
{
static void Main()
{
Console.WriteLine(“Hello World!”);
}
}
}

= = = (7) JavaScript = = =

alert( ‘Hello, world!’ );

= = = (8) PHP = = =

echo “Hello World!”;

= = = (9) SQL = = =

BEGIN
dbms_output.put_line (‘Hello World…’);
END:
/

= = = (10) Objective-C = = =

#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
NSLog(@“Hello, World!”);
}
return 0;
}

Cool. And of those, people who code who aren’t coders write python, js and php.

Ok, I’m imagining an Excel user. Why would they even code anything, if not macros?

To the undergrad student on their first day of coding ever - does it really matter that much to them whether their first app is one line of six lines? Beginners rarely complain about boilerplate, it’s usually the advanced users after they had to write it a hundred times.

It is usually the experienced coder who writes code to process data. Others import their data into Excel.

This is going to be my last reply on this topic. I want as many people as possible to use scala, from people engineering critical business components through to people who write a bit of code half way through working through their end of year accounts, and I want as few people as possible to be put off from using scala when they first try it out. I’ve watched people walk away from coding before they even really start because their first experience involved barriers to entry. And I’ve seen people take to it right away because they could type a sum into the javascript console in their browser, and right away get the computer to do fun things. You get casual adoption by making the casual experience rewarding. That means getting rid of everything you can that delays gratification or gives an opportunity for mistyping boilerplate to make it fail.

4 Likes

PHP exists to put server-side logic into web pages, so whoever uses PHP definitely needs to know HTML first. The hello world program in PHP is in itself absolutely useless, because you could just put the string directly into the HTML.

JavaScript exists to put client-side logic into web pages. If you want to do in JavaScript anything other than filling the log or opening alert dialogues, that would be manipulating the DOM, which would be quite tricky for people without much coding experience.

The only language in the list that (a) is easy on beginners and (b) has a hello world app shorter than Scala is Python.

1 Like

Allowing users to type a sum? We can do that in Scala:
**Welcome to Scala 2.12.8 (OpenJDK 64-Bit Server VM, Java 1.8.0_191).
Type in expressions for evaluation. Or try :help.

3+4
res0: Int = 7**

if you have this main.scala

println("hello")

and you use:

scala main.scala

it works. why do we need more?

1 Like

The hypothesis is not that brevity of hello world is strongly correlated with language popularity, i.e., that it is the most important, or only important, variable that affects the popularity of the language.

The hypothesis is that for any given language, the ease of starting is an important variable that affects its popularity. That is, whatever its popularity is as influenced by other factors, having a better getting started experience will increase its popularity relative to itself, and having a worse getting started experience will decrease its popularity relative to itself.

That’s not something you can falsify with a popularity ranking of languages. (Without getting into the flaws that have been pointed out in the TIOBE method.)

1 Like

Great question. I think the answer is that there’s too big of a gap between that and a compiled program. You can’t use them together.

1 Like

It is undeniably.
Nobody have said that it is not so.
I can give a good example of good getting started for everyday:

I have searched for java and scala and I have found

Python’s strength in making writing simple scripts quickly doesn’t translate to big popularity among big projects. Big projects are still written in Java, C#, C++, etc and it doesn’t seem that will change. It doesn’t seem Python is a good choice for projects of every scale.

Scala scripting should only be good enough to convince newcomers that Scala language is convenient and productive. After that they be willing to put a little effort to create proper Scala projects based on a build tool (probably SBT) and regular Scala code with objects with main method. It’s really not a long task to create new (nearly) empty SBT project with proper structure and some library dependencies. If Scala scripting will support dynamic importing of any library dependencies (like Ammonite does with import $ivy) then even some minor hurdles with SBT setup won’t prevent a Scala newcomer from using external libraries (i.e. he’ll be using Scala scripting until someone else helps him resolve problems with SBT).

Java and C# aren’t oriented towards beginners. You can’t write loose code in Java or C#, neither you can loosely import external libraries straight from within the source code (skipping any build tools, IDEs support, etc). Does that mean that advertising Java and C# to beginners is a “bad publicity stunt”?

1 Like

From what I see in the industry, python is the “quick and dirty” testing ground before seriously implementing the final product.

1 Like

Thare are interesting questions, but I am sorry. I leave that topic. It seems like offtopic, so I do not want to show disrespect

This is only true if your industry is “professional software engineers working on large services”, and even limited to that tiny subset, the amount of “final product” implemented in Python already dwarfs Scala usage.

Python’s “industry” is much larger than that. For data scientists, analysis, sys admins, devops, mathematicians, mechanical engineers, and many others who use Python on a daily basis. Unlike Scala, which is very much just people working on backend services, Python has a very broad base of usage across all fields. If we think Scala is a good “general purpose” language, this broad appeal is something we should very much be striving to emulate, not turning up our noses at as “unserious”.

17 Likes

Python is used not only because of its conciseness. It’s also used because many people don’t want to deal with types and complicated software engineering in general, so they will have more time to spend on the business domain. That doesn’t scale to big programs, because for big programs you need proper software architecture and strong typing helps with that.

Is there a precedent of statically typed language displacing duck-typed one? I don’t think so. Golang was supposed to be one such attempt, but it doesn’t seem it comes even remotely close to Python’s popularity. That’s despite Google backing, fast compiler, super-low GC pauses and simplicity of the language. If Google can’t do it, why should we risk wasting time on it?

As for Python being “quick and dirty testing ground”, I was speaking with HFT (high frequency trading) developers and the situation there is that mathematicians are developing their algorithms in Python (which results in slow programs), which are then rewritten into C++/ Java/ etc by proper programmers.