[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
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 31
File: ij.png (3 MB, 1280x720) Image search: [Google]
ij.png
3 MB, 1280x720
What are you working on, /g/?
>>
Linked lists are the best data structure.
>>
What is F#, OCaml, Scala, Dylan, ML, Haskell, Clojure? I only know PHP and Perl
>>
>>52041939
This.
>>
>>52041944
They don't exist, memers on /g/ just like to play pretend and invent fake languages.
>>
Merry Gnu/Christmas everyone
>>
File: kid-flying-robots.png (153 KB, 475x474) Image search: [Google]
kid-flying-robots.png
153 KB, 475x474
What's a high level language that pairs well with C? I'm thinking of learning Guile cause scheme/lisp master race.
>>
>>52041984
Lua or Cython
>>
There's no reason to use a linked list in a stack or queue.

>>52041984
Guile is shit. Lua is a great scripting language, very easy to interface with.
>>
File: smart_tabs.png (29 KB, 727x507) Image search: [Google]
smart_tabs.png
29 KB, 727x507
Okay, last thread we had an argument combining tabs and spaces. To those of you who do not get it, this is called smart tabbing, and it's actually pretty amazing. Consider the example in pic related.
>>
>>52041984
Every high level language ever made.
>>
>>52042024
You mean people don't do this?
>>
>>52042024
Whats the name of your theme fedora man
>>
>>52042024
Here's the failure:

>What we do not care about is how far they are indented. That can be decided by the user.

It makes sense in theory, but it's not a benefit in practice. No one is retarded enough to use 1 space or 8 spaces. Each language community just settles on either 2 spaces or 4 spaces, and that's it.

There's very little upside to "user-defined indentation", and what little there is is outweighed by the potential downside of some retard who doesn't understand smart tabbing fucking everything up (think: some guy from the marketing department just needs to change some copy)
>>
>>52041824
>>52041772
>>52041695
TIL: people who oppose tabs for indentation have no idea how they're meant to be used properly.

It's like saying chocolate should be illegal because babies might rub it all over their faces and look like minstrels.
>>
>>52042064
>8 spaces
Common as fuck in C.
>>
>>52042004
Why is guile shit? It's the universal extension language
>>
>>52042064

The guy from the marketing department is not allowed to make any changes for any reason. If he's not a programmer and he hasn't read the style guide, he's not allowed into the codebase.
>>
>>52042114
The C interface is awful, you end up writing a Guile program instead of a program using Scheme. I've never found a satisfactory library for embedding Scheme, while Lua just werks.

Also, for a "universal extension language" there sure aren't a lot of things using it.
>>
>>52042056

The theme is called midnight. That said, there's a bunch of themes called midnight, and I don't have the original location bookmarked.
>>
>>52042114
>universal
You mean those 4 GNU programs?
>>
>>52042128
Popularity of use isn't the point of the "universal" title. Universal is a reference to the fact that its purpose and design is for it to be general and reusable for any situation that demands for an embedded language interpreter.
>>
https://github.com/filmgirl/TextMate-Themes/blob/master/Midnight.tmTheme

Found it.
>>
>>52042174
It's just as much a "universal extension language" as Lua, then. Lua, like Lisp, is a language of DSLs. And far more people are used to working with Lua.
>>
>>52041939
Linked lists are the worst data structure.
>>
>>52042202
You shut your whore mouth.
>>
>>52042202
Worst? They aren't arrays
>>
>1280x720
>2.65 MB

Remember to use proper image formats for the job!
>>
>>52042064
I have not seen anyone sporadically switch between one and two tab indents in a single block of code.

I have however, seen people randomly switch between 2, 3 and 4 space indents.

Tabs give you better customisation if you want it, and make it harder to fuck up the formatting unless you're really retarded.

I don't even care if you default to 8 and keep lines to 80 chars, making them wrap at well under 70 because I use 4-spaces, that's still better than me having to run a fucking script over your code and making diff chances on every goddamn line, rather than just changing one setting in my editor to display it exactly how I like.

I kinda understand, you've been burned before by fuckheads who use inconsistent shit, so agreeing on one fixed spacing format made everything easier.
But if you use tabs, you don't even have to agree on the spacing, that's the fucking beauty of it, but you're too stubborn to see.
>>
>>52041939

Hash
>>
>>52042265
>But if you use tabs, you don't even have to agree on the spacing, that's the fucking beauty of it, but you're too stubborn to see.
Apparently people are too stupid to understand the difference between indentation and alignment.
>>
>>52042265
But there is no actual value to the customization. It's just a theoretical benefit. Everyone uses the same spacing anyway.
>>
>>52042287
I prefer 2-wide indentation. Most people don't.
>>
>>52042242
Properly compressed that PNG is only 400kb.
>>
Daily reminder that raw text files are the only kind of files you should be using
>>
File: huh.jpg (32 KB, 615x456) Image search: [Google]
huh.jpg
32 KB, 615x456
>>52042274
Even better, you find people who use spaces for indentation and tabs for alignment.
>mfw

>>52042287
They literally don't. Most terminals default to 8, and most editors default to 4 or 2 for a fucking start.
A couple of guys at work actually have meld or whatever set to use different spacing to their editors so that any whitespace fuckups are easily noticed.
E.g. if you use 4 spaces (I don't even understand how but whatever) rather than a tab it'll look fine in your editor, but will come up as half a space in meld.

Insisting that everyone uses the exact fucking same number of spaces will only result in people working with what they want, and then changing things to fit your autistic needs on commit.
This is only going to lead to more fuckups.
>>
Threadly reminder that the act of writing code is not coding, it is programming

You are a programmer not a coder
>>
Reminder that if you don't code exclusively in COBOL you don't deserve to call yourself a programmer.
>>
>>52042335
Do you also spell it "programme", like we're all writing a TV show?
>>
What Python editor does /dpt/ recommend?
>>
Threadly reminder that OCaml is the only good language.
>>
Reminder that programming involves programming.
>>
>>52042387
Doesn't matter, as long as you're sitting in starbucks with your macbook air
>>
>>52042387

I'm kind of in love with NINJA-IDE
>>
>>52042414
You confused Python for Ruby.
>>
>>52042422
I just called him a faggot, I didn't say he had full blown AIDS too.
>>
>>52042445
quality keks to be had
>>
>>52042114
It's not, it's fucking gr8
>>52042128
>The C interface is awful
spoken like someone who's never tried it
>>52042388
It feels really weird not being the only one shilling OCaml on here
>>
>>52042525
>spoken like someone who's never tried it
Oh, but I have, and I hated it. Maybe I was just conditioned by Lua to think that embedding scripting languages was generally pleasant?
>>
>>52041984
Regular old CPython is pretty good with C
>>
>>52042387
Pycharm
>>
>>52042525
>It feels really weird not being the only one shilling OCaml on here
Coming first in a one horse race isn't much of an achievement
>>
>>52042549
the interface is literally just as easy to use as the one for Lua. the only problem i forsee is it being slightly less documented, but the official docs explain everything pretty well so it's not a problem if you just read the API reference.
>>
Rate my program nerds.

using Microsoft.Win32;
using System;

namespace MemeProgram
{
class Program
{
static void Main()
{
RegistryKey processorSubKey = Registry.LocalMachine.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0");
Console.WriteLine("Subkey open:" + processorSubKey);
Console.WriteLine("\nYour Processor is: " + processorSubKey.GetValue("ProcessorNameString"));

RegistryKey motherBoardSubKey = Registry.LocalMachine.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\BIOS");
Console.WriteLine("\nSubkey open:" + motherBoardSubKey);
Console.WriteLine("\nYour Motherboard is: " + motherBoardSubKey.GetValue("BaseBoardManufacturer") + motherBoardSubKey.GetValue("BaseBoardProduct"));
Registry.LocalMachine.Close();

}
}
}
>>
>>52042582
i just mean that i felt like everyone hated OCaml on /dpt/ a few months ago and now suddenly everyone likes it
>>
>>52042600
0/10
>>
>>52042611
w-why senpai
>>
>>52041944
Clojure is the only thing needed and it's fucking awesome
>>
>>52042620
>using Microsoft.Win32;
>>
>>52042603
I doubt there's many people on here (me included) that can give an informed opinion on it at all.
>>
>>52042634
How else am I suppose to get the registry key values tho
>>
>>52041893
Finishing up the code for a word clock I'm building for my sister for christmas.
>>
>>52042620
Would have been less ugly in batch, the ugliest language.
>>
>>52042645
What is ugly about it?

Literally what?
>>
>>52042665
There is nothing wrong with that, you are getting trolled
>>
>>52042600
babby learns to code
>>
>>52042665
>>52042600
> RegistryKey motherBoardSubKey = Registry.LocalMachine.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\BIOS");
>motherBoardSubKey.GetValue("BaseBoardManufacturer")
Abstract you nigger, don't just spew that ugly filth everywhere.
>>
>>52042698
:^)
>>
>>52042708
>Abstract you nigger, don't just spew that ugly filth everywhere.

What does that even mean?

I'm sorry I don't wear a fedora or have a neckbeard so you'll have to step down to my level.
>>
>>52042708
>>52042698
>>52042645
Is there any other way to access registry values is 'elegant'
>>
>>52042717
Write a function to get the value you need instead of that subkey shit you're doing twice.

Notice the verbose code you're doing twice.
>>
>>52042620
Because you rely on arbitrary registry keys that can be overriden by any program, query the hardware instead.
>>
>>52042734
>Write a function to get the value you need instead of that subkey shit you're doing twice.

How would that even look? Like a function that opens the subkey then returns the key value?
>>
>>52042114
It is as full of gotchas as C and its errors are usually just as useful. It also leaks memory like crazy in high-performance, data-intensive tasks because lol boehmgc.
>>
File: code-tattoo.jpg (59 KB, 600x316) Image search: [Google]
code-tattoo.jpg
59 KB, 600x316
Who /tattoo/ here?

What is the output of this program?
>>
>>52042803
gay
>>
Who /too stupid to understand and learn C#/ here?
>>
>>52042862
just you man, C# is easy to learn and implement
>>
File: tattoo2.jpg (22 KB, 500x268) Image search: [Google]
tattoo2.jpg
22 KB, 500x268
I hope these are shopped.
>>
>>52042803

>global loop counter
>main returning anything other than int

Please don't tell me this is a real tattoo.
>>
>>52042862
Probably just you.
In the whole world.
>>
>>52042872
I don't understand all the class and namespace shit. Can you explain it to me?

What's up with the name spaces and weird main() function?
>>
>>52042876
http://news.bme.com/2008/01/25/damn-code-hippies/
Here's the output. Isn't it cute?
https://ideone.com/f6uSCo
>>
My summarizing news article site
>>
>>52042803
love
>>
>>52042880
Namespace is just a place to put your classes. What if you want two classes named exactly "Poster"? You could have one in the "Billboards" namespace and another in the "4chan" namespace.
>>
>>52042875
>pehpy
>>
>>52042635
Go read Real World OCaml. You owe it to yourself.
>>
>>52042894
gay
>>
rudy is stinky
>>
>>52042907
So why all of them need a namespace? And what are the naming conventions for it because I'm kind of confused why I would ever want two classes with the same name.
>>
>>52042880
The main() function is just the entry point for a console program.

Namespaces are containers for classes

Look at this following line
System.Console.Writeline("Hello World!");


System is the namespace that contains classes like Console, and Writeline is a method in the Console class that writes to the standard output

Your going to have a hard time with this if you don't know oop
>>
>>52042947
Well, sometimes you use code written by other people. You want to make sure that your class names don't interfere with their code. What if half of the Class names you made failed because some random microsoft programmer who made basic windows/.net classes happened to use the same name?
>>
>>52042970
More importantly,
Math.log
Logger.log
>>
>>52042947
vector<int> xa; // vector data structure
vector<int> xv; // mathematical vector
vector<int> xb; // abstract path travelled
>>
>>52042961
Then how come sometimes it's not even in a namespace? It's just a method all by itself?

>>52042961
>>52042970
>>52042993
I guess i understand all the namespace stuff but I kind of get confused sometimes with it all.
>>
C# will make up a namespace for you if you have stuff outside of it. It's something like Test.Application or whatever your project specifies.
>>
>>52043002
Because it's being called from a function within that namespace.
>>
>>52043002
If you are a beginner to programming then your confusion is understandable.

To understand what a namespace is, you first need to understand what a class is and what makes up classes. Do you know what a class is
>>
>>52043033
>To understand what a namespace is, you first need to understand what a class is and what makes up classes. Do you know what a class is

So you can instantiate a member of a class and it inherits the properties and functions right? And then it has public and private functions/variables? I don't know much beyond that
>>
File: 1444960302763.png (167 KB, 376x328) Image search: [Google]
1444960302763.png
167 KB, 376x328
Merry Christmas, /dpt/.
>>
>>52043002
they're literally just like directories
>>
How to reduce repetitive GUI code in Python?
I have lots of similar code (like window1 = ... window2 = ... window4324 = ...) but it doesn't follow well-defined rules, so I can't just eval() and loop it easily.
>>
>>52041893
Metronome app for android.
>>
>>52043093
I'm Jewish.
>>
>>52043093
Merry Gnu/Christmas
>>
File: 2015-12-24_23-23-34.png (37 KB, 915x519) Image search: [Google]
2015-12-24_23-23-34.png
37 KB, 915x519
>>52043067
pretty much, but you instantiate an "instance" of the class.
>>
>>52043121
https://www.youtube.com/watch?v=bTwDhbTwTAo
>>
>>52043126
>two things: variables and functions
>two
>>
File: 1444960034304.jpg (59 KB, 586x515) Image search: [Google]
1444960034304.jpg
59 KB, 586x515
>>52043121
Merry Christmas you fucking jew.
>>
File: 9780262533058.jpg (46 KB, 420x475) Image search: [Google]
9780262533058.jpg
46 KB, 420x475
Going through this book with Python, it's great fun~~~

>>52043093
Merry christmas - u -
>>
>>52043141
>tfw functions aren't variables in your language
:\
>>
>>52043164
pick a better language
like F#, F# or F#
>>
>>52043125
'Christmas' is proprietary closed source garbage, please don't compare it with the GNU project you god damned autistic fucko.
>>
>>52043180
>Christmas
>closed source
Get out of here you fucknigg catholic scum
>>
>>52043156
>Tfw I bought that book in 2004 for college and never opened it again after passing the class that required it
it's still sitting on my shelf.
>>
>>52043198
>buying books
>ever
>>
Do I need to know C in order to learn C#?
>>
>>52043172
I was poking fun at the post I replied to
I use Python so it's okay

>>52043198
Downloaded it for free~
I think the class at my university that should be using it uses a different book, which is insane. I'm just reading this on my own as I lack a good project idea to work on; might as well learn.
>>
>>52043204
If you don't already know C, pick it up in order to do some crazy shit down the line.
>>
>>52043205
>I use python so it's ok
>I
>use
>python
>so
>it's
>ok

>i use python
>its ok

>python
>i
>ok

>ok
>ok
>ok
>ok
>ok
>ok
>>
>>52043204
no
>>
>>52043204
No, it's not needed, but it's recommended, but it's also recommended to not learn C#
>>
>>52043223
>it's also recommended to not learn C#
Why not?
>>
Python doesn't even have structs, it's a shitty hack of a language.
>>
>>52043239
>what are dictionaries
>>
>>52043219
Functions are first class so we good.
Don't worry, I'm also a C-tard, perhaps that redeems me some. :_)
>>
>>52043253
>python
>py>python
>okthon>python
>ok
>ok>python
>ok
>ok>python
>ok>pyth>python
>okon
>ok>python
>ok
>>
>>52043239
>classes
>dictionaries
nice
>>
>>52043218
You don't need to start with C/C++ for that
I've only been using C# and I use pointers, unmanaged arrays, my own types that manually manage memory, etc... all day
>>
>>52043257
>implying
>>
File: sun.png (320 KB, 680x543) Image search: [Google]
sun.png
320 KB, 680x543
are there any resources for learning to write cool shaders for shadertoy
>>
>>52043257
nice meme!
>>
>>52043266
>python is ok

