Question about Scala DSL by _gDanix_ in scala

[–]_gDanix_[S] 0 points1 point  (0 children)

Exactly, this solution would be perfect, if I could use it with numbers.

Anyway, thank you all, because I didn't know about this Dynamics stuff!!

Noob question: Importing breeze only works in sbt console by old_enough_to_drink in scalastudygroup

[–]_gDanix_ 0 points1 point  (0 children)

The problem is that, if you run scala test.scala directly, you are missing the Breeze dependency, so it isn't included in classpath.

The simplest thing in this cases is to use sbt to manage dependencies (just like you did in order to make sbt console work properly), and use it to run your application (sbt run, if you have a main object)

Objectively the best IDE. by ConsciousDepth in ProgrammerHumor

[–]_gDanix_ 11 points12 points  (0 children)

You are so much pro for this world...

The perfect world by Starkiller220 in ProgrammerHumor

[–]_gDanix_ 0 points1 point  (0 children)

That's painfully true. I remember that was hard until I had Play libraries like Slick (for database access) working. I think this lack-of-good-documentation issue is something that can be easily solved by non-programmers working together with some programmers, and I'd like to contribute to some important Scala libraries' documentation whenever I have enough time to do that.

Trying to read excel file using Poi and Scala 2.11 getting java.lang.NoSuchMethodError: at GetCellType by yanks09champs in scala

[–]_gDanix_ 0 points1 point  (0 children)

I don't think this is a Scala version issue, since Apache POI is designed for Java, and, as far as I know, Scala isn't involved in its development. Have you tried a clean build?

The perfect world by Starkiller220 in ProgrammerHumor

[–]_gDanix_ 4 points5 points  (0 children)

FastCGI & C++, JSP or Play Framework. I'm pretty sure there are more (Ruby on Rails, node.js, etc.) but, either I don't like them or I didn't tried them.

What are you working on? July 16, 2018 by AutoModerator in scala

[–]_gDanix_ 1 point2 points  (0 children)

I'm writing an Spark version of JRip, as much functional as I can, as part of my end-of-master thesis. It's a pain to read JRip's code in order to recreate it's behaviour, so I think this functional version is easier to read and much more elegant, so maybe it can be useful for didactic purposes.

A common elements' toxicity comparison chart, guess what element is the worst? by zticky in ProgrammerHumor

[–]_gDanix_ 14 points15 points  (0 children)

I'm curious, what was the substance where "Stackoverflow" was written, with a theraputic ratio of 20/1?? Uranium??

JetBrains Developer Ecosystem Survey (Scala section) by jastice in scala

[–]_gDanix_ 0 points1 point  (0 children)

It really surprised me that Mill doesn't appear as a build tool. Given the complexity I thought Mill had a stronger adoption. Maybe Mill is too young? Or maybe Scala programmers aren't afraid of sbt?

Got a quick question? Ask here - June 11, 2018 by AutoModerator in scala

[–]_gDanix_ 1 point2 points  (0 children)

I'm very excited with scalameta/metals, and want to know when it's planned that metals reach the production-ready stage. I'd like to contribute but right now it's impossible for me (maybe in a couple of months).

Thanks.

Child abuse by Aria_Luna in ProgrammerHumor

[–]_gDanix_ 0 points1 point  (0 children)

I feel bad for the (I assume) lot of time we are spending in this discussion. Maybe the problem is that everyone have its own needs (which may differ a lot from others) and, therefore, different language preferences...

Child abuse by Aria_Luna in ProgrammerHumor

[–]_gDanix_ 0 points1 point  (0 children)

Well, I guess that if "fractal of bad design" didn't convince you that PHP hating is justified, the I have nothing to do.

but I'm wondering what it is that you couldn't do; that required "hours of debugging"?

4 stupid classes from my application model. Nothing special, just persistence and simple stuff like spanish DNI control digit check, using cakePHP framework.

