Search Results

Search found 972 results on 39 pages for 'scala'.

Page 2/39 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Historical origins of Scala implicits

    - by Frank
    Scala has been called complex with its rich feature set by many of my colleagues and some even blamed all those new features of it. While most programmers are aware of the OO-features, and at least the decent ones also know about functional programming, there is one feature in particular in Scala for which I am not aware of its historical origins. Given that a major mantra of our profession is to not reinvent the wheel, I am rather confident, that Scala does not have any actual unheard-of-before features, but I stand to be corrected on this one if necessary. To get to the actual question, while I am aware of the origins of most of Scala's features I have never seen something like its implicit declarations before. Are there other (older!) languages out there which also provide this feature? Does it make sense to distinguish the different cases of implicits (as they may originate from different sources), namely implict conversions and implicit parameters?

    Read the article

  • Is Scala ready for prime time?

    - by jayraynet
    Now that I've done a few trivial things with Scala (which I love for "hello world" and contrived applications!) I am left wondering.. part about maturity of the tools to support development, and part about general applicability. Are the toolsets ready? Is Scala appropriate for use on enterprise / business applications? Would "you" use it on a non-trivial project? Some of my (possibly unfounded) concerns would be: are the IDE and toolsets as rich as what we have to develop .net and java applications (eclipse for Scala seems limited compared to eclipse for java)? are the build / CI / testing toolsets able to effectively deal with Scala? how maintainable is the concise code that can be (encouraged?) written in the language? is it possible to find developers with Scala experience? is there enough critical mass to get help through on-line reference and books that are more than "intro" to the language? So bottom line - is the ecosystem mature enough to use now, or better off waiting to see how it evolves? EDIT: let's say "non-trivial" is a multi-year, multi-release, 10-20 developers project.

    Read the article

  • The idea of functionN in Scala / Functionaljava

    - by Luke Murphy
    From brain driven development It turns out, that every Function you’ll ever define in Scala, will become an instance of an Implementation which will feature a certain Function Trait. There is a whole bunch of that Function Traits, ranging from Function1 up to Function22. Since Functions are Objects in Scala and Scala is a statically typed language, it has to provide an appropriate type for every Function which comes with a different number of arguments. If you define a Function with two arguments, the compiler picks Function2 as the underlying type. Also, from Michael Froh's blog You need to make FunctionN classes for each number of parameters that you want? Yes, but you define the classes once and then you use them forever, or ideally they're already defined in a library (e.g. Functional Java defines classes F, F2, ..., F8, and the Scala standard library defines classes Function1, ..., Function22) So we have a list of function traits (Scala), and a list of interfaces (Functional-java) to enable us to have first class funtions. I am trying to understand exactly why this is the case. I know, in Java for example, when I write a method say, public int add(int a, int b){ return a + b; } That I cannot go ahead and write add(3,4,5); ( error would be something like : method add cannot be applied to give types ) We simply have to define an interface/trait for functions with different parameters, because of static typing?

    Read the article

  • Translate Java class with static attributes and Annotation to Scala equivalent

    - by ifischer
    I'm currently trying to "translate" the following Java class to an equivalent Scala class. It's part of a JavaEE6-application and i need it to use the JPA2 MetaModel. import javax.persistence.metamodel.SingularAttribute; import javax.persistence.metamodel.StaticMetamodel; @StaticMetamodel(Person.class) public class Person_ { public static volatile SingularAttribute<Person, String> name; } A dissassembling of the compiled class file reveals the following information for the compiled file: > javap Person_.class : public class model.Person_ extends java.lang.Object{ public static volatile javax.persistence.metamodel.SingularAttribute name; public model.Person_(); } So now i need an equivalent Scala file that has the same structure, as JPA depends on it, cause it resolves the attributes by reflection to make them accessible at runtime. So the main problem i think is that the attribute is static, but the Annotation has to be on an (Java)Object (i guess) My first naive attempt to create a Scala equivalent is the following: @StaticMetamodel(classOf[Person]) class Person_ object Person_ { @volatile var name:SingularAttribute[Person, String] = _; } But the resulting classfile is far away from the Java one, so it doesn't work. When trying to access the attributes at runtime, e.g. "Person_.firstname", it resolves to null, i think JPA can't do the right reflection magic on the compiled classfile (the Java variant resolves to an instance of org.hibernate.ejb.metamodel.SingularAttributeImpl at runtime). > javap Person_.class : public class model.Person_ extends java.lang.Object implements scala.ScalaObject{ public static final void name_$eq(javax.persistence.metamodel.SingularAttribute); public static final javax.persistence.metamodel.SingularAttribute name(); public model.Person_(); } > javap Person_$.class : public final class model.Person__$ extends java.lang.Object implements scala.ScalaObject public static final model.Person__$ MODULE$; public static {}; public javax.persistence.metamodel.SingularAttribute name(); public void name_$eq(javax.persistence.metamodel.SingularAttribute); } So now what i'd like to know is if it's possible at all to create a Scala equivalent of the Java class? It seems to me that it's absolutely not, but maybe there is a workaround or something (except just using Java, but i want my app to be in Scala where possible) Any ideas, anyone? Thanks in advance!

    Read the article

  • How to extract valid email from larger string in Scala

    - by luigi-prog
    My scala version 2.7.7 Im trying to extract an email adress from a larger string. the string itself follows no format. the code i've got: import scala.util.matching.Regex import scala.util.matching._ val Reg = """\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b""".r "yo my name is joe : [email protected]" match { case Reg(e) => println("match: " + e) case _ => println("fail") } the Regex passes in RegExBuilder but does not pass for scala. Also if there is another way to do this without regex that would be fine also. Thanks!

    Read the article

  • Stable Scala 2.8 plugin

    - by Felix
    Does anyone know if there exists a stable version of the Scala plugin for eclipse, running with Scala 2.8 (any version of scala 2.8...RC or beta or whatever). I like the fact that it compiles 10 times faster than the netbeans plugin, but it is very unstable, and auto-imports doesnt work. Also, sometimes it cant find classes when I hit "run", then I have to clean it again. This is with some random nightly build of the 2.8 eclipse scala plugin. Is there a stable version? If so, can you link me to it? Thanks in advance :)

    Read the article

  • scala 2.8 breakout

    - by oxbow_lakes
    In Scala 2.8, there is an object in scala.collection.package.scala: def breakOut[From, T, To](implicit b : CanBuildFrom[Nothing, T, To]) = new CanBuildFrom[From, T, To] { def apply(from: From) = b.apply() ; def apply() = b.apply() } I have been told that this results in: > import scala.collection.breakOut > val map : Map[Int,String] = List("London", "Paris").map(x => (x.length, x))(breakOut) map: Map[Int,String] = Map(6 -> London, 5 -> Paris) What is going on here? Why is breakOut being called as an argument to my List?

    Read the article

  • Replacing deprecated <:< Manifest type witness in Scala 2.10

    - by Josh
    Can someone point me at what I should be doing under scala 2.10 in place of this deprecated type witness on Manifest? reflect.ClassManifest.singleType(foo) <:< barManifest Honestly, my goal here is just to replace it with something that doesn't raise a deprecation warning. I'm happy to use the new reflection API. Here's the code in question in context, if that's important: https://github.com/azavea/geotrellis/blob/master/src/main/scala/geotrellis/feature/op/geometry/geometry.scala#L45

    Read the article

  • Scala puts precedence on implicit conversion over "natural" operations... Why? Is this a bug? Or am

    - by Alex R
    This simple test, of course, works as expected: scala var b = 2 b: Int = 2 scala b += 1 scala b res3: Int = 3 Now I bring this into scope: class A(var x: Int) { def +=(y:Int) { this.x += y } } implicit def int2A(i:Int) : A = new A(i) I'm defining a new class and a += operation on it. I never expected this would affect the way my regular Ints behave. But it does: scala var b:Int = 0 b: Int = 0 scala b += 1 scala b res29: Int = 0 scala b += 2 scala b res31: Int = 0 Scala seems to prefer the implicit conversion over the natural += that is already defined to Ints. That leads to several questions... Why? Is this a bug? Is it by design? Is there a work-around (other than not using "+=")? Thanks

    Read the article

  • Scala Interpreter scala.tools.nsc.interpreter.IMain Memory leak

    - by Peter
    I need to write a program using the scala interpreter to run scala code on the fly. The interpreter must be able to run an infinite amount of code without being restarted. I know that each time the method interpret() of the class scala.tools.nsc.interpreter.IMain is called, the request is stored, so the memory usage will keep going up forever. Here is the idea of what I would like to do: var interpreter = new IMain while (true) { interpreter.interpret(some code to be run on the fly) } If the method interpret() stores the request each time, is there a way to clear the buffer of stored requests? What I am trying to do now is to count the number of times the method interpret() is called then get a new instance of IMain when the number of times reaches 100, for instance. Here is my code: var interpreter = new IMain var counter = 0 while (true) { interpreter.interpret(some code to be run on the fly) counter = counter + 1 if (counter > 100) { interpreter = new IMain counter = 0 } } However, I still see that the memory usage is going up forever. It seems that the IMain instances are not garbage-collected by the JVM. Could somebody help me solve this issue? I really need to be able to keep my program running for a long time without restarting, but I cannot afford such a memory usage just for the scala interpreter. Thanks in advance, Pet

    Read the article

  • Play 2 with Scala or Java?

    - by Mik378
    I want to develop a big personal project using Play 2 Framework. I am expert with Java language but it seems, with the few articles I read that Play 2 works perfectly and especially with Scala. I've never worked with Scala but I already learned concept as closures, functional programming etc... Learning it would be interesting. I am really motivated for but I wonder if there are some people who have started coding with Play2/Java and have changed for Play2/Scala that could explain their major concrete advantages.

    Read the article

  • Scala 2.8 Actors

    - by Dave
    Hi, We're looking at using actors in our Scala code quite soon. We're also thinking of moving to Scala 2.8 in the next few weeks. We've been keeping an eye on Akka but it doesn't currently support 2.8 and plans for it have slipped from the 0.7 release to 0.8 We would like distributed, supervised actors. Is there an alternative to Akka? Or does anyone know if Akka 0.8 will definitely have 2.8 support (and when it's scheduled for)? Perhaps it's possible to just use Scala actors for the time being and switch to Akka at a later stage? Thanks, Dave

    Read the article

  • Scala simple dummy project.

    - by Lukasz Lew
    Currently my whole work cycle is: edit foo.scala fsc foo.scala && scala -cp . FooMain But my project is getting bigger and I would like to split files, make unit tests, etc. But I'm too lazy for reading sbt documentation and doing whatever needs to be done to get a sbt's "Makefile". Similarly for unit tests (there are so many frameworks, which to choose?) What would make my day is a simple zipped dummy project with a dummy unit tests using sbt. Do you know whether such thing exists?

    Read the article

  • Resources relating to Java EE and Scala

    - by Ant Kutschera
    Are there any good sites / blogs / books / articles on using Java EE together with Scala? Or indeed articles saying that it should not be done. Many Scala resources talk about using Akka and Lift. Akka solves a different domain problem than Java EE. I don't know Lift, but I assume its geared towards the web end of Java EE and doesn't replace app server containers which provide transactions, security, scalability, resource management, reliability, etc. (all those things which Java EE markets itself as being good at).

    Read the article

  • Scala Array constructor?

    - by Lukasz Lew
    scala> val a = Array [Double] (10) a: Array[Double] = Array(10.0) scala> val a = new Array [Double] (10) a: Array[Double] = Array(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) Why these two expressions have different semantics?

    Read the article

  • What are nested/unnested packages in Scala 2.8?

    - by retronym
    In Scala 2.7, I could write: package com.acme.bar class Bar . package com.acme.foo class Foo { new bar.Bar } This doesn't compile in Scala 2.8 -- however this does: package com.acme package bar class Bar . package com.acme package foo class Foo { new bar.Bar } What was the motivation for this? What is the precise meaning, with regards to scope and visibility? When should I use one form over the other?

    Read the article

  • What are nested/unnested package in Scala 2.8?

    - by retronym
    In Scala 2.7, I could write: package com.acme.bar class Bar . package com.acme.foo class Foo { new bar.Bar } This doesn't compile in Scala 2.8 -- however this does: package com.acme package bar class Bar . package com.acme package foo class Foo { new bar.Bar } What was the motivation for this? What is the precise meaning, with regards to scope and visibility? When should I use one form over the other?

    Read the article

  • scala 2.8 implict java collections conversions

    - by nablik
    I have problem with JavaConversions with 2.8 beta: import scala.collection.JavaConversions._ class Utils(dbFile : File, sep: String) extends IUtils { (...) def getFeatures() : java.util.List[String] = csv.attributes.toList } And then exception: [INFO] Utils.scala:20: error: type mismatch; [INFO] found : List[String] [INFO] required: java.util.List[String] [INFO] def getFeatures() : java.util.List[String] = csv.attributes.toList [INFO]

    Read the article

  • Have you actually convinced anybody to Scala?

    - by Lukasz Lew
    I had limited success myself. I was able to hype a few persons about Scala. But in fact none of them made a meaningful effort to try to switch (usually from Java). I would like to read both success and failure stories here. Both long tries and short ones. My goal is to find ways of presenting Scala to another person, friend, co-worker (not an audience) that will make them want to use this great language.

    Read the article

  • maven and lift using scala 2.8 : lift-mapper missing?

    - by Bjorn J
    Newbie question since I'm not up to speed using maven at all. I'm trying to use scala + lift using scala 2.8, environment is a win7 box if that matters. I create a basic project using: mvn archetype:generate -U -DarchetypeGroupId=net.liftweb -DarchetypeArtifactId=lift-archetype-basic -DarchetypeVersion=2.0-scala280-SNAPSHOT -DarchetypeRepository=http://scala-tools.org/repo-snapshots -DremoteRepositories=http://scala-tools.org/repo-snapshots -DgroupId=com.liftworkshop -DartifactId=todo -Dversion=1.0-SNAPSHOT So far so good, but then, I try to cd into my new project and do: mvn jetty:run I after quite a few downloads end up with a error like below: [ERROR] BUILD ERROR [INFO] ------------------------------------------------------------------------ [INFO] Failed to resolve artifact. Missing: ---------- 1) net.liftweb:lift-mapper:jar:2.0-scala280-SNAPSHOT Try downloading the file manually from the project website. Then, install it using the command: mvn install:install-file -DgroupId=net.liftweb -DartifactId=lift-mapper -D version=2.0-scala280-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file Alternatively, if you host your own repository you can deploy the file there: mvn deploy:deploy-file -DgroupId=net.liftweb -DartifactId=lift-mapper -Dve rsion=2.0-scala280-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -Dr epositoryId=[id] Path to dependency: 1) com.liftworkshop:todo:war:1.0-SNAPSHOT 2) net.liftweb:lift-mapper:jar:2.0-scala280-SNAPSHOT ---------- 1 required artifact is missing. for artifact: com.liftworkshop:todo:war:1.0-SNAPSHOT from the specified remote repositories: scala-tools.snapshots (http://scala-tools.org/repo-snapshots), scala-tools.releases (http://scala-tools.org/repo-releases), central (http://repo1.maven.org/maven2) Any ideas?

    Read the article

  • Adding multiple rss feeds to a script in SCALA InfoChannel Designer 5

    - by godleuf
    Okay, since it is impossible to talk to anyone on the phone or get support through Scala's "forum", I am going to take a shot and see if anyone out there is feeling my pain. I have a client that uses Scala's InfoChannel Designer and Content Manager. I have had to learn this software from scratch and I have to say it hasn't been easy. I think I am at a point where the overall design is set, but I need to implement a couple of things before I can make this happen. RSS feeds are my issue at this point. Multiple RSS feeds to be specific. I need a feed coming in for 3 areas of content: Wiki News (or equivalent), local weather and a stock ticker. I have learned how to setup a "crawl" using a script example available from Scala's file center and copying and pasting into my design. But from what I have learned first hand and through reading through other forums, you can not have a feed from 3 different sources or urls happening simultaneously. Doesn't seem like it would be an issue, but apparently it is. This small step has held up this project for far too long and I need to get it figured out. This doesn't even touch on my issue of feeding in streaming video as a background but I have gone over this in another question but with no luck thus far. If there is ANYONE out there who is in anything similar using this software, your feedback and/or suggestions would be greatly appreciated. Thanks you for allowing me to vent!

    Read the article

  • simple scala question about httpparser

    - by kula
    hi all. i'm a scala newbee. i have one question. in my code ,i try to import httpparse library like this scalac -classpath /home/kula/code/201005/kookle/lib/htmlparser.jar crawler.scala and i run this code. scala main and it tell me that java.lang.NoClassDefFoundError: org/htmlparser/Parser at FetchActor$$anonfun$act$1$$anonfun$apply$1.apply(crawler.scala:21) at FetchActor$$anonfun$act$1$$anonfun$apply$1.apply(crawler.scala:13) at scala.actors.Reaction.run(Reaction.scala:78) at scala.actors.FJTask$Wrap.run(Unknown Source) at scala.actors.FJTaskRunner.scanWhileIdling(Unknown Source) at scala.actors.FJTaskRunner.run(Unknown Source) i check the file./home/kula/code/201005/kookle/lib/htmlparser.jar and it is no problem.anyone can tell me how cause this bug?

    Read the article

  • Is the Scala 2.8 collections library a case of "the longest suicide note in history" ?

    - by oxbow_lakes
    First note the inflammatory subject title is a quotation made about the manifesto of a UK political party in the early 1980s. This question is subjective but it is a genuine question, I've made it CW and I'd like some opinions on the matter. Despite whatever my wife and coworkers keep telling me, I don't think I'm an idiot: I have a good degree in mathematics from the University of Oxford and I've been programming commercially for almost 12 years and in Scala for about a year (also commercially). I have just started to look at the Scala collections library re-implementation which is coming in the imminent 2.8 release. Those familiar with the library from 2.7 will notice that the library, from a usage perspective, has changed little. For example... > List("Paris", "London").map(_.length) res0: List[Int] List(5, 6) ...would work in either versions. The library is eminently useable: in fact it's fantastic. However, those previously unfamiliar with Scala and poking around to get a feel for the language now have to make sense of method signatures like: def map[B, That](f: A => B)(implicit bf: CanBuildFrom[Repr, B, That]): That For such simple functionality, this is a daunting signature and one which I find myself struggling to understand. Not that I think Scala was ever likely to be the next Java (or /C/C++/C#) - I don't believe its creators were aiming it at that market - but I think it is/was certainly feasible for Scala to become the next Ruby or Python (i.e. to gain a significant commercial user-base) Is this going to put people off coming to Scala? Is this going to give Scala a bad name in the commercial world as an academic plaything that only dedicated PhD students can understand? Are CTOs and heads of software going to get scared off? Was the library re-design a sensible idea? If you're using Scala commercially, are you worried about this? Are you planning to adopt 2.8 immediately or wait to see what happens? Steve Yegge once attacked Scala (mistakenly in my opinion) for what he saw as its overcomplicated type-system. I worry that someone is going to have a field day spreading fud with this API (similarly to how Josh Bloch scared the JCP out of adding closures to Java). Note - I should be clear that, whilst I believe that Josh Bloch was influential in the rejection of the BGGA closures proposal, I don't ascribe this to anything other than his honestly-held beliefs that the proposal represented a mistake.

    Read the article

  • Stuck at "Hello World" with IntelliJ IDEA 9.0.1 for Scala

    - by Alex R
    I've been using Eclipse since 2.x and and IDEs in general for over 20 years (since Turbo Pascal and Turbo C in the late '80s!). (that preamble is supposed to imply, "I'm not an idiot" ... LOL :-] ) I'm trying to use the debugger in IntelliJ 9.0.1. I've resigned myself to an old standby: class hello { def main(a: Array[String]) = println("got args: " + a) } Alas, I'm unable to get even this simple Scala example to run. I'd like to eventually put a breakpoint in it, but for now just running it would be great. I have Java 1.6u20 and the Scala plug-in 0.3.473 (January 2010). The error below summarizes my experience: What possibly could I be doing wrong? Thanks

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >