[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: 316
Thread images: 38

File: haskell anime.png (368KB, 498x707px) Image search: [Google]
haskell anime.png
368KB, 498x707px
Pure Functional Programming Edition


What are you working on, /g/?


Previous Thread: >>58002845
>>
Reiterating question:

How difficult would it likely be to write a custom Desktop Environment for BSD?

And what libraries would I need to use? Assume I want to primarily write it in C++ with OpenGL.

Can it be written as standalone, so that its only interaction with the Shell would be through passed Shell commands, and it just overlays itself over everything else (so, theoretically, you could close the DE, and you're left with the CLI behind it)?

Such as, double-clicking an icon on the desktop sends cd [whatever the directory is] and receives ls -a and you know, like then prints it to the screen and stuff?

In other words, not based on the X-Window System, but purely its own application?

In general, I guess my real question is: how would I go about writing a graphical application that can handle physical screens, and that is NOT a derived piece of software, but its own program reliant on nothing but its own libraries - functionally, its own API?

How much would I need to personally fuck with drivers? Assume a driver exists for, idk... an AMD Sapphire graphics card.
So, I have the driver, I have all the standard UNIX C libraries, I have 3 monitors, OpenGL, and I have a lot of time.
Is there anything else I'd need, or is that pretty much it, just look at the return values for the GPU, and use them to define things like screen size and rotation for the DE?
>>
How do I make my own programming language and virtual machine like Python?
>>
>>58009022
Haskell is really good for writing programming languages in

Start by defining the structure of your program, expressions, declarations, syntax etc

A simple example:

data Expr = 
Var String
App Expr Expr
Abs String Expr
-- e :
-- x
-- e e
-- \x.e


data Declaration = Declare String Expr
-- x = e
>>
>>58009022
You write a program that parses entered text based on a custom syntax and does things with it.

Usually, you will write the parser in C/++.

So, in other words, you write a C/++ program that looks through the crap you input, finds where it expects things to be, returns errors if the syntax is wrong, and does other things if it's right
>>
>>58009037
Where could I learn to do this (grammar -> haskell)?
>>
>>58009037
Whoops, forgot |-s
should be
  Var String
| App Expr Expr
| Abs String Expr
>>
>>58009037
Holy fuck, someone in my Discord showed me Haskell code. It's fucking ridiculous.

What autism is required to learn this language, seriously? And, I'm a sperg, too, so I should know.
>>
>>58009047
>>58009054
https://en.wikibooks.org/wiki/Haskell
>>
>>58009017
depends on how hardcore you want to go
easiest route would be to simply use a graphics library like SFML or SDL, make a fullscreen window and then just draw on it
this requires no driver code or any other libraries besides a text library and an audio library if you want to have clicking sounds and whatnot
>>
http://godbolt.org

this is neat
>>
Python is weird. Closures are late-binding but default args are immediate.
>>
>>58009037
>>58009041

What if I want to write the VM first then put my language on top

pls link to resources explaining how stuff works in detail
>>
>>58009062
SFML and SDL would make it an Xorg client.
Anon's wants to make a non Xorg display server
>>
>>58009079
It's really easy to write an interpreter to begin with
>>
>>58009017
reposting from old thread:

I know I am going to sound like a dickhead for suggesting something else, but have a look at Wayland.

Wayland itself is just a way for a client to talk to a compositor and vice versa.

you can get really low level with it, like writing individual pixels on the screen without using anything like OpenGL

Also, your compositor (WM) will be able to support other Wayland clients
>>
File: lambda repl.png (208KB, 1723x859px) Image search: [Google]
lambda repl.png
208KB, 1723x859px
example of untyped lambda calculus in haskell
uses de brujin indices so it'd be a pain to write in
>>
File: naive lambda calculus.png (40KB, 744x536px) Image search: [Google]
naive lambda calculus.png
40KB, 744x536px
>>58009114
And here's a much much simpler one, without a REPL or parsing, and without capture avoiding semantics (it uses naive substitution).
>>
>>58009088
Go on
>>
Working on akari-bbs!

Index mode should be working now.
The old version was 3 times more verbose and randomly froze.
Next up is getting the pager to grow with the actual thread count on the current board.
>>
>>58009141
One second, I'll write an extremely simple example
>>
File: 1437006401732-0.png (379KB, 526x615px) Image search: [Google]
1437006401732-0.png
379KB, 526x615px
>He still programs
>In current year
>>
>>58009022

You might do a search for "make a lisp".

It's a github project aimed at people learning how to create interpreters.

Once you're comfortable with that, learn about how VMs work and the different models.

It's graduate level stuff, though, FYI.
>>
>>58009166
>graduate level
>third semester at my uni
huh
>>
File: stack language pt2.png (49KB, 474x706px) Image search: [Google]
stack language pt2.png
49KB, 474x706px
>>58009141
actually found this from earlier
it just does stack operations

if you look all the way at the bottom, there's a do block in the embedded language
>>
File: fp.jpg (41KB, 432x324px) Image search: [Google]
fp.jpg
41KB, 432x324px
>>58003236
Probably this file from a school project we made for Android. Its a match-three game, the GameSession_update() function is the main loop. 4 different people worked on it. Its just full of magic numbers, non-sensical decisions and general idiocy.
http://hastebin.com/awozojufaz.php
>>
>>58009176

What uni do you go to that has you designing and writing your own stack/register machines in 3rd year?

Assuming here you're not talking about simple MIX-style training VMs.
>>
>>58009192
in this case runComp would be the interpreter

obviously you'd want something much more complicated, and probably a flat structure
>>
>>58009192
H-huh? I dont understand Haskell... Last time I tried to learn language I ended up mindfucked by maths shit like categories or something

I can understand how main and the stack work tho
>>
>>58009061
Bookmarked. I may take a look, but I really don't know why anyone would WANT to write like that.
C/++ is way nicer

>>58009062
I had considered SDL, since I have some limited experience with it. But, will this work for multiple monitors automatically?
Does SDL have a way to detect how many monitors there are and define the window blitting locations based on the coordinates? Like, say, 2 monitors are above each other, and you want the screens to act as if the top one is slightly further off to the left?

I'm talking like REAL hardcore. That's kinda why I was thinking of using OpenGL.

>>58009093
I actually meant the DE to INCLUDE a custom Window Manager.

In other words, without installing KDE, Xorg, Gnome, whatever, it should do the following, as base:
>know how many monitors there are
>know what resolutions I can put on each
>blit a full-screen image to every monitor (which becomes the easy part, just drawing all the icons, taskbars, crap like that)

So... maybe I worded it wrong. What, in general would I need to do with Drivers to receive the physical characteristics of monitors to create the Screen Objects?
>Drawing it is the easy part (if extremely long). I can probably do that without an issue.

>>58009059(last thread)
Hmmm, so, can you explain exactly what it is that the programs will do?
Lemme use an example: Firefox or Chrome
Does FF or Chrome actually make calls to an existing WM or something, or does it just request screen space?
>>
>>58009208
Err, not designing, just implementing. Same goes for the language, was pretty simple but had some cool features.
>>
>>58009232
>C/++ is way nicer
This has got to be bait
>>
>>58009236 (me)
The course was mostly on formal grammars and parsing, btw
>>
>>58009232
>So... maybe I worded it wrong. What, in general would I need to do with Drivers to receive the physical characteristics of monitors to create the Screen Objects?

linux kms/drm

just so you know, your DE wont be compatible with any other applications
>>
>>58009151
Keep up the good work anon
>>
>>58009232
Hey I'm interested in learning how to do this as well but in Linux.

It seems in Linux one can create an OpenGL ES context with no dependencies on X.
>>
>>58009265
Heh...

Ok, that's a valid reason not to do it that way, then...
So, if I want to retain compatibility, I'd want to use Xorg as a basis?

Basically, take Xorg, and make my DE make calls to that, then?
>>
>>58009224
Yeah, the point is just that we define an ADT called Computation that represents our mini language.
The only parts you should care about are:
>Instruction
>runComp
>main

There's the stuff about Free and liftF, you don't need to worry about.
In fact you can rewrite it like this, without using Free
>>
>>58009232

>Does FF or Chrome actually make calls to an existing WM or something, or does it just request screen space?

Firefox doesn't interface with X directly, it uses libraries to do all that. Generally speaking, it uses GTK.

GTK has a modular structure, and uses the backend appropriate to deal with whatever windowing system it finds itself in. GDK, for instance, handles drawing.

You'd have to write your own backends for GTK to make firefox work. These backends would have to handle not only all display-related commands but also things like font handling, keyboard input, etc.

A good start there would be to look at the Wayland port of GTK. GTK was originally written for X, so the Wayland port should highlight the parts that you'd have to change to make it work with your API.

Like I said before, it's a huge task.
>>
>>58009250

Ah, yes, that makes more sense.

I was assuming the guy I was replying to wanted to design his own.
>>
>>58009311
>I'd want to use Xorg as a basis?
if you want maximum compatibility

but seriously, Wayland is much more low-level and is probably what you are looking for. It provides a way for compatibility with all clients no matter how you program your DE as long as you use the protocol correctly. It is difficult to understand how Wayland works at first however.
>>
>>58009236
But how do you design a language and a VM instruction set?

It's important to get this shit right because I don't wanna fuck it up and have to break compatibility with my own programs later.

I already understand a lot of concepts but what I don't know is whether to do a register or stack-based VM, how to design the instruction set, do I make them instructions polymorphic or not, how do I encode instructions and why, this kind of shit

I've written a toy gameboy emulator before and its essentially a VM for the system but then I had a real, already designed system to model, now I wanna come up with my own and I am paralyzed by the freedom
>>
>>58009114
>uses de brujin indices so it'd be a pain to write in
That's what polymorphic recursion is for. Capture-avoiding solution forms a monad.
data Term a
= Var a
| Lam (Term (Maybe a))
| App (Term a) (Term a)
deriving Functor

instance Monad Term where
return = Var
Var a >>= k = k a
Lam body >>= k = Lam (body >>= sequence k)
App fun arg >>= k = App (fun >>= k) (arg >>= k)


This isn't the only way to formulate it, but it's solid. You can experiment with changing abstraction to this:
Lam (Maybe (Term (Maybe a)))

which is a kind of encoding of explicit substitutions but because of laziness I'm not sure it actually makes a difference.
>>
>>58009334
>A good start there would be to look at the Wayland port of GTK. GTK was originally written for X, so the Wayland port should highlight the parts that you'd have to change to make it work with your API.

>>58009352
>if you want maximum compatibility
>but seriously, Wayland is much more low-level and is probably what you are looking for. It provides a way for compatibility with all clients no matter how you program your DE as long as you use the protocol correctly.

Hmmm, I'll look into that, then.

So, Wayland Port of GTK. I'll try to find it, and start looking at it.

Thanks
>>
>>58009363
Er, sorry, that's not right, should be:
Lam (Term (Maybe (Term a)))
>>
>>58009328
>>58009224
So if you look at the n in the instructions, that actually corresponds to a kind of continuation - the remainder of the computation to perform.
e.g.
Push x n
means
push x onto the stack, then do n
e.g.
Push x (Push y (Push z (return ())))
>push x then push y then push z then return unit (analagous to void return;)

return/pure does nothing, it just allows you to insert a regular value into your monad

In the case of Pop, you have a function that expects the item from the stack
Pop (\x -> .. do something with x)
e.g.
Pop (\x -> Pop (\y -> Push (x + y) (return ()) ))
>x = pop()
>y = pop()
>push(x + y);
>return

or in do notation

>do
>x <- pop
>y <- pop
>push (x + y)
>return ()
>>
>>58009192
>that
>extremely simple to someone who doesn't know Haskell
>>
>>58009372
Ah, this makes sense suddenly
Maybe a is a + 1
So I take it you're doing
Term (Term (Term (Term ... ) ) )
?
>>
>>58009387
I'll rewrite something better, but the only parts you should be reading are
Instruction
runComp
main
>>
>>58009374
Speaking of continuations, how the hell are they implemented? I just don't see how

Scheme's default continuations are actually bullshit and extremely hard to explain and understand, someone generalized it into delimited continuations that allows you to "mark the stack" at any point; scheme's traditional continuation being a delimited one that goes all the way to the bottom of the stack. Much easier to understand, but still no idea how to implement that shit


Also please take a look at >>58009362
>>
>>58009393
The type parameter is the set of free variables. A closed term is
forall a. Term a
or Term Empty, same thing.

In the simpler formulation you only have Term (Term a) if you map a substitution instead of binding for some reason. Like I said, it's a regular monad.

Fixpoints of functors (like free monads) are a different thing altogether.
>>
>>58009368

Honestly, man, you're biting off way more than any one person can chew. The fact that you're asking these questions tells me that you're greatly underestimating the amount of work involved.

Figure out what part of the problem interests you most, then work on that using existing software. If it's window management you're interested in, write a window manager for X. If it's low-level graphics you're interested in, learn how to work with the framebuffer console and make screensavers or something.

You know the phrase gotta learn to walk before you can run? In this case, you need to learn to build the floor first.
>>
>>58009412
He's talking about delimited continuations here, which are really just closures. You typically call the function argument of monadic bind a continuation because it's "the rest" of the computation.

Full continuations are kinda wacky.
>>
>>58009463
Not him but I want to deal with something similar: an application that runs directly on top of the Linux kernel and can somehow output graphics and sound and work with input devices. I just want to attain a simple understanding of all this stuff without all these toolkits and libraries in the middle. I want the program to be the toolkit.

Right now I know how to use Linux's system calls and libevdev but I'm kinda stumped on the audiovisual systems.
>>
>>58009463
>Honestly, man, you're biting off way more than any one person can chew. The fact that you're asking these questions tells me that you're greatly underestimating the amount of work involved.
I'm not intending this to be a thing for one person.

I'll be launching a few things, and part of the funding from them after they're up and running will be going towards a full UNIX OS development project.
I intend to have several hundred people working on this, and I'm well-prepared for it to be a few tens of GB. I would want to have a general idea before I get started, though, because I plan to at least be involved in several of the sub-phases, because I actually like to program, and want to have a bit of fun with it.

But, to be fair, maybe I don't have the /Business Rules/ well thought-out, yet...

How about this:
>If I want a system that does NOT use a system-specific API to run programs, what is the best way to go about this?
Or... maybe even...
>What is the best way to create an API that will run anything, with no specific display elements that can't be called somewhere else?
In other words:
Window* win = new Window();

to work on my machine, as well as something running Linux, BSD, Solaris, or OSX?
In other words, what is the best way to make a purely platform-/distro- agnostic display system?
If X will allow me to do that, I suppose there's no issue using it as the base and just building from there. If Wayland will allow me to do that, that'd be good to.

So, when someone calls a new window from OpenGL, SDL, SFML, Qt, whatever, I just want it to pass to the DE and create a generic "window", which is then handled by the DE, through calls to the hardware and such. When it saves, idk, game progress, it should only have to send the DE a POSIX command, which the DE passes down to the Shell.

You know?

This is why I was originally interested in the idea of NOT using X or anything.
>>
>>58009387
Ok, here
module Main where

import Control.Monad.State (modify, execState)

data Instruction = Pop | Push | Swap | Add | Count
-- the various instruction types
data MachineState = Mac Int Int [Int]
-- the first int is register0
-- the second int is register1
-- the [Int] is the stack, a list of ints
type Program = [Instruction]
-- A program is a list of instructions

execute Pop (Mac r0 r1 stack) = Mac (head stack) r1 (tail stack)
execute Push (Mac r0 r1 stack) = Mac r0 r1 (r0 : stack)
execute Swap (Mac r0 r1 stack) = Mac r1 r0 stack
execute Add (Mac r0 r1 stack) = Mac (r0 + r1) r1 stack
execute Count (Mac r0 r1 stack) = Mac (length stack) r1 stack

program = [Pop, Swap, Pop, Add, Swap, Count, Add]
-- pop a value, swap it into the second register
-- pop another value, add the two popped values
-- swap the result into the second register
-- get the number of items left in the stack
-- add it to the previous total
-- result: [x,y,...] -> x + y + (length of remaining stack)

run :: Program -> MachineState -> MachineState
run = execState . mapM_ (modify . execute)

main = print (run program (Mac 0 0 [3, 6, 8, 3, 4]))
-- 3 + 6 + (length of remaining stack - 3)
-- 12

instance Show MachineState where
show (Mac r0 r1 st) = unlines [
"Register 0\t" ++ show r0 ,
"Register 1\t" ++ show r1 ,
" Stack\t" ++ show st ]


Mostly comments and annotations.
>>
>>58009536
In this case it's extremely easy to read, too.
In fact you could literally just add
deriving (Read)
to Instruction,


then a simple call to readLn and the user can input
"[Pop, Push, Swap, Add]" and Haskell will parse it for you
>>
>>58009536
>its even worse now
>>
>>58009570
How is that worse?

Look:
data Instruction = Pop | Push | Swap | Add | Count

I assume you can understand this?
It's just an enum.

data MachineState = Mac Int Int [Int]

this is like
struct MachineState { int r0, r1; list<int> stack; }

but without names for the fields

execute Pop (Mac r0 r1 stack) = Mac (head stack) r1 (tail stack)
execute, when given the instruction "Pop", and a machine state (Mac r0 r1 stack), will return
Mac (head stack) r1 (tail stack)
Head is the head of the stack, i.e. the top item
Tail is the rest of it
>>
>>58009536
what's the fewest number of characters you can use to make an interpreter for a turing complete language?
>>
>>58009570
run = execState . mapM_ (modify . execute)
might be a bit awkward, but it's basically just this:

run (initialState, program)
state = initialState
foreach instruction in program
state = execute(instruction, state);
return state
>>
>>58009496

Can't help you with the specifics, I'm afraid. I've never messed around with Linux's audio system.

>>58009534

Ah, I misread your intentions.

What you're suggesting sounds a lot like the wxWindows project. Have you check them out? I've used wxWindows for a project, and the end result ran on both Windows and Linux machines (and should theoretically run on anything with notification icons).

You have to compile for each platform, of course, unless the application is interpreted, but it's a great cross-platform system. It might be a good starting point for your universal desktop environment.
>>
>>58009614
Ok, I'll take a look at that one. Thanks.
>>
>>58009075
I don't think they are "late binding". Just that, you need to probably store a copy of n in a new variable and then use that in the variable.
>>
File: 1467948994316.webm (366KB, 704x388px) Image search: [Google]
1467948994316.webm
366KB, 704x388px
i made a new thing using code i wrote in an older thread. scans a board and runs every post thru a sentiment analysis to find the most positive and negative posts. not super accurate of course
>>
>>58009721
So, what would happen if I wrote this:
Go suck a pile of fat dicks, you disgusting homosexual faggot bitch? LOL XD XD

How would it rate me? I'm curious
>>
>>58009736
reddit/10
>>
>>58009114
What color scheme is that?
>>
>>58009756
one dark
>>
I just set up my own php server
this is so cool
>>
>>58009736
Sentiment(polarity=-0.09999999999999998, subjectivity=0.85)


i think TextBlob is pretty bad desu, it just looks for words like "bad", "fuck", "terrible", "disgusting" etc. i dunno what a better library would be, though
>>
Can a Chrome/Chromium user in this thread copy-paste the following code in their console and give me the output? I think I found a bug in firefox and am wondering how Chrome behaves before reporting it.
let a = {x: y}
let a = {"x": "y"}
a = {"x": "y"}
console.log(a)
>>
>>58009496
Yeah, you want to look into DRM/KMS. That will give you control of the screens.
Then you can use GBM and EGL, and you can get an OpenGL (ES) context for that screen, and then you can draw shit using that.
Using libinput, you can get keyboard/mouse events.
For audio, I suppose you would just use ALSA.

Doing this all is actually pretty complicated.
I've done some of this stuff myself, for some testing code, but I only got to an OpenGL "hello triangle" on the screen, with some pretty bad flickering. I was trying to get atomic page flipping working, but never got around to finishing it.
>>
>>58009775
Heh, yeah, you'd need to look at context too.

I'm not really sure off the top of my head how you'd go about that.

But, yeah.
Although, what does subjectivity refer to in that?

I'm curious
>>
>>58009828
i can't really exactly tell. from what I can say though, it seems to just keep a database of words it deems to be more subjective, like "great" being 80% subjective (giving it a value of 0.8) or "very" only being 30% (0.3) subjective.

what's interesting is that polarity (positive to negative) is measure in 1.0 to -1.0, instead of 1.0 to 0.0 like subjectivity
>>
>>58009859
Hmmm

Interesting
>>
>>58009789
Yeah I had no idea how to do sound, I'll look into ALSA. It's the kernel interface correct?

I remember there used to be a lot of drama surrounding Linux audio, basically competition between ALSA, PulseAudio, JACK and god know what else. I have no idea what was the "conclusion" though

Doing graphics and input separately feels funny. I'm so used to having input be associated with "windows" that it's just weird to read input separately

I love this low level shit, I get to learn about all kinds of stuff that libraries usually abstract away.

This project really inspired me:

http://pelulamu.net/ibniz/

Imagine that, but interfacing with the kernel as directly as possible
>>
>>58009885
>It's the kernel interface correct?
Yes, ALSA is the actual in-kernel audio system. It also refers to the userspace library, libalsa, for using that audio system.
>I'm so used to having input be associated with "windows" that it's just weird to read input separately
Yeah, at this level, you're reading straight from the files in /dev/input.
>stuff that libraries usually abstract away
Even at this level, if you want to keep your sanity and actually get anything done, you're going to need to use a few libraries.
Some of the libraries, like libdrm are provided by the kernel itself, so if you didn't do that, you would just needlessly be calling ioctls directly yourself.
Same with ALSA.
libgbm and EGL are a part of mesa. There isn't really any way to get around this if you want hardware acceleration and anything that is even slightly portable across GPUs.
libinput is just a necessity, unless you want to enumerate and use hundreds of different peripherals yourself, and manage all of the different quirks they have.
>>
>>58009965
I'm fine with using those libraries.
>>
>>58009885

>I have no idea what was the "conclusion" though

The conclusion: Linus fucked us all.

Not trolling, I'm serious. The #1 reason why Linux audio sucks so bad is because Linus refuses to put a software mixer in the kernel.

Yes, there are security issues, but those could be addressed.

So what we've got is ALSA, which may or may not support mixing depending on your hardware, with PulseAudio on top of that (which gives so many people problems and doesn't address any of the security issues), with your desktop environment's audio system on top of that. Then JACK on the side, fighting with PulseAudio for the sound device.

There's a lot of history behind all of this (read up on why Linux dropped OSS), and some points are debatable, but Linux's audio system is basically CONFIRMED WONTFIX.

Oh, and all of that is Linux-only. If you want audio on any other UNIX, you start again at the bottom.

It sucks, but that's the reality we have.
>>
>>58010025
>The #1 reason why Linux audio sucks so bad is because Linus refuses to put a software mixer in the kernel.

Yeah that's kinda what I remember, your program would grab the sound card and if another one did the same it'd replace/override/fuck your audio

Seems perfect for my program though, which is going to have the machine all to itself anyway. I'll do mixing from within. As long as some other random process doesn't fuck me I suppose I'll be fine.

>Yes, there are security issues

What security issues?
>>
>>58010025
What about real time audio? Sounds like that's pretty important for programs like ardour. I don't think desktop pulse audio supports that shit
>>
>>58010430
Programs that need low latency audio would typically use JACK.
>>
>>58010277

The sound card is a hardware device with I/O. Any time you have a single resource and multiple users, you have security issues.

To have a system-wide software mixer, who controls the mixer? Can User A mute the sound coming from User B's application? Can User B read from the microphone from a cron job while User A is talking to his doctor/lawyer/mistress/whatever?

There's no good answer for these, and nothing from the traditional UNIX world (at least in my experience - it's been a while). There should be an answer to these, but Linux distributions sidestepped everything by adopting PulseAudio which is user-specific.