WAKE ME UP
>WAKE ME UP INSIDE
I CAN'T WAKE UP
>WAKE ME UP INSIDE
SAVE ME
>>
cheney on the mta is the best hack
>>
>>52043202
>Not buying books
I love books.
>>
>>52043265
>I've only been using C# and I use pointers, unmanaged arrays, my own types that manually manage memory, etc... all day

How?
>>
>>52043275
That looks more like an orange-y black hole
>>
>>52043302
What do you mean "how"?
You can just use pointers as unsafe array
And you can allocate memory to get a pointer
>>
but seriously don't use python

it's not even statically typed
>>
>>52043322
What are the benefits of dong this tho
>>
>>52043251
>what are dictionaries
They are not structures.

>>52043259
Classes are the closest thing to a struct in Python, but the syntax is even nastier and more verbose than C:

class MyStruct:
def __init__(self, a: int):
self.a = a

struct my_struct {
int a;
}
>>
File: ew.png (272 KB, 470x624) Image search: [Google]
ew.png
272 KB, 470x624
How do I learn JS, /dpt/?
>>
>>52043331
feeling like a hardcore programmer
>>
Where can I find the conventional Python project structure?
>>
>>52043341
> __init__

jesus
fucking
christ
>>
>>52043331
Better performance, lower memory usage and in the case of unmanaged arrays you can just do things more directly which also makes your code shorter and easier to maintain
>>
>>52043341
lmfao python syntax is "nasty and verbose" compared to C

