[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: 332
Thread images: 21

File: nichis.jpg (131KB, 1280x720px) Image search: [Google]
nichis.jpg
131KB, 1280x720px
What are you working on, /g/?
Previous thread: >>61477059
>>
Real thread: >>61484433
>>
>>61484482
Thanks for anime picture!
Also, first for Ruby, the /comfiest/ language around!
>>
>If you honestly think using a dedicated new natural number you invented out of thin air to mean "nothing"

No, thats just your interpretation of what you can do with it you brainlet. You could do the same maybe type in idris as well
>>
reboastan from last bread:

just switched from guile 2.0.12 to guile 2.2.2
what am I in for lads

where are my scheme nibbas at
>>
File: thinking_scratch.gif (172KB, 500x506px) Image search: [Google]
thinking_scratch.gif
172KB, 500x506px
>>61484482
I'm working on creating a webscraper which will automatically fill out forms for me.
Does anyone have any good resources to do such a thing?
>>
>picture with nothing related to programming on it
I'm sorry, but the other thread is the real one. Sage, hide and report this shit.

>>61484433
>>61484433

>>61484433
>>61484433

>>61484433
>>61484433
>>
>>61484514
>You could do the same maybe type in idris as well
Yes and that's exactly why having the ability to just put define new locations along a number line in addition to this facility is not only disgusting but to make matters worse redundant.
By the way, this is only a problem for numbers. There's nothing wrong with being able to define new and never-before-seen values of the Type type, and in fact that's incredibly useful.
>>
>>61484535
Fuck off, nobody is going to your shitty thread.
>>
File: face_disgust.jpg (23KB, 480x720px) Image search: [Google]
face_disgust.jpg
23KB, 480x720px
Writing a library in Python to parse and manipulate Avid ALE files I receive from feature film editorial.

It has been working pretty well, but I actually have a dumb question about this:

I parse the text files I receive from clients line-by-line. Current code snippet is this:

with open(fullpath, "rU") as ale_file:
for line_count, line_text in enumerate(ale_file):


However, I need to be able to accommodate any line endings (CRLF, LF, CR). As you can see, I've been opening the files with "rU" mode for Universal line ending support, which has worked SOMEWHAT, but not 100% (particularly with Mac classic CR endings).

In researching this and trying to make it better, I've found that "rU" mode is deprecated. The recommendation has been to open as binary ("r+b") instead, but when I do that, I have LESS support for varied line endings.

Any idea what the most up to date pythonic way is to be able to handle any line endings you throw at it properly?
>>
>>61484539
>you shouldnt be able to do more things
>you should be restricted in a language and paradigm built for expression and type manipulation.
You haskultists are a fucking plague.
>>
>If you honestly think using a dedicated new natural number you invented out of thin air to mean "nothing"

No, thats just your interpretation of what you can do with it you brainlet. You could do the same maybe type in idris as well
>>
>>61484578
>>you shouldnt be able to do more things
>using the meme arrow to imply i am wrong about this fact
go play with your c++
>>
>>61484592
see: >>61484539
>>
>the autist is copying the posts in here to the other bread
kek
>>
File: aya.png (783KB, 1280x720px) Image search: [Google]
aya.png
783KB, 1280x720px
I want to learn a functional programming language. Which one should I learn? I heard Haskell and Idris are good.
>>
>>61484625
Autists*
The posts are too close in between.
>>
>>61484578
Roses are red.
Violets are blue.
New numbers are cancer.
Here, have a (You).
>>
>>61484634
>I heard Haskell and Idris are good.
kek
>>
>other bread got nuked
kek
>>
>>61484655
my brain is too small
the power of new types
i will never get
>>
File: AAAAHHHAHAHAHAHAHAHAHA.gif (220KB, 320x238px) Image search: [Google]
AAAAHHHAHAHAHAHAHAHAHA.gif
220KB, 320x238px
>>61484497
>>61484535
>>61484625
>404
>>
>>61484634
C is a functional language but it's the shittiest functional language imaginable.
>imperative
>no type safety
>no ADTs
>no pattern based overloading
>not even any overloading at all
That being said, it's very standard, very simple, and very fast.
So you should probably learn it.
>>
>>61484672
>nuked
What do you expect from a muslim thread?
>>
>>61484680
>>61484634
Maybe I should preface it with purely functional programming language.
>>
>>61484681
what did you think I was keking about anon
>>
>>61484673
We're not talking about new types, we're talking about new values in existing types that should not support the spontaneous addition of new values.
data X: Nat
does not declare a type. It declares a Nat. One single Nat, whose type is a Nat, and which does not have a more specific type. (In this sense it's arguably an abuse of the "data" keyword.)
>>
>>61484680
>learning a deprecated language that lets buffer overflows happen because it was invented before memory protection
lolno
>>
>>61484692
>a natural number is not data
>>
>>61484687
nibba you basically named the only ones
not even scheme is purely functional
because purely functional languages are s h i t

but learn scheme. a bit of functional language shit makes a language great
>>
>>61484701
Would you consider Ruby a bit of a functional programming language?
>>
>>61484699
It is, but that's not what the data keyword is for. The data keyword is for declaring new types.
data X: Nat
is not a new type, it's a new number. The fact that it works anyway is just a matter of shitty self consistent semantics.
>>
>>61484704
never used it, I don't know
>>
>>61484707
>shitty self consistent semantics
>consistency
>ever bad
the only bad thing is it reporting a warning on this use case instead of an error
>>
>>61484704
Ruby is both heavily functional and heavily object oriented. However, *pure* functional programming is pretty much impossible with it.
>>
>>61484707
Yes, you declared data x of type Nat.
But if you got past chapter 1, youd know you would rarely just leave it at that.
Next youre going to tell me that you shouldnt be allowed to declare a variable of type null.
>>
>>61484687
Haskell and Idris are best in class purely functional languages. Both are very nice. Idris has dependent types, but it's slower and less mature than Haskell.
>>
>>61484718
What is *pure* functional programming anyway? I learnt a little bit of scheme so I have basic understanding of functional programming.
>>
>>61484718
So is *pure* object oriented.
https://github.com/yegor256/eo
>>
File: tenor[1].gif (1MB, 244x200px) Image search: [Google]
tenor[1].gif
1MB, 244x200px
>>61484529
>what am I in for lads
>>
>>61484717
>spends the entirety of this debate defending the fact that Idris makes it possible to inject new possible values into types even when this makes no sense
>suddenly "lol it should be an error"
This is a step beyond moving the goalposts.
This is like twirling the chessboard.
>>
File: mfw.gif (460KB, 283x200px) Image search: [Google]
mfw.gif
460KB, 283x200px
>A C# program written a decade ago just got thrown into my lap
>Code written to interface with an old-as-fuck piece of equipment
>New piece of equipment needs to be implemented
>Different equipment manufacturer, thus zero compatibility with old code
>Need to figure out how to strip out the code for the old equipment and implement code to allow it to interface with the new equipment

>Never touched C# in my life (worked with C++)
>Very small timeframe in which I can complete the project (a couple weeks)
>Dude who wrote the old code is dead

I know it's hard to say exactly without knowing the intricacies of the project, but by your estimation, approximately how fucked am I here on a scale of 1 to 10, /g/?
>>
>>61484732
having everything be either a function or a side effect of a function
scheme fails to be that because (define (x) 3) for example assigns x to 3, rather than assigning 3 to whatever x -represents-
lambda, if, and a few other things also break functional programming rules, IO does it I think

a purely functional programming language never breaks convention
>>
>>61484748
That wasnt me you melon.
>>
I want to write an init system for linux (replacing systemd obviously) but I don't know where to start. I've read some articles about init systems in general but I can't find any tutotrials or books covering the subject of writing one.
Is other people's code the only way to learn?
>>
>>61484738
is it that great or am I being memed on
>>
>>61484726
>Yes, you declared data x of type Nat.
>But if you got past chapter 1, youd know you would rarely just leave it at that.
You seem to be suggesting it would make sense to go on to define X.
For example:
data X: Nat
X = 4

Not so. The use of the keyword "data" renders supplying a definition unnecessary.
That keyword makes the declaration its own definition.
X isn't just any Nat. X is X. Just a whole new Nat, which happens to be called X, distinct from any other Nat that existed before it.
You wouldn't just "rarely leave it at that." You straight up WOULDN'T FUCKING DO this.
>>
>>61484760
go look at devuan's gitlab.
>>
>>61484752
have you ever worked with Java? you may be better off than you realise
>>
>>61484774
What if i want a Nat that can be anything it wants?
Who are you to say i cant you commie?
>>
>>61484788
>What if i want a Nat that can be anything it wants?
Then you declare it like this.
X: Nat

Because if you instead used
data X: Nat

then X actually CAN'T be anything it wants. It can only be X.
>>
So I'm starting my first job this monday, they build webapps using nodejs react and ruby. I'll have a training period of about 2 months where i'll be shown the basics. Any tips or recommendations? (i'm an advanced compsci student but we haven't worked much with js and web things in general so I'm kinda scared)
>>
>>61484777
Devuan uses sysvinit, what's your point?
>>
>>61484810
Are you retarded?
>>
How do you guys not feel like shit about your abilities constantly?
I'll feel like I've finally learned something only to find out that there's far more efficient methods of doing it and the way I learned is actually horrible for about a dozen reasons.
It seems like I'm constantly wrong.
>>
>>61484817
yes
>>
>>61484823
>How do you guys not feel like shit about your abilities constantly?
>implying

>I'll feel like I've finally learned something only to find out that there's far more efficient methods of doing it and the way I learned is actually horrible for about a dozen reasons.
you're learning, that's great

>It seems like I'm constantly wrong.
that's life boy-o
>>
>>61484823
to avoid this i never learned anything in the first place
>>
>>61484817
>>61484824
you probably meant the replacing systemd part. It was a joke
>>
>>61484801
x : Nat
data x: Nat
still return x : Nat
i love how much of a fit youre throwing because idris actually lets you have freedom.
>>
Learn to think functionally. Modularized functions + Flux or Redux (unidirectional data flow) makes it crazy easy to find and fix bugs.
>>
>>61484809
http://bdcampbell.net/javascript/book/javascript_the_good_parts.pdf

i beliv in u anon
>>
>>61484781
>have you ever worked with Java?

Nope. Most of my work has been in Python, and I've done a decent amount with C++ and dabbled with C.
>>
>>61484809
>>61484845
Oops, this reply was for this.
>>
>>61484553
>python
>programming
get out
>>
File: 01155.gif (114KB, 650x450px) Image search: [Google]
01155.gif
114KB, 650x450px
/dpt/ how do I not be addicted to webcomics for teenage girls?
Also will technology ever advance to the point where there are programming languages like ~ATH and games like Sburb?
It would be pretty cool to be able to write software that affects reality and fate but I feel like our understanding of quantum mechanics is not quite there yet
What would that be like post-quantum computing or some shit
>>
File: 1497133960332.jpg (57KB, 339x272px) Image search: [Google]
1497133960332.jpg
57KB, 339x272px
>>61484834
n-no
you were supposed to tell me something comforting
i dont wanna feel like this the rest of my life
>>
>>61484839
also you should probably read the docs and not just assume everything is 1:1
http://docs.idris-lang.org/en/latest/reference/syntax-guide.html?highlight=data#syntax-data-types
>>
>>61484838
Torvalds was joking when he wrote his terminal emulator, too.
>>
>>61484839
There's a huge difference between freedom and bad fucking design.
C++ gives you the """""""freedom""""""" to declare implicit cast operators and dereference invalid pointers.
And look at THAT smoldering heap of garbage.
>>
>>61484857
okay, then whenever you're shown to be wrong, insist that it is in fact you, who is right, denying all evidence saying otherwise
revel in your superiority as others grow through their admitted errors as you are chained by your foolishness

making mistakes and admitting we've made mistakes is what got humans where we are lad
lying to ourselves to avoid bad feels just leads to even more pain
>>
>>61484879
>its a "bring up C++ to give my pedantic qualm "validity" argument
Im done.
>>
>>61484875
Yeah well I'm writing this to learn about linux and init systems and keeping the code in a private repo. But it's rather challenging to start when there are no resources.
>>
>>61484915
data X: Nat

data Motherfucking: Type -> Type
data
X:
Motherfucking
Nat
>>
Does anybody know how Go 2 will be different to Go 1? Will Go 2 finally have generics?
>>
>>61484949
>Will Go 2 finally have generics
Probably not and that's not even a significant problem in golang. It's something people bitch about in the same way they bitch about it not being OOP.
Golang won't be a usable language until they make their environment and package system less fucking retarded
>>
>>61484853
I should add that my degree is not in CompSci, it's in Physics, so this is not exactly my wheelhouse.

The C# program solution has a dozen projects included in it, I don't even know how the fuck they interface. Are there any for-dummies things that could help a scrub like me out?
>>
>>61484949
>Does anybody know how Go 2 will be different to Go 1?
It will be mandatory for all programs to create and run in a GUI or else they will not compile
The compiler will then populate this GUI with Google Ads
>>
>>61484972
kek
>>
>>61484856
>/dpt/ how do I not be addicted to webcomics for teenage girls?
same way you reclaim any other kind of lost masculinity
stop being a slob and exercise willpower
>Also will technology ever advance to the point where there are programming languages like ~ATH and games like Sburb?
no
>>
>>61484771
I'm just fuckin with you dude. I've never even heard of Guile, but from my experience, upgrading to the latest version of anything typically results in a mine-field of bugs and broken packages (many of which are maintained by third-parties and will be abandoned in the coming weeks).
>>
There was a memory leak in my tic tac toe outcome permutation counter. It uses seq properly now.
main :: IO ()
main = print $ games False $ listArray (1,9) $ Nothing<$[1..9]

games :: Bool -> Array Int (Maybe Bool) -> (Int,Int,Int)
games turn arr = fromMaybe play $ score arr
where play = foldl' add (0,0,0) moves
add (a,b,c) (x,y,z) = foldr seq (a+x,b+y,c+z) [a,b,c]
moves = map doMove $ filter (isNothing . (arr!)) $ [1..9]
doMove i = games (not turn) $ arr // [(i,Just turn)]

allIs :: Eq a => [Maybe a] -> Maybe a
allIs (x:xs) = x >>= fold
where fold y = foldlM eq y xs
eq b = (>>= \v -> listToMaybe [b | b==v])

score :: Array Int (Maybe Bool) -> Maybe (Int,Int,Int)
score arr
| isNothing result && not nomoves = Nothing
| otherwise = Just (eq $ Just False, eq $ Just True, eq Nothing)
where eq x = if x == result then 1 else 0
nomoves = all isJust $ elems arr
result = asum $ allIs . map (arr !) <$> streaks

streaks :: [[Int]]
streaks = [1,5,9]:[3,5,7]:rows++cols
where rows = [[i..i+2] | i<-[1,4,7]]
cols = transpose rows


>>61484961
That's because copy pasting code is idiomatic Go, so the problem of reusing code is avoided.

https://golang.org/src/go/ast/ast.go

This is in the Go standard library.
>>
File: 1489864525991.jpg (16KB, 250x272px) Image search: [Google]
1489864525991.jpg
16KB, 250x272px
>>61485010
>This is in the Go standard library.
Don't think I'll be writing anything in that for awhile
>>
Does /g/ have a Discord?

Particularly a programming channel?
>>
>>61485030
>>>/r/eddit
>>
>>61485030
fuck off
>>
>>61485030
You're going to get a bunch of raging autists replying to you anon, but I wish we did.
>>
>>61485050
>>61485030
RRREEEEEEEE
>>
>>61485030
>a Discord?
WHAT THE FUCK
REEEEEEEEEEEEEEEEEEEEEEEEEE
>>
what programming language have an best memes?
>>
File: 1417920280182.jpg (94KB, 762x1024px) Image search: [Google]
1417920280182.jpg
94KB, 762x1024px
how does one write a non-autistic personal profile to go on their CV? i want job
>>
>>61485023
A couple years ago I saw a panel that had some major players in the go community, but obviously most were there because Rob Pike was attending.

Someone brought up generics and Rob Pike actually gave some bullshit answer about using outside code generation tools with a dead serious face. Everyone laughed, but he just kind of looked around and I guess some people must have realized he wasn't joking.

Wish I could find the video.
>>
>>61485087
Rust
>>
>>61485087
C, it's a meme itself
>>
>>61485099
I mean they designed with it a "C-style" philosophy in mind, so I could potentially understand his confusion, but a modern language avoiding it is just....it's dumb. it's really dumb.
>>
>>61485099
Was that the one that had Rob, Andrei and the guy from Rust?
>>
>>61485104
>>>>>>>>>>you dip
>>>>>>>>>>>>>>>>>IT AN MEME THE DIP
>>
>>61485116
Maybe - it's been a long time so I just can't remember.
>>
>>61485050
Honestly curious... What's wrong with Discord?

I know Slack has its problems (ie: it runs Electron), but what did Discord do wrong?
>>
>>61485158
Names.
>>
>>61485158
4channers don't like pseudonymity. Even though for some reason sometimes they tolerate it under an ID system without realizing it.

Discord's great though, even though it uses WebRTC it routes calls through a server so that IPs aren't leaked between users. You get the benefits of the browser (not having to trust any software) the benefits of a voice server (not having to trust other users) and it's free. Plus it uses the Erlang VM on the backend which is pretty sweet

>>61485172
Not names, psuedonyms. It's not Google fucking hangouts
>>
>>61485097
>i want job
lol look at this fool
>>
>>61484760
Use Makefiles.

I'm serious. You can write dependency graphs as complicated as you want with Makefiles and execute independent tasks in parallel. All you have to do is write an init.
>>
>>61485202
>. Even though for some reason sometimes they tolerate it under an ID system without realizing it.
Tripcodes have their use but abuse of them is near-universally condemned.
/pol/ and /b/ id's are only thread-temporary and just serve to solve a problem that shouldn't exist but is hard to prevent.

Discord is different because everything is perpetual and eventually your chatroom will devolve into shitposting, circle jerking, e-personality wanking and more. Atleast casual ones anyway. Thats why discord is shit, because names are shit because we all have egos that cloud and perverse conversation.
>>
from playsound import playsound
from gtts import gTTS as tts
from os import remove

def play(text,lang="en"):
print "tts placeholder:\n"+text

filename = "voice.mp3"
tts(text=text, slow=False, lang=lang).save(filename)
playsound(filename)
remove(filename)

play(raw_input("TTS and playsound test: "))

play("this time it raises an IOError")


why does this happen?
os.remove only deletes the file at the end of the program
>>
If I may ask for advice here:
I'm thinking about starting a graphical / game-like project, and I would prefer to write it entirely in C.
I can't decide whether to use SDL 1.2 or SDL 2.0 based on the documentation avalable for each library.

Any thoughts?
>>
>>61485263
2
>>
TCG game dude here, made a little bit of progress then wasted the rest of my day unsuccessfully trying to set up a blog for myself. Feelsbad

In other news, I made a very ugly Racket DSL with linear typing, now with lists.
 (letrec ([{rev-append : (→ (MList String) (MList String) (MList String))}
(λ ! ([lst : (MList String)]
[acc : (MList String)])
(match-list lst
(cons x xs @ l) -> (rev-append xs (cons x acc @ l))
nil -> acc))]

[{rev : (→ (MList String) (MList String))}
(λ ! ([lst : (MList String)])
(rev-append lst (nil)))])

(rev (cons "a" (cons "b" (cons "c" (nil))))))

This performs an in-place reversal; (cons x y @ l) reuses the location l to create a cons. It's guarunteed that you don't reuse a location multiple times, because of linear typing. Internally, it's implemented with mcons/mcar/mcdr
>>
>>61485227
>All you have to do is write an init.
That's what I'm trying to do, but are there any books/tutorials covering the subject?
>>
>>61485289
>λ
how does one type an actual lambda into their code
>>
>>61485301
\lam C-c C-\


Additional unicode characters include:
> → for (unrestricted) function type; the linear function is (-o arg .. ret)
> ⊗ for linear pair

There's lots of unicode in the source as well.
>>
>>61485301
A bunch of scheme editors will substitute a lambda with the symbol automatically when you type it.

>>61485289
Yeah racket makes the most sense for your purposes I suppose. I completely forgot about it.
>>
>>61485295
Here's all you need for /sbin/init (pid 1):

#define _XOPEN_SOURCE 700
#include <signal.h>
#include <unistd.h>

int main()
{
sigset_t set;
int status;

if (getpid() != 1) return 1;

sigfillset(&set);
sigprocmask(SIG_BLOCK, &set, 0);

if (fork()) for (;;) wait(&status);

sigprocmask(SIG_UNBLOCK, &set, 0);

setsid();
setpgid(0, 0);
return execve("/etc/rc", (char *[]){ "rc", 0 }, (char *[]){ 0 });
}


/etc/rc (shell script) should then launch make with whatever Makefile you choose to start the system.
>>
>>61485281
Welp, 2 it is I suppose.
>>
>>61485233
That's the best answer you could give - because that's the difference in central mechanic between IDs and discord. However, it's not correct because guests can use Discord through the web interface if the server allows it.

But even disregarding that, we still have "psuedonyms"
on 4chan for lots of people in these threads - the guy who pushes D all the time (the main one, anyway), the guy working on a Chicken Scheme+C minecraft clone, the troll who directs people to /v/, one or two of the anime posters I can consistently pick out, and so on.
>>
>>61485263
Why would you use sdl1? sdl2 runs better if you're going to use builtin 2d functions, and I can't think of any reasons to not use it.
>>
>>61485357
Its a side-effect of generals that you cant get rid of nor should you. But at the same time, I could also post about another language i like and no one will take me for the D guy. That's the difference.
>>
>>61485345
don't know what you expected lad
why would you use the old lib unless you were adding stuff to a codebase that already used it
2.X adds good shit, just at the cost of having no backward compatibility
>>
>>61485340
thanks pal
>>
>>61485366
>>61485383
I'll admit, I'm still learning about all this multimedia programming stuff, so I'm just going going by what kind of documentation is out there.
Google returned quite a bit of docs for 1.2.
>>
>>61485381
And similarly, you can pop another guest on discord and do the same. You should be using 4chan in incognito already so there shouldn't be a difference. I don't mean to be pissy about supporting D, btw, it seems like I might have sounded kind of rude. It seems like a pleasant language, I just don't know much about it.
>>
>>61485394
not much changed from 1.2 to 2.0 desu, mostly it was just additions
the version number changed simply because backwards compatibility broke for some specific things
you could definitely learn SDL 1.2, then jump into the documentation and read what changed

these pages might be helpful
https://wiki.libsdl.org/Introduction
https://wiki.libsdl.org/MigrationGuide
>>
>>61485418
Being a guest on discord is like being a tripfag here.
People will always regard you as a faggot and pester you to change it.
>>
>>61485428
I myself initially followed that logic, but was annoyed to find that the simple program I wrote was incompatible.

Once you get a working window, after that it's mostly a matter of reading the API to find what you want desu.
>>
>>61485443
That's only because of the big divide we have between Discord users and 4chan users. You saw how people reacted. It's the people that make that culture a thing, not the computer program
>>
>>61485428
Thanks, anon!
Looking through some of those pages, I did happen to find some tutorials for SDL2, so I think I might get started with those.
>>
>>61485474
4chan is inherently anonymous, discord is inherently not. Its not really hard to see why discord is hated here. I dont like chatrooms or it. If you want to see why discord is bad, go to /agdg/ and wait for them to bring up how most everyone refuses to put a negative opinion about another game to their identity.
>>
Does anyone find themselves trying to use vim movement commands while writing 4chan posts?

>>61485474
Well program structure influences culture, just as culture influences program structure.

Tripfagging on 4chan requires specific knowledge. You have to go out of your way to setup a tripcode on 4chan. Fuck I still don't know how to setup a tripcode, and I don't really care either. Discord guides you to setup a name and gives you a unique user id (I think?)

Avatarfagging requires you to have a collection of different images of the same thing, not to mention it's discouraged because of the image bump limit. But on discord, it's easy and you need just one image, not an entire folder.
>>
>>61485557
>he doesnt use vim browser extensions
>>
>>61485515
>4chan is inherently anonymous, discord is inherently not.
We've already been over that, it's pseudonymous and, with the guest system, capable of transient pseudonyms.

And yeah, obviously no one's going to put negative opinions to their permanent name. That's not what we're proposing here.

>>61485557
>Well program structure influences culture, just as culture influences program structure.
Using discord with a transient identity is a one click process. It's actually harder to set up an account.
>Discord guides you to setup a name and gives you a unique user id
Yeah, without asking to set up an account, upon page load. You just enter a name (can be anon) and start chatting immediately. Next incognito session, your anon user will have a different user id
>>
There is literally nothing wrong with programming Python on a regular basis.
>>
>>61485753
>That's not what we're proposing here.
Its the sole reason why Discord and named chatrooms are flawed. Conversation is filtered.
>>
>>61485788
You can't filter people if their usernames change on a daily basis
>>
>>61485840
>You can't filter people if their usernames change on a daily basis
its crazy how you still fail to realize why its so bad.
And i dont mean literally filtering people , i meant conversation isn't natural because people are holding back their opinions at the expense of some false rep constructed by their ego.
>>
>>61484634
Haskell is more popular in general so it's a good first language. If it turns out you want to use Idris anyway, the skillset carries over extremely easily.

If you learn with Haskell lots of obstacles and errors will have dedicated guides and QAs from previous learners and teachers
>>
>>61485875
> i meant conversation isn't natural because people are holding back their opinions at the expense of some false rep constructed by their eg
Not if your fucking identity changes on a daily basis. There is no maintenance of reputation because there is no reputation because you're signing on to a discord server where everyone's called anon#1347 where the numbers come and go every day. It's crazy how you still fail to realize what guests are on discord
>>
>>61485906
Well alright m8, we've shit up /dpt/ enough with this off-topic shit. Enjoy discord i guess.
>>
File: dabs autistically.jpg (257KB, 2048x1150px) Image search: [Google]
dabs autistically.jpg
257KB, 2048x1150px
Is there any way I can pay a gook to program for me for peanuts?
>>
what's better - spiritual weapon or flaming sphere?
>>
>>61485958
spiritual weapon
>>
>>61485779
sage
>>
>>61485925
Yeah, fair enough.

>>61484809
JS has a kind of specific and complicated object model. Writing better JS is basically about dodging (most of) the hard to reason about aspects of this object model. So it pays to understand how it works.
>>
>>61485970
why?
>>
>>61486038
a flaming sphere can kill a person
a spiritual weapon can destroy an entire civilisation

look at Europe for example
>>
>>61485931

Why not just write the program yourself?
>>
>>61486043

We don't know how big of a flaming sphere we're talking about. If it's the size of the Earth, it'll kill most life on the planet.
>>
>>61486086
not if by flames you mean flames
>>
File: trillion.jpg (29KB, 599x383px) Image search: [Google]
trillion.jpg
29KB, 599x383px
>>61485958
>>
https://blog.rust-lang.org/2017/07/20/Rust-1.19.html

Since I know there's a few Rust fanboys in here, you should probably know there's a new update. For those who don't want to read, here's a TL;DR:

1. Rust now has an untagged union data type for better compatibility with C. All usage of a union is unsafe.
2. Loops can now break with a value to evaluate as an expression.
3. Lambda expressions that don't close over anything can be coerced into a function pointer.
4. There are now eprint! and eprintln! macros for printing to stderr instead of stdout.

And some other minor improvements.
>>
>>61486211
>4. There are now eprint! and eprintln! macros for printing to stderr instead of stdout.
I'm surprised it didn't have this already.
>>
>>61486174
The sun is only about 10000000000000000x heavier so it's hard to say.

>>61486211
>3. Lambda expressions that don't close over anything can be coerced into a function pointer.
Never used Rust in my life but what in the fuck does this mean? Why wouldn't a lambda expression be a function pointer? What in the hell is it if not a function pointer?
>>
>>61486287
Some kind of object with member variables, I guess?
I'm not familiar with Rust, but in C++ you can do something like this.
int x = 5;
auto multiply_by_captured_var = [x](int y){ return x*y; };

multiply_by_captured_var can't a plain function pointer because it needs to remember x until it's invoked.
>>
>>61486299
Well what you're describing is a closure. I don't see why a lambda couldn't capture that as a function pointer though.

Couldn't you just compile x as a relative offset to where multiply_by_captured? They're both stack variables.
>>
>>61486287
Not if the lions were moving towards the sun at (1-10^-33)c. Then they'd be picking on an opponent their own mass
>>
>>61486376
*nb

I have no idea if that anonymous function is actually a stack pointer. I see no reason for it not to be though.
>>
Is Rust taking off yet?
>>
>>61486299

Basically this. If there's no x to remember, you can coerce into a function pointer. Otherwise, it's a mess.
>>
>>61486299
Oh wait. I forgot about execute vs readwrite memory. The anonymous function can't be a stack variable without turning off a security setting. Stupid fucking security.
>>
>>61486418
> The anonymous function can't be a stack variable without turning off a security setting.
The state of Rust.
>>
Can you debug effectively using GDB with rust? When I tried it more or less worked but would jump in and out of nasty rust internals and other places I didn't expect that made it really hard to use. I didn't test reading more complicated data structures either.

This is my fault somehow, but it's worth adding that even though I installed my distro's rust library sources package, for some reason I couldn't get GDB to use them in my program, so I'd just be completely lost besides my call stack whenever I entered library code.
>>
>>61486389
>>61486376
x might change in the meantime. The point of the closure is to capture the environment at the point at which it's created.

int main()
{
int x = 5;
auto multiply_by_captured_var = [x](int y){ return x*y; };
x = 1;
std::cout << multiply_by_captured_var(6); // prints 30
}

You can't bake the captured variable in as an offset to a function pointer because that function pointer might be moved elsewhere and the captured variable may be mutated/go out of scope.
>>
>>61486440
No.
#;6> (define x 0)
#;7> (lambda () x)
#<procedure (?)>
#;8> (define closure (lambda () x))
#;9> (closure)
0
#;10> (set! x 1)
#;11> (closure)
1
#;12>
>>
>>61486440
That's really just a C++ specific thing. Change the capture list to [&x] and you would print 6 instead.
>>
>>61486384

Yeah, but we don't exactly have the requisite amount of energy to accelerate them to that velocity.

>>61486395

Not really.

>>61486440

You can capture by value or by reference.
>>
>>61486488
That's why we need to get our hands on a spiritual weapon

We need a lion railgun to destroy this solar system
>>
>>61486460
You can capture by reference if you want that kind of behavior (in C++, no idea if Rust has similar behavior)
int main()
{
int x = 5;
auto multiply_by_captured_var = [&x](int y){ return x*y; };
x = 3;
std::cout << multiply_by_captured_var(6); // prints 18
}

But you have the same pitfalls. If you return the lambda from a function or pass it to another function, the offset to the captured variable will change. And in a language without GC, that variable could easily go out of scope. Under the hood you still must create a pointer to the variable that is a part of the lambda's environment.
>>
>>61486499
>We need a lion railgun to destroy this solar system

Program a planet teraformer first m8.
>>
>>61486511
>But you have the same pitfalls. If you return the lambda from a function or pass it to another function, the offset to the captured variable will change.
It only does that because C++ sucks. It shouldn't change because the anonymous function should be on the stack, or some elaborate memory mapping should be used to copy it into executable memory if the stack is execution forbidden.

If the variable goes out of scope, the function ideally should to. C++ sucks.
>>
>>61486554
>It shouldn't change because the anonymous function should be on the stack
Are you talking about some sort of runtime compilation here?
The original post was about Rust, I don't think this kiind of systems programming language is concerned about executing data as code at runtime, which is the only use case I can think of for putting executable data on the stack.
>>
>>61486554

Stack execution is never allowed on decent platforms, and if it required heap allocation, it wouldn't work in a freestanding environment.
>>
>>61486586
Well you'd also need executable data on the stack for real closures, or some emulation of it with the needed stack contents being mapped to some executable memory.

>>61486599
new/delete doesn't work in a freestanding environment. That didn't stop the C++ devs.
>>
>>61486649
Rust and C++ aren't Lisp. I still don't see why you need to put code on the stack.
>>
>>61486599
Defend this --->>61484292
>>
>>61486671
why wouldnt you prefer stack?
>>
>>61486677
Rust and C++ were never designed for self modifying code, which is the only use case I can think of for putting code outside of the data segment.
>>
>>61486649
>Well you'd also need executable data on the stack for real closures
no
>>
Why do most programming languages use garbage collection nowadays? Why can't they be manually memory managed?
>>
>>61486736
compile-time gc is the best
>>
>>61486736
that's called progress.
>>
>>61486745
>>61486748
There is only three high level languages that I know of that don't use garbage collection, C, C++ and Rust.
>>
>>61486759
>and Rust
False
>>
>>61486698
>self modifying code
I'm not talking about eval. I'm talking about closures.

Suppose I want to create a sort function that sorts an array of tuples given a norm.

Now suppose I use libstd because it should work and there shouldn't be a million exceptions. So I think hmm, let's make an anonymous function d(x,y) = ||x - y||, where || || is passed as an argument along with the array.

Apparently, this is illegal. Some closures.
>>
>>61486736
people are too lazy

>>61486745
what languages actually do this?
>>
>>61486772
>what languages actually do this?
Mercury
>>
>>61486772
Go, Crystal that's all I got.
>>
>>61486777
Go just has a bit of token escape analysis doesn't it?
>>
>>61486649

new and delete are just function calls, and can be defined by the user in a freestanding environment.

>>61486675

No sane behavior can or should be assumed out of @@class_variables. If you want a member variable associated with a class, use a class level @instance_variable.

Basically, class variables are a mistake and we only keep them around because a few idiots still use them.
>>
>>61486677

Because the OS will bitch slap you if you try to execute code on the stack.
>>
>>61486785
If a language features uses new and delete then, then implementing new and delete implements that language feature.
>>
>>61486767
>So I think hmm, let's make an anonymous function d(x,y) = ||x - y||, where || || is passed as an argument along with the array.
But why would this be created in the stack? The || || function is compiled ahead of time. Why would you paste the body of that function from the data segment onto the stack unless you're changing it somehow?
>>
>>61486785
>this feature of the language shouldn't be used because it was implemented badly; the language isn't bad though!
Nice deflection there faggot
>>
>>61486767
closure's code is static, only the captured variables are dynamic.
>>
>>61486785
>Basically, class variables are a mistake and we only keep them around because a few idiots still use them.
lmao is this some jank programming style you picked up in academia or is that language really that shitty?
>>
>>61486810
>>61486824
So you can have working relative offsets to the data on the stack. Alternatively you could complicate function pointers by making them longer than normal pointers, including a stack offset.

I guess that would cause a serious fault with calling C functions like qsort in C++, but C++ already reimplemented a lot of those anyway.
>>
>>61486811

I have never claimed Ruby to be perfect. It's slow as balls and has a few odd quirks here and there. It's comfy as hell for a number of uses, but that doesn't mean I go out of my way to use every feature the language has. Very rarely do class variables do what you want. But classes are singleton objects themselves and can have their own instance variables, so that's what should be used most of the time.

>>61486825

Nah. I'm pretty sure I've seen it in at least one style guide. Oh, here's one...

https://github.com/bbatsov/ruby-style-guide

>Avoid the usage of class (@@) variables due to their "nasty" behavior in inheritance.
>As you can see all the classes in a class hierarchy actually share one class variable. Class instance variables should usually be preferred over class variables.
>>
>>61486886
You just admitted that Ruby is shit. Why the fuck should any one even use Ruby is beyond me when there are other much better languages to use that are way better and faster. You must have Stockholm Syndrome or some shit to defend a language that shitty. You also didn't even defend the fact that constant variables aren't even constant and that you can modify them. What would you even describe as the perfect language then?
>>
>>61486879
>So you can have working relative offsets to the data on the stack.
It's better to copy the entire function body and patch all the offsets to bound variables every time you want to pass or return it? Including the initial copy to the stack.
>>
>>61486920
Slow as balls and a few odd quirks doesn't make it shit. Speed isn't everything.
>>
>>61486928
>Speed isn't everything.
Did I say that? There are other languages that are more expressive while being much faster than Ruby. People must have Stockholm Syndrome or Baby Duck Syndrome to defend ruby, the shit lang.
>>
>>61486926
Now it doesn't work in multithreaded situations.

I think the most elegant solution would simply be to make function pointers twice as long, one for the pointer to the function, and one for where the offsets are centered around.
>>
For anyone who actually wants to discuss programming instead of what ever happens in these threads (Language pissing competitions, IDE/Editor wars, etc) infinity chans /prog is pretty decent.
>>
I'm about to try Haste. I love Haskell but I'm really disappointed in Cabal.

>>61486920
I don't like your attitude anon.

>>61486964
How often do people post there?
>>
>>61486764
Wrong
>>
>>61486987
True
>>
>>61486981
its definitely slower than here, but the quality of posts are pretty high, and its fast enough to have a solid conversation over the course of an hour or so
>>61486964
>>
>>61486981
Ive found stack much better desu.
>>
>>61486990
Correct
>>
>>61487004
Incorrect
>>
>>61486953
That doesn't work unless all the variables you capture are at the same offsets to each other every time. It breaks down as soon as you try to capture variables from outside the current stack frame (or even inside that stack frame if you have VLAs).

And your closure is still limited by the lifetime of the function that created it. What good is a closure that you can't return?
>>
>>61486964
>infinity chans
Only literal retards post there.
the real /prog/ is better
>>
>>61486981
No, the rubyfags are just dumb and I'm trying to enlighten them from their blind devotion of a shitlang.
>>
>>61486964
>literally a thread titiled "Editor Wars" present
wwwwwwwwwwwwwwwww
>>
>>61486920

>Why the fuck should any one even use Ruby is beyond me when there are other much better languages to use that are way better and faster.
Because I don't always care about speed. Ruby is about as slow as Python, and any use case for one is a use case for another. Generally, I find Python uncomfortable to program in, while in Ruby, it's easy to churn out a quick script to do whatever I need.

>You must have Stockholm Syndrome or some shit to defend a language that shitty.
Honestly, it's not for everyone, and I don't really try to sell it to people. Most of the problems you're describing with the language are problems I don't run into, because I don't write code like a dumbass, and I never use Ruby where performance is something I care about. I use it mostly for utility scripts and one off scripts for processing a bunch of strings/lists/whatever. Some people do that with Bash, Perl, or Python; I do it with Ruby.

If you want to talk Stockholm Syndrome though, I genuinely like, rather than merely tolerate, C++.

>You also didn't even defend the fact that constant variables aren't even constant and that you can modify them.
Ruby gives you plenty of room to blow your foot off. You can redefine the + operator on Fixnums, and crash the REPL when it tries to increment the line number. Every method is basically public if you interface it through object.send :methodname. You can access instance variables even if it doesn't have a reader/writer method defined. There's generally an assumption that you know what the fuck you're doing. If you don't, well, tough titties.

>What would you even describe as the perfect language then?
There is none. Different styles of languages fit well to different types of tasks, and are enjoyed by different types of people.
>>
File: 4chan_argument.png (203KB, 1000x857px) Image search: [Google]
4chan_argument.png
203KB, 1000x857px
>>61486964
Like, what's the point of browsing 4chan if I can't shit talk other people? I may as well go to reddit if I want the illusion of having a constructive discussion. At least you learn shit in /g/ by arguing with other people.
>>
>>61486994

>and its fast enough to have a solid conversation over the course of an hour or so
Posts Per Hour: 0
Unique IPs to post in the last 72 hours: 0
Total posts: 4752
>>
>>61487082
>tfw i love getting into arguments out of my depth because i always have a new subject to learn about, and new programming knowledge.

/dpt/ is olev.
>>
>>61487011
>What good is a closure you can't return
A closure you can pass. Closures are primarily useful for passing not returning. The main use for returning closures that I'm aware of is creating ghetto objects in lisp.

>It breaks down as soon as you try to capture variables from outside the current stack frame (or even inside that stack frame if you have VLAs
I'm not seeing how this is going to break things. If it's higher up in the stack, then it's higher up in the stack. Stack frames are just marked by pushed stack pointers anyway.

I'm not seeing how a VLA is going to break things either, if a VLA would break what I'm describing, it would break all code.
>>
>>61487114

Variables outside the stack frame:
void ex1(int &x)
{
int y; // x is not a constant offset from y
}

Unless you plan on capturing the offset of the pointer in the stack frame and shitting your code up with needless indirection it won't work.

VLAs
void ex2(int n)
{
int x;
int arr[n];
int y; // y is not a constant offset from x.
}

VLAs aren't strictly C++ but plenty of compilers support it anyway.
>>
>>61487183
>int &x
This is just a pointer under the hood. That's easy. Just dereference the pointer.
>y is not a constant offset from x
How do you read it then? I'm guessing the stack is arranged like
x
arr's length
arr
....
....
....
y

If it's arranged like that, reading y with a closure is easy.

*y = closure's offset + sizeof(x) + sizeof(arr's length) + arr's length * sizeof(arr's elements)
>>
>>61487253
>Dereference the pointer you get by dereferencing the pointer you get by offsetting to find this stack frame
>Increment and dereference your pointer so you can increment the pointer by the value you find and dereference the new pointer.
All of this sounds like a bit pointless compared to just pasting the variable in at the point of use.

