There have been multiple accounts created with the sole purpose of posting advertisement posts or replies containing unsolicited advertising.

Accounts which solely post advertisements, or persistently post them may be terminated.

programmer_humor

This magazine is from a federated server and may be incomplete. Browse more on the original instance.

h30x , in Guess what my favourite language is:

That’s how Julia looks. julialang.org

grimdeter , in Guess what my favourite language is:

Package manager for biologists and purpose made for data science makes me think of R. But if its true, i never knew you can write inline c++

merari42 OP ,

RCpp is crazy good. You can super easily write Cpp inline with R code, it is easy to use and half of the tidyverse is written in it.

grimdeter ,

I saw RCpp in my package manager, but I thought that it is not for users and just a dependancy. Maybe I will look into that

BlueBockser ,

How to write a package in R

Step 1: Use C++

itsnotits ,

if it’s* true

Aatube ,

to everybody downvoting: read the username

i wonder if this is a bot? it doesn't have the bot label

Yax ,

Bot or not, it’s no tits!

charolastra ,

notitsbot

marcos , in Guess what my favourite language is:

Most sane language designers stop at embedding C.

C++ is really taking it up to 11.

RustyShackleford , in Guess what my favourite language is:

R is for Removed by moderator.

krewjew , in Some of my iterations are delightfully recursive

I’ve been learning Haskell, and now I won’t shut up about Haskell

affiliate ,

what’s the appeal of haskell? (this is a genuine question.) i’ve been a bit curious about it for a while but haven’t really found the motivation to take a closer look at it.

pkill , (edited )

purely functional paradigm (immutable data structures and no shared state, which is great for e.g. concurrency) and advanced type system (for example you could have linear types that can be only used once). Lisps build on the premise that everything is data, leaving little room for bloated data structures or tight coupling with call chains that are hard to maintain or test. In Haskell on the other hand, everything is a computation, hence why writing it feels more like writing mathematical equations than computer programs somehow. It might, along Scala be good for data-driven applications.
Also the purely functional syntax means that on average, functional programming languages will arrive at the same solution in approx. 4 times less LOC than procedural/OO according to some research. Just look at solutions to competetive programming problems.
And even though I’m not a big fan of opinionated frameworks, compare some Phoenix codebase to a Symfony or even a Rails one to see how much cleaner the code is.

But if you’re new to FP you should rather pick Scheme, Elixir or Clojure since the paradigm itself can be a little bit hard enough to wrap your head around at first (though Elixir and is a bit imperative, depends on how deep are you ready to dive in), not to mention having to learn about ADTs and category theory.

krewjew ,

My favorite feature is how currying is applied literally everywhere. You can take any function that accepts 2 args, pass in a single arg and return a new function that accepts one arg and produces the result. In Haskell, this is handled automatically. Once you wrap your head around using partially applied and fully saturated functions you can really start to see the power behind languages like Haskell

CanadaPlus ,

It’s been noted that functional code accumulates less bugs, because there’s no way to accidentally change something important somewhere else, and Haskell is the standard for functional languages. Also, it might just be me, but the type system also feels perfect when I use it. Like, my math intuition says there’s no better way to describe a function; it’s showing the logic to me directly.

Where Haskell is weak is when interactivity - either with the real world or with other components - comes up. You can do it, but it really feels like you’re writing normal imperative code, and then just squirreling it away in a monad. It’s also slower than the mid-level languages. That being said, if I need to quickly generate some data, Haskell is my no-questions go to. Usually I can do it in one or two lines.

victorz ,

Out of curiosity, what kind of data do you generate with Haskell? And would be willing to show an example of a one or two liner that generates the data? 🙏

CanadaPlus , (edited )

Uh, let’s look at my GHCi history…

It looks like I was last searching for 12-member sets of permutations of 7 which come close to generating every possible permutation of seven elements, as well as meeting a few other criteria, for an electronics project. It ended up being more like 10 lines plus comments, though, plus a big table generated by GAP, which I formatted into a Haskell list using probably a line of Haskell plus file loading.

Unfortunately for providing code, me playing with the finished algorithm has eaten up my whole 100 lines of history. So, here’s a two-liner I posted on Lemmy before, that implements a feed-forward neural net. It’s not exactly what you asked for, but it gives you an idea.


<span style="color:#323232;">layer layerInput layerWeights = map relu $ map sum $ map (zipWith (*) layerInput) layerWeights
</span><span style="color:#323232;">
</span><span style="color:#323232;">foldl layer modelInput modelWeights
</span>

