[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip / qa] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/lgbt/ - Lesbian, Gay, Bisexual, & Transgender


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


File: 0_7QC0bR0l_NIo2oN1.png (26 KB, 491x720)
26 KB
26 KB PNG
this gen is for cs trannies to discuss cs things
qott: thoughts on functional programming?
>>
gay
>>
i like functional programming a lot it's true af what they say abt being less error prone, often times i had to implement some like statistical formula or smth and doing it functionally stuff just werks whereas it would have been a nightmare to debug using an imperative approach
>>
>>35490770
>cs trannies
are cs twinks also allowed being here?
>thoughts on functional programming?
nice in moderation
>>
>never used a functional language
am i even a real CSfag
>>
>>35490802
>cs twinks
ofc!! do u ever wish u could have sucked Alan turings dick
i used to wish that a lot and then i sublimated that desire by wanting to suck my compatibility theory professors dick but it was during the quarantine and he was married
>>
>>35490830
that's ok fren nobody uses fp anyways lol
actually i would be interested to know
are there any scala fans here??
>>
>>35490841
>do u ever wish u could have sucked Alan turings dick
no and i'm glad i will never have to think about turing machines anymore
>>
>>35490893
lol im glad i never actually had to think about turing machines, instead we had smth called ummm a register machine which u can prove is actually equivalent to a turing machine but it's more akin to a modern computer so easier to think about imo
>>
>>35490794
>it would have been a nightmare to debug using an imperative approach
But when it doesn't work functionally, debugging a lazy evaluated recursive statement is absolute fucking hell.
>>
has anyone been doing any fun coding projects lately? i have been learning about vulkan, i wanna make a basic renderer and then maybe give some physics to the objects
still working through all the set up stuff tho, vulkan has a lot more setup than opengl
but I've got it to compile, all my libraries are linked and it opens a blank window! :0 lol
>>
>>35490951
hm well i can't deny that
recursion always makes my head spin lol, sometimes i just write the um like reduction step and then just keep adding base cases until it works lol
>>
File: code.png (156 KB, 1744x886)
156 KB
156 KB PNG
>>35490770
not a tranny, but fuck when I see a thread about functional programming I can't resist.

Haskell is my favorite language I never use, because while it is absolutely amazing for building theoretical algorithms and datastructures, building an actual program dealing with filesystems, I/O and anything actually useful is annoying af.

Also monads suck. I know they are incredibly useful and "Muh mathematical consistency" but let's be real, if I wanted to write iterative code, I'd use an imperative language. If you can't write it recusively, why even bother?

>pic related one of my favorite functions from a regex engine I've wrote
>>
>>35490931
>u can prove is actually equivalent to a turing machine
also called turing complete
>>35490968
>has anyone been doing any fun coding projects lately?
if i have time next to uni i currently build a smol programming lang (mostly for fun and a bit for the resume)
>>
>>35490770

i am uncomfortable with it because i am unfamiliar.