Anyway, I see no reason why C++ lambdas can't do what roughly you're asking when you capture by reference. They're totally opaque and can be interpreted in any sensible way (though usually a 1:1 pointer mapping for obvious reasons)
void ex3()
{
int x;
int y;
int z;
auto my_closure = [&](){ return x + y + z}; // Why shouldn't the compiler just use a single pointer to this stack frame?
}

I doubt a compiler would really do that but this entire conversation has been a bit out of my depth so I can't really say.
>>
>>61487183
>y is not a constant offset from x.
definitions have no order
>>
>>61487360
That's what I'm describing, but per >>61486511 it doesn't have practical value. You'd have to pass the pointer to the stack frame as a packaged part of the anonymous function pointer.
>>
>>61487401
void ex4(int n, bool cond)
{
int x;
int arr[n];
if (cond)
{
int y
auto my_lambda = [&](){ return x + y;};
}
}

You can abuse block scope to force that particular behavior.

>>61487408
my_closure in >>61487360 could compile down to nothing more than a pointer to ex3's stack frame in the same way.
>>
>>61487548
scope doesn't change anything with gcc or llvm
>>
>>61487548
>could compile down to nothing more than a pointer to ex3's stack frame in the same way.
Then you couldn't pass it without some modifications.

What you're describing would make the function part of the function pointer a doubly indirect pointer, so it would be incompatible with standard function pointers, and procedures which accept standard ones, so you'd have to change how function pointers are compiled so that they all have double indirection.
>>
>>61487548
Oh and before I go to sleep, there's also the problem in general that to have real closures which capture by reference and are actually useful, you'd have to throw out C++ being called with the System V ABI since all arguments would have to be pushed on the stack.
>>
please god liberate me from c++

