[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y / ] [Home]
4chanarchives logo

/dpt/ - Daily Programming Thread


Thread replies: 356
Thread images: 40

File: hime c.png (1MB, 1280x720px) Image search: [Google] [Yandex] [Bing]
hime c.png
1MB, 1280x720px
old thread: >>54771122

What are you working on, /g/?
>>
File: glitchy_gdb.png (81KB, 938x973px) Image search: [Google] [Yandex] [Bing]
glitchy_gdb.png
81KB, 938x973px
>>54776509
I'm being confused by GDB weirdness.

Does anyone use GDB? I learned about the TUI mode today. It works fine for a bit, until eventually it really starts messing up.

The control characters stop being interpreted correctly; they are being output to the input field. The screen stops being rendered correctly. Redrawing the screen with ^L will only seemingly fix it until I enter another command in.

I'm using xterm but the same thing happens with screen-256color.

>>54776530
I thought you couldn't delete threads on 4chan.
>>
>>54776509
dumb weeb
>>
>>54776509
>trap
fap-fap
>>
File: the end of code.png (133KB, 600x786px) Image search: [Google] [Yandex] [Bing]
the end of code.png
133KB, 600x786px
Will there ever come a day when programmers put themselves out of a job?
>>
>>54776563
They do it all the time with automation, or more precisely they put others out of work.
>>
>>54776563
We will live in AI-governed utopia by then.
DeepMind is world's top Ai company, so it's not unreasonable that they will play a large role in that. See an interview with their ceo/chief scientist http://www.theverge.com/2016/3/10/11192774/demis-hassabis-interview-alphago-google-deepmind-ai
>>
>>54776563
I think if code can code itself, then code can code the thing that builds itself. At that point, everyone will be out of a job.
>>
What's ur favorite pointer type and why is it void?
>>
>>54776617
You don't even need code rewriting, just good enough general learning. Software able to learn is a reality by all measures now. It's only a question of quality of learning.
>>
File: 1459372659891.png (718KB, 800x600px) Image search: [Google] [Yandex] [Bing]
1459372659891.png
718KB, 800x600px
Imagine a waifu app:
a qt anime waifu on your screen
you can interact with her via typing text and even by saying phrases into the mic (say, you use google voice API)

Which cool interactions between user and could you imagine in this framework?
>>
>>54776683
[spoiler]hand holding[/spoiler]
>>
>>54776551
I discovered a workaround if y'all ever encounter this problem.

Entering TUI mode via ^xa will cause this problem for some reason, but entering TUI mode by launching gdb as
gdb -tui
this problem will not be encountered.
>>
File: get a job.webm (3MB, 1118x834px) Image search: [Google] [Yandex] [Bing]
get a job.webm
3MB, 1118x834px
>>54776509
>What are you working on, /g/?
finding a job ;_;
>>
>>54776836
>r9k
>>
It took two fucking days but I've finally figured out how to get the Vendor and Product IDs from a drive letter.
>>
File: Capture.png (4KB, 517x72px) Image search: [Google] [Yandex] [Bing]
Capture.png
4KB, 517x72px
>>54776509
HELP GEE

how do i get this arraylist element to equal something?! the compiler says it has to be a variable and .get wont do justice?!?!
>>
>>54777026
language?
>>
>>54777056
JAVA
>>
>>54777026

If only ArrayList had a set function.
>>
java.lang.ArrayIndexOutOfBoundsException


I swear I don't have any array index errors.
>>
>>54776596
Deepmind is not by any means world's top AI company. It's right in the middle. The only reason why you think otherwise is because it's attached to google, so there's constant sensationalism and clickbait about them.
>>
>>54777065
I SAID it has to be a variable
>>
>>54776817
[spoiler]too lewd[/spoiler]
>>
>>54777065
oh wait nevermind i think i got it
>>
>>54777105
>The only reason why you think otherwise is because it's attached to google

Actually the reason is I'm reading machine learning papers and look at who works where. DeepMind has clearly stated it's general AI goals, attracted top machine learning Phds and funding.

But I'm open to discussion. Do you think there are other better general AI companies or divisions?
>>
File: Capture.png (4KB, 497x79px) Image search: [Google] [Yandex] [Bing]
Capture.png
4KB, 497x79px
HEY /g/UYS

can you help me with this swaping method too??
>>
File: no.gif (1MB, 636x342px) Image search: [Google] [Yandex] [Bing]
no.gif
1MB, 636x342px
>>54776683
>on your screen
>2016
>>
My 2d mmorpg sex sim
>>
>that feel when you finish program and it works but since its going on your public portfolio you have to go back and use
>muh best practices and rewrite a shit ton of stuff just so you hope people wont judge you as bad
>>
>>54777217
do your own homework
>>
>>54777217
I have no idea what your stupid abstractions are trying to do.
int tmp = a;
a = b;
b = tmp;
>>
>>54776551
>>54776825

>linux problems

i have no idea what the fuck you just said
>>
>>54777231
Shouldn't your sex sim be single-player only?
>>
>>54777246
im in a time crunch
>>54777251
im using arraylist though
>>
>>54777291
then fail like you deserve to faggot
>>
>>54777291

Time to rewrite the whole project in Ruby.
>>
>>54777297
fuck you this is my extra DAMN CREDIT. IM NOT ENDING UP LIKE YOU
>>
>>54777288
ayy
>>
>>54777189
>Actually the reason is I'm reading machine learning papers and look at who works where.
If you did you would not think of deepmind anywhere near as highly as you do, which shows that not only you have never read a single ML paper, but I clearly hit the nail on the head when calling you out as a MSM consumer. Even baidu, despite their constant use of underhanded tactics and lies, are significantly more relevant in the grand scheme of things.
>>
>>54777217
why the fuck are you mixing primitive array and ArrayList operations.

It's fucking highlighting it for you

4/10, made me reply
>>
>>54777291
All those Java abstractions complicate things. Just write it in assembly on some paper and hand-assemble the program with an Intel manual or something for reference.
>>
>>54777306
>his grades are so shit he needs extra credit
you're not gonna make it anon
>>
>>54777306
>i can't succeed but i don't want to fail
Selfish cunt
>>
File: Capture.png (4KB, 455x78px) Image search: [Google] [Yandex] [Bing]
Capture.png
4KB, 455x78px
>>54777327
NO i didnt explain well. but look, this is what i DID GEE R8 HOW I DID?
>>
>>54777322
>MSM consumer
>https://en.wikipedia.org/wiki/Methylsulfonylmethane#Medical_and_dietary_use
???
>>
>>54777217
not sure if trolling
>>
>>54777355
Why do you need that arraylist shit?
>>
>>54777341
>>54777344
I already aced my final, its just the last project i gotta finish. Im doing the extra credit portion

now look here>>54777355
>>
>>54777217
"a" is passed to the function you don't need to initialize it again.
>>
>>54777376
>can't implement a basic swap function
>aced the final

Wow your degree is worth shit all isn't it?
>>
>>54777368
for selection and insertion sorting, with an arraylist

its part of the extra credit
>>
>>54777359
Mainstream media
>>
>>54777390
Why can't you use a normal array?
Even if you need dynamic resizing, it's trivial to write a wrapper for it.
>>
>>54777384
Im sorry im not a swapping expert like you, the first time i swapped shit with arrays
>>
Rust is the best language I've ever used. it's simply magical. The only issue I see with it is that closures are "special" and can't easily be returned from functions or methods (as opposed to lambdas).
>>
started an internship

how the fuck do I learn this massive codebase