i would like to learn more about it but unfortunately i have had my attention span rotted
>>
>>35491021
>monads suck if i wanted to write iterative code id use an imperative language
T_T glad I'm not the only one
based haskell fren :))
i like haskell too, when ur just writing like math and logic, the syntax is so beautiful, feels just like writing a proof
my background is more in math with some cs on the side >_<
that looks rly cool, i don't rly understand it but the syntax is beautiful cc:
>>
>>35491026
>smol programming lang
woa that sounds super cool :0 wud love to hear more if u wanna tell c:
>>35491060
that's ok fren, nobody uses it anyways lol
>>
is matlab/octave technically functional? I found it underwhelming even though it was really good for its specific use cases, since I grew up learning in an object-oriented kind of paradigm with early exposure to C++
>>
going to start studying CS at university this year what should i expect
>>
File: isar.png (27 KB, 723x233)
27 KB
27 KB PNG
>>35490990
You should try isabelle, it's an ML implementation combined with a theoreme proving language, in which you can write functional programs and prove that they are correct.
It's absolutely amazing and a lot of fun. See the picrel it's a proof by contradiction for that an isabelle function is not surjective
>>
File: yuckck.png (109 KB, 924x1231)
109 KB
109 KB PNG
Am I allowed in this thread if im a math major tranny, but taking some CS modules and writing a paper on linear programming atm
>>
>>35490770
HoTT is sick as fuck and is gonna replace set theory, functional programming is fundamental to the universe, OoP fuckers can choke
>>
File: operators.png (98 KB, 1386x511)
98 KB
98 KB PNG
>>35491076
My guilty pleasure is to define my own operators to make my code look cooler xD
Like also same regex engine, I've implemented myself the klenee operators to test the automata construction
>>
>>35491191
>OoP fuckers can choke
nobody cares in the futures everything will be written in js/ts
>>
>>35490802
>nice in moderation
/thread
>>
>>35490770
it is useful for formal verification
>>
>>35491177
Modern CS is very data heavy meaning probability takes central stage now.
>>
>>35491212
yea y'all can keep writing soft thats addictive as vapes for the general consumer, won't stop the fact that functional programming is where the real academic work will get done
>>
>>35491212
JavaScript is an amazing language. It basically only has 3 concepts, base datatypes, lambdas and dictionaries and from that alone such a massive ecosystem of different coding styles, frameworks, etc. has grown.