i never want to see this trashcan language again in my life
>>
>>61487635
What's wrong with C++? Why not use C then?
>>
I'm currently working on a program for a coworker. Even though there are plenty out there, he wants me to make a macro recording and playing software for some games.

It's proving to be much more complicated than I initially thought it would be. However I've also found that enormous chunks of it I can still completely understand and get how and why it works even if I needed to lookup the specific reference to use. So that's progress I guess. (C#)
>>
>>61487588
What assembly is your compiler emitting?

>>61487610
In C++ lambdas variables don't contain a function pointer, just the variables they close over. Type information is used to determine what code to call rather than a function pointer. Templates are used to propagate the type information and ultimately inline the call.
If you don't capture any variables, the variable is completely empty.

>>61487642
We have this conversation every day.
>>
>>61487642
What isn't wrong with c++?
>>
>>61487796
>deflecting the question
>>
>>61487796
A few good ideas like RAII and templates.
Just the ideas though, the implementations are often botched.
>>
>>61487796
Its not C
>>
>>61487803
C sucks
Trying to patch C by being C also sucks
>>
okay so in sepples, say you have for example a global double x, and a function f that returns 1000000.0 / x
assuming you set x once and don't change it:

double y = f();
...
double z = f();
assert(y == z);

should this assert ever fire?

