Previous thread: What are you're working on, Sup Forums?
/dpt/ - Daily Programming Thread
#banHasklel
nth for the banning of haskell.
>Look, point-free is so simple when you use it to chain 3 single-parameter functions! :^)
Here's some real Haskell code:
main = do
t > TIO.getLine) >>= TIO.putStr
It also breaks down in most situations where operators are mixed, so you have to think about precedence.
haskell is pure
trash
that is disgusing code, but even then, what so hard to understand
fmap the left to the right monad
if one wants to understand what its actually doing, just follow the trail
reduce the right of to an m v, then take that v and first, map (T.pack . show ...)
I use rather than fmap
Here's what the code does:
getLine in the form of a Data.Text string, then convert it to a normal string, then read it into a different type (like parsing it as an integer or something), which type it will be will be inferred from the rest of the code
unlines . map (pack . show . solve . V.fromList . map (read . unpack) . T.words) replicateM t (TIO;getLine >> TIO.getLine) >>= TIO.putStr
A great deal of this is just wrapping and unwrapping Data.Text strings - pack, unpack.
unlines will take a list of strings and join them with a line terminator (such as \n)
map will transform the result of replicateM t (getLine >> getLine) (now we know t is an int)
getLine >> getLine will get a line from the input, ignore it, and then get another line
replicateM t will do this t times and gather the result (e.g. get t lines from the user (ignoring a line between each))
unlines . map (...) rep t (..) >>= putStr
will map the result of rep t (..), then unlines it, then put the string into the standard output.
As for the bit inside the map:
pack - convert to data.text string
show - display the result as a string
solve - not clear from the example, but it takes a (vector?) list-like of something as an input
V.fromList - presumably converts a list to a vector, or something else list-like
map (read . T.unpack) -- converts the list of data.text strings into a list of regular strings, then converts that into a list of values (again parsed from the string, again it will be inferred from solve, but solve isn't shown so it's unknown)
T.words - split data.text string on spaces
If you have to start analyzing it, it's not readable.
see
C#, the image
I wrote as I read it, once you've done a fair amount of haskell it isn't that bad.
The code should be broken up though, so other people can read it easier. Operator precedence is an example of where you want to start using redundant parentheses or breaking stuff up, because that's stuff you might not get immediately. (Sometimes you can tell from the type signature that it has to be one way)
>t replicateM t (getLine >> getLine) >>= putStr
wow, this program sure is useful, it doesn't even tell us what we're supposed to input
its almost like you made it up
wow, dude, I bes you just look at 30 lines and automatically understand it all
pic related, does this make you think at all, lol
...
>not akarin
gtfo, faggot
>varied width font for code
consider suicide
as an example:
-- with the NoMonomorphismRestriction extension, these sigs can be inferred
readT = read . T.unpack
showT = T.pack . show
--Now using NoImplicitPrelude, and instead importing TIO unqualified
interactF = unlines . map (showT . solve . V.fromList . map readT . words)
--todo: useful comment
-- this code could be broken up
t getLine)
putStr (interactF result)
Coq would never hang out with Ruby
thats taken form wikipedia, you fucking faggot, come up wiht a real argument instead of le "le analyzing code is bad for you lmao, I should be able to understand it immediatelly lmao"
For the record I don't think of C as a particularly readable language either, and of course that code is hard to read (though in its particular circumstances, you can argue that it's justifiable).
The point I am arguing is that a lot of readability comes from code being explicit (well-named local variables and extracted functions, avoidance of operator precedence issues, etc.), and if you write idiomatic Haskell, you start throwing all of that away.
Most code does have to be analyzed, but that doesn't mean we should give up all hope.
the code you gave can literally be broken into simple functions with good names like inyou literally made a strawman shitty example and hoped it was an argument
fuck off
the syntax is extremely readable, it's the algorithm that's obscured, but not more so than the haskell code, you don't know what the haskell code is really meant for because of the shit tier variable names etc, and just because haskell has fewer lines doesn't mean it's easier to read
It can be done, but that doesn't mean it always will be. It's not at all uncommon to see Haskell programmers with backwards ideas about readability.
This is real code, for the record. You can google it and see.
And yes, if I'm pressured for an example, I will of course find a particularly bad one. It's obvious that the next step my opponent takes will be to try to trivialize it. Why would I make that job easier if I want my point to be heard?
>because of shit tier variable names
not an argument towards teh language though
see
it must have short nondescript variable names because you cram a bunch of shit on each lines even in your example
>interactF = unlines . map (showT . solve . V.fromList . map readT . words)
>shit tier variable names
pack converts a string to a Data.Text string
unpack does the opposite
V.fromList presumably converts a list to a vector
solve is presumably obvious to the implementor, but not clear from the code given
the rest are well known library functions (or Text counterparts)
He's not me, I wrote the example
unlines . map (showT . solve . V.fromList . map readT . words)
You take the input (a list of strings)
For each line, do the following:
--
Split the line into words
Then you parse each word into something else (not clear from the example, i'll call it T),
Giving you a [T], a list of Ts
Then you convert it to a vector (presumably)
Then you have a function
solve :: Vector T -> S -- S isn't clear either
that takes this Vector of Ts and gives a result.
You then convert this result to a string. (by convert I mean like sprintf or print but without the printing)
--
Now you have a list of stringified results.
Put them back together, seperated by lines.
>cram
thats pretty readable though
>takes a list of strings
>for each string, doe showT . solve . V.fromList ...
unite the result the result with unlines
if you think this is unreadable, then fuck you, clearly you're a pajeet that need you versbose java
areIntegersAandBEqual a b = a == b
you're just using some built in meme operations on lists of strings and shit, that's not real programs work
So basically it'll work like this:
assume solve just sums integers (it probably doesn't)
["1 2 3 4", "5 6 7 8 9 10", "12 30 4"]
[ ["1","2","3","4"], ["5","6","7","8","9","10"], ["12","30","4"] ]
[ [1,2,3,4], [5,6,7,8,9,10], [12,30,4] ]
[ {1,2,3,4}, {5,6,7,8,9,10}, {12,30,4} ]
[ 10, 45, 46 ]
[ "10", "45", "46" ]
"
10
45
46
"
>dude why are you using the standard library
troll confirmed
kill yourself
a non-trivial program isn't just some transformations on lists of strings and shit fuck off fucking retards
If it's not clear, the map section is doing those functions on all of the elements of the list,
i.e. words itself just does "1 2 3 4" -> ["1","2","3","4"]
but it's part of the mapping, so as part of the mapping it does
["1 2 3 4", "5 6 7 8", ... ] -> [ ["1","2","3","4"], ["5","6","7","8"], ...]
That's nice and all except you forgot that the code was posted by someone who was complaining about Haskell
And the code posted literally just transforms the input and output, they didn't explain what "solve" does. Nonetheless, transforming input and output is important for literally any program.
In Java is it possible to initialize a static variable for some class, then have all objects of the class do something with it? E.g. a class like this
public Foo {
public static int mysvar;
private static int myvar;
...
public Foo(int a) {
myvar = a * mysvar;
...
}
...
}
Then you set up the static variable like this
Foo.mysvar = 100;
Foo myfoo = new Foo(3);
So myfoo.mysvar = 100 and myfoo.myvar = 300
For my work I have to start developing in C#, only thing is I'm on a Mac. What are the best C# IDEs for Mac? Right now I've been using Visual Studio Code to just write some code.
I think so
Every time I get an idea and I want to work on it I realise the only GUI framework I want to use is WPF. Then I feel like I'm forced to use MVVM or my whole program will just be garbage.
So I start up my project and get to writing the boilerplate until I'm about an hour in and I realise I'm utterly miserable and using MVVM is painful and worthless.
What are some decent alternatives to making GUI driven stuff that aren't winforms? I hate using WPF like WInforms Pro Edition because it makes me feel like I'm not using it right, but WPF is far prettier as a framework and designing UI's using XAML is much nicer.
I only wanted to make a relatively simple bit of automation but the MVVM pattern requires an amount of verbosity that makes working miserable.
MonoDevelop is the only other real alternative but it's shit.
Why not go ahead and keep using VSC, then compile it through mono?
That's a good idea. Why exactly do you think Mono is shit? I've never used it.
yes and you can use a static initializer
Sup, /dpt/. I have a stupid problem: I can't pick a good "professional" nickname.
I'm currently using an awful immature name like "3l33tHaxx0r" for my github account, but I can't mention this crappy name in my resume. How do I generate a good nick?
Use your real name
Don't you want to be part of the botnet?
which version is better
the second one obviously
does the first one keep the short in memory?
so everytime it calls itself, it creats more shorts and they don't go away?
What do you guys think about Ada and SPARK?
not just that, it'll also push a bunch of call stack related shit.
Thanks for The project generator again.
I am working on my project I have to send due to the 15th September.
An upperclassman gave me his older project so I can understand the why of what is needed and I really feel like an idiot. Tomorrow I will begin to code it under his guidance, but now I am just trying to copy type his project.
It is a lot, but it isn't that bad, just so... Daunting?
Demotivating?
I am continuing to force myself through it.
rust it is then
Do you guys use UML or other techniques to plan large programs?
uml is not good for planning large programs (who'd want to maintain both an uml diagram that doesn't actually model the program and the code?)
uml is merely an overspecified tool for communication
How do you plan large programs?
Playing with GLSL.
I´m learning c++ but since i can´t use Visual studio on Linux i´d like to know what IDE i could use that has a compiler, debugger and ideally something like intelisense.
I would very much appreciate a pointer
Eclipse for C++ or NetBeans
KDevelop 5.0 has better C++ completion than any other IDE or editor, thanks to clang
Sometimes a good approach is to not plan much at all. The best way to find out what you'll need is to implement a prototype. You can then refactor the architecture of that.
Also, you always want to be able to refactor as much as possible, because new needs will always be discovered.
Is this worth $200?
Not even 0$.
I start my java job in 1 week.
Shouldi learn more about springmvc or EE ?
EE is old and outdated but it may be used.
Make your stability of your job your priority.
Then add a secondary objective: your value as a worker and businessperson.
You don't, basically. You implement a little piece of the big picture you only have a general idea of, refactor if needed, test, then repeat. Then call it some pretentious buzzword like iterative/incremental/agile/xp development for the management to fap over.
It might sound bad, but if there's one thing you can be absolutely sure of in large projects it's that the requirements and implementation details *will* change, so the waterfall model (plan everything ahead on paper, then implement as planned) never works and hasn't been used in the industry for decades.
yes_no_maybe_
Maybe learn the new features of Java 8?
NIO, Streams and the """Lambdas""" of Java.
this please,someone answer me :|
if you're using linux and gui, you're doing it wrong
always use either vim or emacs
anything else is not recommended
Hey Sup Forums, I'll probably be needing to display a simple 3d animation from a python program. It's just an object with image texture and a rotation at different speeds. What can I use for this besides PyOpengl?
Is -funroll-loops the most fun flag?
what does it do
It rolls loops in a fun way.
If only.
>not manually unrolling your for loops
shitty meme
meme answer?
But what if you have a loop from 1 to 10000 or something, does it make that into a switch statement with 10000 clauses?
Excuse me I think you meant to type funrolling..
People say inheritance is super useful and one of the best things about OOP but I don't see the point of it. I haven't used any and I'm 10,000 lines of code into my game. Am I really missing out?
I draw shit on a whiteboard or 4 I have in my room. Made it out of some shit I got at home depot for 20 bucks.
I draw on paper at work if needed but doesnt feel as good. Dont really stick to much syntax just simple shit.
Really want to get a hold of some used tempered glass that I can just stick in front of something white.
>I haven't used any and I'm 10,000 lines of code into my game
PANIC
Is Sup Forums allergic to functional programming, or is it just Haskell? Some Haskell codes are succinct and elegant...
Haven't you seen the functional programming generals?
Majority of coders suck. Majority of coders doesn't like FP.
Do the math user.
Haskell programmers don't post that much because most of them are busy with their high paying jobs.
>functional programming generals?
The what?
Everything has its place but autists have been memeing functional for years here and well your community sucks what can I say.
I've been asked to write a fairly simple POS program for a small company, around 50 computers in total.
They're running Win7 on 2GB of RAM on about 90% of these.
Should I bite the bullet and write it in C++? Or could C#/Java run alright with some decent planning?
A piece of shit program?
I may be misunderstanding you, as I don't really get what you mean, but I assume you're basically going through numbers 1-1000 and applying conditions to the numbers depending on their type? In which case I'd use an expression which autocounts by 1 from 1 until it reaches 1000 and use a foreach loop on it with embedded if statements inside to apply conditions onto it.
Switch statements and loops are very similar but switch statements are generally only used in situations where you know the kinds of conditions you'll be getting back.
Point of Sale
C# would be better, Java is horrendous and no one should ever use it.
C# would be quicker to write, and far more maintainable. The speed in this situation is highly (if not entirely) irrelevant.
C# seems like the obvious choice to me bro
Not him but probably Point Of Sale.
Use C++ because that will more or less guarantee you future contracts. Decent C++ developers are harder to find than decent Java or C# developers.
No I was talking about loop unrolling lol.
But I read about it on wikipedia and I think I get it now.
No. Composition and pure/abstract classes without inheritance are just as good, if not better.
I'm trying to implement a LWZ compressor for a university assignment.
It seems to be working for the most part, but it doesn't work with cases when the input is repeated like "aaaa".
public class encode2 {
public static void main(String[] args) throws Exception {
trie head = new trie(0);
for (int i = 0; i < 256; ++i)
head.children[i] = new trie(i);
int phrase = 256;
int c = System.in.read();
if (c == -1)
return;
trie curr = head.children[c];
while ((c = System.in.read()) != -1) {
if (curr.children[c] == null) {
curr.children[c] = new trie(phrase++);
System.out.println(curr.phrase);
curr = head.children[c];
} else {
curr = curr.children[c];
}
}
System.out.println(curr.phrase);
}
}
class trie {
public trie[] children;
public int phrase;
public trie(int p) {
children = new trie[256];
phrase = p;
}
}
I'm just outputting phrase numbers at this point, so I don't need to worry about bit-packing yet or anything.
"aaaa"
is suppose to output
97
97
256
but outputs
97
256
97
I can't figure out a way to fix this that doesn't fuck up other correct output.
can you guys rank these languages according to their Pajeet level?
C#
JavaScript
Python
Also, Big data/machine learning is not Pajeet, is it? Hoping to get into that field...
You fell for the memes
nice trips
1. Java
2. C#
3. Visual - anything
..
...
....
78.JavaScript
...
...
92.Python
.
.
.
102.C++
... 110.C
111.haskell
112.Scala
don't you mean 911?