Sure actual js development sucks ass and is somehow more degenerate than enterprise java, but the fact that it is possible is absolutely amazing
>>
>>35491103
>wud love to hear more if u wanna tell
still at the beginning of that, so can't tell much. for now the goal is to create a dynamic general purpose lang (with an limited scope) powered by rust (obviously)
>>
>>35491306
>is where the real academic work will get done
you do you
>>35491307
>Sure actual js development sucks ass and is somehow more degenerate than enterprise java
if you ignore the deranged tooling it's actually kinda nice
>>
>>35491145
omg this looks rly cool thank u for telling me abt it! gosh i wonder how u write a proof checker/system for modeling logic.. would b a cool project!
>>35491177
c; i was a math major too
>>35491199
woa.. that looks rly rly cool gee u rly know ur haskell, huh :0 :)))
>>35491120
c++ enjoyer c: call me crazy but i think c++ is my fav language lol... most of the stuff I've done recently is in Python but i love getting to work close to the metal where u can have really good control over ur program and u know exactly what ur code is doing under the hood
I'll admit it's not a pretty language, but otoh in c++ there's always a way!
>>35491191
i feel like OOP has just been taken too far
do i rly need like a fucking object factory or smth?? like at this point WTF am i even doing????
>>35491212
sad but real ;_;
but i hate the webdev world!!! we never should have left web 1.0, it has everything we needed :/
>>35491306
ugh ya it makes me so depressed thinking about how nowadays some software is written to be addictive like wtf who writes that shit
>>35491326
waow that sounds rly rly cool anon, good luck! i hope u get a chance to work on it
>>35491307
idk if I'd call it amazing but i agree with the sentiment, i was surprised when i learned javascript how much nice goodies were there, i love arrow functions c:
>>
>>35491519
>good luck! i hope u get a chance to work on it
thank u, there is always a bit of free time
>>
File: e6sh1XW-1789764219.png (134 KB, 1131x721)
134 KB
134 KB PNG
>>35491326
>powered by rust (obviously)
I really fucking hate rust. It's an amalgamation of all the language features the developers could think of, just put into one language without regarding consistency in style and vision. You clearly see that they are all C++ developers, let's remake C++ but less aweful (basically the only advantage is that Rust doesn't need to be backwards compatible with C and thereby can explore new features in more depth).

A great language is a language that with very little rules that setup the language. For example in Haskell you only have pattern matching and recursion, and this alone is enough to setup the whole language. You can even define base datatypes like integers solely within language, and in theory don't even need the prelude (which is the core runtime of haskell). You obviously still use it for optimization reasons, but you don't need that.

There is only one perfect language tho, LISP, through it's homoiconicity you can create macros introducing new language features in language. The core LISP features basically haven't changed basically since the 50s and to this day you can write a proper LISP interpreter in like 30 lines of code, yet it can solely through it's macro functionality support all kinds of modern features such as pattern matching, OOP, variables, etc.
It's one of the first languages to ever been created, and to this day it is nearly unchanged. Thats what perfection means. This is the pinacle of programming language design and it was already figured out in the 50s. All other attempts at trying to build a better language have been pointless.
>>
>>35491519
>gosh i wonder how u write a proof checker/system for modeling logic.. would b a cool project!
Back in Uni, the chair I worked on did some research into provable software modelling. What they did is create a component programming language (basically where you wire up block diagrams for engineers), which the compiler would compile down to C for the actual program and down to Isabelle/ML, for the proofing.
The developer would then formulate requirements on the code in logic terms, and would use Isabelle with a library of base proofs (developed at the chair to to prove specifically properties of that language), to validate that the software satisfied these requirements. It's actually used by car manufacturers and other companies in the high safety sector, to ensure their code works as intended.

Really cool stuff.

>woa.. that looks rly rly cool gee u rly know ur haskell, huh :0 :)))
Like once every few years I have a few weeks where I get really into Haskell, and start building some algorithmical program. Last was the regex engine, and my next step is to build n LALR parser.
When everything works out, I'm soon being able to build my own language parsing engine in Haskell :)
>>
>>35491546
>You clearly see that they are all C++ developers, let's remake C++ but less aweful
that's why i've used it, best for this use case
>A great language is a language that with very little rules that setup the language
a great language is one that lets you be productive and create shit, that's all you care. rust still has some problems with that to be fair
>write a proper LISP interpreter in like 30 lines of code
done that actually
>>
>>35491546
nta but gee i wish i knew lisp, if for no reason other than to use emacs lol (im a neovim user myself)
i also rly liked how integers were just defined as functions, it rly kinda changed the way i look at the world like.. everything is a function :0 also pattern matching was my fav thing abt haskell, it's such a beautiful intuitive way to define a functions behavior
lately i have been reading abt these things called signed distance functions, idk if ur familiar
it's a function that represents a 3d object in the sense that, given a point in space, the function will output that points distance from the surface of the object, and it will be positive if the point is outside the object and negative if the point is inside
turns out that tells u everything u need to know to render the object using a ray marching approach :0
so i have been working on putting together a simple renderer in vulkan to play with SDFs
oo wait i forgot to say why i was talking about this- i thought they were cool cause it's a way of like extending this functional paradigm to describe objects in space :0
>>
>>35491636
>a great language is one that lets you be productive and create shit, that's all you care.
No a good language lets you feel smug after using it for how pure and pleasing it is to use

If all I wanted was to get fast results, I'd still be using Java
>>
>>35491661
>No a good language lets you feel smug after using it for how pure and pleasing it is to use
but that doesn't give you any monies, but it's nice for hobby projects
>I'd still be using Java
java 21 is quite comfy
>>
>>35491677
>but it's nice for hobby projects
Thats why I don't program for a living. I enjoy it way to much to ruin that fun by having to do it.

Still work on some open source projects in my free time tho, where I have to use stuff like C++ anyway (but I must say I really tied up between loving and hating that language)

>java 21 is quite comfy
Ngl. if it wasn't for the enterprise development "culture" around Java, it would actually be quite a nice language. Simple enough to not be distracting and wondering "whats the best way to do something" (like you often have in C++), yet flexible enough that you can't do much things wrong with it
>>
>>35491631
omg i keep saying this lol but that's actually so so cool omg
I'm always trying to come up with a way i could do something mathy/logic-y that would actually be useful lol but that makes perfect sense!
>my own language parsing engine in Haskell
woa ok that's getting like way beyond my area of expertise lol but that's genuinely really cool, i'm impressed! cool to meet a real Haskell shark, i admire it a lot! :)))
>>
>>35491744
One thing you may also want to look into could be symbolic execution. Basically it's an emulator that uses "symbolic" values, which can be anything, and then collecting restrictions on them. For example take this code:
assert x in 0..10
if (x < 5) return x + 5
else return x