I would have said no before, but it will fire on g++ 5 through 7 when certain optimizations are on in specific contexts, when compiling 32 bit

it will in specific situations store y on the stack as a double, then when it calculates z it will leave z in the fpu and load y back in and then compare

since the fpu stores 80 bit values but y has been truncated to 64 bit the values are different

is this standards compliant behavior? it seems to me that the compiler should be forced to truncate z also to 64 bit before comparing as you've explicitly declared it double
at the very least it ought to either compare both values as 80 bit or truncate both values...
>>
>>61487796
"Within C++, there is a much smaller and cleaner language struggling to get out." - Bjarne S.
>>
>>61487817
The whole C family just need put down, desu.
>>
>>61487796
>>61487803
Both languages are far superior to alternatives because they're one of the few non-dead languages that have a non-meme standard. An outdated version of C#, ironically, has one too.

I wish Python had an ISO standard. Maybe in a couple of decades.
>>
This is a listing from Mitchell, chapter 4.4.5 Semaphores for threads
https://pastebin.com/Xk451CZe

>/* Because of the semaphore, we know the queue is not empty. Get the next available job. */
What if thread gets terminated after decrementing the semaphore but before processing the job? The semaphore will indicate the job queue is empty even though there will be some jobs left and they might never be processed.
How do I protect from such bug? Is PTHREAD_CANCEL_DISABLE enough? What if I get a signal or something?
>>
>tfw your objects vtable pointers are mysteriously turning null at various randomly chosen points in your program and you still can't find the cause after hours of debugging.
I don't know how I fucked up so bad.
>>
>>61487845
>X lang is dead
My favorite buzzphrase