I'd like to see something that can address these issues at the kernel/libalsa level, but I don't think it'll ever happen. Filesystems solve all these problems, why can't the audio system?
>>
>>58010444
How does Apple's CoreAudio do it? Seems to be the most sophisticated API out there
>>
Why aren't programs statically recompiled on install rather than directly compile to machine code or use a vm?

Programs would be compiled to bytecode like vm languages but you don't get the performance penalty.

Id say you could get even more performance because you can optimize the code for the specific chip you're running on even if they have the same architecture.
>>
File: genetics_are_to_blame.png (139KB, 1336x743px) Image search: [Google]
genetics_are_to_blame.png
139KB, 1336x743px
>>58009006
I'm studying some dataset to support police data driven decisions
pic related
>>
>>58009114
>>58009123
And they said my Perl code is illegible.
>>
>>58010462

No idea, I'm not a Mac guy.

Note that I don't actually work with this stuff; I've just been around a long time and paid attention when all this shit was going down. I'm one of the people that had really bad issues with Pulse in the early days, and followed a lot of the mailing lists at the time.
>>
>>58010485
Nobody cares enough to do it, and any advantages would be extremely minimal.
Not to mention that it would require a massive overhaul of the compilation and linking system we have today.

If you really care about that stuff, install gentoo.
No, really.
>>
Why is GHC's output such garbage?
>>
>>58010485

