Why can't Scala auto-build like Python?

classic Classic list List threaded Threaded
28 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Why can't Scala auto-build like Python?

Russ P.
I'm trying to migrate over from Python to Scala. I recently looked into build tools for Scala. It appears that buildr is the way to go, but as I started reading up on it, I started wondering why I should even need to bother with a build tool. I'm an aerospace engineer, so I may be naive about this, but one of the great features about Python is that you never need to explicitly build anything. Everything just happens automagically (including the generation of .pyc files when they need to be created or updated). Why can't Scala work that way too?

Yes, I realize that you may want to compile explicitly, so that capability obviously should not be eliminated, but I personally never need or want to do that. I prefer to just let things get built automagically as needed.

Russ P.

--
http://RussP.us


Reply | Threaded
Open this post in threaded view
|

Re: Why can't Scala auto-build like Python?

Daniel Sobral
Use either maven or sbt. Maven has a mvn scala::cc, which will keep compiling everything. SBT has something similar.

On Sat, Dec 19, 2009 at 9:47 PM, Russ Paielli <[hidden email]> wrote:
I'm trying to migrate over from Python to Scala. I recently looked into build tools for Scala. It appears that buildr is the way to go, but as I started reading up on it, I started wondering why I should even need to bother with a build tool. I'm an aerospace engineer, so I may be naive about this, but one of the great features about Python is that you never need to explicitly build anything. Everything just happens automagically (including the generation of .pyc files when they need to be created or updated). Why can't Scala work that way too?

Yes, I realize that you may want to compile explicitly, so that capability obviously should not be eliminated, but I personally never need or want to do that. I prefer to just let things get built automagically as needed.

Russ P.

--
http://RussP.us





--
Daniel C. Sobral

I travel to the future all the time.
Reply | Threaded
Open this post in threaded view
|

Re: Why can't Scala auto-build like Python?

Tony Morris
In reply to this post by Russ P.
I've tried them all. Haskell is by far the most practical build tool for
Scala. I like this magic idea though; perhaps I am missing out.

Russ Paielli wrote:

> I'm trying to migrate over from Python to Scala. I recently looked
> into build tools for Scala. It appears that buildr is the way to go,
> but as I started reading up on it, I started wondering why I should
> even need to bother with a build tool. I'm an aerospace engineer, so I
> may be naive about this, but one of the great features about Python is
> that you never need to explicitly build anything. Everything just
> happens automagically (including the generation of .pyc files when
> they need to be created or updated). Why can't Scala work that way too?
>
> Yes, I realize that you may want to compile explicitly, so that
> capability obviously should not be eliminated, but I personally never
> need or want to do that. I prefer to just let things get built
> automagically as needed.
>
> Russ P.
>
> --
> http://RussP.us <http://russp.us/>
>

--
Tony Morris
http://tmorris.net/


Reply | Threaded
Open this post in threaded view
|

Re: Why can't Scala auto-build like Python?

Warren Henning
In reply to this post by Russ P.
Neither of the previous responses addressed the OP.

Scala has a different execution model from Python. It can be run
interpreted but normally it is first compiled to Java bytecodes. Scala
was designed from the beginning to have maximal Java interop, so it
shares the same compilation model. This has certain benefits: without
special libraries like numpy, Scala will almost always be much faster
than Python.

Scala and Python aren't better or worse than one another, just
different. Use what works for you.

Warren

On Sat, Dec 19, 2009 at 3:47 PM, Russ Paielli <[hidden email]> wrote:

> I'm trying to migrate over from Python to Scala. I recently looked into
> build tools for Scala. It appears that buildr is the way to go, but as I
> started reading up on it, I started wondering why I should even need to
> bother with a build tool. I'm an aerospace engineer, so I may be naive about
> this, but one of the great features about Python is that you never need to
> explicitly build anything. Everything just happens automagically (including
> the generation of .pyc files when they need to be created or updated). Why
> can't Scala work that way too?
>
> Yes, I realize that you may want to compile explicitly, so that capability
> obviously should not be eliminated, but I personally never need or want to
> do that. I prefer to just let things get built automagically as needed.
>
> Russ P.
>
> --
> http://RussP.us
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Why can't Scala auto-build like Python?

Randall R Schulz-2
In reply to this post by Russ P.
On Saturday December 19 2009, Russ Paielli wrote:
> I'm trying to migrate over from Python to Scala. I recently looked
> into build tools for Scala. It appears that buildr is the way to go,
> ...

It is no doubt a matter of opinion, but I'm very pleased with Simple
Build Tool (SBT).

<http://code.google.com/p/simple-build-tool/>


> Russ P.


Randall Schulz
Reply | Threaded
Open this post in threaded view
|

Re: Why can't Scala auto-build like Python?

Mohamed Bana-6
In reply to this post by Russ P.
have you looked at SBT?  it's fantastic.