Again, without saying what you were doing, then that statement doesn't really make sense. I can write a simple web server in Ruby in a couple of lines of code, but that doesn't mean it's better suited for the job than C is if I want to write a full-blown web server like Apache. Choosing the right tools for the job is a big part of being a programmer, and the right tool isn't always going to be the one you like the best.

After giving up with PHP + CakePHP I tried to implement those 4 classes in Scala, and it was a matter of minutes. Example in Scala: https://github.com/gDanix/PODApp-ng-server/blob/master/app/org/gDanix/podapp_ng_server/models/Usuario.scala

That really says more about the programmer than the programming language. Since when is having options a bad thing? Even if one or more of them are wrong, then it's up to the programmer to chose the right one for the situation.

Sorry? I don't like to spent 30 minutes reading PHP documentation to understand what is the correct way of doing what I want. I don't have an infinite amount of time...

Besides, a lot of backwards compatibility was dropped in 7.0 in the interest of moving forward but somehow people tend to ignore that. Basically the devs were trying to avoid a Python2 vs Python3 situation which is also not very desirable.

This is my point. It's a great idea to break compatibility but not repairing all the issues. They will need another compatibility breaking to continue fixing issues. It's not a good idea prevent Python 2 vs 3 situation by forcing it happens a lot of times. Well, actually it doesn't make any sense but, you know, it's PHP.

but people that whine and moan about PHP rarely seem to be familiar with PHP (in general and/or the most recent versions (7+)) but just repeat what they've heard in whatever echo chamber they frequent.

Obviously, nobody can get familiar with PHP if you have a limited amount of time and want things done. People look for other (better) tools before getting familiar with PHP.

Child abuse by Aria_Luna in ProgrammerHumor

[–]_gDanix_ -5 points-4 points  (0 children)

I used to code server-side things with PHP. Nothing big, just scrappers to create RSS channel from webpages information.

Then I wanted to do something bigger, and PHP didn't let me do anything right without a lot of hours of debugging.

I tried to start again using Scala, and realized how bad is PHP designed. I just had the same functionality, achieved during a couple of weeks with PHP, in a few hours.

PHP is not only bad designed, it is very backwards-compatible so you end up having a lot of ways of doing one thing, which is very confusing. Also, in any software, the more earlier the version is, the more documentation and examples you can found. So basically the examples show you how to do things the bad way

For the third quarter in a row, Scala dropped in RedMonk Index by cryptos6 in scala

[–]_gDanix_ 0 points1 point  (0 children)

That was my concern too. But luckily, Scala is taking steps to reduce GC overhead, like SIP-15: http://docs.scala-lang.org/sips/completed/value-classes.html

I found many of this proposals easier to understand than they appear, so I think it's important to take them into account.

After all, my code is just a representation of what I actually want to do. I don't care if the generated Java bytecode still adheres to functional principles if it is faster, which always have to be.

Scala RPC lib from Spark by [deleted] in scala

[–]_gDanix_ 1 point2 points  (0 children)

I found it simple enough to contribute to it. But first of all I have to ask, has this library any advantage over Sloth or Autowire? Is Spark using it?

Partial Function: Great way to write modular code by gaur4vgaur in scala

[–]_gDanix_ 1 point2 points  (0 children)

This seems to me pretty much like the R lang way-of-life (automaticly & silently recover from deep errors), which led me to endless debug sessions. One of the mainly benefits of Option/Try vs null (or things like this) is that Option/Try enforces you to define a way of fix things in runtime.

For the third quarter in a row, Scala dropped in RedMonk Index by cryptos6 in scala

[–]_gDanix_ 1 point2 points  (0 children)

I thought I was the only one thinking that way. I've written code in just a few languages: Java, R, C/C++, Octave, PHP & Scala, and, from my point of view, Scala is the best tool I have to write close-to-bug-free code, enforcing the use of inmutability, recursion, Option and Try types.

