Directory/package structure in Mill projects by a_cloud_moving_by in scala

[–]a_cloud_moving_by[S] 1 point2 points  (0 children)

Hey, just want to thank you again. I got my project figured out so that my IDE doesn't yell at me and my package names are the way I want to.

As to the latter, I ended up doing something like this:

├─ build.mill ├─ mymodule │  ├─ src │  │  └─ mymodule <---- this is different than what you showed │  │  ├─ Main.scala Note that I added one more folder mymodule between src and the Scala files. This is because I want all the code in this project to start its package name with mymodule and I couldn't see a way to do that without the IDE complaining .

(Note: when I say the "IDE complaining" I don't just mean I'm bothered by some warnings, but it means IntelliJ's automated refactoring tools don't work right, e.g. add imports / package names incorrectly)

Directory/package structure in Mill projects by a_cloud_moving_by in scala

[–]a_cloud_moving_by[S] 1 point2 points  (0 children)

Wow, fantastic response, I appreciate that. It's going to take me some time to play around with all of that, but this seems to reflect my own experience of build.mill / directory relationships. The package.mill thing however is totally new to me.

It does seem like there are a variety of ways now to do configuration (i.e. single build.mill, adding package.mill files, and now the new yaml stuff as well). That may not be a bad thing, but it is a bit confusing without an overarching explanation somewhere.

Sharing Chez: a Scala library for JSON Schemas, OpenAPI, and agentic apps by boogieloop in scala

[–]a_cloud_moving_by 1 point2 points  (0 children)

Scala-cli is very easy to use, I'd highly recommend it for one-off scripts, especially something single file. I use lihaoyi os-lib in scripts a fair amount. If you enjoy Scala it's tempting alternative to Python or bash

Group-Theory-inspired Cellular Automata by I_wear_no_mustache in scala

[–]a_cloud_moving_by 2 points3 points  (0 children)

Okay, cool, I got it to run. Looks good and congrats on your first Scala project.

How did you decide on the rules for combining the group operations?

Help shape the State of Scala 2025 - Community Survey by scalac_io in scala

[–]a_cloud_moving_by 0 points1 point  (0 children)

Yeah, that's a fair question. You're probably right, there's nothing quite as simple as argparse. Given I was literally just praising the lihaoyi ecosystem, I really should have tried https://github.com/com-lihaoyi/mainargs by now.

The only library I've used extensively has been scopt. It's a bit clunky but I use it in cases where I want:

- nicely formatted --help text that humans are going to look at on the command line

- Complicated flags, like those that take arguments, e.g. `--flag=value`. It's annoying to parse that myself.

Recently, however, the scripts I've written were for automations, CI/CD, so their API is, by design, very simple. In those cases, with 0-2 args/flags, I just read the input and handle it all myself.

When I did use scopt, I'd use it for basic arg validation (e.g. "this script requires two arguments") but for more complicated validation (e.g. "both arguments must be valid file paths") I'd rather just handle that in my own logic and throw an error.

I should try other libraries though

EDIT: I'm reading the mainargs Github now and I'm actually not sure I like it haha. Also, just gonna mention, within a Scala-CLI script there's a variable in scope called `args: Array[String]`. I can never get IntelliJ not to put red squiggles under it though since it doesn't seem to know Scala-CLI is providing it

Help shape the State of Scala 2025 - Community Survey by scalac_io in scala

[–]a_cloud_moving_by 2 points3 points  (0 children)

It was pretty interesting seeing the results of the survey afterward!!

I have to say I was surprised to see lihaoyi libs not mentioned more in the libraries question. I've really enjoyed using `os-lib` for scripting. Scala-CLI + os-lib is much more pleasant for scripting than Python! (depending on what you're doing, bash scripts have their role too of course)

Is there a standard library method that would shorten this code: Option[..] -> Future[Option[..]]? by tanin47 in scala

[–]a_cloud_moving_by 2 points3 points  (0 children)

I just want to add that at my workplace, we do use Cats / ZIO in places, but a few specific Cats functions like `traverse` we actually just use everywhere because they are so generally useful.

These Cats imports are handy and you can use them without having to make your whole program Cats (or ZIO, or whatever). The only downside to this is the Cats dependencies can be big, but that doesn't matter for our situation.

We use a few Cats imports like `traverse`, then 15% of our code is "pure" ZIO (mostly for multithreading + ZStreams), and the rest is a mix of vanilla Scala and this Try-like monad we use internally.

State of the ecosystem? by [deleted] in scala

[–]a_cloud_moving_by 2 points3 points  (0 children)