Most of the time it doesn't matter enough to bother with.

In the cases where it does, oftentimes several versions of a critical function are included, and the program detects what CPU features are available and picks the function that best fits those features.

I believe ffmpeg does this, for instance - if you have SSE2, it uses one function, and if you have an AMD processor it uses another that uses AMD's instruction set, and if you don't have either it uses a generic one that uses standard x86 instructions.
>>
>>58010485
install gentoo
>>
>>58010519
How is that second one illegible?
>>
>>58010593
>>58010630
Couldn't you use LLVM IR for this?

Rather than having a compiler switch that either compiles SSE or NEON instructions, you just use LLVM intrinsics.

For example with windows coming to ARM this seems like the superior option to either writing in a vm language, distributing different binaries or just x86 emulation.
>>
Do strings ever stop becoming boring? Fuck I hate anything involving manipulating or inputting them
>>
>>58010666
Again, nobody cares enough to do this.
>>
>>58010677
It seems like you'd benefit from learning Python, or better yet, Perl.
>>
File: code.jpg (208KB, 1580x1200px) Image search: [Google]
code.jpg
208KB, 1580x1200px
Hello
who 's using i3 to dev ?
>>
>>58010677
What are your problems with strings?
>>
>>58010718
>i don't know how to screenshot on a tiling wm
>>
>>58009775