The symbolic execution engine would execute all possible runs of the program, so one for x < 5 and one for x >= 5, and collect the information as a set of assertions. So basically you have 2 paths one with x>=0, x<=10 and x<5, and the other one being x>=0, x<=10 and x>=5.

Right now this kind of software is only used to find bugs during execution and to generate test cases (e.g. one test case would be x=0 and one would be x=5, to archive 100% code coverage). But one of my ideas which I wanted to make reality for some time is to basically use the assertions that are collected, and rn only used to compute examples for test cases, and use a theoreme prover to prove statements over them.

For example it would be quite trivial with the example above to prove that the result is always >= 5. And most of it is already in place.

So in Uni I worked on this engine called KLEE, which does this on LLVM basis, so can work on pretty much all LLVM languages (mostly C and C++, but potentially also Rust, Swift, etc.). So what I want to do at some point is to take this open source engine, add constraint statements to the program (e.g. in Object Constraint Language OCL), and then use KLEE to simulate all paths and use a prover to show that on this path all the defined constraints still hold.

It actually shouldn't be that difficult to do, basically when I was working at Uni I've built similar things with KLEE already, I just need the time to do it.
>>
>>35491825
If you wanna check it out, see http://klee.doc.ic.ac.uk/
It's a web playground where you can play around with simple C code to check how symex works
>>
>>35491728
>Thats why I don't program for a living.
that's fair then
>if it wasn't for the enterprise development "culture" around Java
if you use it for yourself it can actually be avoided, no need to use bloated frameworks
>>
File: templates.png (21 KB, 726x238)
21 KB
21 KB PNG
>>35491519
>c++ enjoyer c: call me crazy but i think c++ is my fav language lol...
I don't know if I should love or hate this language lol
>>
I don't understand why you would ever use your life to study mathematics or coding. Your goal is to eliminate humans right?
>>
>>35492107
>Your goal is to eliminate humans right?
Depending on the use case buggy software can kill people
>>
File: o_0.jpg (8 KB, 256x254)
8 KB
8 KB JPG
/g/ thread?
>>
>>35492162
>/g/ thread?
The idiots over there can just rice their desktops
>>
>>35492107
It's the only science where you can actually prove things. Like in physics or chemistry, you can make hypothesis and verify them, but you can never prove something. We assumed that newtons gravity was the law of the universe until we noticed some irregularities with mercury.

In math or cs on the other hand, you can make very precise statements, you can prove things without uncertainty. It's the description of systems which are so complex that it is always surprising, but so structured that you still can understand them looking deep enough. You can even prove what you can't prove (gödels incompleteness theorem, diagonal proves for the halting problem, etc.). And at least for me, this "thirst for knowledge" so to speak is what drives me.

As Hilbert put it, which even though the specific thing he was describing was disproven my Gödel, it is still true as ever:
>Wir müssen wissen, wir werden wissen!
(We must know, we will know!)
>>
>>35492211
What do you want to prove?
>>
>>35492242
No big mathematical problems, but I'm this guy >>35491825 so what fascinates me most is creating formalisms for proving statements about software. Like imagine as a software tester, instead of having to create test cases, you would instead just need to write a description of what the code needs to do, and then it will be automatically evaluated if the code actually does what it is supposed to...

I know rice's theorem, and that a non trivial property of a program is generally not computable, but it is amazing on how much actually is, especially if you break it down into smaller sub problems (e.g. working on a function level instead of whole program level).