% xsbt
Project does not exist, create new project? (y/N/s) y
Name: a
Organization: a
Version [1.0]:
Scala version [2.7.5]:
sbt version [0.6.0]:
Getting Scala 2.7.5 ...
:: retrieving :: org.scala-tools.sbt#boot-scala
    confs: [default]
    2 artifacts copied, 0 already retrieved (9831kB/355ms)
Getting org.scala-tools.sbt sbt_2.7.5 0.6.0 ...
:: retrieving :: org.scala-tools.sbt#boot-app
    confs: [default]
    13 artifacts copied, 0 already retrieved (13451kB/258ms)
[success] Successfully initialized directory structure.
[info] Building project a 1.0 against Scala 2.7.5
[info]    using sbt.DefaultProject with sbt 0.6.0 and Scala 2.7.5
> ~compile
[info]
[info] == compile ==
[info]   Source analysis: 0 new/modified, 0 indirectly invalidated, 0 removed.
[info] Compiling main sources...
[info] Nothing to compile.
[info]   Post-analysis: 0 classes.
[info] == compile ==
[success] Successful.
[info]
[info] Total time: 0 s
Waiting for source changes... (press enter to interrupt)




 —Mohamed

On 19/12/09 23:47, Russ Paielli wrote:
I'm trying to migrate over from Python to Scala. I recently looked into build tools for Scala. It appears that buildr is the way to go, but as I started reading up on it, I started wondering why I should even need to bother with a build tool. I'm an aerospace engineer, so I may be naive about this, but one of the great features about Python is that you never need to explicitly build anything. Everything just happens automagically (including the generation of .pyc files when they need to be created or updated). Why can't Scala work that way too?

Yes, I realize that you may want to compile explicitly, so that capability obviously should not be eliminated, but I personally never need or want to do that. I prefer to just let things get built automagically as needed.

Russ P.

--
http://RussP.us


Reply | Threaded
Open this post in threaded view
|

Re: Why can't Scala auto-build like Python?

Russ P.
In reply to this post by Warren Henning
Thanks for the explanation, but I still don't understand why Scala can't automatically build. Python automatically determines when .pyc files are out of date (or nonexistent) and builds them. Why can't Scala do the same for .class files? It knows what it needs, so why should I have to tell it? Couldn't it be a compiler option or something?

Russ P.


On Sat, Dec 19, 2009 at 5:59 PM, Warren Henning <[hidden email]> wrote:
Neither of the previous responses addressed the OP.

Scala has a different execution model from Python. It can be run
interpreted but normally it is first compiled to Java bytecodes. Scala
was designed from the beginning to have maximal Java interop, so it
shares the same compilation model. This has certain benefits: without
special libraries like numpy, Scala will almost always be much faster
than Python.

Scala and Python aren't better or worse than one another, just
different. Use what works for you.

Warren

On Sat, Dec 19, 2009 at 3:47 PM, Russ Paielli <[hidden email]> wrote:
> I'm trying to migrate over from Python to Scala. I recently looked into
> build tools for Scala. It appears that buildr is the way to go, but as I
> started reading up on it, I started wondering why I should even need to
> bother with a build tool. I'm an aerospace engineer, so I may be naive about
> this, but one of the great features about Python is that you never need to
> explicitly build anything. Everything just happens automagically (including
> the generation of .pyc files when they need to be created or updated). Why
> can't Scala work that way too?
>
> Yes, I realize that you may want to compile explicitly, so that capability
> obviously should not be eliminated, but I personally never need or want to
> do that. I prefer to just let things get built automagically as needed.
>
> Russ P.
>
> --
> http://RussP.us
>
>



--
http://RussP.us
Reply | Threaded
Open this post in threaded view
|

Re: Why can't Scala auto-build like Python?

Donald McLean-3
Normally with Java and Scala, the user gets the object files, already
compiled. It's, perhaps, less convenient in development but I suppose
that you might be able to create a custom class loader that auto
compiles at need.

On Sat, Dec 19, 2009 at 11:01 PM, Russ Paielli <[hidden email]> wrote:
> Thanks for the explanation, but I still don't understand why Scala can't
> automatically build. Python automatically determines when .pyc files are out
> of date (or nonexistent) and builds them. Why can't Scala do the same for
> .class files? It knows what it needs, so why should I have to tell it?
> Couldn't it be a compiler option or something?
--
Family photographs are a critical legacy for
ourselves and our descendants. Protect that
legacy with a digital backup and recovery plan.

Join the photo preservation advocacy Facebook group:
http://www.facebook.com/home.php?ref=logo#/group.php?gid=148274709288
dpp
Reply | Threaded
Open this post in threaded view
|

Re: Why can't Scala auto-build like Python?

dpp
In reply to this post by Russ P.