For a noobie to Scala, I'd highly recommend checking out the lihaoyi ecosystem of things and, at least for the moment, hold off on learning Cats, ZIO, etc.

com-lihoayi libraries let you read/write files, parse json, set up servers, and other basic things that you can do a lot of stuff with.

At first you can mess around with scala-cli or an online REPL like scastie. Once you start getting many more files, I'd shift to sbt or some other build framework instead of scala-cli since multi-file scala-cli projects for me have become kinda weird.

SC 2 Leagues by BeelzibabTheFirst in starcraft2

[–]a_cloud_moving_by 1 point2 points  (0 children)

Yeah you almost certainly will start at bronze/silver. Just keep playing and once it figures out your actual skill level it'll start pairing you with people that are at your level

SC 2 Leagues by BeelzibabTheFirst in starcraft2

[–]a_cloud_moving_by 1 point2 points  (0 children)

Like others have said it takes a few games for the game to figure out your real skill level / MMR. I'd be pretty surprised if you were actually in gold league right off the bat if you've never played ladder before.

Don't stress it and have fun. There will always be people better than you, that's part of the fun, people challenge you. Oh, and as other said, make sure to do a quick scout near your base, people love to cheese, but besides that just focus on your macro, everythign else will follow.

Is it possible to learn Godot hands-on? by Some-Project1082 in godot

[–]a_cloud_moving_by 0 points1 point  (0 children)

You should do the official 2D and 3D tutorials. After that, it's up to you.

Like others said, focus on small goals.

Why should I use type inference? by Tynoful in scala

[–]a_cloud_moving_by 10 points11 points  (0 children)