you C tryhards are a riot
>>
>>52043356
Codecademy has a decent course for fundamentals
>>
>>52043356
The same way you learn any other language. Combination of reading reference materials and trying stuff out.
>>
>>52043341
>a: int
What is this magic?
>>
Why are there so many programming languages? Can't humans just stop making more for a little while?
>>
>>52043356
Buy the rhino book
>>
>>52043385
Go write more trailing and leading underscores all over your code faggot.
>>
File: 4413246790_da5f8b7e68.jpg (66 KB, 312x312) Image search: [Google]
4413246790_da5f8b7e68.jpg
66 KB, 312x312
>>52043341
That syntax
>>
How long does it take to get to a decent level of understanding programming where you can actually understand what's going on?

I saw a meme on github where some guy hooked firefox process in order to feed chess position to a chess engine to make a chess bot. I want to eventually do something cool like that, how many years would it take to be able to understand do that?
>>
>>52043369
same as always my man

put (groups of) classes/functions in their own file, etc, have one file for main(), all that good stuff.
>>
>>52043402
Don't worry, we've got F#
>>
>>52043341
class MyStruct(object):
a = None
b = None
# why make a ctor that doesn't do any logic?

inst = MyStruct()
inst.a = 2
inst.b = 4
>>
>>52043411
very high level of discourse you guys have here
>>
>>52043421
Do you think python's scope=indentation is ableist?
>>
>>52043432
That's not how programming works
>>
>>52043440
What is functional programming? It sounds gay.
>>
>>52043443
because it's a constructor you moron
that's literally what it fucking does