most of my day is spent with breakpoints and go to definition
>>
File: Capture.png (9KB, 409x208px) Image search: [Google] [Yandex] [Bing]
Capture.png
9KB, 409x208px
>>54777401
oh yeah, because of pic
>>
File: swap_2_ints.png (10KB, 280x305px) Image search: [Google] [Yandex] [Bing]
swap_2_ints.png
10KB, 280x305px
>>54777376
Here is how you do it.
>>
>>54777410
jesus fucking christ, why is every bit of your text fully highlighted?

it's like taking a highlighter and running it through every paragraph in the book, nothing stands out if everything is colored.

Also, I can guarantee that your CS program isn't worth jack shit if you can't even write a simple swap function.
>>
File: PhD in Incompetence.png (125KB, 813x600px) Image search: [Google] [Yandex] [Bing]
PhD in Incompetence.png
125KB, 813x600px
saved
>>
Just doing some Unity Tutorials. Tired of only making web apps at work.
>>
>>54777429
i just need help with the arraylist man
>>
>>54777515
You don't need array lists.
>>
>>54777532
let me explain, the extra credit wants me to fill up arrays with random values but each value is unique (cant have duplicate numbers). I can only do this with arraylist because I can use Collections.shuffle to mix up the elements after i fill the lists up. I DO need arraylists
>>
>>54777322
Baidu hasn't published much and I haven't seen any baidu results on reinforcement learning at all.

By general AI I mean cutting edge reinforcement learning, not mere better voice recognition.

DeepMind isn't just hype, their reinforcement learning agents literally made impossible possible, especially the latest A3C: arxiv.org/abs/1602.01783
>>
>>54777486
iktf

no geimu no laifu

btw I'm writing a javascript game engine.
>>
>>54777564
Wow, your CS program is truly worthless.

You can't even begin to imagine how to write a random shuffler function?

This is who I'm competing with?
>>
>>54777606
You should be thankful, anon
>>
File: costanza.jpg (9KB, 250x250px) Image search: [Google] [Yandex] [Bing]
costanza.jpg
9KB, 250x250px
>>54777570
>cutting edge
>isn't just hype
>made impossible possible
You're right. That's more than hype. That's fanboyism.
>>
>>54777680
*yawn*
debate the technical part, please
>>
>>54777606
google didnt tell me i could do that, and it looks more time consuming
>>
>>54777686
>made impossible possible
This is a useless and masturbatory way of saying "invented a new thing."
>>
>>54777570
M8, you don't even have a single clue. You don't even begin to show any hint of understanding of what you're saying. The only thing you can do by posting more is getting BTFO even further.
>>
>>54777705
ok, I'm going to bed
see ya later
>>
>>54777694
I gave it 5 seconds of thought
>take array
>create second array
>populate second array with values randomly selected from first array
>memmove overlap that value to delete it
>return new array
>>
>>54777217
>>
>>54777737
i dont know what memove is
>>
>>54777761
use your imagination you dumb kid
>>
>>54777288
underrated dubs
>>
File: progress.png (305KB, 1825x955px) Image search: [Google] [Yandex] [Bing]
progress.png
305KB, 1825x955px
Working on refactoring. I moved from a "big-ball-of-state" main structure to one containing only two fields: one representing the player, and the other representing the quadtree. The quadtree is now the main data structure of the game, and the player field (containing another struct) is just for convenience since it needs to be passed to some of the other entities in the quadtree. This has simplified a lot of functions. For example, rendering is no longer a manually nested sequence of rendering functions for each field representing each set of entities in the game, now I just walk the tree and render entities as I go along. There's a similar process for updating the game. Now I just have to figure out a simple way of "exiting" the quadtree while in the middle of it in order to reinsert entities, for when entities fire projectiles at one another during game updates.
>>
>>54777822
>normal comments instead of doc comments
>>>/trash/
>>
>>54777406
Welcome to the enterprise life.

:^)
>>
>>54777831
>doc comments instead of normal comments
>>>/r/eddit
>>
>>54777831
I don't know what that means.
>>
File: Capture.png (15KB, 338x376px) Image search: [Google] [Yandex] [Bing]
Capture.png
15KB, 338x376px
>>54777765
Im NOT making another array, or listening to you, disgraceful edgy BASTARD
>>
>tfw emacs STILL doesn't have proper OTF font support
ligatures and proper font rendering when?
>>
>>54777885
>ThreadLocalRandom

It's ogre. It's all ogre.
>>
I need to select a specific element in an array and update it's contents.

I have a limit of 5 of these elements, but they are not reset in order of usage.

I need to find ONLY the first 'available' slot in the array and use it.

So bullet 0 and 3 may be active, because 1 has collided with and object (4,5 are waiting as well), thus been reset to a ready state.

Language is C, I just don't know how to do the control statement for making sure that only the first 'available' element will be chosen.
>>
>>54777885
I already gave you a solution (>>54777428)
m8.

If you're unsure what those instructions do just google them like you googled everything else.
>>
>>54777885
I'm not familiar with java, is your dumbass function duplicating your values?
>>
>>54777900
how old are you burger?
>>
>>54778012

21
>>
>>54778018
and how's the .22 riffle?
>>
>>54777973
man you dont even know what the hell is going on
>>
>>54778018
>I'm older than the OSGTP
feels superior.
>>
>>54778094

fuck off already
>>
>>54778164
who hurt you, anon?
>>
>>54778094
And it only gets worse.
>>
>>54778050
it's really not that great a feeling
>tfw you will be 30 years old and still stuck here
>>
>>54778273
>Stuck here
I guess I came here too early. I want to be stuck here; it's better than being stuck anywhere else. Fuck the real world.
>>
File: 1451035301826.jpg (64KB, 600x687px) Image search: [Google] [Yandex] [Bing]
1451035301826.jpg
64KB, 600x687px
>>54778256

Thank you for the kind words.
>>
>>54776509
ou do cast, because:

It makes your code more portable between C and C++, and as SO experience shows, a great many programmers claim they are writing in C when they are really writing in C++ (or C plus local compiler extensions).
Failing to do so can hide an error: note all the SO examples of confusing when to write type * versus type **.
The idea that it keeps you from noticing you failed to #include an appropriate header file is rather stupendously stupid. It's the same as saying "don't worry about the fact you failed to ask the compiler to complain about not seeing prototypes -- that pesky stdlib.h is the REAL important thing to remember!"
It forces an extra cognitive cross-check. It puts the (alleged) desired type right next to the arithmetic you're doing for the raw size of that variable. I bet you could do an SO study that shows that malloc() bugs are caught much faster when there's a cast. As with assertions, annotations that reveal intent decrease bugs.
Repeating yourself in a way that the machine can check is often a great idea. In fact, that's what an assertion is, and this use of cast is an assertion. Assertions are still the most general technique we have for getting code correct, since Turing came up with the idea so many years ago.
>>
Abstraction was a mistake
>>
>>54778418
Can you be more specific?
What do you mean by abstraction?
>>
Encapsulation was a mistake
>>
>>54778418
A little abstraction is good, too much and you get dumb shit like reduce map and filter.
>>
>>54778443
Beyond machine language
>>
>>54778454
Machine language is pretty abstract 2bh
>>
>>54778447

reduce, map, and filter are GOAT, though.
>>
>>54778475
Explain why without using memes.
>>
>>54778588
DRY
>>
how would you implement this in OCaml/F#
-- | The 'intersect' function takes the list intersection of two lists.
-- For example,
--
-- > [1,2,3,4] `intersect` [2,4,6,8] == [2,4]
--
-- If the first list contains duplicates, so will the result.
--
-- > [1,2,2,3,4] `intersect` [6,4,4,2] == [2,2,4]
--
-- It is a special case of 'intersectBy', which allows the programmer to
-- supply their own equality test. If the element is found in both the first
-- and the second list, the element from the first list will be used.