>i dunno what a better library would be, though
MAKE ONE.

>>58010485
This is literally what Android does.

>>58010718
I use a Core i7 6700HQ. Doesn't really make a difference.
>>
>>58010727
>wasting precious RAM and CPU cycles
>>
>>58010666

Dunno, I've never used it. But again, in most cases it doesn't make enough of a difference to matter.

Think about it - how many programs do you use where the CPU is the bottleneck? For most users, the only time it makes any difference at all is encoding or decoding, and those libraries are usually optimized appropriately. Damn near everything else is either a) I/O bound or b) not performance critical.

If CPU performance was as big an issue as some people seem to think it is, we wouldn't have interpreted programming languages.
>>
>>58010677

Anything that involves a fuckton of string manipulation and nothing else, I generally use Ruby for.
>>
>>58010742

You wasted more cycles in whatever driver controlled your camera.
>>
>>58010759
They weren't being used, they were on the mobile
>>
>>58010718
I wanna try it out. I'm on manjaro. How can I have an easy way to switch back and forth between my current wm and i3?
>>
>>58010770

Right, but you were using CPU cycles on your phone.
>>
>>58010677

What language are you using?

If you're using C, then yeah, that's the breaks.

If you're using C++, you might be doing things wrong. You're not using char[] arrays, are you?

If you're using Java, they're boring so that they match the rest of the language. Good god is Java boring. Look ma, two dozen new slightly different but incompatible classes to do the same thing! Weeeee, here comes the boilerplate! Let's write some lambda functions and pretend we're modern - hey, why are the LISP guys laughing at us?

If you're using Perl, then what the fuck do you want, someone to wipe your ass for you? It don't get easier than that.
>>
>>58010741
>This is literally what Android does.
Yeah, but Android uses Pajeetlang, so there can actually be a significant benefit from getting away from having to execute that shit on a VM.
"Normal" C, C++, Fortran, or whatever programs aren't going to benefit nearly as much.
>>
>>58010778
Yes, which wasn't in use
Keep up
>>
>>58010779
if you're using haskell you have to choose between
>glorious to use but horribly inefficient [Char]
>extremely efficient oh god what is with all these casts text/bytestring
>??? mythical promised library ??? dozens of string functions that are polymorphic over the type of string
>>
>>58010793

Ah, well, if I get the urge to do functional programming, I write Clojure 'til it's out of my system and then move on. Can't say I've ever had the urge to use Haskell, but I'm not a mathematician.
>>
>>58010718
i3wm + gvim

think I'll switch to an "actual" IDE at some point tho
>>
File: dijkstra.png (44KB, 643x220px) Image search: [Google]
dijkstra.png
44KB, 643x220px
>>58010805
haskell is well nice when you've learned it

there are definitely areas for improvement though
>the standard library
>non-standard extensions (that we would like standardised)
>records
>package manager (particularly dependencies)
>lack of first class patterns, type classes, modules
>no dependent types
>no way to write non-GC code

in the words of dijkstra
"not perfect but orders of magnitude better than java"
>>
How do I into lambdas?

I know the syntax but man I don't know how to use them or how to think about using them other than "hurr let's pretend it's a nested function".
>>
>>58010778
Anon he's clearly giving you more information with this picture than a screen shot. He had other things to show apparently.
>>
>>58010847

What language?

Using lambdas in something like LISP is a completely different experience than using them on something like Java or C++.
>>
>>58010677
Strings suck.
Input in general sucks.
Output too.
I wish my programs could just run infinitely and never produce output.
>>
>>58010864
Was thinking C++ (and imagine same applies to Java more or less?)
>>
>>58010871

Ah, you sound like a natural Haskell programmer.
>>
>>58010871
this guy summed it up, never done a fun string manipulation and error handling user input is cancer
>>
>>58010886

More or less. I haven't done a lot of stuff with lambdas in C++, so someone else would be better qualified to talk about them.

I've used 'em with collections. Need a custom comparator? Just pass a quick one-off lambda function that compares two objects - you don't have to add it to your class. Need a custom filter? Same thing.

I'm not sure how much more they can do in C++. My fucking school decided to switch from C++ to Java right when it was getting interesting.
>>
std::ofstream outfile(path, std::ofstream::out);
if (outfile.is_open())
{
if (outfile << items.size() << "\n")
{
for(auto item : items)
{
outfile << item->data() << "\n"
<< item->hash() << "\n";
}

outfile.close();
}
}

std::ifstream infile(path, std::ifstream::in);
if (infile.is_open())
{
std::size_t num;
if (infile >> num && num > 0)
{
items.clear();

std::string hash, data;
char newline;
while(infile >> data >> newline >> hash >> newline)
{
auto item_new = std::make_shared<Item>();
item_new->setData(data);
item_new->setHash(hash);
items.push_back(item_new);
}
}
}


Why doesn't this program enter the while loop when loading the file?
>>
>>58010861

Like his drink? Why is it relevant?
>>
File: intelligent.jpg (8KB, 221x228px) Image search: [Google]
intelligent.jpg
8KB, 221x228px
>>58009161
>tfw too intelligent to program
>>
>>58010974
I don't know.
>>
>>58010935
Yeah that makes sense, figured it'd be something like that. Guess small part of me I was hoping for it to revolutionize everything I ever did with the purity of functional programming or something
>>
>>58011026

Well, that's the nice thing about C++, you can technically do any style of programming in it, but you might have to bend over backwards sometimes.

There's some good talks about functional programming in C++ at cppcon. Search for "cppcon functional" (without quotes) on youtube. I just haven't had the time to actually try the stuff out.
>>
>>58011026
Lambda's are pretty useful in C++ as well. Here is a function that times functions, using lambdas.

//Actual Timing function
template<typename F>
auto timeF(F f) -> double{
auto start = std::chrono::steady_clock::now();
f();
auto end = std::chrono::steady_clock::now();
double toReturn = std::chrono::duration<double, std::milli>(end - start).count();
return toReturn;
}
//Called elsewhere in main to time a parallel quicksort function
double time = timeF([=](){parallelQSortHelper(i); });

//Posts functions to be ran on a threadpool using lambdas
void parallelQSortHelper(int threadCount){
ThreadPool tp(threadCount);
ThreadPool* tpPtr = &tp;
tp.post(([=](){pQSort(0, (int)v.size() - 1, tpPtr); })); //Posts the quicksort function to the threadpool
}



As you can see, using lambdas allows me to time functions that have varying parameters and well as use a generic ThreadPool class that can add functions to the pool which have varying parameters as well.
>>
>>58009781