In practice, you might also need to define relu in another line:

relu x = if x > 0 then x else 0

Edit: No wait, I think that was a different problem related to the same project. There’s another module attached that generates all permutations of n items. After breaking it up so it’s a bit less write-only:


<span style="color:#323232;">allPermutations :: Int -> [[Int]]
</span><span style="color:#323232;">allPermutations 1 = [[0]]
</span><span style="color:#323232;">allPermutations n = concat $ map (addItem $ allPermutations (n-1) ) [0..(n-1)]
</span><span style="color:#323232;">
</span><span style="color:#323232;">addItem :: [[Int]]  -> Int -> [[Int]]
</span><span style="color:#323232;">addItem old new = map (y -> new : map (fitAround new) y) old
</span><span style="color:#323232;">
</span><span style="color:#323232;">fitAround :: Int -> Int -> Int
</span><span style="color:#323232;">fitAround n y
</span><span style="color:#323232;">	| y >= n	= y+1
</span><span style="color:#323232;">	| otherwise	= y
</span>
victorz ,

Cool! Thank you for sharing!

I just recently read the man page for GNU Parallel, and that seems like a pretty nifty tool to generate permutations of data as well. It’s command-line so great for scripts, utilizes many cores, quick to do without mind-bending Haskell project setup, etc…, for anyone interested. 🙂👍

CanadaPlus ,

I’ll look into it, although this probably wasn’t directed at me. GHC can compile multi-threaded, and “setup” here was just opening GHCi and starting, and then moving it into files once it got large enough I didn’t want to repeat the work, so I’m happy.

victorz ,

I still haven’t been able to learn project setup with Haskell and know exactly what I’m doing lol. But I’m glad you have a working setup! But yeah, do look into parallel if you want, maybe it can prove useful, or not. It was directed at you, considering your use case of generating permutations. :-)

Take care!

victorz ,