On Sat, Dec 19, 2009 at 8:01 PM, Russ Paielli <[hidden email]> wrote:
Thanks for the explanation, but I still don't understand why Scala can't automatically build. Python automatically determines when .pyc files are out of date (or nonexistent) and builds them. Why can't Scala do the same for .class files? It knows what it needs, so why should I have to tell it? Couldn't it be a compiler option or something?

Scala references classes.  There is not a one-to-one correspondence between source code files and class names.  Thus, it's not possible to determine what source code file to load when a particular class is referenced.

Further, Scala has a statically enforced type system.  Thus, in order to determine if a particular method exists on a given class that is referenced in another class, one would have to load and compile the referenced class which will reference other classes, etc., so you're going to wind up loading many classes in order to load the source code of a single class and make sure that the loaded class is correct within the bounds of Scala's static type system.

So, even if you could map from class name to source file, you would still go through the same compilation process on many many classes when you load the first class.

 

Russ P.



On Sat, Dec 19, 2009 at 5:59 PM, Warren Henning <[hidden email]> wrote:
Neither of the previous responses addressed the OP.

Scala has a different execution model from Python. It can be run
interpreted but normally it is first compiled to Java bytecodes. Scala
was designed from the beginning to have maximal Java interop, so it
shares the same compilation model. This has certain benefits: without
special libraries like numpy, Scala will almost always be much faster
than Python.

Scala and Python aren't better or worse than one another, just
different. Use what works for you.

Warren

On Sat, Dec 19, 2009 at 3:47 PM, Russ Paielli <[hidden email]> wrote:
> I'm trying to migrate over from Python to Scala. I recently looked into
> build tools for Scala. It appears that buildr is the way to go, but as I
> started reading up on it, I started wondering why I should even need to
> bother with a build tool. I'm an aerospace engineer, so I may be naive about
> this, but one of the great features about Python is that you never need to
> explicitly build anything. Everything just happens automagically (including
> the generation of .pyc files when they need to be created or updated). Why
> can't Scala work that way too?
>
> Yes, I realize that you may want to compile explicitly, so that capability
> obviously should not be eliminated, but I personally never need or want to
> do that. I prefer to just let things get built automagically as needed.
>
> Russ P.
>
> --
> http://RussP.us
>
>



--
http://RussP.us



--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Surf the harmonics
Reply | Threaded
Open this post in threaded view
|

Re: Why can't Scala auto-build like Python?

Randall R Schulz-2
In reply to this post by Russ P.
On Saturday December 19 2009, Russ Paielli wrote:
> Thanks for the explanation, but I still don't understand why Scala
> can't automatically build. Python automatically determines when .pyc
> files are out of date (or nonexistent) and builds them. Why can't
> Scala do the same for .class files? It knows what it needs, so why
> should I have to tell it? Couldn't it be a compiler option or
> something?
>
> Russ P.

One might well ask, why can't people trim unnecessary quoted material in
their email replies?

Anyway, SBT has a mode that autonomously monitors source files watching
for them to be modified and when it detects their mod time has changed,
recompiles as necessary.


Randall Schulz
Reply | Threaded
Open this post in threaded view
|

Re: Why can't Scala auto-build like Python?

Daniel Sobral
In reply to this post by Russ P.
Because Scala is not a build tool, it is a compiler.

There's plenty of automatic compilation around. You have it with Maven, you have it with SBT, you have it with Eclipse, you have it with Netbeans, you have it with IntelliJ, you have it with Play framework... 

On Sun, Dec 20, 2009 at 2:01 AM, Russ Paielli <[hidden email]> wrote:
Thanks for the explanation, but I still don't understand why Scala can't automatically build. Python automatically determines when .pyc files are out of date (or nonexistent) and builds them. Why can't Scala do the same for .class files? It knows what it needs, so why should I have to tell it? Couldn't it be a compiler option or something?

Russ P.



On Sat, Dec 19, 2009 at 5:59 PM, Warren Henning <[hidden email]> wrote:
Neither of the previous responses addressed the OP.

Scala has a different execution model from Python. It can be run
interpreted but normally it is first compiled to Java bytecodes. Scala
was designed from the beginning to have maximal Java interop, so it
shares the same compilation model. This has certain benefits: without
special libraries like numpy, Scala will almost always be much faster
than Python.

Scala and Python aren't better or worse than one another, just
different. Use what works for you.

Warren

On Sat, Dec 19, 2009 at 3:47 PM, Russ Paielli <[hidden email]> wrote:
> I'm trying to migrate over from Python to Scala. I recently looked into
> build tools for Scala. It appears that buildr is the way to go, but as I
> started reading up on it, I started wondering why I should even need to
> bother with a build tool. I'm an aerospace engineer, so I may be naive about
> this, but one of the great features about Python is that you never need to
> explicitly build anything. Everything just happens automagically (including
> the generation of .pyc files when they need to be created or updated). Why
> can't Scala work that way too?
>
> Yes, I realize that you may want to compile explicitly, so that capability
> obviously should not be eliminated, but I personally never need or want to
> do that. I prefer to just let things get built automagically as needed.
>
> Russ P.
>
> --
> http://RussP.us
>
>



