[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 315
Thread images: 18

File: h a s k e l l.png (126KB, 400x400px) Image search: [Google]
h a s k e l l.png
126KB, 400x400px
What are you working on, /g/?


Previous thread: >>58906092
>>
What's the Haskell on anime?
>>
>>58913043
"The most powerful programming language is Lisp. If you don't know Lisp (or its variant, Scheme), you don't know what it means for a programming language to be powerful and elegant. Once you learn Lisp, you will see what is lacking in most other languages." -Richard Stallman
>>
>>58913060
s/on/of
>>
>>58913061
I don't care about it because I don't write compilers. I use language which is suitable for work.
>>
>>58913114
>I don't care about it because I don't write compilers
is it good for writing compilers?
>>
>>58913114
ocaml is better for compilers kek
really lisp and scheme have no use anymore since the 1990s
>>
>>58913128
You could have picked anything else, but you pick OCaml? Really?
>>
>>58913128
Why is Clojure gaining traction then?
>>
>>58913152
Yes, have you ever written a compiler
>>
>>58913127
Stallman wrote gcc, it's normal for him to be concerned about languages, I don't write compilers, I don't care which language is better, I use one which just werks.
>>
>>58913163
Yes, for a small toy language. Anyone who has written in OCaml shouldn't overlook its horrid deficiencies.
>>
>>58913152
Is haskell good for this kind of thing?
>>
>>58913180
?
It has polymorphic variants among other things which makes it vastly better than whatever you used
>>
>>58913200
I know it has parsec, but I'm not experienced enough in Haskell to give any formal conclusions. It did seem promising. You can try the Write You a Scheme wikibook to give you an idea, though it's a bit dated.
>>
>>58913218
Did you use ocaml?
>you can try the Write You a Scheme wikibook to give you an idea
Yeah, that's what I'm planning to do pretty soon.
>>
A simple board game in C
>>
>>58913229
Yeah, I messed with SML first then OCaml.
>>
Is there any reason why people use function_exists() on php?

Say you have function a which was recently introduced on the latest version of PHP. For compatibility, you do the following:

if (function_exists("a")) {
a();
}
else {
// Code of a() here
}
>>
>>58913259
What if the function
doesn't exist?
>>
>>58913277
That's why you include the source of the function `a` in the else()
>>
>>58913259
Tip: PHP makes no sense.
>>
>>58913303
I know, but >>58913259 was wondering why people use it. I assume one reason is to test for collisions in the namespace.
>>
>>58913331
I know, I'm just wondering why you'd check instead of just copy/pasting or implementing the same function yourself and avoid the call.
>>
whats the point of defining zero to 0 here?
>>
File: 1462559970905.jpg (40KB, 390x418px) Image search: [Google]
1462559970905.jpg
40KB, 390x418px
>>58913259
>web development
>>
>>58913371
I can only assume it is in order to avoid magic numbers.
>>
>>58913379
How is ZERO less of a magic number than 0?
>>
>>58913371
I assume the author is retarded.
>>
>>58913407
Well, books are for retards.
>>
>>58913417
:^)
>>
Can I ask questions about unity coding here / get help on why something isn't working ?
>>
>>58913430
No, no you cannot. But seriously, just ask your question instead of asking to ask next time.
>>
>>58913043
Why does Lisp have an anime but not Haskell?
>>
>>58913371
It makes sense to define the initial bank account value, but naming it ZERO is retarded. The author should've used something like INITIAL_ACCOUNT_VALUE.
>>
>>58913407
its c++ primer plus
>>
File: anime.png (786KB, 1000x1300px) Image search: [Google]
anime.png
786KB, 1000x1300px
>>58913458
>>
>started working on a proof-of-concept for a new game using javascript
>spent most of Friday just getting the UI to not look terrible
>got some basic shit done Saturday, also split the javascript into multiple files
>realize I'm in way over my head

A-at least I'm going to learn new things.
>>
>>58913497
tfw you'll always be in way over your head
>>
>>58913458
they are both anime though, they don't even need anime.
>>
>>58913233
Details, progress?
>>
is it possible to make 3d games that use external graphics in a non oop language?
>>
>>58913043

haskell is such a fucking joke

academics keep pushing functional programming but nothing of consequence has ever been made with it

and they keep pushing it, and keep pushing it
>>
>>58913578
Yes.
>>
>>58913586
FP was the future we deserved, if it weren't for the rise of liberalism we'd have it
>>
>>58913588
how would it be done? how can you even manipulate data like that?
>>
Should I learn haskell or scheme? Which language is the most high level?
>>
>>58913612
Both
https://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_Hours
>>
Preparing for a cyber security course that i applied for , dont know any good books to help though , does anyone else know any good cyber security books i could purchase that aren't over $50
>>
>>58913586
Haven't you heard of the functional reactive programming meme yet, anon?
>>
>>58913597
>FP was the future we deserved
Yeah, but defenitely not the one we needed.
>>
>>58913639
Anything prefixed with the term 'cyber' shouldn't be taken seriously.
>>
>>58913744
Elaborate on what you mean by that
>>
>>58913619
Wow this is pretty cool, I assume it's focused more on writing haskell code, but will I actually learn haskell or just copypasting code samples from wikibooks?
>>
>>58913750
It's a term coined by normies to sound 'techy'.
>>
>>58913756
if you read it enough
>>
>>58913770
thanks for the tip, it looks pretty challenging and fun
>>
>>58913761
If you are going to criticize a name of a subject , go back to /b/ , i'm not here to argue pathetic points about the names of things , i just want book recommendations and useful advice , basically what i am saying is just drop whatever motive you have to insult me and rather be useful or ignore me.
>>
>>58913606
Under any graphics library lies another abtraction layer for interfacing with the GPU. These libraries abstract the job of doing all the different possible calls there could be for different GPU models making it posible to do things like calling a function "draw_pixel_in_screen(x_coordinate, y_coordinate)". Today the most popular are DirectX and OpenGL. OpenGL is pure C.
>>
>>58913586
Haskell is something like Arch linux.