BTW: I think you need to put the “```” on separate lines.

test


<span style="color:#323232;">test
</span>

Edit: huh, nope, that had no difference in effect for me. Wonder why your code doesn’t render for me…

CanadaPlus ,

Which frontend are you on? I’m using lemmy-ui (the default webapp) and it renders fine, not sure how to find which version.

victorz ,

I was using Sync for Lemmy when your comment didn’t render properly. No idea why. Especially since my own comments were rendering fine. 🤷‍♂️

CanadaPlus ,

I’d guess it has to do with the specific symbols I was using, and there’s a bug in rendering of markdown in Sync.

victorz ,

Maybe so!

victorz ,

I learned some Haskell. Did some problems on Advent of Code and such. But since then I’ve heard about OCaml, which seems super interesting. Hopefully the tooling is simpler, but I’ve not had time to try anything yet.

Does anybody have any experience with it?

owsei ,

Im pretty sure tsoding has some videos with it

victorz ,

I’ll check it out, thank you very much! I approximate it a lot. 🙂🙏👍

tunetardis , in Unused variables

Compiler/interpreter: Can’t find variable farfignewton.

Earlier:

Me: Declare variables near, far

IDE: Oh! You mean farfignewton right? I found that in some completely unrelated library you didn’t write. Allow me complete that for you while you’re not paying attention.

gregorum ,

thank you for flooding my memory with a bunch of silly 90s car commercials

frezik ,

And people wonder why I stick to Vim.

lud ,

I mean, if you want something dumb you can use any text editor.

frezik ,

Yes, compared to the annoyances of “smart” IDEs, I do want something dumb.

FizzyOrange ,

No I’m good with smart IDEs. Anyway don’t people set up Vim as practically an IDE these days anyway? That’s what Vim users always tell me.

frezik ,

The advantage there is that you pick and choose how you turn things on, so you leave out the annoying bits.

tunetardis ,

One thing most text editors can do is print. I was shocked the other day when I couldn’t print a readme from vscode when someone asked for hard copy.

lud ,

Print?

Why would you ever need to print?

Threeme2189 ,

when someone asked for hard copy.

bitcrafter ,

Because some of us are bitter at the trees for generating so much pollen at this time of year and want revenge.

lud ,

That’s fair, I didn’t think of that.

andnekon ,

using lsp in vim has pretty much the same problem especially with java

elxeno ,

near, far

The obvious autocomplete is , wherever you are

tunetardis ,

This is why I fear activating any AI features in the IDE.

RagingRobot ,

Then it automatically imports the library for you too lol

dojan ,
@dojan@lemmy.world avatar

Visual Studio: PROPERTY DOESN’T EXIST ON TYPE!! NOTHING EXISTS ANYMORE!!! REALITY HAS COLLAPSED!

Me: What? I haven’t even touched that class, let me check.

Visual Studio: Oops, nevermind, héhé 🙃

DacoTaco ,
@DacoTaco@lemmy.world avatar

I swear to god this didnt used to be a problem few years ago. However im having that bug constantly now…

dojan ,
@dojan@lemmy.world avatar

Yeah, I also feel like it’s fairly recent.

brisk , (edited )

I try my best to make my IDEs follow the principal that I should be able to type without looking at the screen, but apparently IDEs are really invested in return accepting completions to the point it’s often not configurable even when every other key is.

kevincox , in Unused variables
@kevincox@lemmy.ml avatar

IDE is one thing, Go refuses to compile. Like calm down, I’m going to use it in a second. Just let me test the basics of my new method before I start using this variable.

Or every time you add or remove a printf it refuses to compile until you remove that unused import. Please just fuck off.

treechicken ,
@treechicken@lemmy.world avatar

VSCode with Go language support: removes unused variable on save “Fixed that compilation bug for ya, boss”

kevincox ,
@kevincox@lemmy.ml avatar

Like actually deletes them from the working copy? Or just removes them in the code sent to the compiler but they still appear in the editor?

FizzyOrange ,

Yeah IIRC it deletes them, which is as mad as you would expect. Maybe they’ve fixed that since I used it last which was some years ago.

jose1324 ,

Bruh that’s insane

FizzyOrange ,

Yeah I think it’s trauma due to C/C++'s awful warning system, where you need a gazillion warnings for all the flaws in the language but because there are a gazillion of them and some are quite noisy and false positives prone, it’s extremely common to ignore them. Even worse, even the deadly no-brainer ones (e.g. not returning something from a function that says it will) tend to be off by default, which means it is common to release code that triggers some warnings.

Finally C/C++ doesn’t have a good packaging story so you’ll pretty much always see warnings from third party code in your compilations, leading you to ignore warnings even more.

Based on that, it’s very easy to see why the Go people said “no warnings!”. An unused variable should definitely be at least a warning so they have no choice but to make it an error.

I think Rust has proven that it was the wrong decision though. When you have proper packaging support (as Go does), it’s trivial to suppress warnings in third party code, and so people don’t ignore warnings. Also it’s a modern language so you don’t need to warn for the mistakes the language made (like case fall through, octal literals) because hopefully you didn’t make any (or at least as many).

bobburger , in Guess what my favourite language is:

Should include "has duckplyr" which is bad ass in the few weeks I've been using it.

eran_morad ,

Bruh, this looks cool af. Seriously has me wondering whether I should port my shit from SQLite to duckDB.

bobburger ,

I love duckDB, my usual workflow is:

  • initially read my data from whatever source (CSV, relational database somewhere, whatever)
  • write it to one or more parquet files in a directory
  • tell duckdb that the directory is my data source

Then duckdb treats the directory just like a databese that you can build indexes on, and since they're parquet files they're hella small and have static typing. It was pretty fast and efficient before, and duckdb has really sped up my data wrangling and analysis a ton.

Ironfacebuster , in Guess what my favourite language is:

It has to be Kepler, my terrible home grown interpreted language that has none of these features!

JK it’s gotta be JavaScript

Bye , in Guess what my favourite language is:

Also my fav OP :)

Rcpp is probably the best thing to ever exist.

I reject tidyverse though

anzo , in Guess what my favourite language is:

Best IDE ever, help pages with references to statistics journal articles, and the most useful feature: pipe()

witty_username , in Guess what my favourite language is:

Should’ve included:
ridiculously good at plotting if you can figure out the correct syntaxes

merari42 OP ,

Also multiple systems included. the old base plotting from the 90s, lattice for really custom things, ggplot as the most humanely understandable and reasonable system for composing plots and great interfaces to plotly and d3.js

lowleveldata , in Guess what my favourite language is:

F#? I know it’s probably not but I love F#

nieceandtows , in Guess what my favourite language is:

Must be python, because it’s my favorite, and I reject this image.

devfuuu , in Guess what my favourite language is:

The many oop systems makes me think perl.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • [email protected]
  • lifeLocal
  • goranko
  • All magazines