the real question is why doesn't your language do that automatically (cough F# cough)
>>
>>52043443
Those are static attributes, i.e. any MyStruct you make shares a and b, unless you override them, but if you then do MyStruct.a = 3, all non-overriden MyStructs have their .a changed.
You really should do the constructor instead.
>>
>>52043432
>How long does it take to get to a decent level of understanding programming where you can actually understand what's going on?
It completely depends on the scenario.

>some guy hooked firefox process in order to feed chess position to a chess engine to make a chess bot. I want to eventually do something cool like that, how many years would it take to be able to understand do that?
This requires understanding of (a specific) software architecture more than programming in general.
>>
>>52043454
I just mean at around what point do most people start to "get" programming? Right now it feels like just trying random shit until it works
>>
>>52043460
C doesn't have constructors, it must be so bad. Down with C! Down with C! Raa Raa Raa!
>>
>>52043472
Read a book. No, seriously.
>>
>>52043472
It takes years. But even after you "get" it:

>Right now it feels like just trying random shit until it works

still happens.
>>
>>52043462
>Those are static attributes, i.e. any MyStruct you make shares a and b, unless you override them
Yes

>You really should do the constructor instead.
Why?

Why add tonnes of boilerplate to do something simple as hold multiple values?
>>
>>52043487
C has constructors if you make them lmao
>>
>>52043443
Because Python is shit and does not have structures. Classes are not structures and your code does not act like a structure:

class MyStruct:
var = []

ONE = MyStruct()
ONE.var.append('SHOULD NOT HAPPEN')

TWO = MyStruct()
print(TWO.var) # does print 'SHOULD NOT HAPPEN'
>>
http://norvig.com/21-days.html

Teach yourself programming in 10 years.
>>
>>52043472
This really depends on how autistic you are
>>
>>52043498
See >>52043495

Also
>making a class but not inheriting from object
>>
>>52043501
>pete norvy
my nigger.
>>
>>52043495
You're an idiot. Your implementation is wrong and does not emulate a structure type.
>>
working on a programming site that offers a free websocket server

result:
http://168.235.82.152/#2092881667
editor:
http://168.235.82.152/#source_2092881667

thoughts?
>>
>>52043465
>This requires understanding of (a specific) software architecture more than programming in general.

What do I have to learn in order to make something cool like that then?

Basically I'm just tired of making dumb meme programs, I want to make something actually usable and valuable.
>>
>>52043521
B U T T H U R T
U
T
T
H
U
R
T
>>
>>52043527
You have to learn how to interact with things outside of your program.
>>
>>52043457
a lot of stuff to do with excessive use and rearragement of functions, metaprogramming and other stuff

very basic examples of using higher order functions (fold and the |> operator)

let sum arr = arr |> Array.fold (+) 0
//Array.fold(+, 0, arr) // (+) is a function
//fold with that array would work like this:
//(((((((((0 + 1) + 2) + 3) + 4) + 5) + 6) ...) + 100

[|1..100|] |> sum
//sum([|1..100|])

f# code to sum an array

let prod arr = arr |> Array.fold(*) 1
f# code to get the total product of an array
>>
>>52042271
A hash is not a data structure you peasant.

Saying hash when you mean hash table is as retarded as saying link when you mean linked list.
>>
Can we all agree that Haskell at least has the nicest looking syntax and code of all the programming languages and that Lisp has the ugliest?