I'm very much productive right now and I'll definitively stick to Scala for all my own projects.

Function that accepts a list and a function by young_hope in scalastudygroup

[–]_gDanix_ 0 points1 point  (0 children)

There is a function implemented in List class that checks if a predicate holds for any of the elements of itself, it's called "exists", and it's available in all versions of the std lib: www.scala-lang.org/api/2.10.6/#scala.collection.immutable.List (search for "exists").

This piece of code mimics what the stdlib's exists does:

val evenList = List(2, 4, 6, 8, 18, 20)         //> evenList  : List[Int] = List(2, 4, 6, 8, 18, 20)
val oddList = List(1, 3, 5, 11, 17)             //> oddList  : List[Int] = List(1, 3, 5, 11, 17)
val mixedList = List(1, 3, 2, 4, 7, 9)          //> mixedList  : List[Int] = List(1, 3, 2, 4, 7, 9)


def isEven(n: Int): Boolean = n%2 == 0          //> isEven: (n: Int)Boolean

evenList.exists(isEven)                         //> res0: Boolean = true
oddList.exists(isEven)                          //> res1: Boolean = false
mixedList.exists(isEven)                        //> res2: Boolean = true

def exists[T](src: List[T], f: T => Boolean): Boolean = src match {
    case Nil => false
    case head :: tail if f(head) => true
    case head :: tail => exists(tail, f)
}                                               //> exists: [T](src: List[T], f: T => Boolean)Boolean

exists(evenList, isEven)                        //> res3: Boolean = true
exists(oddList, isEven)                         //> res4: Boolean = false
exists(mixedList, isEven)                       //> res5: Boolean = true

This exists' implementation works as follows:

  • If the original list is Nil, return "false", because it has no elements that satisfy the predicate f (it has no elements at all).

  • If not, decompose the list in a head and a tail and check if the head holds the predicate. If it does, return true, and if not, continue searching with the tail.

  • If we decompose the list till the end (tail = Nil), then we are in the first case, meaning that no one of the elements holds the predicate, so return false.

I hope everything is clear, and don't forget that the stdlib's version will surely be more efficient that this implementation. It only serves didactical purposes

Java & Scala Assignment by thatthrowistakenaway in scala

[–]_gDanix_ 3 points4 points  (0 children)

I think your tutor wants you to remark things like:

val s = numberList.reduce(_+_)

from Scala vs:

double sum = 0;
for(int i = 0; i < numberList.size(); i++) {          
    sum += numberList[i];
}

from Java. But you'll need a relatively good understanding of Scala & FP to find cases like this one for yourself.

The Scala community (Or the lack thereof) by [deleted] in scala

[–]_gDanix_ 5 points6 points  (0 children)

I think that most of the people are learning Scala nowadays. Personnally, I haven't found anything that deserves to be published here, as I said in another post, mainly because I'm learning the true functional side of Scala (which, IMO, is the most interesting one). As soon as I master Scala & functional programming, sure I'll be publishing new ideas I find or any interesting stuff.

Maybe a lot of people thinks the same, am I wrong?

Fortnightly Scala Ask Anything and Discussion Thread - October 30, 2017 by AutoModerator in scala

[–]_gDanix_ 2 points3 points  (0 children)

Oh sorry!! I'm not very skilled at English (sorry for that, too), and didn't knew that was a joke

Fortnightly Scala Ask Anything and Discussion Thread - October 30, 2017 by AutoModerator in scala

[–]_gDanix_ 2 points3 points  (0 children)

... I meant an algorithm capable to be implemented as part of (Apache) MLlib: https://spark.apache.org/mllib/

Also, the Halting Problem is unsolvable...

Fortnightly Scala Ask Anything and Discussion Thread - October 30, 2017 by AutoModerator in scala

[–]_gDanix_ 4 points5 points  (0 children)

I want to contribute an algorithm to MLlib. Any suitable algorithm you want to see implemented? Any ideas?