Uncaught SyntaxError: Identifier 'a' has already been declared
>>
>>58011174
Thanks anon. No other error message?
What if you execute the code one line after the other?
>>
am I banned again
>>
>>58011298

Nope.
>>
File: senor_hansen.gif (30KB, 450x675px) Image search: [Google]
senor_hansen.gif
30KB, 450x675px
>>58011298

Quick, post some CP and you can be banned all over again.
>>
I'm starting a Data Science course at University next year and I'll have to learn Python for one of my classes. I switched from CS (after one semester and dropping a couple classes), and in CS we were forced to code in Java and it left a sour taste in my mouth. Not Java itself, more so the cunt lecturers that would give pretty much zero help.

Here's the description:
>Topics include data representation in a computer, algorithm design, submodules, Boolean expressions, selection and repetition control structures, basic Object Oriented programming design and File I/O. These will be discussed in the context of implementation in the Python programming language. The unit will also cover coding, data manipulation and visualisation in R which is a language aimed specifically at statistical computing and data mining.

Is there any tips you guys could give on getting started, some resources, things to do, some things related to Python? Want to try have some knowledge going in so I don't just get thrown into the deep end again
>>
>>58011112
Got to finish some stuff but saved the code snippet, will have a look. Sounds neat
>>
>>58011367

Python's pretty easy to pick up. If you were comfortable with Java, you'll have no trouble with Python. Even if you didn't like Java, you very well might like Python; Java has a telephone-pole sized stick up its ass compared to pretty much every other language out there.

Just look up the documentation and follow some tutorials, it's pretty easy. Unless you have a specific reason to use 2.x, try to stick with Python 3.x material.

Never worked with R, so I can't tell you anything there.
>>
>>58011415
Yeah, I think seeing as it was a Computer Science course they purposely made us use the hardest language possible to ween out all the people who weren't 110% devoted to programming (me).

Everything was pretty easy up until loops and object orientation. They're pretty hard concepts and out lecturer was VERY shit at trying to explain it and give examples - I'll google it all now though and look up the documentation, cheers

R shouldn't be too bad, hopefully
>>
>>58011415
what makes people hate Java so much? in the setting of "student learning programming"
>>
Just finished my first year of my CS degree, learning C and not really where to go from there. Any tips ?
>>
>>58011473
..sorry but, loops were hard?
>>
>>58009775
>>58009859
https://docs.microsoft.com/en-us/azure/cognitive-services/cognitive-services-text-analytics-quick-start

You're probably going to want an API hosted by IBM, Microsoft, Google, etc. that actually do fucktons of research into things like sentiment analysis.

Azure's pretty easy to work with, and it's free up to a certain # of requests per month for testing.

AWS and IBM Bluemix would be the other options if you wanted something legit.
>>
What's a good book on Algorithms that does NOT contain a metric fuckton of Math?
I want sometthing hat isn't esoteric as hell.
>>
>>58011473

Java's not the hardest language possible by a long shot, it's just annoying.

>>58011487

Java is overly verbose ("My god! It's full of boilerplate!"), has an overly bloated standard library, and insists that everything be object-oriented.

Don't get me wrong, object oriented programming has a lot of uses, but languages like C++ get it right; they don't insist you use it for things where it's not useful. A beginner learning C++ doesn't even see the word "class" until they've already mastered the basics, while in Java you have to instantiate multiple objects just to do basic I/O.

Python's like C++ in that regard, but even simpler for beginners (given they have a decent editor so they don't get indentation levels confused). I don't like Python personally, but I'd much rather see that used as an introduction to programming than Java.

Hell, I'd rather see Visual Fucking Basic used rather than Java.
>>
>>58011488

Pick up a scripting language. Python might be a good choice. Or you could try some Javascript.

Avoid the more esoteric languages until you have two or three procedural languages under your belt. Otherwise, you'll wind up with a PhD and wonder what happened.
>>
>>58011631
yeah i've been thinkin bout picking up python since it seems like everyone knows it. Other than that i was thinking about picking up sql.
>>
>>58011578
Scanner object, printing and public static void main, other than that what's so verbose? It's just a handful of things you have to learn without understanding as you start, and that doesn't take long at all. Also the Java API is very easy to use, unlike C++ for example.
>>
File: 1467667985686.jpg (165KB, 761x800px) Image search: [Google]
1467667985686.jpg
165KB, 761x800px
What's a good book for low level programming knowledge?
I've been programming in C/C++ for several years now, but I'm worried that if I go to a job interview for a programming gig my low level knowledge about the computer implementation side isn't up to scratch. Stuff like floating point precision, stack management for objects/function calls, etc sometimes doesn't quite click.
>>
>>58011507
>algorithms
>not a fuckton of math

What exactly are you looking for?

Can you give me an example or two of an algorithm that would be representative of a book like this?
>>
>>58011499
It's not that they were hard, it's just that I'd all but given up on most of the CS based classes at that point so I had no motivation to go past the shit lectures and sus it out myself
>>
>>58011678

SQL isn't really meant to be used standalone. It has to go with something else.

You can use SQL with C, but you'd be better off with something like PHP or Python.
>>
>>58011748
okay. either way i'd recommend seeing it as a good thing and learning to google
not trying to be a dick, but learning to find and understand new programming concepts on your own is essential to programming, and the internet is full of resources to help you do so
>>
>>58011678
>Other than that i was thinking about picking up sql.
Do this.

Every programmer should know basic SQL.
>>
>>58011780
Yeah of course, I get that completely. It's just I had no motivation to even teach myself because I'd made up my mind that I'm going to drop the course anyway.

Much more keen on the new course though so I'll be googling left and right
>>
>>58011741
I mean something that explains the algorithms mostly using logic and pseudocode (or regular code is fine), and the math used is essentially an additional explanation, but not making the reader RELY on the math to understand how it works?
A practical guide, where any related math is in the text boxes for 'extra info'
>>
>>58011837
It sounds like you don't want to study algorithms; you just want to learn how to take problems and express them in code.

Literally any beginner's programming book will help you start to visualize this. Pick one in the language you're learning.
>>
>>58011821
fair, anyhow not sure where you are now but if you aren't familiar with recursion and only know OO conceptually starting to code with both would be a good idea

neither is hard when it clicks but it takes a while for a lot to have 'em click. recursion moreso, it goes from "what the fuck" to not that bad very quick
>>
Might be a little off-topic, but I guess people here know most about programming.

So, I've graduated uni in engineering and learnt C,C++ and Java. Now I would like to learn python. I've made some small stuff in python before, but never without trouble and googling. So can you recommend me a good book on Python 3 that covers pythonic ways of doing stuff?

>tl;dr Can program, want a book on pythonic ways in Python 3
>>
>>58011687

I wouldn't recommend C++ as a beginner language either, but I'd use it over Java. You'd want to use a modern book, though. Pre-C++11 stuff was pretty horrendous. I like to say that modern C++ is a beautiful, small, concise language buried under a pile of outdated shit.

Java's problem is its ideology. The "everything is OO" idea leads to ridiculous code. Comparator classes? Really? And since everything has to be a class (or in a class), you get lots and lots of boilerplate.

The Java API is bloated. How many different string classes are there in Java? How many different I/O classes?

Java 8 is an improvement with streams, but before that it was intolerable.

Granted, a lot of this is personal opinion, but I'm not the only one that feels this way.
>>
File: 1480548437602.jpg (666KB, 840x960px) Image search: [Google]
1480548437602.jpg
666KB, 840x960px
>>58011860
>two lines
>tl;dr
>>
>>58011903
>Java 8 is an improvement with streams, but before that it was intolerable.
I has to use Java for some university assignments before, and I decided to use the "modern" shit just for the sake of it.
However, Java's stream API is the most half-baked shit I've ever seen in a programming language trying to be taken seriously. It's incredibly lacking in the shit you want to do, and just makes you wish you were using a better language.
>>
>>58011860
>Phyton 3
stopped reading there
>>
>>58010444
>letting other people use your computer
>>
File: Theorem1.png (37KB, 508x458px) Image search: [Google]
Theorem1.png
37KB, 508x458px
>>58011856
Ok, let me put it another way.

I've taken a number of programming classes, read or am reading a number of programming books, taken Data Structures and Algorithms (which was somewhat difficult, but mostly it explained everything clearly), and will be taking Software Engineering next semester.

