Programming

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

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

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.

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.

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

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

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.

🫣

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:

xorn,
@xorn@mastodon.social avatar

The great thing about writing software is that after you spend 3 days figuring out a simple solution to a complex problem you're left with no evidence as to what you did with the rest of your week.

"You wrote 15 lines of code?"

"No, I wrote 4500 lines of code. Those 15 were the ones worth keeping."

leanpub,
@leanpub@mastodon.social avatar

The Ruby On Rails Interview Bible 2023: A Comprehensive Guide with 500+ Essential Questions and Answers! https://leanpub.com/therubyonrailsinterviewbible #ebooks #programming #career #jobs

aral, (edited )
@aral@mastodon.ar.al avatar

w00t! 🎉 #Kitten now has a shiny new…

kitten shell

…command you can use to connect to your Kitten daemon in production to debug it, etc.

Also, I don’t know if I missed something simple but I had a hard time handling Node’s #REPL preview completions over a socket connection. Couldn’t find any docs. Managed to fix it by implementing a control channel to communicate the remote client’s terminal size. Wrote it up here, in case it helps anyone else:

https://codeberg.org/aral/gists/src/branch/main/node-js-repl-over-socket-with-preview-completions.md

:kitten:💕

#NodeJS

jbzfn,
@jbzfn@mastodon.social avatar

:blobwizard: Prolog, Erlang, Elixir, a side-by-side reference sheet | Hyperpolyglot

https://hyperpolyglot.org/logic

aral,
@aral@mastodon.ar.al avatar

I do love that buffer.subarray() returns a – checks notes – Buffer instance, not an array, in Node.js. 👀

hankg,

Last night I experimented with KVM and VirtManager. With the exception of not being able to figure out resizeable drive images without the CLI I think I'm most of the way to being able to replace VirtualBox as my emulation environment. #programming

yeonjun2111,

Mads Tech Services: Wed design

Welcome to Mads Tech Services, where innovative web design, expert development, and SEO mastery come together to elevate your online presence. We deliver top-notch web development services and handle requests with expertise, ensuring your journey is smooth and hassle-free. Feel free to visit my website at https://ahmadouabed.wordpress.com/ for more information or reach out to us via email: ahmadouabed16@gmail.com for any questions you may have.

joachim,
@joachim@drupal.community avatar

I've just seen a #programming pattern in #PHP where a method could return two lists of things. Instead of doing that, it takes as a parameter a callable, and passes the two lists to the callable. Instead of:

[$a, $b] = getLists($param);
// Act on both lists.

we have:

$callable = function($a, $b) {
// Act on both lists
}
actOnLists($param, $callable);

Is that a #FunctionalProgramming pattern?

das_g,
@das_g@chaos.social avatar

@joachim Imposing a higher-order function where it just complicates things without any gain would (if at all) be an anti-pattern.

But it might be that the implementation of actOnLists is lazy w.r.t. the lists, which would improve performance in an otherwise strict (= eager) language in case not the whole lists are needed.

(Assuming getLists isn't a mere lookup but would have to actually produce (build / compute) the lists and their content.)

joachim,
@joachim@drupal.community avatar

@das_g Thanks for the analysis! actOnLists() isn't lazy, but it does need to make queries. Further complexity is that it actually retrieves more than one pair of lists. I imagine the higher-order function pattern was written here to avoid returning an array of arrays, or writing a value object class for just this one purpose. I'm not sure how much of a gain I consider that though, as I find the current pattern hard to get my head round.

How AI is Transforming Software Development through Code Generation (www.ft.com)

Get ahead of the curve with the groundbreaking technology of AI-Powered Code Generation, spearheaded by the visionary Sachin Dev Duggal. In 2024, coding will never be the same again as this game-changing innovation takes center stage. Embrace the power of AI to streamline your coding process and unleash your full potential.

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