I understand that Lisp is probably the most powerful programming language, still it's parenthesis syntax is ugly as fuck.
>>
>>52043576
a hash is a data structure dude. it's a function. takes an input, gives an output. those are the data. structure.
2016 soon. should know this.
you have much to learn.
>>
>>52043601
Haskell definitely has the nicest, I agree with you there. But I wouldn't say that Lisps are the worst, and I also disagree that Lisps are the most powerful.
>>
>>52043553
btw with the
fold(+, 0, arr)
to do it explicitly it'd actually be
fold(+)(0)(arr)

>>52043601
F# looks nicer
>>
>>52043605
10/10
>>
>>52043601
You do know that Haskell did not originate most of it's syntax, right? It's syntax was heavily inspired by Clean and Hope.
>>
>>52043618
I haven't gotten too far in lisp, I read a couple of chapters in the "learn lisp while making games" book.

The fact that some lisp dialects can "go back in time" and program nondeterministically blew my mind. The fact that you can program the language itself and use whatever paradigm you want certainly makes it the most powerful language of those I've ever heard of.
>>
>>52043432
>>52043527
Well senpaitachi?
>>
>>52043658
Whoah, what the fuck is this shit. Sounds pretty fucking cool. Worth learning before I die, probably. But I've wasted too much time learning languages this break, and I'm behind where I'd like to be regarding algos/data structures (I've never any self-balancing tree, for example) so I'll have to put it off. :( Added to my todo list, though. Probably CL or Clojure.

/blog
>>
>>52043684
I have a couple years of experience at programming, I also have about half a years experience with Haskell so I'm not completely new to programming though I don't regard myself as all that good. After getting a bit into this book I felt that I was too fresh for lisp and went into android development so that I can have more software under my belt before having another crack at Lisp.

The language seems great but feels overwhelming.
>>
merry christmas you fucking niggers
>>
>>52043645
Actually I didn't know that.

>>52043620
Post some code example?
>>
>>52043472
When use start doing things like this:
static unsafe void FillCircle_AA(RECT rect, COLOR color, IntPtr _buffer, int dib_w, int dib_h)
{
if (rect.Width == 1 || rect.Width == 2)
{
color.A = (byte)(color.A * 0.7854f);
FillRectangle(rect, color, _buffer, dib_w, dib_h);
return;
}

COLOR* dib = (COLOR*)_buffer;
...
}
>>
>>52043620
"ML with |> and .Net" is certainly not nicer looking than Haskell.
>>
>>52043705
Pretty similar background here, except in C and Python rather than Java and Haskell. Pretty excited about Lisp now, though.

>>52043707
merry christmas nigger lover
>>
Can someone explain to me why Haskell uses arrows between arguments to functions in type declarations? Like why
function :: Int -> Int -> Int

for a function that takes two args returns one int rather than
function :: Int Int -> Int

??
I think Clean did it like that. LYHFGG said "there's a reason" but I haven't found it.
>>
>>52043714
>Actually I didn't know that.
Why am I not surprised.
>>
>>52043601
> I understand that Lisp is probably the most powerful programming language, still it's parenthesis syntax is ugly as fuck.

Unfortunately, the two largely go together. What makes it powerful is that it uses lists for everything, including its code structure.
>>
>>52043762
To be fair I've never even heard about "clean and hope"

Also don't be too smug, anon. It's christmas.

>>52043767
I get that, I really do. Doesn't make it any prettier, though.
>>
File: black-santa-296x300.png (121 KB, 296x300) Image search: [Google]
black-santa-296x300.png
121 KB, 296x300
>>52043739
>nigger lover

Hoes Hoes Hoes.
>>
>>52043726
But I want to start hooking processes and reading/writing to process memory
>>
>>52043760
maybe to be match currying and partial application

//f#
let f x y = x + y // Int -> Int -> Int
let g = f 5 // Int -> Int
let h = g 3 // Int
>>
>>52043762
Because Clean and Hope were obscure as fuck you moron.