BUT, classes like Discrete Math are EXTREMELY difficult.
For example, are there any books that would say:
Based on the number of elements you will be (sorting or something), such and such an algorithm will require at least this many operations, and this is why...
Therefore, you should use this type of algorithm instead.

INSTEAD of throwing a bunch of formulas at me that are about the 6th+ level of abstraction away from the verbal explanation.

For example, NOT this (as I'm reading stuff from Discrete right now)
>pic related

So, you know, a book that can explain that in human-readable language. Something like English, consisting mostly of verbs, nouns, and such.
I have absolutely no idea how to interpret this textbox at all, and none of the examples are any clearer
>>
>>58011903
>it's opinion
Yeah of course, what I was asking for.

Disagree on C++ for beginners, or I'm at least very glad I learned Java and Python before starting C++. Think C++ would be overwhelming, doable, but overwhelming.

Not disagreeing on bloat, but eh, you find a way that works and stick with it for the most part. There may be a bunch of string classes but how many do you have to use learning beginner programming?

Just don't think it's that bad. That said I started in Python, maybe forcing OO fucks with you more if you have never seen anything else
>>
>>58011935

True, but it's better than shitloads of for loops.

>>58011964

You realize UNIX is a multiuser operating system, right? Straight out of the minicomputer world?
>>
>>58011906
Looked more on my tablet.

>>58011944
Python2.7? I don't care too much, I just wanna read an informative book.
>>
>>58011989

Bear in mind I mostly do Lisp, C++, and C these days, and only do Java for school. C and C++ make me hate the forced OO in Java, and Lisp makes me hate how "stiff" Java feels.

Plus my school just switched from C++ to Java for their data structures and "advanced programming" courses, which just seems ridiculous to me. Call me old fashioned, but data structures and algorithms should be taught in C.
>>
>>58012076
Yeah, my DS&A class was in Java, too.

I actually had to learn Java AS I took the class.
I do NOT like Java. I mean, I don't absolutely hate it, but it's so fucking annoying.
C and C++ are so much nicer.

Never used Lisp, though
>>
How does one implement functions with closure in Haskell?

Implementing Lisp in Haskell and having huge difficulties implementing functions.
>>
>>58012076
I'm not even a programmer (maths major) so programming experience is more limited, get your points even if I don't agree with all of them, thanks for the perspective though.
>>
>>58012145
I'm no Haskell expert, but I guess you mean like this:
add :: Int -> Int -> Int
add x = (\y -> x + y)

add_one :: Int -> Int
add_one = add 1

main :: IO()
main = putStrLn $ show $ add_one 2

But considering Haskell doesn't really have state to have closure over, I don't see how this would that helpful.
>>
File: hadescoffeecup.jpg (321KB, 792x825px) Image search: [Google]
hadescoffeecup.jpg
321KB, 792x825px
>>58009006

Want to hack brogue 1.7.4 to turn on the debug mode, but have trouble in programming the source code. That's what I currently am planning to do.

Coding and compiling crap is pretty hard, since brogue can't be scripted easily to compile it. I'd pretty much would want to make a debug mode to open access to the items early in the rogue.h file in codeblocks.
>>
>>58012194
No I have

type Env =  [(String,  Expr)]

data Expr = LSymbol String
| LNum Int
| LBool Bool
| LString String
| List [Expr]
| LAtom String
| Nil
| LFunction Expr Expr Env
deriving (Show, Eq)

prepareFun :: Env -> Expr -> (Expr, Env)
prepareFun e (List [LAtom f, List p]) = eval e'' b
where fun = getVar f e
p' = funParam fun
e' = funEnv fun
e'' = bindParameters e' p' p
b = funBody fun
[\code]

Basically a function is "(function f (x y) (+ x y))"

where f is the function name, x y are the parameters and x+y is the body.

an LFunction is a function with [Expr] parameters, [expr] body and an environment (hashmap that stores string-> expression)

Say I'm calling
 (f (1 2))[\code]. 
I then evaluate the take the parameters of the function declaration, store (x -> 1, y -> 2) then evaluate the body in the environment where x->1 and y->2.

It's not working properly though.
>>
>>58012237
Well, I managed to fuck that post up pretty badly.
>>
>>58012248
>backslash
>>
>>58010847
Monads are a good use case for lambdas
>>
>>58012237
I dunno about this Env stuff, but you can always just do regular substitution

But don't forget capture avoidance

[x := t] \a.e
(substitute x for t in \a.e)

a must not be in the free variables of t
>>
Can you write a kernel in a pure functional way?
>>
>>58012364
no
>>
>>58012187

No problem. I like talking to people that aren't trying to act like edgy teenagers... which makes me wonder why I come here.

I got lots of respect for math majors. I wish I could take a math minor, but all my classes are remote and they don't offer math classes remotely.
>>
>>58012387
why not?
>>
>>58011631
>Otherwise, you'll wind up with a PhD and wonder what happened.
Elaborate.
>>
>>58012538

It's a joke. Basically, I'm insinuating that early exposure to languages like Lisp and Haskell will cause you to become an academic.
>>
>>58012465

Not the guy you were talking to, but at the kernel level you're dealing with all kinds of mutable state. You're working with bare, untyped memory addresses, CPU registers, and I/O devices on the one side, and from the other side you're dealing with userland and everything that's going on there. There's interrupts - hardware and software - from both sides, as well as from other parts of the kernel code.

I'm not an expert on functional languages, but my best guess is that implementing all that in a pure functional language would likely be impossible.

Take a look at the languages typically used in kernel development sometime.
>>
https://www.jetbrains.com/go/

they did it again...
>>
>>58012671
the main problem is explicit memory de-allocation
>>
>>58009166
It's really not graduate level. Especially making a LISP interpreter.
>>
>>58012597
Dunno, I feel like Lisp is more useful than Haskell.
With Lisp you can write Emacs extensions.
With Haskell you can professionally fizzbuzz on /g/.
Though that's the matter of priorities, maybe one likes professional fizzbuzzing more.
>>
>>58012733

I was referring to designing your own language with a non-toy VM.

Implementing a basic LISP, no, that wouldn't be.
>>
>>58012738

I'm not saying they're not useful, just that they'll lead you down the path of academics rather than production. And I'm saying it jokingly. I'm rather fond of elisp and Scheme myself.
>>
>>58012832
Actually whatsapp was done in haskell, Facebook spam filters also use haskell.
>>
>>58009006
I'm writing a self-healing microkernel in PHP.
>>
>>58012895

OK. I used to write text adventure games in BASIC. I'm not sure what your point here is.
>>
>>58012917
You said haskell is more academia and less software development. I just listed two huge examples that show haskell can get you a job in SD pretty easily.
>>
File: IMG_3096.jpg (1MB, 3000x2000px) Image search: [Google]
IMG_3096.jpg
1MB, 3000x2000px
building a remote for my canon eos 700d.
>>
>>58012895
>whatsapp was done in haskell
That was Erlang
>>
>>58012946
>I just listed two huge examples that show haskell can get you a job in SD pretty easily.
No you didn't.

How are two examples of Haskell *ever* being used anywhere in industry proof that you can "easily" get a job in the industry with haskell?
>>
>>58012967
https://wiki.haskell.org/Haskell_in_industry
Yeah good bait, made me reply.
>>
>>58012946
>I just listed two huge examples that show haskell can get you a job in SD pretty easily.
Yes, because any given person has more than a minuscule chance of working at either of those two (2) companies you've named. Bonus points for the fact that Haskell is only a small component of Facebook's service, and the rest of their stack is in more commonly found languages.
>>
>>58012946

I said that early exposure to the more esoteric programming languages (and later used Haskell and LISP as examples) would lead you into academia.

It has nothing to do with the actual languages. It has to do with how it makes you think about programming languages in general, and that it would make academia more attractive than the industry.

And I stated - more than once - that it was a joke.

Yeesh, you must be a fun one at parties.
>>
>>58013002
My point is still correct you retard.
>>
>>58009006
>functional programming edition
>anime
Why am I not surprised?
>>
>>58013084

I dunno, because you're on 4chan, where there's anime everywhere?

At least she's clothed and not getting ravished by a furry in a dragon suit.
>>
>>58010827
I don't think you could feasibly add dependent types to Haskell at this point. It would be a completely different language.
>>
>>58013144
there's a plan to do it
it's obviously gonna be messy, but i guess the point is it's better than not having it
>>
>>58013208
Oh cool, I'd like to see it. It would take a hell of a lot of work, though.

The thing that really gets me is the laziness, but again, it would be a completely different language.

From your list, I'd suggest using 'stack'. I use it for pretty much everything now.
>>
>>58010827
>April 2001: Dijkstra complains about Java
>September 2001: Pakistan-supported terrorists fly planes into WTC

Coincidence? I don't think so.
>>
>>58013517
>Pakinstan
Keep believing, good goy.
>>
File: requests.png (151KB, 1026x1334px) Image search: [Google]
requests.png
151KB, 1026x1334px
Hey guys, I'm having problems making a Java scraper for phonevalidator.com.

Whenever I try to completely mimic the request I make one the actual website and all of its parameters, I don't get the same response.

It should be a 302 response that redirects me to the results page, but I get a 200 that just fetches the home page. Even when I try to resend the request in the network view, I get the exact same result.

I'm using HttpURLConnection.

Does anyone know what the problem might be?
>>
>>58010659
Being illegible, or at least having extremely ugly syntax seems to be a common thing for most, if not all functional languages.
>>
File: quite a ruff victory.jpg (46KB, 653x510px) Image search: [Google]
quite a ruff victory.jpg
46KB, 653x510px
God, this entire fucking thread is just one big meme.

By the way? Dogs > shitpaws.
>>
>>58013544
SessionID? Referer?
>>
>>58010697
>Perl
>in 2016
No.

Out of those two, go with Python.
It's great for scripts.
>>
>>58013613
>le meme
>le returning from le reddit once again
>>
>>58013631

This is what I use in the code, exactly the same as in the original request:

String headers = "Host: www.phonevalidator.com\n" +
"User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0\n" +
"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\n" +
"Accept-Language: en-GB,en;q=0.5\n" +
"Accept-Encoding: gzip, deflate\n" +
"Referer: http://www.phonevalidator.com/\n" +
"Cookie: ASP.NET_SessionId=ziq5khpgbukiwztyo3ndqzuz\n" +
"Connection: keep-alive\n" +
"Upgrade-Insecure-Requests: 1\n" +
"Content-Type: application/x-www-form-urlencoded\n";


The request body is also the same.
>>
>>58013676
Off yourself, memelord.
>>
what sites/services do you use to find programming jobs or simple one-off contracts?
>>
If I must make an application graphical interface that is portable between different desktop environments (I will ignore windows and only consider *nix) what choices do I have?
>>
>>58013904
make a gtk and a qt version
>>
What is the maximum amount of visual studios did you ever have open at once?
>>
>>58013924
that's what I wanted to avoid, I hoped of writing code only once.
>>
File: ifk3.png (19KB, 489x210px) Image search: [Google]
ifk3.png
19KB, 489x210px
Am I insane or is + not working?
>>
There should be no problem with this right?
    u16 size_struct = sizeof(some_struct) * struct_count;
u16 size_struct2 = sizeof(some_struct2) * struct2_count;
char *tmp = malloc(size_struct + size_struct2);
some_struct *p0 = tmp;
some_struct2 p1 = (some_struct2*)(tmp + size_struct);
>>
File: ifk4.png (34KB, 753x384px) Image search: [Google]
ifk4.png
34KB, 753x384px
>>58013975
>>
>>58013959
Four, as far as I know.

My scratchpad console app, a simple website, a massive website, and a GUI tool I was half-ass devving in my spare time.
>>
>>58013988
Impossible to tell, you're writing unsafe code.
>>
>>58014050
have you tried compiling with -O0?
>>
File: asfasfd.png (5KB, 617x109px) Image search: [Google]
asfasfd.png
5KB, 617x109px
Please help. How do I subtract decimals here. This doesn't do anything. If I change the value to 1 or another integer it works. Timer is defined as a decimal
>>
>>58014151
no what does this do?
>>
>>58013904
You could use Electron. But deployment can be a bitch, and the size of your executable will be huge. Worth it for a relatively big app, but not so much if you're doing something tiny.
>>
>>58014172
turns optimizations off
>>
>>58013975
What's your colorscheme? Do want.
>>
>>58014194
didn't do it, thanks anyhow bet i can use that at some point
>>
>>58014197
base-16 ocean
>>
>>58013785
Stackoverflow
>>
File: tiobe.png (122KB, 936x442px) Image search: [Google]
tiobe.png
122KB, 936x442px
is-

is C alright?

what happened at the end of 2015?
>>
>>58014292
They decided to rewrite the code in assembly (notice the assembly surge in 2015)
>>
>>58014307
Who did? Also the assembly spike is tiny compared to the C fall.

C has been hovering between 15-20% for the past 15 years and now it fell like a lead balloon to below 9% in twelve months with no stop in sight.
>>
>>58014292
>Rustchi (凌迟; 凌遲; rustchí; rust-ch'ih, alternately transliterated Rust chi or Rust t'che), translated variously as death by a thousand meme languages (杀千刀/千刀万剐; 殺千刀/千刀萬剮; shā qiān dāo/qiāndāo wànguǎ), the slow process, the lingering death, or slow slicing, was a form of torture and execution used in China
>>
>>58014292
Tiobe is a waste of your time, depending on what you're actually trying to find out.
>>
File: 1480801459935.jpg (685KB, 2335x2507px) Image search: [Google]
1480801459935.jpg
685KB, 2335x2507px
>tfw you're too dumb to program
I'm glad I chose network technology, I'm barely going to pass programming classes.
>>
>>58013975
Where are x and y defined.

Also, it's a terrible idea to return a vector.
>>
File: 1465958963167.gif (2MB, 245x276px) Image search: [Google]
1465958963167.gif
2MB, 245x276px
>>58014400
>Take programming
>Fuck this is hard
>Transfer to networking
>Wow this is a lot easier and I'm not writing programs for 3+ hours a night
>graduate
>Now making $31/h, significantly more than my programming friends
>>
>>58014436
At least I'm not an useless fat fuck.
>>
>>58014408
class variables, followed y throughout that function and it's constant at 1

apparently vector<T>.push_back is incrementing targety

which is impossible, so I suspect some weirdass memory corruption case?
>>
File: anal beads.png (7KB, 203x196px) Image search: [Google]
anal beads.png
7KB, 203x196px
Haskell :(
>>
File: 1470961144663.jpg (334KB, 1200x839px) Image search: [Google]
1470961144663.jpg
334KB, 1200x839px
>>58014162
Please, I feel like this should be very simple but I can't get this to work. I mean I guess I could change my time format to minutes or something but that looks lame
>>
http://codepen.io/anon/pen/QGJZMO?1111

anyone have time to finish this?
>>
>>58014500
>javascript '''''''developer'''''''
What could this job possible involve?
>>
>>58014162
>>58014506
What DBMS, slut?
>>
>>58014540
Developing components of an application using the Javascript language.
>>
is there an easy way in python to create a tree directory like this?
 ── compiler/
│ └── contents/
│ ├── README.md
│ ├── doc.txt
│ ├── another.txt
│ ├── abc.txt
│ └── Resources/
│ └── en.lproj
>>
File: 1481793841715.jpg (7KB, 250x228px) Image search: [Google]
1481793841715.jpg
7KB, 250x228px
>>58014556
''''''''''''''Developing components''''''''''''''
''''''''''''''Javascript''''''' '''''''''''''''''''''Language''''''''''''''''''''''''''''
>>
>>58014574
Yeah, it's not much code at all.
>>
Any pascal user here?
>>
>>58014544
MySQL, writing in Python
>>
>>58014587
I learned Pascal a couple of years ago
>>
>>58014481
Just to confirm: this is single-threaded, right?
>>
Is Go worth learning? What is it good for?
>>
>>58014481
Can I see your entire class?
>>
>>58014610
Yeah
>>
>>58014349
Indian population raised a lot in those 20 years, see the growth rate of java.
>>
>>58014597
Run this, please:
SELECT DATA_TYPE 
FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_name = 'PLAYER'
>>
>>58014587
Sure, I don't ONLY use Pascal but I know and like it.
>>
>>58014641
But Java also declined during that period, if less dramatically.
>>
>>58014664
>Pascal
>The same as Ada, except when you pull the trigger a little sign pops out reading "BANG!".
>>
File: chpc.png (145KB, 899x924px) Image search: [Google]
chpc.png
145KB, 899x924px
>>58014627
it inherits from this and just overrides some functs
>>
>>58014675
You must see the effective number of people using it. I mean, 20% of 1000 is less than 10% of 10000.
>>
>current_year := 1983 + 33;
>pascal
>>
>>58014704
I'm learning it in turbo pascal with borland compiler on xp virtual machine
>>
>>58014597
>>58014648
er

disregard that, I suck cocks

Run
EXPLAIN databasename.PLAYER


Even if it's a DECIMAL type, you might have no precision.
>>
>>58014712
Where are you from?
>>
>>58014723
Slovenia
>>
>>58014704
Could be worse, if you believe TIOBE, Visual Basic is the new hot thing...
>>
>>58014723
Italy motherland, I have 2Mb adsl
>>
>>58014712
I learned it in Turbo Pascal on a Windows machine but it was 1992.
>>
>>58014677
I also use Ada. What I like comparatively about Pascal is its simplicity. Otherwise I tend find Ada to be a much better Pascal++ than Delphi/Object Pascal.
>>
>>58014683
And where do you call Pawn::nonCapturingMoves?
>>
>>58014704
In my country Pascal is used in pretty much every university that has I.T courses to teach basic programming logic, but I've never heard of anyone who actually works with it
>>
>>58014741
Ada is just so fucking verbose though
And the GPS IDE is such a flaming piece of shit holly fuck
>>
>>58014725
Do you visit /int/?
>>
>>58014725
do you do push-ups as punishment if the compiler finds an error?
>>
File: download.jpg (16KB, 314x160px) Image search: [Google]
download.jpg
16KB, 314x160px
Was anyone used Intel TBB?
>>
>>58014765
sometimes. i'm not from Slovenia thought.
i just said that because reasons
>>
>>58009588
2 ofc.
>>
>>58014772
why would you do that when go exists?
>>
>>58014704
That's not portable, _ isn't allowed in ISO Standard Pascal identifiers
>>
>>58014772
*Has.

>>58014784
Because I want performance and don't want a >garbage-collector.
>>
>>58014749
Oh boy here we go
>call Board::validMove(x, y, to_x, to_y) in main()
>calls Pawn::validMove(to_x, to_y)
>calls Pawn::nonCapturingMove(to_x, to_y)
>>
>>58014818
apparently it's not memory leak related
because i just fixed all
>>
Why did Google of all companies decide "Go" was a good name for a language?

Searching for a common word like that is problematic as hell.
>>
>>58014876
That's why you use "golang"
>>
>>58014818
>calls Pawn::nonCapturingMove(to_x, to_y)

You are running a different function in GDB. >>58014050 shows Pawn::nonCapturingMoves(), which has an s at the end and does not accept any parameters (other than pointer to object).
>>
>>58014876
At least they didn't call it D.
>>
>>58014886
I would, but my search-space (posts, SO issues...) doesn't.

>>58014911
A single letter that isn't a commonly used word is much easier to search for.
>>
File: sdfdsf.png (1KB, 205x19px) Image search: [Google]
sdfdsf.png
1KB, 205x19px
>>58014720
Oh man I'm dumb, I hadn't defined the M, D. It works now, thanks
>>
>>58014292
Please note that Tiobe is literally gauged on how many LINES OF CODE are written in a language.

This is why C and Java dominate: they're verbose.
>>
>>58015013
>Please note that Tiobe is literally gauged on how many LINES OF CODE are written in a language.
It's not, it's based on search engine results. Which is still a terrible metric.
>>
I'm new to C++ and programming in general and am currently getting some compiler errors regarding redefinition of "gauge" and "<< illegal for class". Can someone help me out?
My task is to make a speed gauge which counts the mean of the last 5 speeds and stops the program once the speed goes below 0.
int main()
{
int gauge = 0;
int speed1 = 0;
int speed2 = 0;
int speed3 = 0;
int speed4 = 0;
int speed5 = 0;
int sum = (speed1 + speed2 + speed3 + speed4 + speed5);
int gauge = (sum / 5);

while (gauge >= 0)
{
for (int i = 0; i = 5; i++)
{
cout << "Give speed : ";
cin >> speed5;
cout << "Speed = " << gauge << endl;
cout << "Give speed : ";
cin >> speed4;
cout << "Speed = " << gauge << endl;
cout << "Give speed : ";
cin >> speed3;
cout << "Speed = " << gauge << endl;
cout << "Give speed : ";
cin >> speed2;
cout << "Speed = " << gauge << endl;
cout << "Give speed : ";
cin >> speed1;

return speed1, speed2, speed3, speed4, speed5;
}
}
return 0;
}
>>
>>58015013
>Please note that Tiobe is literally gauged on how many LINES OF CODE are written in a language.
While TIOBE is certainly shit, you are also a moron if you believe this.
>>
File: bt.png (30KB, 922x145px) Image search: [Google]
bt.png
30KB, 922x145px
>>58014890
my bad
>>
File: FinderIconX.png (39KB, 270x270px) Image search: [Google]
FinderIconX.png
39KB, 270x270px
I've recently started developing for OS X. There's not many modern resources out there, as the platform is pretty dead as far as 3rd party goes.

I know anything Mac/Apple is an easy target here, but be honest with me: is developing a (non-trivial) desktop application a waste of time nowadays?
>>
File: burger.png (11KB, 939x53px) Image search: [Google]
burger.png
11KB, 939x53px
>>58015013
>>
>>58015049
Okay, now how do you instantiate the objects?
>>
>>58015052
>is developing a (non-trivial) desktop application a waste of time nowadays?

That depends on your users.

Many enterprise LOB applications have a desktop and a web component.

Anything web-based will be much more accessible, but I also wouldn't want anything web-based to do file management on a client machine.
>>
>>58015042
>int main()
>{
> int gauge = 0;

You declared gauge here.

> int speed1 = 0;
> int speed2 = 0;
> int speed3 = 0;
> int speed4 = 0;
> int speed5 = 0;
> int sum = (speed1 + speed2 + speed3 + speed4 + speed5);
> int gauge = (sum / 5);

You declared gauge again here.

> while (gauge >= 0)
> {
> for (int i = 0; i = 5; i++)

What are you trying to do here? "i = 5" assigns the value of 5 to the variable i, it doesn't test for equality (that would be "i == 5").

> {
> cout << "Give speed : ";
> cin >> speed5;
> cout << "Speed = " << gauge << endl;
> cout << "Give speed : ";
> cin >> speed4;
> cout << "Speed = " << gauge << endl;
> cout << "Give speed : ";
> cin >> speed3;
> cout << "Speed = " << gauge << endl;
> cout << "Give speed : ";
> cin >> speed2;
> cout << "Speed = " << gauge << endl;
> cout << "Give speed : ";
> cin >> speed1;
>
> return speed1, speed2, speed3, speed4, speed5;

WTF are you hoping to do here? You can't return multiple values like that.

> }
> }
> return 0;
>}
>>
>>58015040
http://www.tiobe.com/tiobe-index/
>It is important to note that the TIOBE index is not about the best programming language or the language in which most lines of code have been written.
>>
File: instant.png (54KB, 718x511px) Image search: [Google]
instant.png
54KB, 718x511px
>>58015082
chessboard is just an object, all the pieces (like pawn) is instantiated in overloading << operator
>>
New thread:

>>58015111
>>58015111
>>58015111
>>
>>58015042
>int gauge = (sum / 5)

You are redefining gauge. In C++, syntax like
type name
or
type name = ...
are variable declaration. To set the value of a previously defined variable, just use
gauge = ...
.
>>
>>58015133
Are you responding to the correct person?
>>
>>58015042
>which counts the mean of the last 5 speeds and stops the program once the speed goes below 0.

Since this is presumably supposed to continue indefinitely, you probably want to store values in a ring buffer.

Something like:

const int RING_BUFFER_SIZE = 5;
int speedValues[RING_BUFFER_SIZE] = {0};
int head = 0, count = 0;

while (meanSpeed >= 0)
{
int nextSpeed;
cout << "Next speed? ";
cin >> nextSpeed;

if (count == RING_BUFFER_SIZE)
{
// Ring buffer is full. Overwrite the oldest value and increment the head.
}
else
{
// Ring buffer isn't full yet, Add the new value and increment the count.
}

// Average the last 'count' values.
}
>>
>>58015148
Yes. But this guy didn't: >>58015063

Were you trying to respond to him?
Thread posts: 316
Thread images: 38


[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.