It's good as an example of the lambda calculus computational model instead in comparison to the Turing machine computational model. It has no good use neither for intensive computations on the Von Neumann architecture nor for scripting purposes.

As well as Arch is good to learn kids CLI in Linux but it has no real use in production.
>>
>>58913761
Also side note , if you wish to criticize the subject name , go complain to the Scottish education system not me , i have no control over any of that , all i know is that it is a IT field that is in demand and that there can be a substantial amount of money in
>>
>>58913793
>>58913836
Does the Scottish education system teach you proper punctuation?
>>
>>58913043
Just finished modernizing my projects to have logging and actual configs

Looking how to build a webserver in go now
>>
>>58913853
>Does public education teach proper punctuation?
No
>>
>>58913830
Haskell makes you a much better programmer though, which will influence your code and your thinking while arch is just a meme
>>
>>58913043
Holy fuck, am I retarded?
I have the following directories:
├── default
│ ├── a_file
│ ├── a_dir
│ │ └── another_file
│ ├── another_dir
│ │ ├── subdir
│ │ │ ├── subfile
│ │ │ ├── subsubdir

and the following .gitignore:
/default/another_dir/subdir/subsubdir/**
/default/another_dir/subdir/subsubdir/*

Why does git add files and directories located in `subsubdir` when I do
git add -A
?
>>
>>58913597
Only multiparadigm languages will be left in the future.
>>
>>58913967
Is the directory already being tracked by git?
>>
>>58913997
No it isn't.
>>
>>58913972
>only multicultural societies will be left in the future
Exactly the opposite of the truth.
Combining completely different languages, facing all of the problems and enjoying none of the benefits
>>
>>58913961
>Haskell makes you a much better programmer
By what metric?
>>
>>58914007
This analogy is retarded, but I'll bite anyway: Name one society that is not multicultural in the developed world. Hint: you can't.
>>
>>58913961
What's this redditry? Arch isn't a "meme", it's just trash. Use the word correctly.
>>
>>58914029
All of the developed world.
Despite liberal attempts, they have yet to depose the original cultures.
>>
>>58914029
china
>>
>>58914029
>Name one society that is not multicultural in the developed world
This question doesn't even make any sense. For something to be a part of the developed word it must be non-multicultural in the first place.
>>
Still working on my CTF. Why would a compiler use
mov byte ptr [eax], 0

Instead of
mov [eax], 0

I am going to guess I am missing something huge here. Is this just to specify what type it is?
>>
File: languages3.png (17KB, 522x384px) Image search: [Google]
languages3.png
17KB, 522x384px
Reminder
>>
>>58914134

Quit posting your dumb image.
>>
>>58914158
Does the truth hurt?
>>
>>58914158
Go away nigger boy.
>>
>>58914134
People who disagree are dumb

>>58914158
Case in point
>>
Ok, I'm trying to get Sublime to compile my shit so I can use a faster text editor than Code::Blocks, but I'm getting errors if I only include my .h file.
But, wait... if I include the .cpp file, no errors.

Fuck is that shit?

Why is it doing this?
>>
>>58914104
There are like 20 different mov instructions.
When used for loading/storing to memory you must specify the operand size, i.e how many bytes are loaded/stored..
Some assemblers will infer the size, or pick some default when no size prefixes are used.
>>
>>58914168
>>58914170
>>58914172

Samefag with a 4chan pass
>>
>>58914178
Wrong, faggot
>>
>>58914173
Is your header file missing function definitions/data structures?
What's the compiler error?
>>
>>58914178
Wrong again burger king.
>>
>>58913967
Use
/default/another_dir/subdir/subsubdir
instead.
>>
>>58914204
>Is your header file missing function definitions/data structures?
The header only has the declarations, not the definitions. Those are in the cpp file.

>What's the compiler error?
C:\Users\GS\AppData\Local\Temp\ccOAmMeG.o:main.cpp:(.text+0xeb): undefined reference to `initGL()'
C:\Users\GS\AppData\Local\Temp\ccOAmMeG.o:main.cpp:(.text+0x10c): undefined reference to `render()'
C:\Users\GS\AppData\Local\Temp\ccOAmMeG.o:main.cpp:(.text+0x158): undefined reference to `update()'
C:\Users\GS\AppData\Local\Temp\ccOAmMeG.o:main.cpp:(.text+0x15d): undefined reference to `render()'
collect2.exe: error: ld returned 1 exit status

Basically, it's saying all the functions are undefined... which they are... and the linker should be linking the cpp file, so they are NOT undefined.
Why is it not linking the cpp file?
>>
>>58914134
c++ is fast? lmao
>>
>>58913967
>/default/another_dir/subdir/subsubdir/
Not sure how git handles it, but that is typically an absolute path, i.e it would only work if default was in the root /
>>
>>58914242
And what flags are you using in order to link your objects?
The process should be something like
gcc -c myfile.c -o myfile.o
gcc -o myexecutable.exe myfile.o main.c
>>
Would /dpt/ rather use C++ or Java?
>>
>>58914277
C++
>>
>>58914277

Neither.
>>
>>58914277
C++ any day.
>>
>>58914275
Uhhh...
I never really used CLI for compilation. I've been trying to fuck with this thing, and I only just got the OpenGL and SDL libraries to link... after trying several (many) times.

This is apparently the command I'm using:
{
//"shell_cmd": "make"
"cmd": ["g++", "${file}", "-o", "${file_path}/${file_base_name}.exe", "-IA:/CodeBlocks/MinGW/Dev_Lib/include",
"-IA:/CodeBlocks/MinGW/Dev_Lib/include/SDL2", "-IA:/CodeBlocks/MinGW/Dev_Lib/include/GL",
"-lmingw32", "-lSDL2main", "-lSDL2",
"-lOpenGL32", "-lglu32", "-lfreeglut"
]
}

>Don't think the Dev_Lib things are needed anymore, though... I had to move the files to the main thing.

So, yeah, whatever this command does is the flags I'm using.
>>
>>58914297
What's your choice for OOP, then?
>>
>>58914297
That wasn't an option.
>>
>>58914297
>hahaha watch me pick netiher xD
>>
>>58914308
>A:/
what the fuck
you installed mingw on a floppy?
>>
>>58914277
java

flexible
no retarded x system incompatibility (int changes size lmfao)
amazing gui programs

c++
platform lock in
difficult to know where to start
a trillion ways of doing the same thing
obsession over memory addresses
>>
>>58914324
No, but I wasn't gonna waste the letter. It's a 64GB partition on my SSD
I also use B:\ for media
>>
>>58914332
p
a
j
e
e
t
>>
>>58914312
>>58914314
>>58914321

Samefag
>>
>>58914346
You caught me.
>>
>>58914308
That looks like it only compiles and links a single file.

Either include all.cpp file in main.cpp so you only have a single translation unit (and that is a serious suggestion, it can speed up your compile/link time significantly, at least for <50K line projects), or learn how to use a makefile/build script.
>>
>>58914346
I'm not samefagging though
>>
>>58914346
>>58914312 wasn't samefag, I'm the guy who asked the original question.
>>
File: languages4.png (14KB, 522x384px) Image search: [Google]
languages4.png
14KB, 522x384px
>>58914134
FTFY
>>
>>58914380
>that awkward moment when you've got to talk to the one retarded kid with autism
>>
>>58914277
Java
>>
>>58914365
So, there's no actual/real issue with including .c or .cpp files?

It's just I've always heard it was like fucking terrible to do.
>>
>>58914380
Go combines all the disadvantages of a garbage-collected language with all the disadvantages of a systems language.
>>
>>58914332
>Java
>amazing gui programs
You seem to have wandered in from a parallel Universe.
>>
>>58914404
Exactly my point. It's relatively good performance, relatively fast development and useless in many cases.
>>
>>58914398
All an #include does is just literal copy&paste of the file contents, so if you imagine all of foo.cpp being dumped into the place where it is included there's no difference between you manually copying the code into main.cpp from foo.cpp and #including it.
>>
>>58914450
Hmmm, alright.
>>
>>58914177
x86 is a confusing mess.
>>58914332
The one thing Java does right is it runs on EVERYTHING the jvm runs on. Anything after that it's pretty meh at.
>>
>>58914513
It also doesn't have header files. And its synchronization model (every object can be used as a mutex/condition) is great too.
But yeah, the rest isn't that fun.
>>
>>58914312
If you want OOP, pure OOP, then you should go for smalltalk. But OOP is garbage so just chose scheme when in doubt
>>
>>58913497
>proof of concept
>fucking around with UI instead of writing the actual game
>>
>>58914064
it is multicultural though, look up the definition. Just because the original culture still exists does not make it non-multicultural
>>
OOP is great for making video games in programming Checkmate /dpt/
>>
>>58914614
>OOP is great for manchildren
wtf i hate oop now
>>
>>58914134
what the fuck is idris, another flavour of the month language?
>>
>>58914628
a pure, dependently typed language based on Haskell and Agda/Coq
>>
>>58914614
It's not though.
>what is cache
>what is ECS
>>
>>58914614
functional programming will never work in game development because of changing state but that does not mean OOP is great, it's the imperative/procedural style that's great
>>
>>58914671
>functional programming will never work in game development because of changing state
monads
>>
>>58913472
>plus
retarded fits right in
>>
>>58914653
All the top most successful video games in the industry all use OOP I am sure there is a reason they are all using OOP for their games
>>
OK /g/, try to explain how creating functions that accept a struct as the first argument is meaningfully different than OOP.
>>
>>58914640
>Coq
More like my coq in you're mom
Haskell can do everything I want to so I don't see any reason to switch
>>
>>58914683
Prove it.
>>
>>58914699
haskell is awkward with dependent types, but Idris definitely has a lot of flaws
>>
is this the same as trial division to find the gcd?
// gcd(a, b)

long answer = 1;
for (long i = 1; i <= a/2; i++){
if(a % i == 0){
if(b % i == 0){
answer = i;
System.out.printf("Trial Division = (%d)\n", answer);
}
}
}
>>
>>58914712
>haskell is awkward with dependent types
Haskell doesn't have dependent types.
>>
>>58914552
how is not having header files a bonus
>>
>>58914733
GHC can reflect runtime integers and symbols to type level and back
>>
>>58914671
Wasn't jak and daxter programmed in LISP.
>>
>>58914682
whats a better book then? the one by the creator felt more like a reference than a learning aid
>>
>>58914691
taking the bait
OOP is a design pattern, it is about the relations in your code, not about the implementation. Just because a language provides classes/structs does not mean all your code is going to be OOP. For example you could do FP in c++, a "OOP" language.
In your case the struct just packs some variables together, it is not an object as it does not have a relation with the real world
>>
>>58914734
Code deduplication. When you modify a file you have to make sure to modify the other too.
>>
>>58914450
>>58914365
Ok, so I actually got it to work by fucking around on Stack Overflow.

Apparently, THIS works...
{
//"shell_cmd": "make"
//"cmd": ["g++", "${file}", "-o", "${file_path}/${file_base_name}.exe",
"cmd": ["g++", "*.cpp", "-o", "${file_path}/${file_base_name}.exe",
"-IA:/CodeBlocks/MinGW/Dev_Lib/include",
"-IA:/CodeBlocks/MinGW/Dev_Lib/include/SDL2",
"-IA:/CodeBlocks/MinGW/Dev_Lib/include/GL",
"-std=c++11",
"-lmingw32",
"-lSDL2main",
"-lSDL2",
"-lOpenGL32",
"-lglu32",
"-lfreeglut"
],
"working_dir": "${file_path}",
"selector": "source.c, source.c++"
}

But, does anyone know how I can get it to work on both .c AND.cpp files in the same build thing?
>>
>>58914743
It reflects the value/type level definitions to the type/kind level. It does not let types depend on values.
>>
>>58914653
>ECS
thats OOP buddy
>cache
ok you dont know what you're talking about
>>
>>58914691
How about explaining how they're remotely the same?
You've taken it as a faith based assumption that OOP is the modern standard.
But the problem with this, is that OOP has been moved away from for many years.
Everywhere you look - "don't use inheritance", "use lambdas", "no deep heirarchies", "xyz(not object) driven/oriented design/programming", etc.
And even then, all of that started from the basis of C++ style programming, which is 90% imperative C like, and only a small small portion is OOP - inheritance and method call.
(There was even an attempt to generalise method calls to something not OOP-related!)

So modern "OOP" isn't actually OOP at all.
>>
>>58914756
>it does not have a relation with the real world
Just like functionalfags
>>
>>58914756
I read a lot of buzzwords but no actual reasons
>>
>>58914759
youve lost me
>>
>>58914764
>values can be reflected to types (which types can depend on) but somehow this doesn't mean types can depend on values

>>58914769
ECS is not OOP.
It's a kind of programming oriented over a particular kind of composition, entity components.
It lends itself much more naturally to row polymorphism (and hence paradigms closer to PLT, like FP)
>>
>>58914769
>thats OOP buddy
No it's not. ECS is structs and functions.

>ok you dont know what you're talking about
Encapsulation and virtual methods are awful for cache. Encapsulation groups data together for the benefit of the programmer, which often conflicts with the optimal layout for the machine. Virtual methods thrash the instruction cache.
>>
>>58914799
>Create function
>You have to remember to add it to the header file

>Change function arguments
>You have to remember to change it into the header file

>Change the way a function is called
>You have to remember to change the comments in the header file

And so on.
>>
>>58914715
Very inefficient and doesn't work. What if gcd(a, b) = a?
Check out the Euclidean algorithm.
>>
>>58914784
yeah well FP doesn't have to have a relation with the real world, as it's based on the concept of mathematical (= abstract) functions.
The whole point of OOP is that it makes programming/system building easier by having a relation with real-life objects
>>
>>58914762
Eh, fuck it, I'll just rename it and make a separate one that does .c instead.

Probably don't need to, though; I always compile AS C++. I just write it like C. You know, IN CASE I actually decide to use Classes or something.

But, eh.
>>
>>58914801
GHC lets you define a data type:
data Nat = Zero | Succ Nat

and use the type at the kind level and the constructors at the type level like so:
data Fin :: Nat -> * where
FZero :: Fin (Succ m)
FSucc :: Fin m -> Fin (Succ m)

It does not allow you to have types that depend on values:
foo :: (m :: Nat) -> Fin m
>>
>>58913371
>.cpp
Stopped reading right there
>>
>>58914835
Real life objects is the problem. Abstraction is by definition far from real life objects.
In FP and PLT inspired languages you can model stuff as objects if you like. You can use state if you like.


>>58914841
You have to bust out all of the extensions, and use a bunch of GHC TypeLit stuff
>>
>>58914861
Show me some dependently typed Haskell code, then.

>GHC TypeLit
If all you're doing is writing Fin 2 instead of Fin (Succ (Succ Zero)) that changes nothing.
>>
>>58914134
Is this new meme?
>>
Java is a 100% OOP and it is one of the best programming languages used everywhere and you cannot deny it isn't good
>>
>>58914875
A type family or type class can effectively give you type level functions, and the fact you can reify some values back to types gives you dependent types
>>
>>58914890
Show me some dependently typed Haskell code. Oh wait, you can't.
>>
>>58913043
So I've got a functioning PhantomJS script going and have finally ironed all the bugs out so that it works without error.

The only problem is it is very slow and requires me to manually manipulate the variables in the script every time I want to change them, which is required every time the script completes.

What's the best way to go about adding a visual interface of some kind that will allow me to input variables and run the script from a single window without having to manually edit the script itself every time?
>>
>>58914888
Java is ok. It was more user friendly than C and ran on everything which got it a huge market share. These days it is mostly industrial lag and Javascript is mostly taking it's place as the run on anything language.
>>
>>58914134
Severàl benchmarks show Haskell and Go beating C and C++ in certain situations
>>
>>58914834
you're right, I changed the loop to "i <= a", works now
this is for an assignment where we compare runtime to euclid's theorem runtime for large numbers
>>
>>58914914
You mean like in webservers, when the Haskell implementation was dropping 80% of requests?
>>
>>58914914
>>58914938
Java and C webservers are the best
>>
>>58914951
>PHP
>>
>>58914898
https://www.schoolofhaskell.com/user/thoughtpolice/using-reflection
>>
>>58914914
Haskell is faster than asm in certain situations too. Haskell is faster than machine code in certain situations. Haskell is faster than even Haskell in certain situations.
>>
>>58914958
How is this dependently typed at all? The types don't depend on the values, they are simply markers like with ST.
>>
Why are exercises in programming books always so contrived and time-consuming?
>>
>>58914991
http://stackoverflow.com/questions/30752653/can-i-have-an-unknown-knownnat
look at the answer
>>
>>58915019
Because real-life clients have contrived and time-consuming ideas that you'll be forced to attempt to bring to life.
>>
>>58913371
It was for the purpose of the course, to show how it is used, I guess
>>
>>58915031
The type is not dependent on the value itself. If you took the same natural number and put it into two SomeNats, the type variables induced by the proxies would not be identified. It's just an existential trick that allows you to tag a value with a type so that it gets passed around implicitly.
>>
>>58914991
>>58915031
here's part of the magic

natVal :: KnownNat n => proxy n -> Integer
SomeNat :: KnownNat n => Proxy n -> SomeNat
someNatVal :: Integer -> Maybe SomeNat

natVal (Proxy :: Proxy 3)
> 3
-- type -> value

someNatVal 3
> Just 3
-- that 3 is actually (Proxy :: Proxy 3)
-- using ScopedTypeVariables you can case match on it (_ :: Proxy n) and get that value out as a type
-- value -> type
>>
>>58915083
It's literally lifting a value to a type, what's your problem?
obviously you can then use that type with all of Haskell's other type machinery
>>
>>58915106
It's not lifting the value itself to the type level. The value is still there floating around at the value level, all you are doing is putting an existentially quantified phantom type with it that can somehow be traced back to that value. Am I wrong that making two SomeNats out of the same natural number will end up with two different types?
>>
>>58915106
>>58915134
And if the value is at the type level then surely you should be able to actually use it up there. Can you apply succ to it? Can you pattern match on it?
>>
>>58913961
>>58913586

Haskell is a programmers's programming language

it's like a luxury automobile while C++ is a Cat d9
>>
>>58915154
https://blog.jle.im/entry/fixed-length-vector-types-in-haskell-2015.html#conclusion
>>
>>58915154
>>58915246
Actually not sure if he does that
It's hard finding these links

But you could in theory.

GHC has some problems with typelits, in that it doesn't really have special typechecking for stuff (e.g. a + b ~ b + a, known nat n => known nat (n + 1)) but otherwise you'd be fine
>>
>>58915154
>>58915261
https://hackage.haskell.org/package/typelits-witnesses
>>
>>58915261
That's just using constant type level values (i.e. not actual values) and implementing Fin with instances and Proxy instead of a GADT.

>>58915285
I'm still going to argue against this being dependent types. What SomeNat allows you to do is say "there exists a type n that is associated with some natural number value". The value itself is not obtainable at the type level - at the type level it's just a phantom type. All these things do is let you turn a SomeNat n into e.g. a SomeNat (n + 3) which, when reflected, gives you the value of the original one + 3.
>>
File: 1485747356525.png (818KB, 1280x719px) Image search: [Google]
1485747356525.png
818KB, 1280x719px
>>58913060
>>
>>58915328
c..cute
>>
>>58915326
You could presumably use these obtained types as indices into a GADT and still do dependent types

At some point Haskell will get (practically) real dependent types though
>>
If you want some actual dependent type stuff in Haskell, try LiquidHaskell. Not full dependent types, but refinement types which are a well-behaved special case.

>>58915350
>You could presumably use these obtained types as indices into a GADT
Nope, because they are just phantom types. There's no way for Haskell to do the constraint checking on them.
>>
File: algorithm.jpg (58KB, 810x506px) Image search: [Google]
algorithm.jpg
58KB, 810x506px
Lads, I'm starting to learn JavaScript and the professor assigned this over the weekend when we missed class on Friday, we haven't gone over algorithms yet and his example didn't help. Tips/Help?
>>
>>58914854
>>.cpp
>Stopped reading right there
Retarded detected... go back to try learning Javascript...
>>
>>58915390
I wouldn't call multiplications algorithms.
>>
>>58914951
> Not Ada web server
>>
>>58915390
>javascript
Stopped reading right there.
>>58915394
>.cpp
Stopped reading right there.
>>
>>58915390
import Text.Printf (printf)

request :: Read a => String -> IO a
request s = do
putStrLn s
readLn

main = do
hours <- request "How many hours did you work?"
hrpay <- request "How much do you get paid per hour?"
printf "%d * £%.2f = £%.2f\n" hours hrpay (hrpay * fromInteger hours :: Double)
>>
File: 1486906634339.jpg (58KB, 851x233px) Image search: [Google]
1486906634339.jpg
58KB, 851x233px
>>58915433
>>
File: 1484313885363.jpg (40KB, 500x400px) Image search: [Google]
1484313885363.jpg
40KB, 500x400px
>>58915390
>algorithms
>>
>>58915390
var hoursWorked = prompt("How many hours did you work?");
var payPerHour = prompt("How much do you get paid per hour?");
var grossPay = hoursWorked * payPerHour;

alert("Your gross pay: " + grossPay);
>>
>>58915496
You need to abstract this and put in an ajax request. Also having an alert in 2017 is just gross.
>>
File: 1471458374373.png (177KB, 664x520px) Image search: [Google]
1471458374373.png
177KB, 664x520px
>>58915496
Thanks a lot man :)
>>
>>58915523
Excuse me?

back the fuck off?
>>
File: 540.png (118KB, 657x527px) Image search: [Google]
540.png
118KB, 657x527px
01001101 00100111 01110001 00100000 01110001 01100101 01101111 01101101 01110010 01101011 00100000 01100101 00100000 01101011 01100101 01110001 01101001 00100001
>>
>>58915523
>>58915496
Install Node.js, NPM, Gulp, Webpack, Sass, Bootstrap, React, Redux, Express.js, MongoDB, Mongoose, and THEN you might be able to create something worthwhile.
>>
>>58914254
Fast to execute, slow to compile.

The argument you'll usually get is "well you RUN the code a lot more than you compile it".
100% true for users or build servers, but a real pain in the ass for developers.

Which is even funnier, because C++ is meant to be the programmers' programming language.
>>
>>58915563
But does it web scale, though?
>>
Who /overloadabuse/ here?

{-# LANGUAGE GeneralizedNewtypeDeriving #-}

newtype IO' s a = IO' { unIO' :: IO a }
deriving (Functor, Applicative, Monad)

instance (Show a, Read a) => MonadState a (IO' a) where
get = IO' readLn
put = IO' . print



unIO' (modify (*100))
>>
File: 76512876143.jpg (11KB, 180x176px) Image search: [Google]
76512876143.jpg
11KB, 180x176px
>>58915590
What is this abomination?
>>
>>58913259
you know
you could just
// code of a() here

if you're uncertain if the function exists

the if makes no sense
>>
>>58915590
bitch please
-- explicit type recursion based on functors
newtype Mu f = Mu (f (Mu f)) deriving Show
in x = Mu x
out (Mu x) = x

-- cata- and ana-morphisms, now for *arbitrary* (regular) base functors
cata phi = phi . fmap (cata phi) . out
ana psi = in . fmap (ana psi) . psi

-- base functor and data type for natural numbers,
-- using a curried elimination operator
data N b = Zero | Succ b deriving Show
instance Functor N where
fmap f = nelim Zero (Succ . f)
nelim z s Zero = z
nelim z s (Succ n) = s n
type Nat = Mu N
>>
>>58915641
>abuse
>>
>>58914277
Are you actually happy to use 100% OOP?
If so, you may as well use the padded cell that is Java.

If you want to escape the meme occasionally then maybe C++ would make it easier, but only to make your code a spaghetti mess of different flip-flopping codestyles.

The only benefit of using C++ is it allows you to do all of the terrible things that no sane language will.
>>
>>58915641
What is the purpose of this shit?
>>
>>58915614
treats the user as a state machine
>>
Best way to learn haskell??? Doesn't have to be quick (like: learn X in Y hours), as long as it's a high quality resource.
>>
>>58915687
wikibook
https://en.wikibooks.org/wiki/Haskell

feel free to ask questions


>>58915445 is pretty basic (except that printf is variadic, ignore that)
>>
>>58915641
>babby's first generic programming in Haskell
>abuse
>>
>>58915675
For example C++ can be compiled into a useful program for humanity.
>>
>>58915687
See >>58915700
>>
Implementing the "Fishy" and "Asteroids" games in functional java code (no mutation of state, all persistent data structures) for class.
>>
>>58915687
What is the purpose of knowing a language which isn't an industry standard.
>>
I've got two structs that I need to initialise.
typedef struct{
uint32_t t;
uint8_t *v;
uint8_t d;
int64_t a;
} b_t;

typedef struct {
b_t **bs;
} l_t;

I malloc the first one like so,
l_t *t_c;
t_c = (l_t *) malloc(sizeof(b_t) * num_lt);

And it works fine. Then I have to initialize an array of b_t's inside t_c by mallocing them. I tried
t_c[i].bs = malloc(sizeof(b_t) * num_b_per_lt);

but I get a coredump on cygwin and an access boundary error on ganhooh. What am I doing wrong? Any help appreciated.
>>
>>58915738
This code looks much more sane than the haskel bloatware.
>>
>>58915679
Composable recursive pattern matching.
>>
>>58913128
Lisp is used all the time in science/research, D-wave directly hires from comp.lang.lisp, JPL still uses it, same in medicine http://www.lambdanative.org/ and still used in AI.

>>58913152
Most university courses in compiler writing you're using SML or OCaml
>>
>>58915738
>>58915738
What the fuck are these names
This is completely unreadable
Maybe if you made it more clear what is and isnt an array then youd be able to tell what you havent initialized
Maybe its that malloc() only allocated space for the array, it doesnt allocate space for individual members
struct A { ... };
struct A** list_of_As = malloc(sizoe(A*) * 10);
list_of_As[0] = <uninitialized garbage>
>>
>>58915731
Why don't they just use a functional language to teach you FP?
>>
>>58915738
what are the values of num_lt and num_b_per_lt
>>
>>58915738
Don't use typedef please.
>>
File: 1486269739056.png (260KB, 620x640px) Image search: [Google]
1486269739056.png
260KB, 620x640px
>>58915731
>functional Java
>>
>>58915738
Why do you need a struct containing the pointers?

It'll make the declaration easier, but every time you access the base struct you'll be dereferencing all over the place.

Just make an array of b_t, you're already need a loop to malloc the elements anyway.
>>
>>58915834
They teach lisp first semester, and then they teach this abberation of java to appease the industry and the whiny assholes who didn't like new things and thought APCS made them hot shit (now they think theyre even hotter shit, but they can't stop pulling out Java features they think are absolutely fabulous when its not that hard to follow the curriculum and you might learn something about OO in the process)
>>
>>58915738
Also, b_t.v needs malloc-ing on top of the b_t struct for each element in the array when you use it.
All the b_t malloc will put aside is enough room for the pointer, but not the actual array.
>>
>>58915822
It's very cool. It means that if you know Lisp, you're automatically becoming an AI scientist. I always thought that their primary language is probability theory, calculus and numerical analysis.
>>
>>58915552
damn i converted that to decimal expecting it to correlate to ascii for some reason.
>>
>>58915802
Why don't you use 'grep' instead?
>>
>>58915825
Sorry about the variable names, trying to not get fucked for posting my code on the net.
All you need to know is that l_t is supposed to a variable number of b_t's, but at least 1.

>>58915835
Sane numbers, num_lt is 256 at most, num_b_per_lt is about 32 or 64. Small enough to fit in like two or three pages, I think.

>>58915878
Yeah, that's what I thought, I originally just used
b_t *bs
and used . to get members, but I had the same issues.

>>58915921
Oh shit, that's a good point. Would it help if I had a literal array of b_t instead of fucking around with l_t?
>>
>>58915959
I agree about the variable names.
>>
>>58915885
Java and C# should be banned in undergraduate CS.
>>
>>58915990
Java definitely but not C#
>>
>>58915876
interface IFunc<T,U> {
U apply(T arg);
}

interface IList<T> {
...
<U> IList<U> map(IFunc<T,U> fn);
}
class Cons<T> implements IList<T> {
T first;
IList<T> rest;
...
<U> IList<U> map(IFunc<T,U> f) {
return new Cons<U>(
f.apply(this.first),
this.rest.map(f));
}
}
class Empty<T> implements IList<T> {
...
<U> IList<U> map(IFunc<T,U> f) {
return new Empty<U>();
}
}

^ this is what kind of shit we do in the class

Equivalent haskell:
data [t] = [] | t:[t]
map f [] = []
map f (x:xs) = f x:map f xs
>>
>>58915552
6a 6e 78 20 63 6e 78 7a 68 3f
>>
>>58915990
It looks like that Haskell is also becoming bloated by 4chan-tier pros who hate cpp and oop.
>>
>>58916000
Yes C# too. A well-taught graduate will be able to pick it up in a couple of weeks.

Churning out Java and C# code monkeys is deskilling the industry.
>>
>>58916009
>2017
>still can't define exfix type operators or overload [] and (:)
>>
>>58916009
For fuck's sake.

The concepts being taught are lost in all the pointless Java noise.
>>
File: paypay.png (234KB, 600x599px) Image search: [Google]
paypay.png
234KB, 600x599px
/dpt/ programmers are the kind of programmers who all complain about how bad Java is but they get a Java developer position and outsource all their work because they can't figure it out for themselves
>>
>>58915959
>Would it help if I had a literal array of b_t instead of fucking around with l_t

That depends, is each instance of b_t going to have a v array allocated?
Would you ever need to swap once instance of v for another array?

If you are just storing shit and reading it back, there's no point using pointers at all.
The main reason for using them is to cheaply pass along a reference to the data, or because you need a reference to memory that was allocated elsewhere that you won't be free-ing yourself.
>>
>>58916060
Java is an utterly trivial language that forces you to write an unnecessarily large amount of code.
>>
>>58916065
You could always reference to locations in the array.
Also pointer chasing is not free and moving a few words is not always that expensive
>>
>>58913043
For the past two weeks I've been working on adding FLIF support to my image viewer, Ivy. I think I'm almost done, but I'll do some more tests before I merge to master.
>>
File: image.jpg (58KB, 640x480px) Image search: [Google]
image.jpg
58KB, 640x480px
>>58913043
I need to code a money exchange program in c# for school. It needs to pull the dollar price from a bank website and MUST use delegates and event handlers.
Someone please point me in the right direction, tutorials, examples or anything regarding
Delegates
Web scraping (basic)
Event handlers
>>
>>58916077
poor baby
>>
>>58916087
>You could always reference to locations in the array
That's what I was getting at.

Generally though, I don't pass anything by reference unless something actually needs to mutate the original.
As soon as copying large enough structs is a speed problem, you should probably restructure them OR pass members instead of whole blobs.
>>
>>58916065
>is each instance of b_t going to have a v array allocated?
Yes, but that happens after I have the array of b_t's allocated, which isn't working right now.
An alternative I could think of is having v be a bit vector, since each entry is gonna be a bit long, but the issue is I don't know how long v should be, ie 32 bit/64 bit. Sane numbers leads me to say it's around 16 bit, but I *really* don't want to deal with bitmasking to get values from v.
>>
>>58916124
I could do this easily for you in like 12 minutes in Java sorry I don't know C# all you have to google is http response and requests in C# event handlers and delegates
>>
Let's design a CS curriculum, /dpt/. I'll start:

>digital electronics (logic gates, flip flops, etc.)
>programming in C
>programming in ML/Haskell
>>
>>58916126
>hurr poor baby wanting to use tools instead of harvesting the crops with his bare hands what a snowflake
>>
>>58916159
start with signals and systems
>>
>>58916137
Sorry dude, I completely misread your reply.
Doesn't matter if you use a b_t array directly or l_t, b_t.v still needs to be malloc-ed manually.
>>
>>58916159
>problem solving logic
>programming in Java
>databases
>web programming in php
>>
>>58916205
>>problem solving logic
Yes
>>programming in Java
No
>>databases
Yes
>>web programming in php
No
>>
>>58916205
>web programming in php
so it's a community college then?
>>
>>58915390
xD

(function(){
"use strict";
var rNumber = /^[0-9]*$/i, nHoursWorked = 0, nHourlyPay = 0, nGross = 0;
do {
let sInput = prompt("How many hours did you work?");
if (rNumber.test(sInput)) nHoursWorked = sInput << 0;
} while(!(nHoursWorked > 0));
do {
let sInput = prompt("How much do you get paid per hour?");
if (rNumber.test(sInput)) nHourlyPay = sInput << 0;
} while(!(nHourlyPay > 0));
nGross = nHoursWorked * nHourlyPay;
console.log("Your gross pay: ", nGross);
}())
>>
>>58916029
You can definitely overload [] and (:).
>>
>>58916219
>>58916222
I thought of the most realistic ones to get people actual software positions
>>
>>58916257
not the type constructors or patterns though mang
>>
>>58916269
Yup.
>>
Writing a custom printf for my kernel
struct pt {
int x, y;
};

void write_pt (struct pt* p) {
writef("<{d}, {d}>", p->x, p->y);
}

int pt_mag_sqr (struct pt p1, struct pt p2) {
int dx = p1.x - p2.x;
int dy = p1.y - p2.y;
return dx*dx + dy*dy;
}

void init ()
{
vga_init();

struct pt p1 = { 4, 6 };
struct pt p2 = { 7, 2 };
writef_output = vga_print;
writef("first point: {?}\n"
"second point: {?}\n"
"magnitude squared: {d}\n",
write_pt, &p1,
write_pt, &p2,
pt_mag_sqr(p1, p2));
}
>>
>>58916269
OverloadedLists and TypeOperators, bra.
>>
>>58916283
>>58916304
wrong
>>
y'all are a bunch of hand fuckers
>>
>>58916124
Delegates are ezpz, they basically just let you pass methods around as arguments. Here's an example:

public delegate bool ExampleDelegate(int requiredArgument);

public bool ExampleMethod(int value, ExampleDelegate comparer)
{
return (comparer(value));
}

public void UsingTheExample()
{
bool result = ExampleMethod(5, x => x > 0);
}}


You can now call ExampleMethod with a Lambda that takes an int and returns a boolean. This is useful if you have some code that you need to change the behavior of based on some knowledge of what the program is supposed to be doing.

Event handlers are also easy - it basically just means "when this event happens, run all the code waiting for the event". Here's an example:

public class MyClass
{
public event EventHandler MyEvent;

public MyClass()
{
// Register MyMethod as a listener
MyEvent += MyMethod;
// Raise MyEvent, causing all listeners to execute
MyEvent(null, null);
}

public void MyMethod(object source, EventArgs e)
{
// Do something when MyEvent happens
}
}


For HTML parsing, there are libraries available like HtmlAgilityPack that will do it for you, but if you have to write everything for your class then it's probably easiest to just fuck around with XMLDocument or plain old strings.
>>
Who F# masterrace?
>>
>>58916392
Nobody
>>
>>58916392
>F#
>masterrace
>>
>>58913043
Deep learning again.

Kinda sucks that keras is now in the middle of a huge API change and I'm not sure if I should use the earlier or the later version (or just use raw tensorflow)
>>
>>58913371
I guess it can be hard to tell the difference between 0 and O in book form.
>>
What's the best framework for cross platform(desktop, android, ios) development?
There's qt but don't experience with it.
There's javafx for java but I hated the api, basically can't do shit in java and if you want to change widget color you basically have to give it css class and then include css file for it... also doesn't provide api hardware like camera, gps...
There's kivy for python which has the same issue as javafx but it at least api for camera, gps...
>>
>>58916460
Qt
>>
>>58916460
>What's the best framework for cross platform(desktop, android, ios) development?
xamarin?

unity? (if you're into games)
>>
>>58916159
https://www.nsa.gov/resources/educators/centers-academic-excellence/cyber-operations/requirements.shtml
>>
>>58916518
xamarin can't deploy to linux so it's literally shit.
>>
>>58916374
Man, thx for taking the time to post the reply, really helpful. I now have an idea how to do it.
>>
>>58916579
what do you want to deplot to linux?


You can build desktop software using MonoDevelop
>>
>>58913213
>polymorphic variants
Is that equivalent to higher kinded types?
>>
>>58916631
Not even close.
>>
>>58916392
Worry not, for you are not alone
>>
>>58916289
Good luck when you get to floating point
>>
File: out.png (58KB, 656x631px) Image search: [Google]
out.png
58KB, 656x631px
>>58913551
Currently working on how to load the game data into the game. Picture shows a sketch of the structure.
Need to learn how to read data (cities, routes) from text files into C structures.

Players can choose different ways to travel from place to place.
>>
>>58913480
I want her to rub her qt anime feet in my smelly virgin dick and say how much of a disgusting pig I am.
>>
>>58916918
What did you use to draw this?
>>
>>58914158
Ruby babby BTFO.
>>
can i have lambdas in assembly?
>>
>>58917129
nyos
>>
>>58917016
Dia, it is free diagramming software.
>>
So I am trying to program something for my app and what I want to do is basically open multiple URLs and display them at once.

I dont want the whole webpages to show but only a certain part and fuse that with the other parts from different pages. Is that possible ?

Trying to do this in Java (Android) with a WebView. Selecting the appropriate HTML code via JSOUP hasnt worked out because it fucks up the formatting and all the links. So how could it be done otherwise ?
>>
>>58917246
to ellaborate what I want to do is copy tables from multiple webpages and display them in the same webview without fucking up the formatting or links.
>>
>>58917246
>>58917274
You could scrap the webpage, gather the required data, and the display that data in your app.
>>
>>58917412
yeah that's probably what I'm gonna do. was just wondering if there would be a faster way. but I guess merging different webpages is probably harder to do than just scraping the required links and building it myself.
>>
File: 1483814776306-g.jpg (8KB, 250x230px) Image search: [Google]
1483814776306-g.jpg
8KB, 250x230px
>>58913761
>William Gibson is a normie
>>
>>58917246
Do your tables have the id attribute? Could try a bunch of iframes with #table-id
>>
>>58917129
Nope
>>
>>58915154
When she applies that good succ
>>
>>58917129
>>58917180
>>58917633
and this is why functional programming is just a meme
>>
>>58918084
you can do functional programming in assembly.
>>
>>58918084
JUMP is functional
>>
>>58918084
Just because it doesn't have lambdas doesn't mean it can't implement first class functions.
>>
new thread when
>>
new thread: >>58918216
>>
>>58917129
Sure.
apply:
pop esi
xor eax, eax
lodsb
lea edi, [esi+eax]
push edi
call esi
ret

call apply
db 3
add ebx, edx
ret
Thread posts: 315
Thread images: 18


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
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.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.