>>52043785
Right, Haskell was in its earlier days purely an academic project as far as I know, likely were Clean and Hope as well; it's not like anyone who has heard of Haskell only after it's "boom" (if you could call it that at all (you can't)) would know of 'predecessors', which were never used anywhere either.

>>52043803
That makes sense, neat, thanks. I don't get the pajeet term but the example helped.
>>
>>52043760
Currying.
function :: Int -> Int -> Int
-- equivalent
function :: Int -> (Int -> Int)

So if you write "function 10", you now have a function from "Int -> Int".
function 10 :: Int -> Int

This is useful for defining functions through composition, in point-free style.
sumEvens :: [Int] -> [Int]
sumEvens = foldl (+) 0 . filter even

Without currying, you'd have to eta-expand everything.
sumEvens xs = foldl (+) 0 $ filter even xs
>>
>>52043760
because functions are curried by default
function :: Int -> Int -> Int
-- a little more explicit
function :: Int -> (Int -> Int)

This function takes in an Int and returns a function that takes in an Int and returns an Int.
(function 2) :: Int -> Int

after partially applying the function, we have a function from Int to Int.
>>
>>52043801
Ah yes, I definitely wouldn't recommend C# for that since it can't compile DLLs that can be injected into other processes
>>
>>52043760
> Can someone explain to me why Haskell uses arrows between arguments to functions in type declarations?
Currying.

In Haskell, functions always have a single argument. Functions with multiple arguments can be handled in two ways: either make the argument a tuple, or write a function which takes the first argument and returns a function which takes the remaining arguments. The latter is known as "currying" (the technique was popularised by Haskell Curry, after whom the language is named).

Arrows are right-associative, i.e.
Int -> Int -> Int

is parsed as
Int -> (Int -> Int)


A function such as
add x y = x + y

is implemented as
add x = \y -> x + y


I.e. "add 7" is a valid expression; it evaluates to a function of one argument which returns its argument plus 7. So you can then do e.g.
map (add 7) [1,2,3,4]
=> [8,9,10,11]


The fact that you can pass different arguments at different stages is why multiple-argument functions are normally curried rather than taking a tuple.
>>
>>52043841
Couldn't I just load DLLs normally or even write my own in C or something?
>>
>>52043826
I mean, just look at this example from Clean.
pushA stack = push 'a' stack

This is much more succinct with currying.
pushA = push 'a'
>>
>>52043845
>>52043831
>>52043826
Thanks anons, I get it now! This is really neat and intuitive, hardly ever see stuff like this as a C programmer.
>>
>>52043860
You can, you just can't inject C# DLLs
>>
>>52043341
You forgot about

struct my_struct* my_struct_create (int a) {
struct my_struct* mystruct = malloc(sizeof(struct my_struct));
mystruct->a = a;
return mystruct;
}
void my_struct_destroy (struct my_struct* mystruct) {
if (mystruct != NULL)
free(mystruct);
}


>P-PYTHON IS V-VERBOSE!!
>>
>>52043879
>You can, you just can't inject C# DLLs

http://stackoverflow.com/questions/6609582/c-sharp-dll-injection

https://github.com/ChadSki/SharpNeedle

Seems you can tho
>>
>>52043912
class myClass {
int a;
myClass(_a) : a(_a) {}
};

>muh C++ is convoluted meme
>>
>>52043937
Classes in C++ are rather nice especially for how they retain value semantics and all that jazz in pretty concise code.
The biggest problems with C++ are C, IMO.
>>
>>52043937
>myClass(_a)
doesn't compile you son of a bitch
>>
>>52043954
>The biggest problems with C++ are C, IMO.

Wisdom.
>>
>>52043918
>The most interesting file is src\Launcher\Injection.cpp
Seems like it's just a wrapper around C++ code
>>
>>52043956
been using python, woops
int _a
cunt nugget

>>52043954
C++ needing to be backwards compatible completely ruined it. I'm glad I can use C libs with C++ but I would really rather use an actual language.
>>
>>52043966
And C++ is just a wrapper around assembly and system calls... what's the point?
>>
>>52043912
T Y P E D E F
Y
P
E
D
E
F
>>
>>52043981
#define class typedef struct
>>
>Making android bullshit
>Whenever I try to switch activities I get "your app stopped working"

Kill me.
>>
>>52043980
My point is .NET DLLs can't be injected into other processes so you need to write your DLL in another language which you won't be able to do if you only know C#
>>
>>52043966
>>52044027
Why can't you just inject .NET DLLs?

I know you can hook native processes using C# managed code...
>>
>he saw a project where someone wrote a program to automatically play an in-browser game
>basing what he is going to learn off of this
>being so tunnel visioned that it's being based off of what can inject .dll's
holy shit
just learn how to program dude
>>
>>52044040
I do not know
I guess Microsoft can't allow this
>>
>>52044045
Thanks for the tip, sherlock.
>>
>>52043912
It's shit.

struct my_struct *my_struct_create(int a, int b)
{
struct my_struct *m = malloc(sizeof *m);

*m = (struct my_struct) {
.a = a,
.b = b
};

return m;
}

void my_struct_free(struct my_struct *m)
{
// free(NULL) is defined to be a no-op, so checking it is completely pointless
free(m);
}


Also I would only write that kind of code for opaque structs, which you would only need when writing library code.
>>
>>52044079
you're welcome, lestrade
>>
>>52044040
What do you need to use injection for btw?
>>
>>52044166
Whoops, I forgot the NULL check in the allocator function. I typically just use a malloc wrapper that will exit(1) the program if malloc ever fails.
>>
>49 Posters

/dpt/ is an autistic circlejerk tbqh
>>
>>52044204
>writing programs that can fail
shame on you
>>
>>52044248
malloc failing is such an extraordinary circumstance, 99.9999% of the time, the only valid thing to do is crash the program.
I don't even think it can fail on Linux.
>>
>>52044243
>49 posters posting on Christmas eve
an autistic loser circlejerk
>>
>>52044265
0.0001% failure rate is even worse than 99% failure rate


shame
on
you
>>
File: 8u.jpg (50 KB, 640x360) Image search: [Google]
8u.jpg
50 KB, 640x360
>>52044280
Even worse for me, it's Christmas here.
>>
Hey guys I am making a python script on my torrent server, and using config parser, and I am little bit of a pickle on how to handle this problem. My first solution was to store the days that my shows would air, which seems fine, but when it goes on mid seasons hiatus, my script would be running everyday for a hour when it does not need to, so, I thought what if I use python to parse the next air dates of my tv shows, and thought, "well, should I labele the config files the air date? or just keep them in Sunday-Saturday file name and just have them check the dates to each show to see if it matches?"

How would /dpt/ do this?
>inb4 some autistic response how python is shit or im shit.
>>
File: 1445253019594.jpg (15 KB, 249x400) Image search: [Google]
1445253019594.jpg
15 KB, 249x400
How to license one's software? I want to license my program under GPLv3. How do I do so?
>>
>>52044307
Include the licence as a file in your source code (usually called 'COPYING' or 'LICENSE'), and possibly the short version as a header in each of your source files.
>>
>Tfw trying to read c# documentation or other people's sourcecode

How do you make sense of this shit? There's 6 gorillion keywords and all these other ham and malloney.
>>
>>52044307
Copy paste the entire license document into your source code
>>
Did you know that the Applicative instance for functions in Haskell is Turing-complete? "pure" is the K combinator and "<*>" is the S combinator.
class Applicative f where
pure :: a -> f a
(<*>) :: f (a -> b) -> f a -> f b

instance Applicative ((->) x) where
pure :: a -> x -> a
pure = const
(<*>) :: (x -> a -> b) -> (x -> a) -> x -> b
f <*> g = \x -> f x $ g x


While this may exactly not be practical, I was happy to discover that <*> could be a useful combinator for defining functions in point-free style.
average :: [Int] -> Int
average = quot . sum <*> length
-- average xs = quot (sum xs) (length xs)
>>
File: ii.png (573 KB, 1012x1088) Image search: [Google]
ii.png
573 KB, 1012x1088
>>52044307
Just release it without a licence and let people do whatever they want with it, including sell for profit or use code in propitiatory software.

True freedom is letting people do whatever they like with your program, even things you disagree with.
>>
when will it be possible to render moving images without frames
>>
>>52044338
>BSD-like: Freedom for the developer
>GPL: Freedom for the user
Libraries should be BSD-like, applications should be GPL.
Only fags do otherwise.
>>
File: 1450118781950.jpg (365 KB, 750x725) Image search: [Google]
1450118781950.jpg
365 KB, 750x725
>>52044338
>True freedom is letting people do whatever they like with your program, even things you disagree with.

>Tfw earning money because some neckbeard released his code for free

Thanks neckbeards!

No really, thank you neckbeards. Keep supporting opensource lmao. Pic related
>>
>>52044351
Never.
>>
>>52044367
dumb frogposter
>>
File: 1447643281920.jpg (67 KB, 500x334) Image search: [Google]
1447643281920.jpg
67 KB, 500x334
>>52044380
Dumb neckbeard opensource NEET

Wanna code most of my next project for me in the name of Opensource? :^)
>>
Is Visual Studio the Emacs of IDEs?
It has
-a package manager
-a tiling window manager
-weird key combinations
-more features than any one person could possibly use
-self-writing capability (not only is VS designed in VS, but the compilers used to compile VS are written in VS and then compiled using the same compiler)
-themes
-supports a surprisingly large amount of programming languages


The biggest difference I can see is that Emacs is miraculously small while VS is one of the largest non-game pieces of software I've ever seen, clocking it at almost 10GB.
Thread replies: 255
Thread images: 31

banner
banner
[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.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.