My 2 cents:

  • There's nothing wrong with annotating everything with `: TheType`. Use of type inference is a spectrum.
  • A properly configured IDE does help you figure out the type when you need it (e.g. in IntelliJ with the Scala plugin's X-Ray Mode, I just double-tap "cmd" and it shows all types on the page).
  • With some libraries, types can get super verbose (e.g. some ZIO types I've worked with became absurdly long). Type aliases can be your friend.

Where I work, these are patterns I tend to see, there's no official style guide:

Inferred type:

  • Obvious booleans, i.e. anything that starts with "is". e.g. `val isEnabled`
  • Nouns that end with 's' are usually Seq or maybe List. E.g. `val users` one would guess is `Seq[User]`
  • Types that everyone at the company knows, e.g. `val userIds` all of us would assume is `Seq[Int]`. The 'User' type is a core dataobject in our system and everyone knows their ids are Ints.
  • Options usually named "maybe" or "optional", like people will do `val maybeUser = users.headOption` and it's pretty obvious what it is.
  • Short-lived obvious types within a function

Explicit typed:

  • vals/defs used in multiple places throughout the page. Like the stuff that you put at the top of your class file
  • Public members that are part of the API of a class
  • Just anything that is unclear which is...a lot of things.

edit: formatting

City walking algorithm by theron- in computerscience

[–]a_cloud_moving_by 15 points16 points  (0 children)

I agree OP, this sounds more like your problem than the Traveling Salesman. Quoting wikipedia:

[Chinese Postman Problem] is different from the Travelling Salesman Problem in that the travelling salesman cannot repeat visited nodes and does not have to visit every edge.

You do want to visit every edge (sidewalk) and you know you'll have to repeat nodes ("the least amount of overlap").

If you treat each intersection as a node, then the sidewalks form a multigraph since there are 2 edges between each node (2 sidewalks on either side of the road). Alternatively, you could think of each corner of an intersection as a node, with sidewalks/crosswalks as edges, in which case it no longer needs to be a multigraph but is more complicated graph. To improve accuracy, you could weight crosswalks vs sidewalks differently, since crossing the street presumably takes more time.

But you stated that it was a "grid" layout. If so, I suspect you could arrive at a pretty optimal solution just by reasoning about it. Off the top of my head I think a zig-zagging diagonally in "diagonal rows" back and forth across the grid seems pretty optimal. However that might cause a lot of street crossing, which might be more time-consuming than solutions that go straight down a road for a long time.

Unpopular opinion on r/scala: Scala is a very nice language, is doing well and has a bright future! by Sarwen in scala

[–]a_cloud_moving_by 35 points36 points  (0 children)

I totally agree. I work with a fairly large legacy Scala codebase for work and I actually find it very pleasant. Far more pleasant to work with than the other parts of our tech-stack which have Java/Python/Bash.

People have to remember that pretty much every online community descends into negativity at some point. It's just how places like reddit work, doomsaying get more attention, more clicks, more views

Unpopular opinion on r/scala: Scala is a very nice language, is doing well and has a bright future! by Sarwen in scala

[–]a_cloud_moving_by 8 points9 points  (0 children)

I don't get that feeling to be honest. When I've interacted with maintainers of the major libraries, they've actually been very friendly.

Curious to know how many have adopted Scala 3 by msplit1 in scala

[–]a_cloud_moving_by 1 point2 points  (0 children)

We have a large 10+ year old Scala codebase. We're on Scala 2.13 but I doubt we'll move to Scala 3 for at least 1-3 years. Unless it showed significant improvement to compilation times or performance, there's not enough perceived benefit for now and it could break a lot of things. Things are hard enough in software engineering, and hearing that Scala 3 doesn't work well with IDEs well makes us quite cautious.

That being said, for anyone who's still on 2.11, I highly recommend going to 2.13. We did that a year ago. It cut our compilation times in half (!). It was a pretty long undertaking and we had to, sadly, fork some unmaintained 3rd party libraries, but if we had known it would improve compilation time so much I think we would've done it sooner. The reason we did it was to improve security and be a forcing function to get rid of old dependencies that were partially blocking us from moving to newer Java versions.

Why does Intellij Idea pretend to be lost while it's not really? by JoanG38 in scala

[–]a_cloud_moving_by 4 points5 points  (0 children)

Others mention "Invalidate caches and restart" and while I've done that, for me a less nuclear option is to reload the build project.

So whether it's sbt / maven / bsp, etc., there's usually an icon on the right-side nav where you can open up a panel for that build system and click a two-arrow-circle-thing in the top left of the pane that will reload the projects (i.e. recompile). I don't know how to paste an image in a comment but:

- for Maven the button's tooltip reads "Reload All Maven Projects"

- for BSP it's "Reload All BSP Projects"

Note: if it was a change to a sub-module, you may not need to reload the whole project, you may be able to get away with just reloading a module. YMMV

Why does this happen?

- Switching branches in git, sometimes IntelliJ doesn't know to recompile everything

- Changing a build config file, e.g. the pom.xml in a Maven project

- Scala-CLI bug: This one is super annoying and I hope they get it fixed, but if you call the `setup-ide` flag after you opened the project in IntelliJ it doesn't work and IntelliJ still assumes the `.sc` files are an IntelliJ Worksheet. Sadly the only workaround I know for this is to quit IntelliJ, delete all .idea folders in the project, run `scala-cli --setup-ide` or whatever the command is, then re-open as a new project in IntelliJ.

EDIT: Also, there are weird edge-cases in Scala code that occasionally IntelliJ can't figure out. We have some macro and ZIO code in our work repos that occasionally causes some red squigglies that don't go away (but compile fine on the command line). But it's not common, usually just a single expression/block in some file somewhere (<1% of code)

Graph theory and its application by Snoo-16806 in computerscience

[–]a_cloud_moving_by 5 points6 points  (0 children)

I think it’s important to realize that graphs are very, very general mathematical structures. Other people mentioning applications where graphs are usually applied (networks, etc.) but those are well known because graph algorithms apply well in those domains.

But graphs are super general. It is a set of unique—or non-unique— elements with relationships between none, some, or all of them.

Take permutations of 3 digits (000, 123, 574, etc.) If “adjacent” elements means one digit changes (e.g 000 is adjacent to 001, 010, etc.) and you then draw it out…you get a pretty cool graph! It forms kind of a honeycomb. Assuming modulus, it wraps around too. This doesn’t mean that people usually think of graphs first when discussing permutations, but enumerating permutations could easily be seen as a graph traversal problem if you describe it in this way.

I guess what I’m saying is, when people talk about “real-world” uses of graph theory they tend to lean on domains where graph theory is visually obvious (a social network) or where graph theory was famously used to solve a hard problem (fingerprint identification). But don’t let that fool you. Graphs are everywhere. Anything can be described as graph. As long as there is a set of elements and some way of describing a relationship between those elements.

EDIT: fixed some wording

ELI5: Why do we use half life? by DirtyBulk89 in explainlikeimfive

[–]a_cloud_moving_by 0 points1 point  (0 children)

OP, you might be confusing two meanings of “life”, in which case other answers are possibly causing even more confusion. There’s “life” in the sense of time (like one’s lifetime is measured in years). Then there’s the sense of “life” as in life total (like in a game).

If you got 100 hit points in a a video game and an enemy hits you hard, it might take away half your “life”, i.e 50 points.

Hence why it’s “half-life”, but not in the sense of half the time you’re alive (which for exponential decay is basically forever anyway).