Programming

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

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…

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

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.

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.

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

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.

vascorsd, (edited )
@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

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.

🫣

vascorsd,
@vascorsd@mastodon.social avatar

It doesn't help that it's horrible to try to find out what they do because the code is 5 levels of extending classes, no docs in the source etc.

When confused about some method when you try to ctrl click on intellij to see the source you just end up more confused.

When navigating online, all "go to sources" on the docs are broken links.
(ex: https://www.scala-lang.org/api/3.3.3/scala/collection/immutable/VectorMap.html )

It doesn't help at all in giving confidence about the ecosystem and language health.

When to the quality of rust docs... 😢

jbzfn,
@jbzfn@mastodon.social avatar

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

https://hyperpolyglot.org/logic

#Prolog #Erlang #Elixir

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.

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.

travisfw,
@travisfw@fosstodon.org avatar

I want a type system in my language.

That is, I want the data structures to project back and forth between multiple type hierarchies.

As a result,
• One type system won't have to serve all purposes.
• Smaller, specific models can reuse terminology (not by include nor dependency).
• DSLs would be easier to write.
• Some services won't have to be broken out into separate code bases.
• All hope for perfection may finally be abandoned.

octorine,

@travisfw would this be like an untyped language with type checking provided by external static analysis tools?

Each tool could check against a separate type theory.

travisfw,
@travisfw@fosstodon.org avatar

@octorine I like the idea of having an ecosystem of compatible static type checking tools.

I was thinking it would be typed, but mostly in terms of interfaces (or mixins, traits and similar concepts). In-memory binary data structures would not be explicitly described by the type system, and would be managed by the runtime. Such management would include reconfiguring the literal structures to be represented by compatible terms/types.

faassen,
@faassen@fosstodon.org avatar

A new blog post.

Tool maven versus language maven. Do modern development environments enable you to be both? How does this affect languages?

https://blog.startifact.com/posts/the-tooling-shift/

#programming

dabeaz,
@dabeaz@mastodon.social avatar

@faassen I often feel that the tooling divide is the source of much friction for me in the Python world. I think in terms of the language, not tools.

I sort see the same thing in my music. I'm much more able to think in terms of the music itself instead of tools related to music.

dabeaz,
@dabeaz@mastodon.social avatar

@faassen As the prayer goes... "please give me the strength to respect other people's opinions wrong though they may be."

ericsedge,
@ericsedge@bitbang.social avatar

I’ll livestream again this Saturday morning at 9 am Eastern. The question is what topic?

I could go over more of my #HyperCard Adventure game. Perhaps describe the funky game file format and query code for retrieving information.

Or I could jump into some #Commodore 64 #programming in #BASIC.

Or answer questions about HyperCard authoring?

What say you?

rayckeith,
@rayckeith@techhub.social avatar

@ericsedge I'd like to read this information. Have you written this up anywhere?

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