But desu. I've fried my brain by working in research in that area for nearly half a decade, so I can get very auti about these topics
>>
>>35492279
I guess you enjoy the work itself, well I don't understand. I'll read your posts when I have time later.
>>
>>35491825
wow that is a fascinating idea actually
so the program would be able to take a piece of code and verify that it satisfies certain properties in each like execution case?
>>35492107
hmm i got into math as a way of coping with gd/depression when i wasn't allowed to play video games lol
but it's kinda nice idk, working in a world that's purely theoretical
u don't have to run experiments, everything just happens in ur mind! i guess the joy of math is the joy of solving puzzles kinda, but as the math gets more advanced the puzzles get harder and take longer to figure out but when u do it feels so good
and u come to realize that even the abstract worlds of logic and math have their own structure, and u can learn it and understand things about it, and i find that rly exciting
like we're studying a part of nature so fundamental that it exists without even a physical form
>>
>>35492387
>verify that it satisfies certain properties in each like execution case?
Exactly. There is the caveat that programs may have an infinite number of paths (e.g. endless loop), but there are ticks to deal with that, e.g. you could guide by code coverage, e.g. you say at some point: well I haven't checked all paths but I got 99.9% coverage and this is enough.
Or you break your program down into small functions which do terminate, and check those individually and then make heuristics over their combination in a non halting function.

So take for example the object constraint language, where you can describe functions in terms of pre and post conditions:
context List::addElement(item)
pre: self.items != Null
post: self.items->size > self.items@pre->size and self.items.last == item

It says that on every call the items are not null (pre condition), and that after the call, the size is longer and the last item is the newly appended item.
And because OCL is already a first order logic language, you could pretty trivially encode this into the existing symex engines to check for every path through the function if the post condition follows from the pre condition on that path
>>
>>35492162
The socks make the difference
>>
>>35492638
Just to add to this, so these symex engines already make use of theoreme provers (smt provers to be precise) such as Z3 to prove if a certain path is even possible (e.g. it does not emulate x<5 and x>10 because it proves that this path is impossible).
So what it does is, at the end of each emulated path, basically you get a set of logical equations that describe exactly what happend in that path. You could then just take them, "and" them together with the negation of the post condition from OCL and throw them into Z3 to check if there is a solution such that the post condition would not be satisfied.

If you are interested in this sort of stuff, I'd recommend you the original paper on Klee by Cristian cedar et al, as well as to look into Z3 and OCL verification.

That said, it should be noted that smt solvers are pretty limited, they only really work on integers, strings and fix point values, double support is very limited. But it's already amazing how much you can achieve with only that
>>
>>35492764
*Cadar not cedar fucking autocorrect...
>>
>>35492764
thank u for the wealth of information anon, im actually gonna check those out! u seem rly smart and cool I'm glad we got to talk c:
when i was in college i didn't rly know what i was doing, never got involved in anything interesting lol
i was a math student so when i sorta pivoted to CS i mostly just stuck to like machine learning/data science stuff cause it was easy and there were lots of courses for it
it was kinda disappointing in the end desu, i learned a thing or two about neural networks but so much of machine learning at the end of the day just comes down to fucking around with the model architecture and then trying to justify it lol, at least that's how i ended up feeling about it
>>
>>35490770
I am a professional software engineer.
>thoughts on functional programming?
this thread was the most I've thought about it since college. I'm not a big fan of it myself, though considering how clunky the OOP I write can get I suppose I see the appeal
>>
>>35492907
fair enough anon, what language do u work with the most and also what's ur favorite
>>
>>35492907
>though considering how clunky the OOP I write can get I suppose I see the appeal
I've found a pretty good solution to this problem, use procedural programming wherever possible and only objects and inheritance and stuff where it really makes sense.

Just have the simple rule: whoever introduces a new class must write a 1 page justification in the merge request why a class was needed instead of a struct and functions.