intersect :: (Eq a) => [a] -> [a] -> [a]
intersect = intersectBy (==)

-- | The 'intersectBy' function is the non-overloaded version of 'intersect'.
intersectBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]
intersectBy _ [] _ = []
intersectBy _ _ [] = []
intersectBy eq xs ys = [x | x <- xs, any (eq x) ys]
>>
>>54778606
that's a meme
>>
>>54778588

More compact code.
>>
>>54778636
meme

Give a real, concrete benefit of using higher order functions.
>>
>>54778653
>>54778631

do you code without using functions then?
>>
File: 1448137611091.jpg (68KB, 526x572px) Image search: [Google] [Yandex] [Bing]
1448137611091.jpg
68KB, 526x572px
>>54776509
>posting homosexual trap degenerate crap

End yourself right now you disgusting faggot.
>>
>>54778672
hime isn't gay
>>
>>54778609

let intersectBy eq xs ys =
[ for x in xs do
if List.exists (eq x) ys then
yield x ]


let intersect x y = intersectBy (=) x y
>>
>>54778707
lazy version - use Seq.exists and wrap the whole thing in seq { } rather than [ ]
>>
>>54778707
Wait, you can just do this
let intersect xs ys = List.filter (fun x -> List.contains x ys) xs
>>
I'm a total webdev noob, hoping someone can help.

I'm trying to make a website using django that uses the steam api to show info about a user whose id you input. I can get it to retrieve and show the info with json but I can't figure out how to get that json stuff into an html template. Help please?
>>
>>54778707
>>54778748
cheers
>>
I'm writing R functions to do arithmetic with arbitrarily large integers. A package exists for this but I want the experience of building it.