>wanting ISO cancer
>>
File: c4a.jpg (23KB, 600x484px) Image search: [Google]
c4a.jpg
23KB, 600x484px
>>61484482
https://news.ycombinator.com/item?id=14521386

Anybody down to do daily source code readings of some large, well-written codebase similar to link related? I feel like daily code review of this kind could really improve my abilities as a dev.
>>
File: duty_calls.png (14KB, 300x330px) Image search: [Google]
duty_calls.png
14KB, 300x330px
>>61487100
>tfw i pick fights with people who know more than me just so they spoonfeed me
glad to know I'm not the only one

thank god for people's need to be right on the internet
>>
>>61487863
A language is dead when there are few people who know it or write new code in the industry.

>wanting ISO cancer
You sir, are a code monkey. You don't know what you're doing, others don't know what you're doing, but for your particular machine, on particular system it kind of semi-works. Your "work" is a discardable, unportable, undefined mess. You guide yourself using rumors and things you've heard, thinking that something "should" do something, because that's "the most logical thing". Pathetic.
>>
>>61487894
No, a language is dead when the compiler is abandoned, not when it falls off the #5 rank on github
>>
>>61487819
If not const, the value of x could always change for whatever reason (including FPU shit). If x was const and optimizations enabled, the compiler could prove that y==z is always true, so the assert would never fire.