It's incredible how fast people realize they don't need an mill to produce a factory for creating the Singleton instance of a polymorphic interface which literally has only one implementation
>>
>thoughts on functional programming?
I never understood it, but I always find the haskell implementations of Eratosthenes sieve very cool
>>
>>35492930
I mostly work with C# at my job, along with VB.NET, sql, the frontend stuff. I like C#, Java, Python.
>>35493046
Cool idea, but this doesn't work with enterprise codebases that have been around for years. You'll end up with your own little island of code that doesn't gel with the greater program.
When I said that OOP can get clunky I didn't mean to imply that I hated it, or that it was inferior to other programming approaches. When you get experience in it and organize your libraries with classes in mind it's really rather nice to plug in a shared class and use its methods. I work in government software where having set objects translates very well to the real world, such as with law documents, court cases, forms, etc.
>>
>>35491519
>gosh i wonder how u write a proof checker/system for modeling logic.. would b a cool project!
It’s exactly the same as a type checker thanks to the curry-howard correspondence. Types are propositions and objects of that type are proofs of that proposition.

So functions A->B are also proofs that A implies B, the list constructor is a logical “and,” the union constructor is a logical “or,” and so on.
>>
>>35493851
mm Python is probably my most used language :0 ever since discovering type hints i have come to rly enjoy python, altho i will never not think that white space based scoping is stupid and bad. it's all fun and games until somebody replaces four spaces with a tab and then all hell breaks loose.. but i esp enjoy the way python tries to get u to think in a kinda functional way, esp when working w like numpy and pandas and stuff, and i rly like the *idea* of cute baby toy language that's also powerful
smth that i rly don't like about python tho is it's often hard to know what is going on under the hood, which makes it hard to write efficient code sometimes
>>
>>35492000
oops i missed this one dang and u had digits too
lol it's a lil verbose but not so bad once u know what all those statements mean!
my experience w c++ has been kinda like that, i think.. it gets bad, but it's usually not *that* bad, and working close to the metal feels nice c:
>>
>>35494677
omg woa
i confess i have never written a type checker T_T to my chagrin i never took programming languages ssh don't tell
but i think i can kinda follow, that's v v interesting
so u can basically map the proof to like a function and verify that the function maps A to B?
>>
>>35490770
Bro, being a tranner is unimportant, I do seek those willing to help me, to actually, "git gud" at programming though. Me being a sub-average IQ muthafucka, I have trouble thinking my code all the way through. So, I end up relying on trial-and-error, then pray to God for the best outcome.
>>
>>35494809
Anon I do this as my day job and I still have to trial-and-error solve bugs sometimes lol. I didn't try praying, though; in uni the only god I knew was the Ballmer peak.
>>
>>35494986
Bro, if you ever want to help a legitimate retard, just let me know. However, prayer helps, especially the centering (important) kind. I am glad to know that their are custodians for retards such as me. Note: This is a real cry for help. I love programming, but am dogshit at it.
>>
>>35495096
*there, not their. Further proof of my retardation.
Apologies, >35494986.
>>
>>35495096
>>35495185
I'm no teacher, sorry anon.
But that should not discourage you. Programming is hard! It's dumb sometimes, and tedious, and hard to learn. You only need to know that you CAN learn it. I say this because it can feel impossible and feel, as you say, like you're retarded. I went to college to learn computer science, but I really did not learn much with the classes I took. Instead, online resources taught me almost all of what I know. Do a project, and no matter how insignificant or useless the project is, it will help you.
Check out Advent of Code. It's a yearly holiday group of coding challenges that range from trivial to dummy hard, and just having those challenges to do gives you something to work towards. If you're not in school, then this is doubly important as those dumb projects are a building portfolio to get a nice coding job with no degree.
You can do it, anon! I believe in you, and you should believe in yourself. Last thing:
>I love programming, but am dogshit at it.
That first part is all you need. Motivation from within. I'm also dogshit at programming, and if I can do it, then you can too.
>>
>>35495750
Bro, I appreciate it. I have done Code Warrior challenges, but even after solving them, still fell incapable. I put the "advent" on a sticky. Also, for the future, you being a "teacher" means jack-shit. Some people desire nothing more than to learn, regardless of the degradation that comes with it. Remember, Newton was a piece of shit (from perspectives), but one of the greatest minds to ever grace the Face of the Earth. If you are ever willing to take a retard, just let me know.
>>
>>35495900
from "certain" perspectives. My bad.



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.