--
http://RussP.us



--
Daniel C. Sobral

I travel to the future all the time.
Reply | Threaded
Open this post in threaded view
|

Re: Why can't Scala auto-build like Python?

Alex Boisvert-2
In reply to this post by Russ P.
All good comments from other posters.  I'll mention in passing that continuous compilation will be part of Buildr's next version (1.4.0) and is currently available as patch/branch on Github.

alex


On Sat, Dec 19, 2009 at 3:47 PM, Russ Paielli <[hidden email]> wrote:
I'm trying to migrate over from Python to Scala. I recently looked into build tools for Scala. It appears that buildr is the way to go, but as I started reading up on it, I started wondering why I should even need to bother with a build tool. I'm an aerospace engineer, so I may be naive about this, but one of the great features about Python is that you never need to explicitly build anything. Everything just happens automagically (including the generation of .pyc files when they need to be created or updated). Why can't Scala work that way too?

Yes, I realize that you may want to compile explicitly, so that capability obviously should not be eliminated, but I personally never need or want to do that. I prefer to just let things get built automagically as needed.

Russ P.

--
http://RussP.us



Reply | Threaded
Open this post in threaded view
|

Re: Why can't Scala auto-build like Python?

Aaron Harnly-2-2
In reply to this post by Daniel Sobral
On Sun, Dec 20, 2009 at 2:01 AM, Russ Paielli <[hidden email]> wrote:
Thanks for the explanation, but I still don't understand why Scala can't automatically build. Python automatically determines when .pyc files are out of date (or nonexistent) and builds them. Why can't Scala do the same for .class files? It knows what it needs, so why should I have to tell it? Couldn't it be a compiler option or something?