Btw, will posting things like this on github help land a job or make me look like a helpless autist?
>>
>>54778609
By using rust instead.
>>
>>54778909
Rust is garbage
>>
>>54778909
Rust has that intersect function?
>>
anyway here it is, haskell copied functions (since it wasn't apparently in the standard library)
doing >>54771500 with >>54772078

let span p = 
let rec loop k = function
| x :: xs' when p x ->
let f (ys, zs) = x :: ys, zs
loop (f >> k) xs'
| xs -> k ([], xs)
loop id

let groupBy eq =
let rec loop k = function
| [] -> k []
| x :: xs ->
let (ys, zs) = span (eq x) xs
let f zss = (x :: ys) :: zss
loop (f >> k) zs
loop id

//Special case of 'groupBy', group by equality.
let group xs = groupBy (=) xs
//intersect with duplicates
let intersect xs ys = Seq.filter (fun x -> Seq.contains x ys) xs

finally
let longestStreak x y = List.ofSeq (y |> intersect x) |> group |> List.map (List.length) |> List.max

> "AGR" |> longestStreak "AABGZZZARRRRRR";;
val it : int = 6
>>
>>54779071
you should look into the parser monad
>>
>>54778761
>>54746692
>>
>>54778928
>Rust is the best language
FTFY
>>
>>54779345
let's compromise

Rust is the best garbage
>>
>>54779353
Let's compromise: Every language that's not rust is garbage.
>>
>>54779403
I don't deal with terriblists
>>
>>54779604
use monads
>>
>>54779604
use you're mum's anu's
>>
so what's the best 'functional' language to learn?
perl6?
ruby?
haskell?
lisp?
>>
>>54779604
C++ supports short-circuiting
Just test it dude
if (foo1() || foo2())
;
// only foo1 should execute if it returns true
>>
>>54779910
NIGGER
>>
>>54779902
Rust
>>
>>54779902
Haskell
>>
>>54779902
>haskell
>functional
top kek people actually believe this
>>
>>54779902
out of those 4 Haskell is really the only one that is a "functional language". the rest support FP but that's not what they're specifically meant for
>>
>>54780129
Haskell isn't functional, it's dysfunctional
>>
>>54780217
xD good pun upvoted XDDDDD
>>
>>54780224
Are you new here?
>>
>>54780236
yes i just joined yesterday, can u show me the ropes plz??????
>>
>>54780246
>>
File: 1464274380541.jpg (87KB, 953x960px) Image search: [Google] [Yandex] [Bing]
1464274380541.jpg
87KB, 953x960px
>>54780086
>>
It's time to do that thing again where I program in Java for assignments and shit. In a few weeks though, all of this shall be over, and summer will start.

Java... it's like an office chair. Not the most comfortable sitting experience, but not extraordinarily painful. That said, I'd rather program from my bed or while sitting on a couch.
>>
>>54780418
>Java
>not extraordinarily painful
>>54780267
>>
>>54779317
o shit thanks
>>
Ok so I'm _still_ (day 3, not 8 hours every day) trying to build http://mosra.cz/blog/magnum-doc/getting-started.html
Found Corrade: C:/Magnum/magnum-bootstrap-base/corrade/src  found components:  Containers Utility rc PluginManager 
CMake Error at corrade/modules/UseCorrade.cmake:333 (add_custom_command):
add_custom_command called with OUTPUT containing a "#". This character is
not allowed.
Call Stack (most recent call first):
magnum/src/Magnum/Shaders/CMakeLists.txt:26 (corrade_add_resource)


CMake Error at corrade/modules/UseCorrade.cmake:333 (add_custom_command):
add_custom_command called with OUTPUT containing a "#". This character is
not allowed.
Call Stack (most recent call first):
magnum/src/Magnum/TextureTools/CMakeLists.txt:26 (corrade_add_resource)


Found Corrade: C:/Magnum/magnum-bootstrap-base/corrade/src found components: Containers rc Utility PluginManager
Configuring incomplete, errors occurred!
See also "C:/Magnum/magnum-bootstrap-base/build/CMakeFiles/CMakeOutput.log".
See also "C:/Magnum/magnum-bootstrap-base/build/CMakeFiles/CMakeError.log".

I've progressed quite far now.

But where do I even go to ask about shit like this? Do I just open an issue on the github? Seems a bit obnoxious to clutter their dev stuff.
At what point can I consider it their fault? Really this process is getting quite onerous considering they're saying
"Setting up a new project can be pretty gruesome and nobody likes repeating the same process every time. Magnum provides "bootstrap" project structures for many use cases, helping you get up and running in no time."
At the top of the page..
>>
Is there some kind of "project generator for the uncreative but wanting to work on something programmer"
>>
>>54780633
you've just given yourself a project to make
>>
Can anyone figure out a better way to solve this in Javascript?
Someone posted a really cool answer in Haskell today, but javascript doesn't have a function like 'intersect'. This is my 1st time using reduce().
It would be cool if there was a way to solve this without using "curr" and "longest" to keep track of the longest and current streaks.

array.length would be vital to solving this in a functional way, I'm sure. If there was a way to split the 'str' into substrings or subarrays, then a function could just loop through the array of arrays/substrings and check if currentSubArray.length > longest. but even that's using assignment, which apparently isn't pure functional

/*
Given a string of repeating characters and a list of targets,
find the longest consecutive string of target letters in the
given string.

findConsecutive("AAAZZGYYYYYYYYQ", ["G", "Q", "Z"]);
// returns 2, because two Z's
*/

var str = "AACCCVVVHGJJJDKDNWIEUDNDNDDDLLLWEEJJJTTTIIILWWWWITUENXXNGXGFFFFFF";
var targets = ["A", "B", "C", "W"];

var curr = 0, longest = 0;
str
.split('')
.reduce(
function(previousValue, currentValue, currentIndex, array) {
curr = (targets.indexOf(currentValue) == -1) ?
0 : (previousValue == currentValue) ?
curr + 1 : 1;

longest = curr > longest ? curr : longest;

return currentValue;
});

console.log(longest); // 4
>>
File: Untitled.png (12KB, 979x512px) Image search: [Google] [Yandex] [Bing]
Untitled.png
12KB, 979x512px
I am proud of my tables.

They adapt to fit the content.

wahoo
>>
>>54776836

>winnipeg

rip my man

basically worst province in canada
>>
>>54780708
arr.filter((x) => arr2.includes(x))
>>
>>54780732
>"Name" and "Handle" are right-adjusted but "PID" and "Title" are left-adjusted
>>
>>54780732
Why not use box drawing characters?
>>
>>54780745
ah i tried something like that earlier, only i used indexOf, rather than includes.

problem is, that will make separated target characters suddenly joined.

like so:
'aaazaaa', // target: a
would turn into 'aaaaaa'.
so then that'd be a streak of 6, but that's wrong because the original only had a longest streak of 3
>>
>>54780633
Go to that list of integer sequences and pick a random sequence.
Make a program that generates that sequence.
Optimize it to the best of your ability.
Submit it.
Find another sequence.
>>
>>54780781
i mean that's javascript intersects
>>
>>54780732
senpai you programming your own console? I think we might have some code to exchange.
>>
>>54780708
What if there are two or more longest streaks, such as AGGAAAZZ for G and Z?
>>
>>54780809
i guess the answer would just be the longest? so 2.
>>
>>54780752

it's because it looks fucky when there's a long title or process name if name is left aligned or title is right aligned. I think its better to keep the headings together rather than super spread apart.
>>
if there was a way to break
'aaadddyylrr'
into
'[ [aaa], [ddd], [yy], [l], [rr] ]'
that'd probably be key to solving the problem.

String.split('') would be perfect if i could pass it a callback which takes two args and returns true if they're different and false if the same (and splits the current string if true)
>>
>>54780806

wow what is this
>>
>>54780809
>two or more longest streaks
>two or more
>longest

maximum :: Ord a => [a] -> a
>>
>>54780835
what?
>>
>>54780832
https://github.com/Wunkolo/SaiPal/releases

I did ElDorito too if you've heard of that and some other little off-hands.
>>
>>54780835
what language?
how does it work?
what does it do?
>>
>>54780849
that's fucking neato
>>
>>54780845
>>54780850

the function maximum takes a list of items of type a (where a is an instance of the Ord typeclass) and returns an a
>>
>>54780860
How does that answer the question?
>>
File: Untitled.png (15KB, 977x515px) Image search: [Google] [Yandex] [Bing]
Untitled.png
15KB, 977x515px
>>54780806

it's a general purpose console app for putting input into other processes message queues at a low level. I guess it could be used for automation when it's finished, the one big problem is that it's up to the user to structure the messages correctly. I don't want to rewrite Spy++ for a tiny console app.
>>
>>54780830
Just write a function that keeps track of the previous character and the first index it saw it on. Iterate over the string. When it encounters a new character type save the string/indexes in some way. (maybe in a list since that's what you wanted) and begin counting for the new character type.

Are you writing python?
I'm really surprised that someone would have trouble figuring this out.
>>
>>54780863

there's only ever going to be one result
>>
>>54780884
In your implementation. I was asking what the original task requested.
>>
what's better than strings for haskell
I know some people use OverLoadedStrings pragma
is Data.Text better?
>>
>>54780894
in the original task you numpty
>>
>>54780881
I mean, I solved the prompt.
I'm just trying to come up with ways to solve the problem in a 'more functional' way, rather than relying on the big chunk of code I used in reduce in >>54780708
>>
>>54780781
>so then that'd be a streak of 6, but that's wrong because the original only had a longest streak of 3
I'm pretty sure the Haskell solution actually fails in this case as well.
>>
>>54780898
What for? If you want to support Unicode, you should use something like Text or ByteString.

>>54780899
ok kid
>>
>>54780908
Sounds fairly arbitrary but good luck.
>>
>>54780919
Corrected Haskell version:
longest :: String -> [Char] -> Int
longest str targ =
maximum
$ map length
$ filter ((`elem` targ) . head)
$ group str
>>
>>54777606
Typical CS student at no doubt a 100% Java school who aren't taught anything beyond "if you type this, this should happen"
>>
>>54780982
neat

>>54780925
yeah, i know. im trying to impose this requirement on myself that I go for a 'functional as possible' answer.
>>
>>54780924
just string parsing to interpret 4chan json
hoping to make the binary size smaller and more efficient too

is bytestring better?
>>
>seeing C# code ITT
It's like C++ with Java's inelegance. How do people bare it for things other than Unity? I already know ASP.NET is shit
>>
>>54781008
Yes, ByteString are faster, because they're implemented more reasonably, but consequently dissecting them character by character (why you shouldn't really have the need to) as with regular lists is ineffective.

In comparison to String, which is, as you presumably know, just a linked list of Chars, they're much more efficient for the usual string-handling tasks, though.
>>
>>54780982
That's not total, though.
>>
>>54781076
Forgot to mention that you need Text if you want to work with the JSON as UTF-8 and so on. Also see https://stackoverflow.com/q/7357775
>>
>>54781086
Haskell isn't total.
total < correct
>>
>>54781095
You can easily make it total. Don't be lazy, family.
>>
This will give you a sequence of (char, int) pairs for consecutive occurrences
You can use that to pick the longest
(F#)
let consecutives s = 
let s = Seq.map fst (Seq.filter ((<||) (=)) (Seq.pairwise s))

Seq.fold (fun subs x ->
match Seq.tryHead subs with
| Some (c,i) when c=x -> seq { yield (x,i+1); yield! Seq.tail subs }
| _ -> seq { yield (x,1); yield! subs }
) Seq.empty s
>>
>>54781109
What, it's not total because I used head? group either returns an empty list, or a list of non empty lists, so head is guaranteed to be correct.
I could write excess code to handle this, such as rewriting group, but I like my solution.
>>
>>54781140
maximum is not total either.
>>
>>54781137
actually, this is slightly broken
works weirdly with length 1s and with the edges of the string
>>
>>54781137
Ok, just remove the

let s = Seq.map fst (Seq.filter ((<||) (=)) (Seq.pairwise s))

and it'll work
>>
>>54781076
dissecting char by char is the only way, right?
using other libs which don't even work (json, aeson) won't help
>>
>>54781043

It's pretty hard to beat c# when it comes to writing simple utilities or desktop applications for windows.

It's easy to learn, hard to fuck up, and has a library for most things unless you're doing something weird. Plus you can always just import and call externally the lower level windows API functions if you need them.

It's a productive language. I'll agree with you about ASP.NET though, utter shit, widely used but utter shit.
>>
>>54781152
import Data.List(group)
longest :: String -> [Char] -> Int
longest str targ =
foldl max 0
$ map length
$ filter (any (`elem` targ))
$ group str


>>54781001
The javascript-functional way would be to use callbacks.
function groups (arr, cb)
{
var val = arr[0], n = 1;
for (var i = 1; i < arr.length; i++) {
if (arr[i] == arr[i - 1]) {
n++;
} else {
cb(val, n);
val = arr[i];
n = 1;
}
}
cb(val, n);
}

function longest (str, targ)
{
var n = 0;
groups(str, function (char, len) {
if (targ.includes(char)) {
n = Math.max(n, len);
}
});
return n;
}
>>
>>54780925
man, this took me WAY too long.
But I used reduce and I didn't use a counter :)
although I did have to use a 'return' array and a 'current streak' array

function differenceSplit(str){
var ret = [], curr = [];

str.reduce(
function(previousValue, currentValue, currentIndex, array) {
if (currentValue != previousValue){
if (currentIndex == 1)
ret.push([previousValue]);
else
ret.push(curr);

curr = [currentValue];
if (currentIndex == array.length - 1)
ret.push(curr);
}
else {
if (currentIndex == 1)
curr.push(previousValue);
curr.push(currentValue);

if (currentIndex == array.length - 1)
ret.push(curr);
}

return currentValue;
});

return ret;
}

Array.prototype.diffSplit = function () {
return differenceSplit(this);
};

console.log([1,2,2,3,4,5,5].diffSplit());
console.log(("AAGHJJYYYLRRYRRYRRRRY".split('')).diffSplit());
>>
>>54781219
wow that is some MEAN looking javascript it's going to take me a while to get how it works.
>>
>>54781219
ah that's dope how your callback function references longest's 'targ' parameter, you made a clojure
>>


let consecutives s =
Seq.fold (fun subs x ->
match Seq.tryHead subs with
| Some (c,i) when c=x -> seq { yield (x,i+1); yield! Seq.tail subs }
| _ -> seq { yield (x,1); yield! subs }
) Seq.empty s
let intersectsBy f a b = Seq.filter (fun x -> Seq.exists (f x) b) a
let longestConsecutiveOf chars s = Seq.maxBy snd (seq {
yield! intersectsBy (fst >> (=)) (consecutives s) chars;
yield (' ',0)
})
let soltn c s = snd (longestConsecutiveOf c s) // final solution (just returns length)
printfn "%A" (longestConsecutiveOf "AZQ" "AAAZZGYYYYYYYYQ") // ('A', 3)
printfn "%A" (longestConsecutiveOf "AZY" "AAAZZGYYYYYYYYQ") // ('Y', 8)
>>
>>54781253
>>54781260
Hopefully informative comments for groups() procedure. longest() should be easy to understand
/* calls cb(val,n) for every grouped
sequence of 'val' in 'arr', of length 'n'
e.g.
groups("AABCCC", f)
calls
f("A", 2);
f("B", 1);
f("C", 3); */
function groups (arr, cb)
{
var val = arr[0]; // current value in sequence
var n = 1; // length of sequence
for (var i = 1; i < arr.length; i++) {
// is there a break in sequence?
if (arr[i] == arr[i - 1]) {
n++; // if no, increase seq length
} else {
// if yes, send callback about old seq
cb(val, n);
// create new sequence based on this value
val = arr[i];
n = 1;
}
}
// call again for the last sequence in the array
cb(val, n);
}
>>
Optimized some file I/O code, mostly the "I" part.

Now I can load and parse the same amount of stuff in 100-150 milliseconds that previously took 1.5-2 seconds. It also helps by not reading stuff one byte at a time, but in larger chunks. This in non-optimized builds. In optimized builds I routinely get <50 millisecond times.

Remember kids: I/O is always slow, avoid it as much as possible. When you have to do it, read and write large chunks.
>>
>>54781219
oh my fuck you used a clojure on 'n' as well

i like how in groups, you start your for loop with the 2nd element and compare to the prior. you can carry on with a normal for loop that way without checking to see if you're too close to the end.

not only is your answer badass, it's also shorter than mine, AND you didn't try to cut corners - you used curlies even when you didn't have to, like the if statement in the callback declared in longest.

god damn i wish i could write code like you. it seriously just took me like 7 minutes to wrap my head around your code, fuck. are you like the Mozart of programming or what
>>
File: a.png (258KB, 500x351px) Image search: [Google] [Yandex] [Bing]
a.png
258KB, 500x351px
>>54781283
Isn't that common knowledge?
>>
>>54781268
hey F# dude if you're interested in converting people to F#, tell us why you like F#
>>
File: 1450210916535.gif (295KB, 700x704px) Image search: [Google] [Yandex] [Bing]
1450210916535.gif
295KB, 700x704px
>>54781289
>clojure
lol, "clojure" is a language and "closure" is a function with scope. But I'm glad you understand what makes a closure a closure, people get that terminology confused so often.

>AND you didn't try to cut corners - you used curlies even when you didn't have to,
I'm trying to get used to this coding style. I used to aggressively omit curlies when there was only one statement.

>>54781283
>Remember kids: I/O is always slow, avoid it as much as possible. When you have to do it, read and write large chunks.

>mfw people microoptimizing their for-loops and integer averaging functions when the bottleneck is ALWAYS IO (or the cache)
>>
>>54781318
the code can be really clean and concise
it's nice to write in

though there could be significant improvements, namely
>higher kinded polymorphism
>macros & compile time evaluation
>performance
>>
>>54781343
cool thx
>>54781335
I'm pretty sure I'm going to save your answer and just look at it every day until I can write code like it, that's just how crazy cool I think it is.

Earlier today I wrote some code like this:
while((function(){
// something with somevar
})())
somevar++;


and was pretty proud of myself cuz i felt like i was thinking outside of the box
>>
Is /pol/ the only board being slid right now?
>>
>>54781317
Illya is a cuck and that's a fact.
>>
>>54781460
Women can be cucks if they want
>>
>>54781428
Hopefully.
>>
File: wow anon.jpg (78KB, 884x574px) Image search: [Google] [Yandex] [Bing]
wow anon.jpg
78KB, 884x574px
int i = 1;
++i++;
printf("%d", *(int *)&i)
>>
I was looking through my shelf the other day and I noticed I had this book. My parents must've bought it for me when I was in high school several years ago, anyone have experience with this book? I've been recently looking to relearn C++ since I only ever did an introductory CS class 2 years ago, never did anything with C though so I suppose it's fine to start there. Table of Contents has a chapter titled "On to C++" as well. Worth a read?
>>
>>54781590
look at me im so smart anons!
>>
>>54781343
Ok except macros are really not needed
>>
>>54781622
you could have read the book instead of asking about it
>>
>>54781676
your parents could've aborted you instead too
>>
>>54776509
Hey guys. I'm trying to make a CrackMe program in C++ using CLion. It works fine, but when I try to compile it using G++ for use on Windows 7(to use Olly/Ida on it) it doesn't work.

How do you do cross platform C/C++? I figure now is as good a time as any to learn.
>>
>>54781685
I could have came in your dad's ass instead of your mom's pussy when the three of us planned to attempt to conceive you, but I really wanted a brother.
>>
>>54781709
easy there m8
>>
>>54781730
we're blood brothers. destined to mate for life.
>>
>>54781667
(You)
>>
>>54781751
Thank fuck the core team agrees with no macros
HKT will be added by C#8 though, which is good
>>
File: gourmet.webm (1MB, 720x404px) Image search: [Google] [Yandex] [Bing]
gourmet.webm
1MB, 720x404px
/dpt/-chan, dai suki~

>>54781708
Have you installed mingw ?

You then do mingw32-g++ foo.c -o foo.exe

>>54781708
>I'm trying to make a CrackMe
Source ?

>>54781428
pol is gossip now, they goes nut on depp vs amberd.
>>
>>54781708
>I'm trying to make a CrackMe program in C++ using CLion. It works fine, but when I try to compile it using G++ for use on Windows 7(to use Olly/Ida on it

Don't. It will be a shit crackme if you target Windows with gcc because of all the extreme bloat mingw or cygwin will add.

>How do you do cross platform C/C++
With preprocessor macros used at the lowest level possible, then you build your functionality on that so compiling with gcc (on Linux) is no different than using MSVC on Windows.
>>
>>54781795
Implementing macros is a good thing, and it's incredibly odd to see a language which has so many DSL features saying no to macros. At the very least I hope we get something more like monad comprehensions in F# rather than the less concise computation expressions


also, source on HKT?
>>
>>54781799
Here's my source.

It's nothing special and I threw it together in 2 minutes, and and my C++ sucks.

http://pastebin.com/NBMVEVc6
>>
>>54781842
Well shit.
So do I just stick to using VMs for reverse engineering?
>>
>>54781848
what

And that doesn't compile everywhere?
>>
>>54781880
Nope.
You know what really pisses me off? I just compiled the EXACT SAME source file in Clion IN MY WINDOWS 7 VM and it's still fucking bitching about missing the same DLL. Maybe it's a problem with my Windows setup.
>>
>>54781921
OK GOT IT!
I had to compile it like this:
i686-w64-mingw32-c++ -static main.cpp -o CrackMe.exe
>>
I'm writing an IRC bot. It needs to process incoming messages and reply to them.
Is it a good idea to dump all incoming messages in a queue and have a thread processing them (while also have the same thing for outgoing messages)?
>>
>>54781972
What are you writing it in?

I suggest the Twisted library if it's in Python.
>>
>>54781972
As long as you join the threads before sending any replies to the same server or user. Is your processing really this heavy?
>>
>>54781972
The delay between messages will likely be MUCH MUCH MUCH MUCH longer than it takes you to process a small string.
>>
>>54781972
if your bot has an user interface, then you should have two threads: gui and network. if not, one thread is enough.
>>
File: idiot sandwich.jpg (58KB, 552x621px) Image search: [Google] [Yandex] [Bing]
idiot sandwich.jpg
58KB, 552x621px
>>54781998
I'm indeed writing it in Python, but with raw sockets. Twisted does not sound like a good time, I'll pass.

>>54782007
>>54782032
I guess I should explain the reason for my question.
(I warn you it's a pretty dumb entry-level OOP question)

There are two classes, IRC and Bot. IRC handles all the rx/tx stuff and Bot handles all the command parsing and figuring out what to reply with.
Both IRC and Bot need to use each other's methods: for example IRC needs to give a message to Bot for handling it, and IRC sometimes needs to just send something using a method from IRC.
How does one make it work?

Currently I do this:
bot = Bot()
irc = IRC(bot)

But that doesn't allow Bot to use any of IRC's methods, only IRC use Bot's methods.
I want this:
irc = IRC(bot)
bot = Bot(irc)

but it's obviously wrong.

The queue idea solves this problem, but it's maybe overkill.
>>
>>54782131
What you really want is:
irc_bot = IRC<Bot>();
>>
>>54782131
A queue isn't a bad idea (I'm assuming that's just a basic array structure in python).

I just wanted you to keep in mind that most likely there won't be more than 1 item in that queue, due to the speed it takes a computer to process a string with the length you'd usually get in a chat message, is laughable.
>>
>>54782179
I have no idea what this does.

If it wasn't clear again, my code snippet basically indicated that I passed Bot object as an argument, stored it as a bot variable in the IRC object and then had
self.bot.someBotMethod()
in the IRC class any time I wanted to use methods from it.

I don't think that's how this whole OOP thing is supposed to be done, but that's what I hacked together and now it's falling apart. I should read up on some higher-level OOP concepts or something.
Any pointers?
>>
>>54782229
The most simple solution for you currently would probably be, to create a function in each of those classes that accepts the other class as a parameter and sets it to a local variable.

I have no clue how python works, but probably something like that.

bot = Bot()
irc = Irc()

bot.setIrc(irc);
irc.setBot(bot);

This is obviously terrible, and I don't even know if it's valid python. But it should work if I understand what you've been trying to say.
>>
>>54782131
Why not have a class that contains an instance of both objects and acts as a controller?
>>
>>54782227
>there won't be more than 1 item in that queue
I know. "Queue" could not be a queue at all, for all I care. I just need some medium for two way communication between objects. Two queues is what I came up with.

>>54782275
That will probably work, but it only makes me once again realize that the whole structure of the program is flawed and I just don't know any better.
Thanks anyway, I'll try that.

>>54782319
Huh, I never thought of that. Thanks, I'll look into this.
>>
Programming fast Fourier transform in Haskell's type system.
>>
>>54782750
Is it Turing complete? I wouldn't doubt it.
>>
>>54782818
Yes. That doesn't mean much, though. Agda is Turing-complete as well.
>>
I want to achieve transparency in C# and Windows Forms (don't want to use WPF because of mono).

I get it that you can simply put
this.TransparencyKey = Color.Magenta;
this.BackColor = Color.Magenta;


This works, but I also have text in form of a Label or RichTextBox in front of the transparent background. This way the text gets a very ugly color instead of black and also has ugly white outlines.

Any way to make this better?
>>
Work is slow so I'm going to work a compiler for the soon-to-be compilers course at my Uni. The main feature is that it will visualize the process of compilation from lexing to code generation. And if I have time, execution. It should be able to compile small snippets, but be able to compile entire programs if necessary.

The need for small snippets drew me towards tacit languages like J. But after learning J I feel tacit is lacking something, like holding intermediate computations in a temporary store. So I mixed in a bit of Forth, namely the stack and stack operations. Each function will be defined with a preset number of inputs and a number of outputs. Evaluation will begin on the right side of the input and all values pushed onto the stack, then a function will get its arguments from that stack. For example:
x =: 1 /* this pushes 1 onto the stack, and =: is a function that pops values off the stack equal to the number of labels provided, and assigns the values to the labels */
add_3 =: (int <- int) + 3 /* + is a function that takes two arguments, one if provided and the other is sourced by the stack. This makes a new function that records those instructions. */

Also will include common ADTs, some I/O functions, etc.
>>
>>54783325
mit scheme ? it's only for eduction.

cat file.scm | mit-scheme

or
mit-scheme < file.scm


you don't need mit-scheme for sicp anymore

http://paste.lisp.org/display/313070/
>>
new thread when ? :3
>>
>>54783584
kys
>>
File: animu.png (439KB, 677x1400px) Image search: [Google] [Yandex] [Bing]
animu.png
439KB, 677x1400px
>>54776509
>>
File: oneslowgtp.jpg (102KB, 500x1200px) Image search: [Google] [Yandex] [Bing]
oneslowgtp.jpg
102KB, 500x1200px
>>54783894
>>
>>54783944
WTF is even this shit? Usually it's the anime loving neckbeards who cry every time someone says 'nigger'
>>
File: commies.gif (2MB, 420x236px) Image search: [Google] [Yandex] [Bing]
commies.gif
2MB, 420x236px
>>54783958
>>
>>54783944

See, I don't get why you won't rename this file. I'm not a normie by any means.
>>
>>54784184
But you are into beastiality you interracial pervert
>>
File: friendly advice.png (100KB, 715x611px) Image search: [Google] [Yandex] [Bing]
friendly advice.png
100KB, 715x611px
>>54784184
Also what the fuck are you doing in /pol/ again?
pls
>>
>>54784200

Exactly. That's what makes me not a pervert.

>>54784211

Discussing negresses with racemixing enthusiasts, mostly. Occasionally talking about cultural marxism and communism, and how they're the bane of mankind.
>>
>>54783999
Good. Fuck Lenininist bullshit.
>>
>>54783025
How do you post code snippets like you did with

this.TransparencyKey = Color.Magenta;
this.BackColor = Color.Magenta;
>>
>>54783238
rpc v0.4.0
> << 1 << 2 pick 1 > >> << 2 pick * swasp 1 - swap >> while swap drop >> 'fact sto
<< 1 << 2 pick 1 > >> << 2 pick * swasp 1 - swap >> while swap drop >> 'fact sto
> 10 fact
10 fact
# unknown var: "swasp"
> << 1 << 2 pick 1 > >> << 2 pick * swap 1 - swap >> while swap drop >> 'fact sto
<< 1 << 2 pick 1 > >> << 2 pick * swap 1 - swap >> while swap drop >> 'fact sto
> 10 fact
10 fact
1: 3628800.
> 'fact rcl
'fact rcl
2: 3628800.
1: << 1. << 2. pick 1. > >> << 2. pick * swap 1. - swap >> while swap drop >>
> 10
10
3: 3628800.
2: << 1. << 2. pick 1. > >> << 2. pick * swap 1. - swap >> while swap drop >>
1: 10.
>4 -
4 -
3: 3628800.
2: << 1. << 2. pick 1. > >> << 2. pick * swap 1. - swap >> while swap drop >>
1: 6.
> swap
swap
3: 3628800.
2: 6.
1: << 1. << 2. pick 1. > >> << 2. pick * swap 1. - swap >> while swap drop >>
> eval
eval
2: 3628800.
1: 720.
>
>>
>>54780849
Thank you for doing ElDorito, i never really got around to using it, but it was a good thing to do.
>>
>>54784261
Like this
>>
File: 1361954323525.jpg (77KB, 887x1097px) Image search: [Google] [Yandex] [Bing]
1361954323525.jpg
77KB, 887x1097px
>>54784310
thanks
>>
>>54782131
You might want to look at decorators. Use decorators on your bots functions to register call backs for events that occur.
>>
>>54783025
Nvm, I got it to work. Though, I don't know how. wtf
>>
My first try creating an arp spoofer in python using rawsockets.

http://pastebin.com/kLagLkXD
>>
>>54784348
>“““design patterns”””
>>
>>54777217

a.get(i)
>>
I have a question. I want to learn something about programming, so I was looking at wich language start with. people answered that it depends on what you want to do with it.
I've been looking some threads for a while, and it seems like C++ it's a good option, and C is a "must know" language no matter wich one you use later.
Am I right?
>>
>>54784403
>it seems like C++ it's a good option
No. C++ is an awful languages, and I do not wish its horrors onto even my worst enemy.
>>
>>54784403
We are bored with it. Go elsewhere.
>>
>>54784406

Give reasons
>>
>>54784348
POO
>>
>>54784348
Oh right, those things. I'll see what I can do with them, thanks.
>>
>>54784403
java and C++ are the best for learning programming. absolutely don't learn python, it's truly a horrible language.
>>
>>54784403
>and C is a "must know" language no matter wich one you use later.
haha no
>>
>>54781335
>Always

No.

It's the most latent in terms of bottleneck possibilities, but not in all cases. I.e. factorize a 4000 digit number. Requires almost no I/O but a shit ton of tight optimized loops.
>>
>>54784441
why? I'm used to read about python being a simple language, good to start with

>>54784442
why? you do not provide reasons, but in almost any thread it seems like you have to know how to use C, as a basic thing, and then go for other languages
>>
>>54784465
Anti-python circlejerk is very loud, try to make your own opinions.
I've started programming with Python and it's amazing. You can do so much in so little time, but it's not very well suited for very large projects. It should grant you a long while of fungramming.
>>
>>54784433
That anon didn't say anything, though. First of all, he just said "use this design pattern" as if that's a valid solution. Design patterns are for describing code, not writing it. Furthermore, you don't (and can't) "decorate" methods, you "decorate" objects.
>>
>>54784498
thanks, I think it's a good option as I don't know nothing about code, and I want to lear it just to know a little better how things work, not trying to go into something professional or so.
>>
>>54784465
>>54784540

You basically should learn two languages at once:
>C
It will introduce lower level concepts to you and you'll see how computer works pretty close to the metal.
>Python
It will introduce higher level concepts to you and allow you to write programs that do complicated things without thinking about all the low level stuff that often acts as friction and nothing else.
>>
>>54784547
>It will introduce lower level concepts to you and you'll see how computer works pretty close to the metal.
well memed
>>
>>54784547
Or you could just learn C++, which has both.
>>
>>54784403
Nobody uses C for anything. It's as much a must-know as COBOL. C++, on the other hand, is used everywhere performance is needed, from embedded system to aviation to videogames.

The must-know language is rust. It is guaranteed to replace C++ and to become the full-spectrum language of choice.
>>
>>54784566
Actually, no, I take that back. Rust would be a better beginner language than C++ (for those reasons) by far.
>>
>>54784524
>That anon didn't say anything
He said exactly enough for me to lookup decorators, which I forgot about.
But my two minute primer on decorators didn't show me the light, so I'll just do something else.
>>
>>54784547
>>54784547
well meme'd
both are shit for high level
learn haskell if you want high level

python is just a dynamic C with GC
>>
>>54784547
ASMs are much better languages to learn at the low-level because you're not bogged down in C's billion caveats a.k.a. "undefined behavior" while you actually learn how the machine learn directly instead of through a bad proxy. Additionally, ASMs are much easier to learn than C and, perhaps paradoxically, much easier to get right than C.
>>
>>54784590
>python is just a dynamic C with GC
And forced whitespace, but that's a very apt description of python indeed.

>learn haskell if you want high level
Disgusting. Go rust or go home.
>>
>>54784590
>accusing me of memeing
>mentioning haskell
excuse me?
>>
>>54784608
>rust
he said high level, not why? level
>>
>>54784524
Of course you can decorate methods. That's the prime concept behind frameworks like blocks. Retard.
>>
>>54784524
https://docs.python.org/3/library/functools.html#functools.wraps

Easy enough to retain metadata for methods as opposed to functions.
>>
>>54784622
Rust is as high-level as haskell, though. At the same time it is GC-less while still ensuring no memory issues can possibly happen.
>>
>>54784547
both C and python are complete shit i wonder if you're trolling or just a stupid murriken that can only think in extremes

pick a sensible middle ground like java or C++

python is SHIT for actually learning programming, you can use it to make some shitty ass scripts but do you think you will make some program that is actually good with python or your python "skills"? hell no!
>>
>>54784589
You should still never be using a pattern as a basis for a solution. The patterns may arise naturally, and you can recognize them and use them to describe your code to others. Like instead of saying "I pass an object that has a method to create another one of type X" you say "I pass an X factory". They're mostly useful because OOP makes simple things complicated.
>>
>>54784642
>>>>>>rust is as high level as haskell
>>
>>54784642
No HKT/GADT, still requires memory management, FREAKING STATEMENTS
>>
>>54784642
Eh, not really. Haskell has a lot of type system and syntactic features (e.g. higher kinded types and do notation so it can describe monads) that Rust is missing.
>>
>>54784692
>using do notation over monad comprehensions
>>
>>54784625
>>54784632
Sure, in a language where methods are just fields of function type. That's not generally the case.
>>
New thread: >>54784717
>>
>>54784662
You know where I draw the line? At factories. They give me flashbacks of Java memes like "AbstractSingletonProxyFactoryBean".

>tfw i fell for the OOP meme
>>
>>54784723
>i don't know what a factory is
kys
>>
>>54784707
Comprehensions are okay for small things that would have "return" at the end anyways.
>>
>>54784736
You got something to say?
>>
>>54784661
POO IN LOO
O
O

I
N

L
O
O
>>
>>54784736
It's something not even worth noting in any language with first class functions.
>>
>>54784664
It has typeclasses (traits), matching, destructuring binds, structural typing, or-types, and-types, higher-order functions, first-class functions, etc.

>>54784677
>still requires memory management
No, memory is managed automatically. You manage ownership, but at the same time "not really", you just put an & in front of everything and you're good to go.
>FREAKING STATEMENTS
u wot m8?

>>54784692
A more powerful typesystem just means the typesystem is more powerful, not that the language is higher-level.
Monads in rust use and_then instead of >>, but it's the same shit. Do notation is only needed in haskell on account of it being purely functional (a.k.a. dysfunctional), and it's the default mode in every other language including rust.

Rust does support GADTs by the way.
>>
>>54784708
?
This doesn't make sense, and doesn't address what you said about not being able decorate methods, which you obviously can and maintain reference to the owning type (self).

Which frees the original poster form having to create tightly coupled objects. IRC doesn't have to know about bot, and the bot doesn't have to know about IRC, with the only thing exposed are the salient events that occur within the context of the protocol such as queries, channel messages, dcc, and what ever IRC decides to implement as a registerable callback.
>>
>>54784794
It doesn't have HKTs, it's not purely expression based, every language has or types, and types & most have HO & first class functions, nevermind the vast wealth of shit Haskell specifically has that it doesn't like existential types
>>
>>54784837
>It doesn't have HKTs
True
> it's not purely expression based
Thank god
>every language has or types
False
>and types
True
>most have HO & first class functions
Not even remotely true
>nevermind the vast wealth of shit Haskell specifically has that it doesn't like existential types
It does have existential types.
>>
>>54784870
Most have or types, C# and Java excluded

but in those languages you can still use enums & ints and encode or types
>>
>>54784870
yes, most languages do have HO&first class functions, name some major languages that don't have higher order functions
>>
>>54784917
C, C++, ruby, java.
>>
>>54784985
All of those have higher order functions
>>
>>54785005
>None of those have higher order functions or first class functions
FTFY. Come back when you have even a hint of a clue about what you're saying.
>>
>>54785012
C:
int apply(int, int(*)(int));

C++:
template<typename F>
int apply(int, F);

Ruby:
def apply(param, func)

Java: awkward shit but possible
>>
>>54785012

You're saying that all 4 of these don't even have first-class functions, correct?
>>
>>54785080
Not sure if retarded or just pretending. Not only are none of these HOF but the C++ one doesn't even remotely do what you think it does, it's not possible in java because it doesn't even have real lambdas, and the ruby one actually passes an object instead of an actual functions.
>>
>>54785130
I use a type parameter in the C++ one because it's more convenient and generic. The C++ one literally includes the C one.

Do you not know what a higher order function is? It's a function that takes another function as a parameter
>>
>>54785130
Everything is an object in ruby. There's no difference you idiot. You can call it with whatever arguments you want, partially apply it and pass it around.
>>
>>54785080
>Java: awkward shit but possible

public static int apply(int a, java.util.function.Function<Integer, Integer> b)


Enjoy.
>>
File: 91i328.jpg (142KB, 740x740px) Image search: [Google] [Yandex] [Bing]
91i328.jpg
142KB, 740x740px
>>54785245
>>
>>54785160
>There's no difference you idiot.
Just keep backpedaling it's pretty funny.
>>54785146
The C++ one accepts any arguments, including, but not limited, to functions. Congrats on being retarded. Not only that but it's not actually a function in either C++ or C but rather a function pointer which is externally a structured object instead of merely internally.

Now that you've proven you don't have a clue about any language, don't know what a higher-order function is AND don't know what first-class functions are, you can go ahead and kill yourself.
>>
File: James-Gosling.jpg (103KB, 500x333px) Image search: [Google] [Yandex] [Bing]
James-Gosling.jpg
103KB, 500x333px
>>54785260

He did it all for you.
>>
>hey guys, it is true dat I must know C to learn other languages better?

And so it begins, the shitstorm of our era.

what have I done.
>>
Hey /g/
I'm currently developing a chip-8 with SDL (may seem a bit 'much' but SDL is easy to use) and I've currently hit a wall.

I'm trying to implement this instruction:
Dxyn - DRW Vx, Vy, nibble
Display n-byte sprite starting at memory location I at (Vx, Vy), set VF = collision.

The interpreter reads n bytes from memory, starting at the address stored in I. These bytes are then displayed as sprites on screen at coordinates (Vx, Vy). Sprites are XORed onto the existing screen. If this causes any pixels to be erased, VF is set to 1, otherwise it is set to 0. If the sprite is positioned so part of it is outside the coordinates of the display, it wraps around to the opposite side of the screen. See instruction 8xy3 for more information on XOR, and section 2.4, Display, for more information on the Chip-8 screen and sprites.


(http://devernay.free.fr/hacks/chip8/C8TECH10.HTM)

The problem is, I can't just manipulate the pixels directly since I'm scaling the screen

The function I have is slow, but it works in unit tests. I'm looking to see if there are any alternatives to just storing a separate set of pixels for this DRW function to use as a set of ints then just using bit shifts to get which pixels I should xor?
>>
>>54785272
>The C++ one accepts any arguments, including, but not limited, to functions. Congrats on being retarded.
Not when you call it you dumbass, then you get a compiler error for types that don't provide a function call operator
>waaa they're function pointers
Which are functions that can be called (and even created from JIT code, unlike most languages), deal with it you dumb fucking faggot
>>
>>54785303
Every time you post you show even more how ignorant you are. Just stop, it's unsightly.
>>
>>54785328
Every time you post you mention less programming and more insults

Could it be you've realised you're wrong?
Omedeto.
>>
>>54785342
>Omedeto.

This is America. Speak American, homo.
>>
>>54785476
No, this is 4chan. Speak moon, faggot.
>>
>>54785298
C is super simple, if you take the java -> C++ route you will know C almost automatically
>>
>>54785663
What purpose does learning Java serve?
>>
>>54785663

Isn't more sensible to go C->C++? as C++ comes from C?
>>
>>54785680
java is literally the best and most popular programming language and java is like a simplified version of C++
>>
File: 1449756574386.jpg (3MB, 3264x2448px) Image search: [Google] [Yandex] [Bing]
1449756574386.jpg
3MB, 3264x2448px
>>54785699
Ctards tend to get stuck with the procedural garbage and language lawyering and completely fail to understand OOP
>>
>>54785713
>best
no
>simplified
in the sense that it's for retards and can achieve nothing complicated
>>
>>54784661
>Java
>middle ground
>>
>>54785713
>java is literally the best and most popular programming language

Couldn't be more wrong on both counts
>>
>>54786187
http://www.tiobe.com/tiobe_index

delusional shitlang memers on suicide watch!
Thread replies: 356
Thread images: 40
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y / ] [Home]

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.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
If a post contains illegal content, please click on its [Report] button and follow the instructions.
This is a 4chan archive - all of the content originated from them. If you need information for a Poster - you need to contact them.
This website shows only archived content and is not affiliated with 4chan in any way.
If you like this website please support us by donating with Bitcoin at 1XVgDnu36zCj97gLdeSwHMdiJaBkqhtMK