On the subject of comparison of doubles, there is no reason you would lose precision by converting from 64-bit to 80-bit back and forth, so yeah, the compiler is not compliant with the standard in that case.
>>
>>61487912
A language is dead when there's a few positions that pay you 400k to maintain shitty legacy code for mission critical operations because nobody else wants to learn the shit language

see: cobol
>>
>>61487862
You got to know what nullifies the vtable. Did you try watchpoints?
>>
>>61487925
You sound like a JS/C# code monkey 2bqh
>>
>>61487940
I program python for a living at a hedge fund, lel
>>
>>61487957
Close enough.
>>
>>61487964
Stay mad.
>>
>>61487968
Why would i be mad youre using a shit language that barely constitutes being called "programming". Anybody can go down the shekel route, but thats boring.
>>
>>61487912
The term *is* subjective (because there's no ISO standard convering it that I know of), but I would argue that for all practical purposes, a language is dead when it's not actively used anymore. The signs effects of the language being dead:

> lack of up to date documentation, standards, tutorials, books covering the language
> lack of tools helping the language (static analyzers, debuggers, so on)
> lack of cross-platform support (C11 threads.h haven't been implemented in glibc for 6 years already, for example)

It is uneconomical, and basically, stupid, to practice a dead language.

A language can avoid becoming dead by:
> being old and having a lot of legacy code to maintain
> being hard-to-read thus hard-to-replace
> being simple, thus easy to implement

I don't know where this is going, but I just want to say, that if you're trying to make a commercial application using a dead language, even if standardized, like APL, you're an idiot.
>>
>>61487937
I can't use watchpoints, I'm developing a kernel and don't have a debugger.

I know that I must be overwriting the memory somewhere, but the fact that it seems to happen at various randomly chosen points has really got my head scratching.
I'm currently printing out the value of the vtable pointer at various key points, so hopefully I can narrow down and pinpoint the exact point where the vtable pointer gets nulled.
>>
File: 1482015047100.jpg (112KB, 764x551px) Image search: [Google]
1482015047100.jpg
112KB, 764x551px
>>61487981
>to intelligent to make money
>>
>>61487989
You can debug a kernel with qemu.
>>
>>61487981
>Anybody can go down the shekel route.
Anybody can be a billionaire, you just have to believe.

You chose the brainlet way because you knew you couldn't compete in the industry because you're a stupid.

You can't make a program that's competetive in the market in a competetive time-frame.
>>
>>61487992
Id rather make a lot loss doing something i enjoy than selling my soul to the pythonic or JS devil.
>>
File: 1480735618040.jpg (337KB, 1280x1483px) Image search: [Google]
1480735618040.jpg
337KB, 1280x1483px
>>61488002
>h-haha t-the only reason i-i'm not making large amounts of cash i-is because i d-don't want to, n-not because I couldn't get passed jane street's t-technical screening
sure dude, nice cope
>>
>>61488002
Do you enjoy reimplementing algorithms? Remaking code someone already did? Walking the path that was already walked thousands of times before? Is that your bravery, the path of superiority, all forgotten and left in dust of the 1970s?
>>
>>61487918
>const
are you sure you don't mean compile time const? if x is const but declared outside the current TU I doubt the generated code will change, unless LTO is enabled or something. I'll try it on my test case later.

my main point of irritation is that two values generated by identical code compare inequal though, regardless of the constness of the variables involved. 64 to 80 and back is fine obviously, the problem only happens when one of the values is computed and then left in the 80 bit register without ever becoming 64 bit.
>>
>>61488020
I enjoy learning, so sure.
ill avoid remaking the wheel occasionally though
>>
Should I learn lisp?
>>
>>61488194
Yes
>>
>>61488194
Learn scheme/racket first
>>
>>61488029
>are you sure you don't mean compile time const?
One case or another, if the compiler is smart enough and inlines f, (1000000.0 / x == 1000000.0 / x) is true, even if x is not known at the time.

>my main point of irritation is that two values generated by identical code compare inequal though
Again, they should compare equal, C standard mandates that comparisons are made by numerical value, not at bit level. Namely, ((int)100 == (float)100.0) is true, although their bitwise representation is different.
>>
File: 1479805573993.gif (1MB, 303x307px) Image search: [Google]
1479805573993.gif
1MB, 303x307px
Hey guys, anyone here tried to make an android app mostly by ndk?

It seems rather disregarded on the Web, but I'm not that content on learning java for one application either.
>>
>>61488194
Learn a standardized Lisp, ISLISP, the only Lisp that's not an unportable mess.
>>
>>61488194
Only if you learn Scheme first
Try
>The Little Schemer
>Realm of Racket
>SICP
>>
>>61488349
Learning Java isn't the difficult part, learning Android applications in general is.

But still, even learning Java AND Android is much easier than learning NDK (and NDK Android).
Seriously.
>>
>>61488401
This is kinda not the answer I wanted hear,
How much effort would there be for someone already fluent in java?
>>
>>61488349
I don't think you should learn to program just for android. It's just one platform and mobile operating systems are generally similar.
Don't write phone application in java or just NDK. You can look at how game engine or bigger GUI libraries provide cross platform API if you really want learn the low level stuff.
For making application you should use one of
QT(c++, python, ...?)
kivy(python)
lambdanative(scheme)
javafxports(any jvm langauge) only GUI but getting access to native stuff like camera is really easy
(xamarin?) I don't know anything about it but it says it can export to mobile platforms.
some other cross platform framework
>>
Is Linux written in C99 or C11?
>>
>>61488802
c89
>>
>>61488802
C89 with GNU extensions, which basically means anything fucking goes.
>>
>>61488832
Why the fuck does it use GNU extensions? Honestly, linux was written like shit any way.
>>
>>61488891
Where was Clang when Linus needed it?
>>
>>61488902
Deep inside nu-/g/'s arsehole
>>
>>61488571
Thanks, that was kinda too obvious. I think I need some rest..
>>
>>61488902
Clang is pretty nice though, it has much nicer error messages than gcc does.
>>
>>61488891
The GNU extensions (e.g. extended ASM) are important for writing a kernel
>>
>>61488976
How come other kernels can write in normal C without GNU extensions but Linux is somehow special to need them?
>>
>>61488976
gcc's errors are basically the same as clang's now (gcc 6.4, but it started a while ago)

>>61488989
they don't? all kernels use compiler extensions in their build process, it would be to my knowledge impossible to write one in "pure 100% ANSI C"
>>
>>61484482
My first CLI tool, in Python.
basically a modified and simplified verison of the 'du' command.
Using the 'click' module.

How can I deploy it in other computers without using virtualenv and without polluting their systems with python libraries in global namespace?
>>
>>61484752
>>61484964
C# is one of the easiest languages to jump in and do shit with once you understand the basic concepts.

However, I'm going to tell you right now that there's no chance in hell you're going to be able to adequately make this work in a few weeks. I've had massive old C# projects thrown at me, and they thought the changes they wanted were 'minor'. C# is my main language, and it took days just to be able to really understand how all the pieces fit together because of how horribly written it was.

It sounds like you're dealing with something even larger than what I was trying to add features to, so I'd advise you to set expectations with your manager that it simply isn't going to happen in that timeframe.
>>
File: flat,1000x1000,075,f.u1.jpg (139KB, 1000x1000px) Image search: [Google]
flat,1000x1000,075,f.u1.jpg
139KB, 1000x1000px
>>61484482
If I want to get hired asap, should I learn Java or C++? Or I could do the best of both worlds and go with C#?
>>
>>61489061
C#. There are more and more .Net shops. It may also be regional, though. I'm from the DC area and .Net dominates the region. With defense contractors
>>
>>61487999
Ok I've been debugging with qemu and gdb attached to it.
Looks like I've got a heisenbug. God help me.
>>
>>61489061
C# is nothing like C++. C# is Microsoft's brand of Java.
>>
>>61489010
How would it be impossible? You could write some parts in assembly, but that doesn't mean you need compiler extensions.
>>
>>61489102
Actually, C# is more similar to C++ than it is to Java.
>>
>>61489121
supporting assembly is itself a compiler extension

but even then, even something as simple as __attribute__((packed)) is a compiler extension
>>
>>61489138
In surface level shit. Calling packages namespaces and using : instead of extends does not make C# anything like C++.
>>
>>61489147
Just shows how little you know about C# and C++. You should probably stop talking right now before you embarrass yourself further.
>>
>>61488989
You could write a kernel without any compiler extensions, but it would be shit.
Compiler extensions are essential for performance. Inline assembly which gets optimized (unlike handwritten assembly), placing related code in the same binary sections for cache locality, hints such as likely() and unlikely(), evaluating functions differently if the argument is a constant expression, etc.
>>
>>61489169
You're an idiot, C++ and C# are like fucking oil and water
>>
>>61489169
Java, C#.
>Compiles to bytecode
>Garbage collected
>The class is the basic unit of compiled code
>Always dynamically loaded and linked

C++
>Typically compiles to native code
>Typically not garbage collected
>Code does not have to live in a class
>Can be statically linked and loaded

What makes C# closer to C++ than Java?
>>
Super noob question: Is it normal to write a program in baby steps, like write one part of functionality, compile it, see if it runs then move on?
>>
>>61489373
Yes
>>
>>61489369
>>61489361
He's baiting
>>
>>61489373
I still compile by line sometimes just because i constantly doubt myself.
>>
>>61489373
Yes, Idk how else you would do it?
If you're on Unix, it's very typical to compose programs of many small independent programs, and have them communicate through IPC mechanisms like sockets or pipes
>>
>>61489373
it gets a lot easier when your language has a real REPL, then you can test everything before you try it

>>61489423
pipes are not common outside shell scripts. sockets are, but are not used as frequently for IPC, mmap or shm are the big players there
>>
>>61489423
>Yes, Idk how else you would do it?

I don't know why but it made me feel like a faggot for not "thinking" the whole solution right off the bat before I start writing code. For some reason iterating seems so much better.
>>
>>61489456
I mean it's a good idea to plan things out ahead of time

>>61489449
Named pipes aren't used much anymore, but I still see people using a program pipeline for text processing tasks and such. I've not heard of shm, but a search yielded interesting results. It looks to me like some shared namespace stored in RAM, very useful. Certainly looks less fucky than mmap, which I've always been wary of.
>>
>>61489094
It seems to only happen when I enable KVM in Qemu.
The bug doesn't happen in bochs either.

I'm starting to think now that the bug is not in my kernel, but in qemu.
What could possibly be going on here? does anyone have any idea? I'm at a complete loss.

The memory at virtual address 0xc0911020 which is the location of the objects vtable pointer will randomly get zero'd out at random points, causing a page fault when calling any virtual method.
I have printed out the value of this pointer at specific points, and have caught it turning null somewhere within some range of code which doesn't even touch it and can't find anywhere where it might accidentally overwrite it.
>>
>>61489456
>For some reason iterating seems so much better.
Youd probably love haskell/idris anything else with holes since thats what theyre for.
You just say "this is gonna be something so just fill it in for me while i figure it out and you can keep on working instead of being at a wall.

Theyre not beginner friendly though.
>>
what programming language is the extra spicey mem
>>
>>61489646
haskell
>>
>>61489646
Youd probably like http://www.emojicode.org , s4s-kun
>>
>>61484533
With Chromium you can secondary click on any network request and copy as cURL which will give you a curl command that will perform the exact same request.
>>
>>61488802
https://www.kernel.org/doc/html/latest/process/howto.html#introduction
>The kernel is written using GNU C and the GNU toolchain. While it adheres to the ISO C89 standard, it uses a number of extensions that are not featured in the standard. The kernel is a freestanding C environment, with no reliance on the standard C library, so some portions of the C standard are not supported. Arbitrary long long divisions and floating point are not allowed. It can sometimes be difficult to understand the assumptions the kernel has on the toolchain and the extensions that it uses, and unfortunately there is no definitive reference for them. Please check the gcc info pages (info gcc) for some information on them.
>>
>>61489494
uh

mmap() is the successor to shmget()

to do IPC with mmap, set a global var to the return value of
mmap(NULL, 1234/*len*/, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);


then fork() and bam you have IPC
>>
>>61489716
>and unfortunately there is no definitive reference for them.
Linux was a mistake
>>
>>61489726
woops, that should have been
mmap(NULL, 1234/*len*/, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANONYMOUS, -1, 0);


im gay
>>
>>61489726
Isn't mmap just a shared memory space? Seems like it'd be ezpz to fuck up concurrency.
>>
>>61489726
What if you want to access that memory between processes that have not been spawned together (result of fork or whatever)?
>>
>>61484500
Indeed
>>
File: rage.gif (1MB, 828x828px) Image search: [Google]
rage.gif
1MB, 828x828px
>mfw BFS is too memory hogging for my snake AI so I have to learn A*
>>
>>61489811
A* isn't that hard once you understand it. Basically all the search algorithms are the same, just that the function to determine which node in the frontier to expand is different.
>>
>>61489811
def findShortestPath(self, target):
DIRECTIONS = [State.goNorth, State.goSouth, State.goEast, State.goWest]
if target in self.snek:
return None
old = [self]
new = []
while len(old) > 0:
print(len(old))
for oldState in old:
for direction in DIRECTIONS:
newState = direction(oldState)
if newState is not None and newState not in new + old:
new.append(newState)
if (newState.x, newState.y) == target:
return newState
old = new
new = []
return None


Without "newState not in new + old" it hogs up my 4GB RAM in depth=~15, with it it chokes in performance, and no, I'm *NOT* writing it in C, the memory management would be insanely difficult since I'm making a *PERFECT* snake AI and all map has to be recorded.
>>
>>61489756
you can use futexes etc as usual in mmap()ed regions, just like clone()d processes (aka threads), it's not that hard

>>61489758
use a file-backed mapping
int fd, len;
void *mem;
struct statbuf buf;

fd = open("/tmp/somefile");
fstat(fd, &buf);
len = buf.st_size;
mem = mmap(NULL, len, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
>>
>>61489841
Thank you for encouragement. It just sucks my plan I made yesterday failed and this hobby project will take two days instead of one.
>>
>>61489866
Well, based on your code here >>61489845
it seems like one huge cluster fuck. May I suggest separating things into different functions? It would make your program more readable and more reusable. You should use an object to model a tree and store each possible state in a node of the tree. It would be then much easier to implement the A* tree. I think I got an A* class you can use.
>>
>>61489866
>>61489904
Actually it is kinda a cluster fuck because it is separated into three files and was designed to be a general algorithm. Anyway A* is easy once you understand how search algorithms *actually* work.
>>
>>61489904
>it seems like one huge cluster fuck. May I suggest separating things into different functions?

How would you refactor and divide it (for BFS, that it currently implements)? I thought it was fine until you said it's crap. Here's the whole thing that works (but don't increase that map size, that's why I have to switch to A*):

https://pastebin.com/48DhSawL
>>
>>61490077
>>61490077
>>61490077
>>
>>61490043
You should use pickle to store data, as it allows you to complete serialize a class in a file and then retrieve that class again in a new session.
>>
>>61489518
I caught it turning null literally immediately after object construction:
RamfsFile ctor 2, vtable: 0xc01145bc
alloc_inode 0xc0911020 vtable: 0x00000000


RamfsFile ctor:
RamfsFile::RamfsFile(u64 ino, RamfsInstance *instance) : RamfsInode(ino, instance) {
printk << "RamfsFile ctor " << ino << ", vtable: " << *reinterpret_cast<void**>(this) << '\n';
}


Code that calls above ctor (T is RamfsFile):
auto *inode = new T(ino, this);
// objects vtable pointer and surrounding content get mysteriously zero'd between the above line and the below line
printk << "alloc_inode " << inode << " vtable: " << *reinterpret_cast<void**>(inode) << '\n';


The vtable pointer was valid in the constructor, and then immediately after the constructor I print it out again and it's null. Keep in mind that it gets zero'd like this at random points, I just happened to catch it here this time.
What could be causing this? This is fucking weird.
>>
>>61486964
> images
Definitely not /prog/.
Thread posts: 332
Thread images: 21


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