Programming

vascorsd,
@vascorsd@mastodon.social avatar

You may not like it, but hear me out...

For new code using the newer weird white space syntax you should try to configure the formatter to give you 3 spaces as the indent.

It just makes everything better. Go and try 🫣 :catPOWER:

I tried it the other day before turning the newer syntax off completely and it looked much better than 2 spaces.

:blobpeek:

vascorsd,
@vascorsd@mastodon.social avatar

@dwardoric seeing too deep nesting and the code running off the screen to the right kinda screams at you to try and simplify it earlier and to move things to other functions 🤔

vascorsd,
@vascorsd@mastodon.social avatar

@ragb it's easy to mix them. For understanding when and how to use them you need a deep understanding of what they are meant to be used for, which newbies won't know or understand earlier in their career.

It happened a lot having parameters that you want to align and variable declarations and other things, but then having the tab key not expanding automatically to spaces means that you will use it in the middle of code to try to align things accidentally and inherently things will end up mixed.

oblomov,
@oblomov@sociale.network avatar

I have a question for people with better theoretical background on and especially for developers.

Is the following pattern known and does it have a name?

I have a number of classes (call them C1, C2, etc) that all derive from the same class B. I have a superclass (template, actually) D that derives from C1, C2 etc. To have a single B, the standard solution is to go with virtual inheritance to close the diamond (so far, so good).

1/n

omalley,
@omalley@fosstodon.org avatar

@oblomov most of the newer languages (eg. or ) don’t support inheritance between classes/structs. They only support implementation of traits, which only define interface and not implementation. In general, using inheritance for implementation reuse is brittle and I like to avoid it.

oblomov,
@oblomov@sociale.network avatar

@omalley as interesting this may be, it's not really what I was asking about 8-D

vascorsd,
@vascorsd@mastodon.social avatar

I was pointed out yesterday to scodec for . It has some important things there that seem very useful and will likely use it.

It's just pretty sad that such a known, useful, stable library has most of the site with incomplete docs, broken links and incomplete released version numbers.

Example:

🫣

vascorsd,
@vascorsd@mastodon.social avatar

This library is better than official scala docs where I spent some hours the other day navigating the confusion of some Collections trying to understand the different ways I could create an ordered Map and basically giving up on the idea because I was unsure of what I should use.

I mean I eventually got the information I wanted, but it was from jumping between google, stack overflow, scala main page and a bunch of api docs.

But it didn't left with with any confidence for what I was doing.

😮‍💨

vascorsd,
@vascorsd@mastodon.social avatar

In general the official API docs are very very lacking and generally suck.

Methods have barely any description on them. There are no examples in most methods to understand them. Important methods and collections lack explanation of their characteristics related to performance, runtime, O notations of each etc. Barely describe where each is more appropriate vs others, etc.

🫣

BentiGorlich,
@BentiGorlich@wehavecookies.social avatar

It is very annoying that I think about working on mbin all the time when I am at work.

I started working on messages between users yesterday and I keep having new ideas how to implement them 😁

BentiGorlich,
@BentiGorlich@wehavecookies.social avatar

@melroy
Maybe that would be a good idea 🤔

Btw I was impressed to learn that federation for messages is not only not working it is not implemented at all 😅

melroy,
@melroy@mastodon.melroy.org avatar

@BentiGorlich It is indeed not implemented at all in kbin indeed. It never was. So if we implement this, then Mbin has another new bullet point for on the readme page ;P

vascorsd,
@vascorsd@mastodon.social avatar

And am extremely confused with some of new syntax. So if I have a enum with a case X I can't simply add a method for a specific case by just doing

enum AST
case Str(v : String) {
def newMethodIWantHere...
}

Seems very weird. Probably doing something wrong again 🤔😮‍💨

davesmith00000,
@davesmith00000@mastodon.gamedev.place avatar

@vascorsd This had me stumped for a long time, too! Here is how I think you're supposed to do it:

enum AST:  
 case Str(v: String)  
 case Num(i: Int)

object AST:  
 object Str:  
 extension (s: Str)  
 def foo: String = "value: " + s.v

AST.Str("Hello").foo  
// AST.Num(0).foo // Does not compile  
vascorsd,
@vascorsd@mastodon.social avatar

@davesmith00000 yeah that works. I ended up also using some of those extensions for the enum members as well for their companion objects. Like

extension (so: Str.type) {  
 def empty = ...  
}  

Kinda works, which is nice.

It's a little frustrating that I can't do

extension (_: Str.type) or extension (Str.type).

Extensions and enums kinda pair well with each other.

taxorubio,
@taxorubio@fosstodon.org avatar

It's one of those Mondays...

taxorubio,
@taxorubio@fosstodon.org avatar

I hereby declare war on int.

numeredevs,
@numeredevs@fosstodon.org avatar

@taxorubio Yeah, especially important, if you write files in binary mode and don't lock the bit sizes. We had that problem also during the 64 bit migration

dominucco,
@dominucco@mastodon.social avatar

JarJar is such an epic coder that he’s monitor is backwards

bcon,
@bcon@fosstodon.org avatar

@dominucco not pictured is a mirror. Jar Jar is all about his tricks… sneaky Jar Jar

hankg,

@dominucco …at least they got the fingers right for once, ironically lol…

stevensanderson,
@stevensanderson@mstdn.social avatar
vascorsd,
@vascorsd@mastodon.social avatar

Holy cow, I enabled strict equality on to see if it fixed my problems and now I have to manually add a "derives CanEqual" to every enum that I want to compare. Wth :aaaa: :welp: :wyd:

philip_schwarz,
@philip_schwarz@fosstodon.org avatar

just uploaded to https://fpilluminated.com 🚀🆕 : "A Sighting of filterA in Typelevel Rite of Passage" - based on a short extract from Rock the JVM's great video course

direct link: https://fpilluminated.com/deck/220

pbarker,
@pbarker@social.afront.org avatar

Never, ever write the words:

"I'm planning to send [the next version of my patches] in the next hour or so, assuming my tests pass."

This is actually a magic spell which will cause your tests to immediately fail with a NULL pointer dereference.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • programming
  • ngwrru68w68
  • rosin
  • GTA5RPClips
  • osvaldo12
  • love
  • Youngstown
  • slotface
  • khanakhh
  • everett
  • kavyap
  • mdbf
  • DreamBathrooms
  • thenastyranch
  • magazineikmin
  • anitta
  • InstantRegret
  • normalnudes
  • tacticalgear
  • cubers
  • ethstaker
  • modclub
  • cisconetworking
  • Durango
  • provamag3
  • tester
  • Leos
  • megavids
  • JUstTest
  • All magazines