I haven’t seen mentioned the -savecompiled option to the `scala’ executable:

       -savecompiled
              Save this compiled version of scripts in order to speed up  later  executions  of  the
              same  script.   When running a script, save the compiled version of in a file with the
              same name as the script but with an extension of .jar.  On subsequent runs of the same
              script, the pre-compiled .jar file will be used if it is newer than the script file.

which seems pretty well along the lines of what Russ has in mind.



Reply | Threaded
Open this post in threaded view
|

Re: Why can't Scala auto-build like Python?

Russel Winder-2
In reply to this post by Daniel Sobral
On Sat, 2009-12-19 at 23:10 -0200, Daniel Sobral wrote:
> Use either maven or sbt. Maven has a mvn scala::cc, which will keep
> compiling everything. SBT has something similar.

Or Gradle -- it now has a Scala plugin.

>
> On Sat, Dec 19, 2009 at 9:47 PM, Russ Paielli <[hidden email]>
> wrote:
>         I'm trying to migrate over from Python to Scala. I recently
>         looked into build tools for Scala. It appears that buildr is
>         the way to go, but as I started reading up on it, I started
>         wondering why I should even need to bother with a build tool.
>         I'm an aerospace engineer, so I may be naive about this, but
>         one of the great features about Python is that you never need
>         to explicitly build anything. Everything just happens
>         automagically (including the generation of .pyc files when
>         they need to be created or updated). Why can't Scala work that
>         way too?
>        
>         Yes, I realize that you may want to compile explicitly, so
>         that capability obviously should not be eliminated, but I
>         personally never need or want to do that. I prefer to just let
>         things get built automagically as needed.
>        
>         Russ P.
>        
>         --
>         http://RussP.us
>        
>
>
>
> --
> Daniel C. Sobral
>
> I travel to the future all the time.

--
Russel.
=============================================================================
Dr Russel Winder      Partner
                                            xmpp: [hidden email]
Concertant LLP        t: +44 20 7585 2200, +44 20 7193 9203
41 Buckmaster Road,   f: +44 8700 516 084   voip: sip:[hidden email]
London SW11 1EN, UK   m: +44 7770 465 077   skype: russel_winder

signature.asc (204 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Why can't Scala auto-build like Python?

Russ P.
In reply to this post by dpp
Thanks for the explanation. I played around with Ada a few years ago, and I seem to recall that the Ada compiler was part of a comprehensive build system that eliminated the need for "make" or any other build tool. To my way of thinking, that gave it a more complete and "solid" feel than if some third-party program was needed. If that is not possible in Scala or Java, I think that's a shame.

Let me just make a suggestion. If Scala requires a separate build tool that cannot be properly integrated with the compiler, then why not at least provide a default build tool as part of the standard Scala "distribution"? When someone is first starting with Scala (or any language), they don't want to spend time researching which build tool to use, then reading up on how to install and use it. They just want to start programming. If someone wants to use another build tool, they would still be free to do so, but if someone just wants immediate access to one that works, he should have it, without having to find one somewhere "out there."

By the way, having a choice of 37 different build tools is just confusing when all you want is one that works well and is well designed and supported. That's what I think, anyway.

Russ P.


On Sat, Dec 19, 2009 at 9:07 PM, David Pollak <[hidden email]> wrote:


On Sat, Dec 19, 2009 at 8:01 PM, Russ Paielli <[hidden email]> wrote:
Thanks for the explanation, but I still don't understand why Scala can't automatically build. Python automatically determines when .pyc files are out of date (or nonexistent) and builds them. Why can't Scala do the same for .class files? It knows what it needs, so why should I have to tell it? Couldn't it be a compiler option or something?

Scala references classes.  There is not a one-to-one correspondence between source code files and class names.  Thus, it's not possible to determine what source code file to load when a particular class is referenced.

Further, Scala has a statically enforced type system.  Thus, in order to determine if a particular method exists on a given class that is referenced in another class, one would have to load and compile the referenced class which will reference other classes, etc., so you're going to wind up loading many classes in order to load the source code of a single class and make sure that the loaded class is correct within the bounds of Scala's static type system.

So, even if you could map from class name to source file, you would still go through the same compilation process on many many classes when you load the first class.

Reply | Threaded
Open this post in threaded view
|

Re: Why can't Scala auto-build like Python?

Bernd Johannes
Am Montag, 21. Dezember 2009 01:54:51 schrieb Russ Paielli:
[...]
> Let me just make a suggestion. If Scala requires a separate build tool that
> cannot be properly integrated with the compiler, then why not at least
> provide a default build tool as part of the standard Scala "distribution"?
> When someone is first starting with Scala (or any language), they don't
>  want to spend time researching which build tool to use, then reading up on
>  how to install and use it. They just want to start programming. If someone
>  wants to use another build tool, they would still be free to do so, but if
>  someone just wants immediate access to one that works, he should have it,
>  without having to find one somewhere "out there."

I went through the same experience. It has had a bad and a good side:
bad:
- I spent a lot of time (compared to the remaining "programming time") looking
for some tools to help me on my way to scala
- It was frustrating to some extend and nearly turned me away from scala
(partially my fault: I tried to start with scala 2.8 which was a bad idea at
that time)
good:
- I was forced to take a look at some of them (buildr, maven, eclipse, sbt)
and found the one to suit my needs (sbt in my case). If something had been
prebundled I would probably never have looked for something different.

But I agree - it would be quite nice to have a bundle selection. Sort of
"scala installer with either eclipse or sbt or maven...". But I suppose that
this kind of "service distributions" will emerge as scala gets a wider
adoption.

> By the way, having a choice of 37 different build tools is just confusing
> when all you want is one that works well and is well designed and
>  supported. That's what I think, anyway.

While initially confusing and distracting I think it is a necessary step of
language ecosystem "evolution". The "fitter" tools will survive and prosper.
Some will find their specific niches - the rest will vanish (and their authors
hopefully joining in their forces and expertise to some remaining or new
challenges).

Just my opinion.
Greetings Bernd
dpp
Reply | Threaded
Open this post in threaded view
|

Re: Why can't Scala auto-build like Python?

dpp
In reply to this post by Russ P.


On Sun, Dec 20, 2009 at 4:54 PM, Russ Paielli <[hidden email]> wrote:
Thanks for the explanation. I played around with Ada a few years ago, and I seem to recall that the Ada compiler was part of a comprehensive build system that eliminated the need for "make" or any other build tool. To my way of thinking, that gave it a more complete and "solid" feel than if some third-party program was needed. If that is not possible in Scala or Java, I think that's a shame.

Let me just make a suggestion. If Scala requires a separate build tool that cannot be properly integrated with the compiler, then why not at least provide a default build tool as part of the standard Scala "distribution"? When someone is first starting with Scala (or any language), they don't want to spend time researching which build tool to use, then reading up on how to install and use it. They just want to start programming. If someone wants to use another build tool, they would still be free to do so, but if someone just wants immediate access to one that works, he should have it, without having to find one somewhere "out there."

By the way, having a choice of 37 different build tools is just confusing when all you want is one that works well and is well designed and supported. That's what I think, anyway.

Lift apps use Maven by default.  We only support build-related issues in Maven.  We get kicked in the teeth regularly for being "Maven bigots."  At the end of the day, there's no optimal situation.  However, the JVM eco-system is rich, like the editor eco-system.  So, you may choose "something obvious" (sbt is the most obvious to me) and use it until it no longer works for you.  That day may never come (I still use Emacs).  Or you may find that Ant, Maven, Buildr, etc. does a better job for your use case.

But, at the end of the day, choice is a curse for those who want a simple path.  A simple limited path is a curse for those who have a need for something off that path.
 

Russ P.



On Sat, Dec 19, 2009 at 9:07 PM, David Pollak <[hidden email]> wrote:


On Sat, Dec 19, 2009 at 8:01 PM, Russ Paielli <[hidden email]> wrote:
Thanks for the explanation, but I still don't understand why Scala can't automatically build. Python automatically determines when .pyc files are out of date (or nonexistent) and builds them. Why can't Scala do the same for .class files? It knows what it needs, so why should I have to tell it? Couldn't it be a compiler option or something?

Scala references classes.  There is not a one-to-one correspondence between source code files and class names.  Thus, it's not possible to determine what source code file to load when a particular class is referenced.

Further, Scala has a statically enforced type system.  Thus, in order to determine if a particular method exists on a given class that is referenced in another class, one would have to load and compile the referenced class which will reference other classes, etc., so you're going to wind up loading many classes in order to load the source code of a single class and make sure that the loaded class is correct within the bounds of Scala's static type system.

So, even if you could map from class name to source file, you would still go through the same compilation process on many many classes when you load the first class.




--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Surf the harmonics
Reply | Threaded
Open this post in threaded view
|

Re: Why can't Scala auto-build like Python?

Job Honig
I am old enough to have used Ada 83 and Ada 95 quite a lot.  I got caught
by surprise as I discovered that Java compilation is not nearly as straight-
forward as what I had gotten used to: complete dependency analysis.  
Same for Scala (of course).

The net result was that I ended op with outdated class files even though
the compiler thought that everything had been brought up-to-date.  My
standard solution is to do a "mvn clean"  BEFORE EVERY RECOMPILE.
Hardly efficient, but the closest I can get to what Ada environments used
to offer in long forgotten times.

And yes, I think that this should be part of a tool specification, as it used
to be some 30 years ago ;-)  But then, we don't always progress, as you
can observe in Europe now where everything gets to a grinding halt under
circumstances that were also quite common some 30 yers ago ;-)

Best,

Job Honig

> On Sun, Dec 20, 2009 at 4:54 PM, Russ Paielli <[hidden email]>wrote:
> > Thanks for the explanation. I played around with Ada a few years ago, and
> > I seem to recall that the Ada compiler was part of a comprehensive build
> > system that eliminated the need for "make" or any other build tool. To my
> > way of thinking, that gave it a more complete and "solid" feel than if
> > some third-party program was needed. If that is not possible in Scala or
> > Java, I think that's a shame.
> >
> > Let me just make a suggestion. If Scala requires a separate build tool
> > that cannot be properly integrated with the compiler, then why not at
> > least provide a default build tool as part of the standard Scala
> > "distribution"? When someone is first starting with Scala (or any
> > language), they don't want to spend time researching which build tool to
> > use, then reading up on how to install and use it. They just want to
> > start programming. If someone wants to use another build tool, they would
> > still be free to do so, but if someone just wants immediate access to one
> > that works, he should have it, without having to find one somewhere "out
> > there."
> >
> > By the way, having a choice of 37 different build tools is just confusing
> > when all you want is one that works well and is well designed and
> > supported. That's what I think, anyway.
>
> Lift apps use Maven by default.  We only support build-related issues in
> Maven.  We get kicked in the teeth regularly for being "Maven bigots."  At
> the end of the day, there's no optimal situation.  However, the JVM
> eco-system is rich, like the editor eco-system.  So, you may choose
> "something obvious" (sbt is the most obvious to me) and use it until it no
> longer works for you.  That day may never come (I still use Emacs).  Or you
> may find that Ant, Maven, Buildr, etc. does a better job for your use case.
>
> But, at the end of the day, choice is a curse for those who want a simple
> path.  A simple limited path is a curse for those who have a need for
> something off that path.
>
> > Russ P.
> >
> >
> >
> > On Sat, Dec 19, 2009 at 9:07 PM, David Pollak <
> >
> > [hidden email]> wrote:
> >> On Sat, Dec 19, 2009 at 8:01 PM, Russ Paielli
<[hidden email]>wrote:

> >>> Thanks for the explanation, but I still don't understand why Scala
> >>> can't automatically build. Python automatically determines when .pyc
> >>> files are out of date (or nonexistent) and builds them. Why can't Scala
> >>> do the same for .class files? It knows what it needs, so why should I
> >>> have to tell it? Couldn't it be a compiler option or something?
> >>
> >> Scala references classes.  There is not a one-to-one correspondence
> >> between source code files and class names.  Thus, it's not possible to
> >> determine what source code file to load when a particular class is
> >> referenced.
> >>
> >> Further, Scala has a statically enforced type system.  Thus, in order to
> >> determine if a particular method exists on a given class that is
> >> referenced in another class, one would have to load and compile the
> >> referenced class which will reference other classes, etc., so you're
> >> going to wind up loading many classes in order to load the source code
> >> of a single class and make sure that the loaded class is correct within
> >> the bounds of Scala's static type system.
> >>
> >> So, even if you could map from class name to source file, you would
> >> still go through the same compilation process on many many classes when
> >> you load the first class.

Reply | Threaded
Open this post in threaded view
|

Re: Why can't Scala auto-build like Python?

Ishaaq Chandy
What about situations where you don't have all your dependencies up front? In some cases your dependencies haven't even been conceived of yet, not even written. For e.g., a pluggable system with third party plugin developers.

No, I much prefer being able to bind something in late, it is much more powerful. However, I can see how, for simple applications that don't need such power it could turn tedious.

I think David Pollack hit the nail in the head though with this:
"But, at the end of the day, choice is a curse for those who want a simple path.  A simple limited path is a curse for those who have a need for something off that path".

Me? I prefer the extra power that comes with choice. Even if the initial learning curve is painful.

Ishaaq



2009/12/22 Job Honig <[hidden email]>
I am old enough to have used Ada 83 and Ada 95 quite a lot.  I got caught
by surprise as I discovered that Java compilation is not nearly as straight-
forward as what I had gotten used to: complete dependency analysis.
Same for Scala (of course).

The net result was that I ended op with outdated class files even though
the compiler thought that everything had been brought up-to-date.  My
standard solution is to do a "mvn clean"  BEFORE EVERY RECOMPILE.
Hardly efficient, but the closest I can get to what Ada environments used
to offer in long forgotten times.

And yes, I think that this should be part of a tool specification, as it used
to be some 30 years ago ;-)  But then, we don't always progress, as you
can observe in Europe now where everything gets to a grinding halt under
circumstances that were also quite common some 30 yers ago ;-)

Best,

Job Honig

> On Sun, Dec 20, 2009 at 4:54 PM, Russ Paielli <[hidden email]>wrote:
> > Thanks for the explanation. I played around with Ada a few years ago, and
> > I seem to recall that the Ada compiler was part of a comprehensive build
> > system that eliminated the need for "make" or any other build tool. To my
> > way of thinking, that gave it a more complete and "solid" feel than if
> > some third-party program was needed. If that is not possible in Scala or
> > Java, I think that's a shame.
> >
> > Let me just make a suggestion. If Scala requires a separate build tool
> > that cannot be properly integrated with the compiler, then why not at
> > least provide a default build tool as part of the standard Scala
> > "distribution"? When someone is first starting with Scala (or any
> > language), they don't want to spend time researching which build tool to
> > use, then reading up on how to install and use it. They just want to
> > start programming. If someone wants to use another build tool, they would
> > still be free to do so, but if someone just wants immediate access to one
> > that works, he should have it, without having to find one somewhere "out
> > there."
> >
> > By the way, having a choice of 37 different build tools is just confusing
> > when all you want is one that works well and is well designed and
> > supported. That's what I think, anyway.
>
> Lift apps use Maven by default.  We only support build-related issues in
> Maven.  We get kicked in the teeth regularly for being "Maven bigots."  At
> the end of the day, there's no optimal situation.  However, the JVM
> eco-system is rich, like the editor eco-system.  So, you may choose
> "something obvious" (sbt is the most obvious to me) and use it until it no
> longer works for you.  That day may never come (I still use Emacs).  Or you
> may find that Ant, Maven, Buildr, etc. does a better job for your use case.
>
> But, at the end of the day, choice is a curse for those who want a simple
> path.  A simple limited path is a curse for those who have a need for
> something off that path.
>
> > Russ P.
> >
> >
> >
> > On Sat, Dec 19, 2009 at 9:07 PM, David Pollak <
> >
> > [hidden email]> wrote:
> >> On Sat, Dec 19, 2009 at 8:01 PM, Russ Paielli
<[hidden email]>wrote:
> >>> Thanks for the explanation, but I still don't understand why Scala
> >>> can't automatically build. Python automatically determines when .pyc
> >>> files are out of date (or nonexistent) and builds them. Why can't Scala
> >>> do the same for .class files? It knows what it needs, so why should I
> >>> have to tell it? Couldn't it be a compiler option or something?
> >>
> >> Scala references classes.  There is not a one-to-one correspondence
> >> between source code files and class names.  Thus, it's not possible to
> >> determine what source code file to load when a particular class is
> >> referenced.
> >>
> >> Further, Scala has a statically enforced type system.  Thus, in order to
> >> determine if a particular method exists on a given class that is
> >> referenced in another class, one would have to load and compile the
> >> referenced class which will reference other classes, etc., so you're
> >> going to wind up loading many classes in order to load the source code
> >> of a single class and make sure that the loaded class is correct within
> >> the bounds of Scala's static type system.
> >>
> >> So, even if you could map from class name to source file, you would
> >> still go through the same compilation process on many many classes when
> >> you load the first class.


Reply | Threaded
Open this post in threaded view
|

Re: Why can't Scala auto-build like Python?

Christian Szegedy-3
In reply to this post by Job Honig
AFAIK, sbt solves the problem of outdated class files for almost every
practical scenarios. I am not completely sure though, I remove class
files if I want to go for 100% sure, but since using sbt I have never
run into problems anymore.

On 12/21/09, Job Honig <[hidden email]> wrote:

> I am old enough to have used Ada 83 and Ada 95 quite a lot.  I got caught
>  by surprise as I discovered that Java compilation is not nearly as straight-
>  forward as what I had gotten used to: complete dependency analysis.
>  Same for Scala (of course).
>
>  The net result was that I ended op with outdated class files even though
>  the compiler thought that everything had been brought up-to-date.  My
>  standard solution is to do a "mvn clean"  BEFORE EVERY RECOMPILE.
>  Hardly efficient, but the closest I can get to what Ada environments used
>  to offer in long forgotten times.
>
>  And yes, I think that this should be part of a tool specification, as it used
>  to be some 30 years ago ;-)  But then, we don't always progress, as you
>  can observe in Europe now where everything gets to a grinding halt under
>  circumstances that were also quite common some 30 yers ago ;-)
>
>  Best,
>
>
>  Job Honig
>
>
>  > On Sun, Dec 20, 2009 at 4:54 PM, Russ Paielli <[hidden email]>wrote:
>  > > Thanks for the explanation. I played around with Ada a few years ago, and
>  > > I seem to recall that the Ada compiler was part of a comprehensive build
>  > > system that eliminated the need for "make" or any other build tool. To my
>  > > way of thinking, that gave it a more complete and "solid" feel than if
>  > > some third-party program was needed. If that is not possible in Scala or
>  > > Java, I think that's a shame.
>  > >
>  > > Let me just make a suggestion. If Scala requires a separate build tool
>  > > that cannot be properly integrated with the compiler, then why not at
>  > > least provide a default build tool as part of the standard Scala
>  > > "distribution"? When someone is first starting with Scala (or any
>  > > language), they don't want to spend time researching which build tool to
>  > > use, then reading up on how to install and use it. They just want to
>  > > start programming. If someone wants to use another build tool, they would
>  > > still be free to do so, but if someone just wants immediate access to one
>  > > that works, he should have it, without having to find one somewhere "out
>  > > there."
>  > >
>  > > By the way, having a choice of 37 different build tools is just confusing
>  > > when all you want is one that works well and is well designed and
>  > > supported. That's what I think, anyway.
>  >
>  > Lift apps use Maven by default.  We only support build-related issues in
>  > Maven.  We get kicked in the teeth regularly for being "Maven bigots."  At
>  > the end of the day, there's no optimal situation.  However, the JVM
>  > eco-system is rich, like the editor eco-system.  So, you may choose
>  > "something obvious" (sbt is the most obvious to me) and use it until it no
>  > longer works for you.  That day may never come (I still use Emacs).  Or you
>  > may find that Ant, Maven, Buildr, etc. does a better job for your use case.
>  >
>  > But, at the end of the day, choice is a curse for those who want a simple
>  > path.  A simple limited path is a curse for those who have a need for
>  > something off that path.
>  >
>  > > Russ P.
>  > >
>  > >
>  > >
>  > > On Sat, Dec 19, 2009 at 9:07 PM, David Pollak <
>  > >
>  > > [hidden email]> wrote:
>  > >> On Sat, Dec 19, 2009 at 8:01 PM, Russ Paielli
>  <[hidden email]>wrote:
>  > >>> Thanks for the explanation, but I still don't understand why Scala
>  > >>> can't automatically build. Python automatically determines when .pyc
>  > >>> files are out of date (or nonexistent) and builds them. Why can't Scala
>  > >>> do the same for .class files? It knows what it needs, so why should I
>  > >>> have to tell it? Couldn't it be a compiler option or something?
>  > >>
>  > >> Scala references classes.  There is not a one-to-one correspondence
>  > >> between source code files and class names.  Thus, it's not possible to
>  > >> determine what source code file to load when a particular class is
>  > >> referenced.
>  > >>
>  > >> Further, Scala has a statically enforced type system.  Thus, in order to
>  > >> determine if a particular method exists on a given class that is
>  > >> referenced in another class, one would have to load and compile the
>  > >> referenced class which will reference other classes, etc., so you're
>  > >> going to wind up loading many classes in order to load the source code
>  > >> of a single class and make sure that the loaded class is correct within
>  > >> the bounds of Scala's static type system.
>  > >>
>  > >> So, even if you could map from class name to source file, you would
>  > >> still go through the same compilation process on many many classes when
>  > >> you load the first class.
>
>
12