[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
/dpt/ - Daily Programming Thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

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

Thread replies: 255
Thread images: 24
File: ew.png (389 KB, 934x1000) Image search: [Google]
ew.png
389 KB, 934x1000
What are you working on, /g/?

Old thread: >>52117324
>>
>not programming a virtual machine in a dynamic strongly typed programming language
Just off yourselves lads
>>
If you can't compile to amiga, your language is shit.
>>
If you use Python, fuck off
>>
If you don't like Python, fuck off
>>
If you don't use Python, fuck off.
>>
>java isn't shit
>python isn't shit
>C is shit
>javascript isn't shit
>what is sepples

newfags get out
>>
>>52120164
>C
>not outdated shit
grandads get out
>>
>>52120164
>newfag
Only /b/ users, aka new users use that term.
>>
>>52120182
See >>52119708
>>
File: 452.gif (705 KB, 500x500) Image search: [Google]
452.gif
705 KB, 500x500
Disabled the native extension and making my own, haha.
>>
>>52120207
that post only proves the outdatedness
>>
>>52120207
There's a JVM implementation written in C# anon.
>>
>he's dumb enough to get type errors
lmao staticfags get out
>>
>>52120252
Not him, but I guarantee that it's not as good.
JVM has an amazing JIT compiler
>>
>>52120271
>Uncaught TypeError: undefined is not a function
dynamic typing
>>
Will the anti-python meme ever end?
>>
>>52120334
no
                                                                           because it's not a meme
>>
>>52120351
this
>>
File: slides to.jpg (35 KB, 561x365) Image search: [Google]
slides to.jpg
35 KB, 561x365
Last time on /dpt/
>>
>>52120364
Tadpole operator is still my favourite.
>>
What's with all the people who think that acknowledging the fact Python/Javascript is shit means you have to believe C is the only good language?

Do they think Python/Javascript are seriously comparable to even Java, let alone good languages?
>>
>wahh, Python programers are writting all the cool stuff while I'm stuck with shitty toy programs forever
Classic C fags
>>
>>52120423
Python is at least somewhat useful. Java is a heaping pile of shit and I'd never use it for anything. C++ does everything Java does, and better.
>>
>>52120494
no one is discussing C. There's are piles of languages better than python.
>>
File: KotqBAq.png (59 KB, 661x768) Image search: [Google]
KotqBAq.png
59 KB, 661x768
>>52120364
>Last time on /dpt/

Someone said static typing and the end of the thread exploded
>>
>>52120631
Python ruins everything, even /dpt/ threads.
We used to have more people calling them out on their shitty language.
>>
File: typing.png (41 KB, 579x462) Image search: [Google]
typing.png
41 KB, 579x462
Actually this image is inaccurate since generally in type theory there's no mutable variables at all. So there's neither static nor dynamic typing, or maybe you could say that it's impossible to have dynamic typing.

Still, though, I'd say that's a good argument for static typing because mutable variables are less than ideal IMO as a type theory guy.
>>
>>52120676
Those people left in shame because they couldn't get anything done, having to preppend everything with types
>>
File: laserCleaning.webm (2 MB, 500x282) Image search: [Google]
laserCleaning.webm
2 MB, 500x282
Ask your beloved programming literate anything.
>>
>static typing = no type inference
lmao, this argument is so tired and false
>>
>>52120704
Why did you change the original picture (and add Comic Sans?!!!)

It is supposed to say weak and strong typing.
>>
>>52120745
dynamic or memetic?
>>
Daily reminder that if your language of choice is not on this list you should probably give up and kill yourself:
- C++
- C#
- Lua
- Python
- Elixir
- Haskell
- Bash
- Clojure
- D
>>
>>52120771
I didn't change it, that's how I've always seen it. Though yes, it applies in that way as well.
>>
test
>>
>>52120780
My eternal basketball american
>>
>>52120732
You don't need to do that with a decent statically typed language.
>>
>>52120771
It always said static and dynamic. Though image might be changed, not sure.
>>
File: byUzsFP.jpg (427 KB, 1600x1200) Image search: [Google]
byUzsFP.jpg
427 KB, 1600x1200
>>52120773
Thank you for your question. What are you referring to ?
>>
>>52120804
typing
>>
>>52120780
you would add C if you were serious
>>
What am I doing wrong here?

SELECT
forum_users.UName AS `Name`,
Count(forum_posts.PAuthorId) AS Posts,
Count(forum_threads.TAuthorId) AS Threads
FROM
forum_posts
INNER JOIN forum_users ON forum_posts.PAuthorId = forum_users.UId
INNER JOIN forum_threads ON forum_posts.UId = forum_threads.TAuthorId
GROUP BY
forum_users.UId


It gives me the username and posts but thread is being the same number as posts, where did I mess up
>>
>>52120820
C would have made it to the list if it was serious.
>>
>>52120820
Why would C be anyone's 'language of choice'?

There's nothing wrong with needing it for some things but why in the world would you prefer that over the other great options available?
>>
>>52120820
>he fell for the C meme
>>
>>52120851
Autism
/g/ memes
Baby duck syndrome
>>
>>52120851
See the reasons in >>52119708

Also, embedded systems, firmware, drivers, etc
>>
>>52120866
>Baby duck syndrome
You can't tell me people here have it?
>tfw started from DarkBasic to VB to C++ to Java back to C++ and now in love with Python
>>
>>52120880
>See the reasons in >>52119708
>Also, embedded systems, firmware, drivers, etc
So because of memes then?
>>
File: RpCohdc.gif (2 MB, 250x360) Image search: [Google]
RpCohdc.gif
2 MB, 250x360
>>52120812
Static typing is not better or worst than dynamic typing. Any programming literate wannabe should read this http://danluu.com/empirical-pl/

Although, for learning programming, i would favor dynamic typing.
>>
>>52120164
>>java isn't shit
epic meme
>>
>>52120914
Great answer, you too are my nigga
>>
>>52120906
>everything not web-development are memes
Nice meme you have there.
>>
>>52120820
C is useful for some things but really it's very simple and requires a lot of work for little result. his list is shit but such a list doesn't necessarily need C in it imo
>>
https://challenge.synacor.com/

Come on lads, don't be lazy
>>
>>52120990
>provide your details before we tell you what it is
>provide your details at all
no thanks
>>
>>52121011
That's a remnant of the competition. You can put anything in e-mail field, it's just used for logging in and tracking
>>
>>52121042
>download
lol no
>>
>>52120833
try this:
SELECT
forum_users.UName AS `Name`,
Count(forum_posts.PAuthorId) AS Posts,
Count(forum_threads.TAuthorId) AS Threads
FROM
forum_posts, forum_threads
INNER JOIN forum_users ON forum_posts.PAuthorId = forum_users.UId
INNER JOIN forum_threads ON forum_posts.UId = forum_threads.TAuthorId
GROUP BY
forum_users.UId
>>
meme test
>>
>>52121086
>
forum_posts.UId

that was a mistake

tried your way with

SELECT
forum_users.UName AS `Name`,
Count(forum_posts.PAuthorId) AS Posts,
Count(forum_threads.TAuthorId) AS Threads
FROM
forum_posts, forum_threads
INNER JOIN forum_users ON forum_posts.PAuthorId = forum_users.UId
INNER JOIN forum_threads ON forum_threads.TAuthorId = forum_users.UId
GROUP BY
forum_users.UId


gives me

[Err] 1066 - Not unique table/alias: 'forum_threads'
>>
File: wChloLG.png (59 KB, 645x731) Image search: [Google]
wChloLG.png
59 KB, 645x731
>>52121188
Thanks.

We're off to a rousing fucking start.

Now with more insignificant words filtered out.
>>
>>52121228
That's what the other anon said tho
>>
>>52120990
import sys,funcs
data=open("challenge.bin","rb").read()
reg=[0,0,0,0,0,0,0,0]
callStk=[]
insI=0
adds=list(funcs.lE(data[i],data[i+1]) for i in range(0,len(data)-1,2))

def r(x):return x-32768

def get(x):
if 0<=x<=32767:
return x
elif 32768<=x<=32775:
return reg[r(x)]
else:
print "Err"
sys.exit()

def sets(x,y):
if 0<=x<=32767:
adds[x]=get(y)
elif 32768<=x<=32775:
reg[r(x)]=get(y)
else:
print "Err"
sys.exit()

def Halt():
print "Done"
sys.exit()

def Set(x,y):reg[r(x)]=get(y)
def Push(x):callStk.append(get(x))
def Pop(x):sets(x,callStk.pop())
def Eq(x,y,z):sets(x,int(get(y)==get(z)))
def Gt(x,y,z):sets(x,int(get(y)>get(z)))
def Jmp(x):return get(x)

def Jt(x,y):
if get(x)!=0:
return Jmp(y)

def Jf(x,y):
if get(x)==0:
return Jmp(y)

def Add(x,y,z):sets(x,(get(y)+get(z))%32768)
def Mult(x,y,z):sets(x,(get(y)*get(z))%32768)
def Mod(x,y,z):sets(x,get(y)%get(z))
def And(x,y,z):sets(x,get(y)&get(z))
def Or(x,y,z):sets(x,get(y)|get(z))
def Not(x,y):sets(x,32767-get(y))
def Rmem(x,y):sets(x,adds[get(y)])
def Wmem(x,y):sets(get(x),get(y))

def Call(x):
global insI
callStk.append(insI+2)
return Jmp(get(x))

def Ret():
if callStk==[]:
Halt()
else:
return Jmp(callStk.pop())

def Out(x):sys.stdout.write(chr(get(x)))

def In(x):
try:
char = sys.stdin.read(1)
except IOError:
char = sys.stdin.read(1)
sets(x,ord(char))

def Noop(): pass

opcodes={0:[Halt,0],1:[Set,2],2:[Push,1],3:[Pop,1],4:[Eq,3],5:[Gt,3],6:[Jmp,1],
7:[Jt,2],8:[Jf,2],9:[Add,3],10:[Mult,3],11:[Mod,3],12:[And,3],
13:[Or,3],14:[Not,2],15:[Rmem,2],16:[Wmem,2],17:[Call,1],18:[Ret,0],
19:[Out,1],20:[In,1],21:[Noop,0]}

while 0<=insI<len(adds):
args=list(adds[insI+1+i] for i in range(opcodes[adds[insI]][1]))
a=opcodes[adds[insI]][0](*args)
insI=insI+len(args)+1 if a==None else a
>>
>>52121262
No whitespace because of 4chan post character limit
>>
>>52121262
#returns the decimal equivalent of a hex number, any case allowed
def h2d(n):
n=n.upper()[::-1]
total=0
for i in range(len(n)):
cL=n[i]
total+=(int(cL) if cL.isdigit() else ord(cL)-ord('A')+10)*16**i
return total

#returns a 2-digit-length uppercase hex equivalent of a 8-bit decimal number
def d2h(n):
a=hex(n).upper()[2::]
return "0"+a if len(a)==1 else a

#takes low-byte(as char) and high-byte(as char) and returns the decimal
def lE(a,b): return h2d(d2h(ord(b))+d2h(ord(a)))
>>
>>52120130
>>52120137
>>52120145

Kek
>>
>>52120631
Is that a 4chan desktop client?
Is there a download for it?
>>
F# fag: can you justify the branding of do-notation as a "computation expression" that is then shilled as being better than do-notation?

I know you listed all these reasons:
>monads
>monads+
>monad transformers
>applicatives
>alternatives
>monoids
But all monads are applicatives, and all monads+ are alternatives, and monoids just don't fit at all because they aren't functors.
>>
python is bad and you should FEEL bad
>>
>>52121357
No, it's just a small tool to pull generals from /g/ and get the most-used keywords.

I am working on a 4chan desktop client, though. I'll post it when it's more done.
>>
cgo is actually pretty fast. I was expecting seconds of delay, but it's not that bad tbqh.
#include <aubio/aubio.h>

static int win_size = 1024;
static int hop_size = 256;

int main(int argc, char *argv[])
{
aubio_source_t *source = new_aubio_source(argv[1], 0, hop_size);
aubio_onset_t *onset = new_aubio_onset("default", win_size, hop_size,
aubio_source_get_samplerate(source));
fvec_t *in = new_fvec(hop_size);
fvec_t *out = new_fvec(2);

while (1) {
int read;
aubio_source_do(source, in, &read);
aubio_onset_do(onset, in, out);
if (read != hop_size) break;
}

del_aubio_source(source);
del_aubio_onset(onset);
del_fvec(in);
del_fvec(out);

return 0;
}

Result: 5.144s 5.135s 5.133s
package main

// #cgo LDFLAGS: -laubio
// #include <aubio/aubio.h>
// #include <stdlib.h>
import "C"

import (
"os"
"unsafe"
)

const (
winSize = 1024
hopSize = winSize / 4
)

func main() {
file := os.Args[1]
cfile := C.CString(file)
acfile := (*C.char_t)(unsafe.Pointer(cfile))
defer C.free(unsafe.Pointer(cfile))

method := "default"
cmethod := C.CString(method)
acmethod := (*C.char_t)(unsafe.Pointer(cmethod))
defer C.free(unsafe.Pointer(cmethod))

source := C.new_aubio_source(
acfile,
0,
C.uint_t(hopSize),
)
defer C.del_aubio_source(source)

onset := C.new_aubio_onset(
acmethod,
C.uint_t(winSize),
C.uint_t(hopSize),
C.aubio_source_get_samplerate(source),
)
defer C.del_aubio_onset(onset)

in := C.new_fvec(C.uint_t(hopSize))
defer C.del_fvec(in)

out := C.new_fvec(2)
defer C.del_fvec(out)

for {
var read C.uint_t
C.aubio_source_do(source, in, &read)
if int(read) != hopSize {
break
}
C.aubio_onset_do(onset, in, out)
}
}

Result: 5.217s 5.268s 5.204s
>>
>>52121385
I can't. Because I don't understand them well enough. I know computational expression let you do nice shit with while loops, recursive functions, yield and return keywords. Which makes them pretty powerful. Maybe haskell can do all that, i don't know.
>>
go is in theory a bad language, yet the software developed in go seems to be of higher quality in average than languages that are theoretically superior
assuming that this statement is correct, why would this be?
>>
>>52121406
Very cool, I was going to make one but then I realised I'm too lazy
>>
Hi guys I have a CRAZY idea

How about instead of: arguing over which languages are the best and which are memes

We just discuss programming and if somebody uses a language you don't like, ignore them? So we can have actual discussion.

Crazy idea ikr, but try it
>>
>>52121422
-O3 and -O2 with -march=native shaves off roughly 0.050s. Nothing special.
>>
>>52121519
You're off your rockers mate
>>
>>52120228
Extension of what thing for what purpose, if I may?
>>
>>52121519
It's just baters, bate, and biters. I personally don't care what /g/ thinks of my prog lang preference and will continue to use whatever I'm using.
>>
>>52121604
probably 4chan
>>
Best C++ IDE for Windows?
>>
>>52121422
Looping over the 1st CD of Hibike Euphonium OST in placebo FLAC makes Go run roughly a second longer compared to the C solution.
>>
>>52121674

VS or CLion, in my opinion.
>>
>>52121674
Codeblocks also QtCreator
>>
Rust is clearly based

> no need for null value, be it a pointer or any resource managing class, if it doesn't hold stuff, you don't construct it
> no need to check against it in the destructor, obviously
> variable shadowing, no need for assignment operator
> if you get moved, you are not destructed
Sepples PLEASE

No tail recursion tho
>>
File: pprof001.png (58 KB, 1000x729) Image search: [Google]
pprof001.png
58 KB, 1000x729
>>52121422
Last post of my Go exploration. Here's the visual result of pprof.
>>
>>52121916
Rust's safety guarantees are barely better than what you can do in C++, though.
>>
>>52121916
tail recursion is useless when you have for/while statement.
>>
>>52121960
>implying lots of algorithms aren't way easier to write recursively
>>
Want to learn programming soon, what languages are actually -good-? I've been interested in Java for awhile and I want to learn it, and I have started to take Udacity, Codeacademy, and Udemy classes for Java- but I have a gut feeling that those 3 teaching websites are meme tier.

Help me, /dpt/. Tell me about the various programming languages and where I can learn them.
>>
Man, fucking C# implementation in Unity is a goddamn mess that has no respect for what C# stands for. What the fuck.
>>
>>52122061
http://learnyouahaskell.com/
>>
>>52120851
It's the language I'm most comfortable with, and I've written a bunch of little libraries and code I can reuse to quickly create simple programs including guis, network, containers, string handling, reading/parsing various file formats, etc making me very productive in C.
>>
>>52122111
For real, Anon?
>>
>>52122061
See >>52120780
>>
>>52122162
Well, what's so good about those specific languages?
>>
>>52122087
What do you mean?
>>
>>52121960
Tail calls are not necessarily recursive. Cant think of a "use case" altho I'm sure I've already seen one
>>
>>52122199
EVERYTHING!
Even the goddamn naming conventions aren't followed properly with properties being camel-cased.
Simple things like inheritance aren't done properly. The default template generates a component with "void Update()" and "void Start()" which show no relation to MonoBehavior. Properties can't be serialized, just fields, therefore they're almost never used. They've reduced my beautiful language to some sort of nigger tier script shit ;__;
>>
>>52122199
>>52122295
It's also C# 2.0, don't forget that.
>>
>>52121209
pls
>>
>>52121949
Can you really implement guarded access for example? Honest question
>>
>>52122356
What do you mean by "guarded access"?
>>
>>52120164
>C
>not shit
Choose one.
>>
>>52121916
All of this is available in C++ so I don't get your point.
>>
File: 1362359298629.png (123 KB, 318x470) Image search: [Google]
1362359298629.png
123 KB, 318x470
>Get dream job interview
>Hit all the questions perfectly
>Get along amazingly with the interviewer
>Told that they love me and I have all the skills needed and definitely a top candidate but since I only have 3 years of experience they were going to go with someone else


/prog/ you work your ass off and can blow people away 10 times your senior. I can out program any person with 7 years more experience and design is a specialty. They can love you but in the end of the day it didn't matter
>>
File: penn_jillette.jpg (78 KB, 560x747) Image search: [Google]
penn_jillette.jpg
78 KB, 560x747
>learn C#
>do project
>want to delete instance of class
>you can't
>you can't control the magical garbage man either
>you're at the mercy of the trash man

I'm too much of a control freak and I don't even understand how the trash man works, off I go to learn C++
>>
>>52122371
A lock_guard or unique_lock in Sepples just deals with unlocking the mutex. In rust, the object you protect is inside the Mutex object, and you have to construct a MutexGuard and *dereference* it, which you can't do however you want, to access it.

https://doc.rust-lang.org/std/sync/struct.MutexGuard.html
>>
>>52122476
Why do you need to delete an instance of a class? You are probably doing something stupid.
>>
>>52122061
OCaml is actually good. I think it's the only language I'm comfortable to call good. The only wart it has is that its default tooling is shit (right down to the standard library), but since everyone uses Core and its tools instead, it really doesn't matter. Aside from that, it has two flaws: 1- no multicore without multiprocessing (this is going to be fixed next month and there's a fork you can use right now that has real multicore). 2- GC is always on (but it's a very high-performance GC), so you couldn't use it in very small devices for hard realtime tasks.

ATS is what you should use for hard realtime tasks in very small devices. It's too unwieldy to use in the general case, but it's much higher-level than C while retaining its speed, and it uses linear types and proof transformers to get rid of the GC while ensuring no memory-related bug can possibly happen.

With ATS and OCaml, you have the perfect set of tools for any kind of application.
>>
>>52122476
Don't touch the trashman.
>>
>>52122467
Tell me about the questions and your past experience.
>>
>>52122490
why not? it served no purpose anymore
>>
>>52122492
ATS is awful to write though. I'm trying to improve on its ideas, myself.
>>
>>52122482
So, just overload the dereference operator in a class called MutexGuard. Wow, so hard!
>>
>>52122476
Just implement IDisposable

and you can set all of your dispose options with the GC object and dispose properties
>>
File: bane programming.png (1 KB, 253x76) Image search: [Google]
bane programming.png
1 KB, 253x76
>>
>>52122476
>gpu code
> have to clear up buffers during the dtor
>C# virtual machine CLI garbage collection bullshit
>you have no way of knowing a confident time in which your instance's destructor is going to be called
>gpu will not delete buffers until the magical garbage man happens to run into your instance and delete it
>user closes the application early
>this garbage collection never happens.
>gpu gets leaked memory
>>
File: le shig pig.jpg (4 KB, 180x180) Image search: [Google]
le shig pig.jpg
4 KB, 180x180
>>52120164
Give me one reason I should use one of your meme languages instead of python

Python is straightforward and is robust for the tasks I need to perform
>>
How do I into writing a C compiler? Or is this not a task meant for mortal men?
>>
>>52122512
>ATS is awful to write though.
Yes, that's why I said
>It's too unwieldy to use in the general case

> I'm trying to improve on its ideas, myself.
Got some whitepaper or a repository somewhere?
>>
>>52122529
Python is fine, and as long as you keep shipping working products, you are far ahead of most people on this memeboard anyways.
>>
>>52122520
>I have no idea how to write GPU code!
>>
>>52122530
Bison + flex + x86 assembly.
>>
>>52122508
Let the GC handle it for you. It's not you business.
>>
>>52122418
No mate

Let me define "destructor elision" if you have a unique_ptr, and you call move on it, someone else is responsible for the contents, and your destructor should be a no-op. In Sepples, the move constructor has to set the old object to a conventional "null" value so its destructor knows at run time not to free anything. Perhaps sometimes you get optimisations magically, but this isnt as elegant. Also you can legally use a null object in between moving an destructing, no way you're implementing this safety guaranty M8.
>>
>>52122529
>slow as balls
>no parallelism
>dynamic typing
>most libraries are dogshit
>20 libraries for the same task anyway
>significant whitespace making collaboration a mess

But then again, you unironically called python "robust", so you can't be "performing" any "task" more complex than fizzbuzz.
>>
File: 1430424854172.jpg (20 KB, 345x243) Image search: [Google]
1430424854172.jpg
20 KB, 345x243
>>52122562
how can you be in control of your life if you can't even control your own code?
>>
>>52122546
>have a gpu resource wrapper for textures or vbos or whatever
>the dtor calls glDeleteBuffer or whatever
>dtor never gets called predictably to ensure a proper and timely cleanup of resources
>>
>>52122566
>backpedaling this hard
>still being wrong
smH 2bh Senpai.
>>
>I'll just wrap this GResource thing
>Surely it won't be bad
>What is this GIO anyway
>Oh it is FUCKING EVERYTHING
Yea I am not going to be touching GIO think you very much
This still is so ugly to write.

//Resource is a representation of GIO's GResource
type Resource struct {
*glib.Object
}

func (r *Resource) native() *C.GResource {
if v == nil || v.GObject == nil {
return nil
}
p := unsafe.Pointer(v.GObject)
return C.toGResource(p)
}

func ResourceLoad(filename string) (*Resource, error) {
cstr := C.CString(filename)
defer C.free(unsafe.Pointer(cstr))
var err *C.GError
res := C.g_resource_load((*C.char)(cstr), &err)
if res == nil {
defer C.g_error_free(err)
return nil, errors.New(C.GoString((*C.char)(err.message)))
}
obj := &glib.Object{glib.ToGObject(unsafe.Pointer(res))}
p := &Resource{obj}
runtime.SetFinalizer(obj, (*glib.Object).Unref)
return p, nil
}
>>
>>52122513
I'm not sure you can make it as safe... You're probably right tho, I've been a bit bold with my claims. Still, lifetime checking is cool
>>
>>52122594
>I have not the slightest clue how to write gpu code!
>>
>>52120914
>>52120804
>>52120745

>the programming literate prefers dynamic typing
TOP KEK
Enjoy your slow programs :3
>>
>>52122558
Isn't bison a meme? Writing a parser is really fucking easy.
>>
Quick question.
What distro should I DL to just code, compile and run simple C code ?
I tried Mint but this shit didn't have stdio.h.
>>
>>52122578
>But then again, you unironically called python "robust", so you can't be "performing" any "task" more complex than fizzbuzz.

Ayo hol up, we got a Real Coder ® here
>>
>>52122586
You're letting minor psychological issues get in the way of delivering finished products. You're not fit to be a programmer.

Prove me wrong and implement what you were doing in C++. If you can do it in 2 weeks I'll concede.
>>
you fags are not /writing gpu code/, you're /interfacing with the gpu/ at best, git gut fags
>>
>>52122482
That's not special for C++. Just overload the deference operator to give a const reference for const objects and a mutable reference for mutable objects, construct it with perfect forwarding of the contained object's constructor parameters.

>>52122531
Not yet, no. Still need to decide mainly how I'm going to model linearity.

>>52122566
You're just arguing that Rust makes it more convenient, which is true in certain cases, but it's not strictly safer.
>>
>>52122630
Arch, and avoid anything based on Debian. The idea to separate libs in two part user and dev is so stupid.
>>
>>52122620
Sure, if you enjoy wading through 10k lines of spaghetti code and implementing proper erroring information on back-tracking parsers every time you want to implement a single syntax element.
>>
How much do most of you faggots make ITT?
>>
>>52122633
Kek, it's not hard to rewrite a project from C# to C++. I've rewritten C++ projects to C before and it's at least 5x as time-consuming, mostly because retarded C++-ucks leave their code too vague and I need to go in and specify a bunch of shit manually.
>>
I want to add a simple login system and user database to my c++ application but I have no idea where to start. Any suggestions dpt? Please
>>
>>52122630
Gentoo GNU
>>
>>52122647
Are you kidding me? A few threads ago I asked for a linux distro recommendation that was lightweight, low maintenance, for doing some unix programming, and a bunch of people recommended Debian, except OneTripFag who recommended Ubuntu.

I don't want to touch Arch because shit breaks too often.
>>
>>52122657
bout three fiddy
>>
>>52122596
Fuck no! The existence of this null value is a byproduct of the way move semantics are defined in Sepples and of their interaction with destructors and scoping rules, and it's SHIT! It complicates the writing of resource owning classes, and it fucks up safety, can you see that FFS?
>>
>>52122696
>I know less about what I'm talking about than the ocean knows about the desert!
>>
>>52122685
>I don't want to touch Arch because shit breaks too often.
ebin meme

~ Posted from my 3 year old Arch setup ~
>>
>>52122657
I make about $43,000.
>>
>>52122295
Well I'd imagine at least some of that is done for performance reasons. I don't know why properties would be camal case though
>>
>>52122685
Debian is absolute dogshit. Either you have libraries from a decade ago (good luck compiling anything with gcc 3.5 when the current version is 4.9, especially when you can't get libdicks-18.7 and the latest version on debian is libdicks-0.1.0), or everything breaking every time you so much as touch the mouse because trying to update anything at all causes a massive dependency chain which requires updating the entire system to unstable or worse - testing.
>>
>>52122261
he said tail recursion, no ?
>>
>>52122720
The only people who'd use arch seriously are 3 years olds.
C O N F I R M E D
>>
>>52122529
>Python is straightforward and is robust for the tasks I need to perform
because other languages are more robust and more productive to work with. If you can't be bothered to learn anything else though, stick with python.
>>
>>52122658
I hope you're not keking at me. I know it's not that hard relative to other ports. But it's harder than someone complaining about not freeing his own objects in a managed language can handle.
>>
>>52122746
I'm usually not pro-debian but stop spreading misinformation, the stable version currently has GCC 4.9 in the repos and you can trivially build 5.2 if you need it.

>https://packages.debian.org/jessie/gcc
>>
>>52122261
thunks or wrappers.
int foo(int x, int y)
{
return bar(x, y, 500);
}

As a tail call you just load the 500 argument in the next register and jump to bar and keep the old return address of whoever called foo.
>>
>>52122787
>just build packages manually lmao
Gaybian shill pls go.
>>
>>52122717
Educate yourself child
>>
>>52122746
What if I want to use LLVM/clang? Is that OK?
>>
>>52122833
This. Closures are garbage without tail recursion.
>>
>>52122858
At least you're done humiliating yourself and you're resorting to throwing "n-no u's" around. It's an upgrade.
>>
>>52122857
Building stuff manually is part of programming no matter what platform son...
>>
where is the current meme parser?
>>
>>52122862
It's even worse. Unlike GCC which is already fantastic, clang can't compile many forms of valid C and C++, so you always want to be on the latest to-the-day version. On top of that, llvm and clang's APIs have breaking change with every single release so if you're using them, sticking with an old version is suicide. Beside, this doesn't help the library situation.
>>
>>52122901
OK so is my only option Arch or Gentoo? Surely there's a sane environment that I can easily set up to compile C/C++ on Linux?
>>
>>52122891
parsec.
>>
File: sadloli.png (570 KB, 1080x1600) Image search: [Google]
sadloli.png
570 KB, 1080x1600
>>52122615
Sure

Scheme Gambit:                  1.932229635 seconds time elapsed
Common Lisp SBCL: 3.015000773 seconds time elapsed
Racket: 3.618877176 seconds time elapsed

C++ G++: 4.659448453 seconds time elapsed
C++ clang++: 5.518077517 seconds time elapsed
D LDC: 6.347934615 seconds time elapsed
Rust rustc: 6.583698221 seconds time elapsed
C clang: 9.971914301 seconds time elapsed
Go gccgo: 17.438276362 seconds time elapsed
>>
>>52122971
>the programming literate can't even write proper c/c++ code
TOP KEK
Enjoy your slow programs :3
>>
>>52123009

It was better when the C++ versions took a half hour.
>>
>>52123009
he's benchmarking closures
>>
>>52122971
I'd like to see the source code for these programs.
>>
>>52122994
I ran it on my laptop for like 4 months. Constant emerge conflicts pissed me off. Is Arch actually better or do I still need to waste time resolving conflicts?
>>
>>52122530
read the dragon book.
>>
>>52123023
>>52123024
desu why would you need a closure. Add the function into the namespace/class/etc you're working in.
>>
>>52122916
Arch has issues in that you can't lock a package to a specific version unless you have already downloaded that version in the past. Gentoo doesn't have that issue. Other than that, they're very similar in that they both allow you to have as up-to-date a package as you want without having to put your entire system at risk, and they allow you to directly patch libraries during install at many granularity levels. This is useful to hot-patch critical bugs in development libraries, which happens very often when working in some languages like C or python.
>>
>>52122971
no ocaml/f#/haskell?
are you sure you're a programming literate?
>>
>>52123040
And the optimization flags, and the machine this was run on, and the version of the corresponding libraries (such as the stdlibs), and the tasks running in the background, etc, etc.
>>
>>52122646
Thanks for having an actual discourse while responding to me. unlike >>52122872

Yes, you have a safety guaranty involved. Consider this:
// just for moving in v
fn discard(v: Vec<i32>) -> i32 { v[0] }

fn main() {
let mut v = vec![1, 2, 3];
assert!(discard(v) == 1);
v[2] = 4; // compilation error: use of moved value
}

and that:
#include <vector>
using std::vector;

#include <cassert>

int discard(vector<int> v) {
return v[0];
}

int main() {
vector<int> v = {1, 2, 3};
assert(discard(move(v)) == 1);
v[2] = 4; // Segmentation fault (actually /dpt/'s favourite: undefined behavior)
}
>>
>>52123129
What if i just need a decent standard library and an up-to-date compiler? I don't care about using other people's shitty libraries, outside <stdio.h>. I'll be writing pretty much everything from scratch.
>>
Has anyone here ever written a kernel?
If so, post pics.
>>
>>52123126
closures are a very nice notation for creating anonymous structs
>>
File: kernel-of-wheat1.jpg (238 KB, 612x792) Image search: [Google]
kernel-of-wheat1.jpg
238 KB, 612x792
>>52123218
I'm sorry.
>>
>>52123240
Post sauce?
>>
>>52123191
inb4 you could write a static analysis tool that says use of moved value
It depends. after being moved from, v is still in a valid state and some uses are permissible, but not others, for example:
v = {4, 5, 6};

inb4 it's just redefinition,
 v.append({4, 5, 6}); 
would do the exact same thing since v is now empty.

Whereas in Rust, you just shadow it with whatever you want, which is much, much simpler and much, much cleaner. I know the Core C++ Guidelines exist and they state the first inb4, but that's not going to stop me for arguing that Rust is interesting.
>>
>>52123218
kernel
>>
>>52123344
Biology textbook, mister consecutive dub dubs with stuttering.
>>
>>52123207
>What if i just need a decent standard library and an up-to-date compiler?
Then you want arch or gentoo because other distros would require upgrading your entire system to an unstable state to get that.
>>
>>52123395
Does wheat go well with cellulose?
>>
currently going through Codecademy' s full stack web dev track

rushing the interactive courses, then going to do the projects as a review

html/css
javascript
jquery
angularjs
ruby
RoR
RoR authentication

do you like me, /g/?
>>
>>52123207
Then you download and compile GCC, takes a few minutes at worst.
>>
>>52123443
>full stack web dev
Take a guess...
>>
>>52123191
Say the move constructor for a vector was implemented to swap the storage buffers and then reset the moved-from object's size to zero. Obviously, you still can't use things like subscript because that has a precondition. But you can use push_back, which doesn't have any precondition, and you would have the benefit of not having to reallocate as much.

With Rust you have a loss in flexibility for the gain in safety. Neither language has the type system to verify the safety of "preconditionless" methods on moved values, unfortunately. In a dependently/refinement typed language you would simply have to pass the proof that the index is less than the size to the subscript anyways, and you could use a moved value just fine.

>>52123366
Can shadowing reuse the memory like I just explained?
>>
>>52123443
Wrong general, this is a programming general, not web development general.
>>
>>52122630
>>52122862
>>52122916
FreeBSD
>>
Is there a good website who just lists all existing javascript frameworks ?

I want to see if there's anything about anything.
>>
>>52123479
>shilling for free bullshit distribution
>>
>>52123628
https://en.wikipedia.org/wiki/Comparison_of_JavaScript_frameworks
>>
>>52123207
Any fucking distro will work.
>>
>>52123191
can you explain how move() works and what is going on here to someone who has a good understanding of c++ prior to c11 or c14 whenever this was implemented?
>>
>>52123783
It's basically an optimization for what otherwise amounts to "copy X to make Y but don't keep using X afterwards".
>>
>>52123465
Agreed.

Code:
fn main() {
let mut v = vec![1, 2, 3];
assert!(discard(v) == 1);
let mut v = vec![4, 5, 6];
v[2] = 4;
}


In line 4, a new definition for the variable name v shadows the last one, which is entirely useless anyway because it has been moved from (I should have been explicit on what shadowing is) The new definition doesn't have to be a mutable vector of 32 bit ints, it could be anything.

What this code allocates in my understanding:
- allocate a buffer of unspecified size for the {1, 2, 3} elements when constructing the first v of main,
- move that same buffer when constructing the parameter of discard, and free it when discard finishes,
- allocate a second buffer for the second one, and we're done. So I think this achieve minimal dynamic allocation.

Now you're saying that, in the C++ version when being reset, v in main would get some storage handy? (It clearly doesn't happen in Rust) Yes in that case, you would use it when re-using v, but that would still be 2 allocations, and having "empty" vectors carry storage would be more of a huge potential for waste, if main didn't reuse v, for example, so I think implementations don't do that.

If we want to cut it down to one, after being destroyed, the second v could send its buffer to the first (works out chronologically). but I'm divagating, this is the job of the dynamic allocator.

So yeah, those are my thoughts
>>
>>52123871
There's definitely upsides and downsides to both the Rust way and the C++ way, but I think in general I would prefer to do things the Rust way.

Ideally, the language would have a greater concept of linearity and ultimately let you choose, where the C++ way could be done with an explicit swap and some clearing option that's dependent on the class.
>>
Is openmp a substitute for me uglifying my algorithms to make them multithreaded?
>>
>>52123967
No.
>>
>>52123950
Ya right.

[insert strange rant about the subtle difference between an empty vector and a null vector]
>>
>>52124112
one has a size member equal to zero
>>
>>52124112
>empty vector and a null vector
They are not the same thing except for a zero dimensional space.
>>
>>52123967
Do want to run your code on only one platform?
Do you give a fuck about autists and their >muh hiding details, >muh simplification and lack of deeper understanding?
Are your problems task parallel?

If all answers are "No", then go ahead and use OpenMP
>>
infinite list of fibonacci numbers, computed only as needed:
fibs = 0:1:zipWith (+) fibs (tail fibs)
>>
>>52124259
"infinite"
>>
>>52124259
I prefer a proper definition using codata instead of laziness, which can be checked for productivity and thus can be used to make a total language Turing-complete.
codata Stream : Set -> Set where
head : Stream a -> a
tail : Stream a -> Stream a

zip : (a -> b -> c) -> Stream a -> Stream b -> Stream c
head (zip x2y2z xs ys) = x2y2z (head xs) (head ys)
tail (zip x2y2z xs ys) = zip x2y2z (tail xs) (tail ys)

fibs : Stream Nat
head fibs = 0
head (tail fibs) = 1
tail (tail fibs) = zip _+_ fibs (tail fibs)
>>
all combinations of letters:
combinations =  (inits . repeat) ['a'..'z'] >>= sequence
elem "meme" combinations -- true
>>
This is probably a stupid question that should be asked in /sqt/... anyway, I can't understand from wikipedia what a closure is, could you guys enlighten me?
>>
>>52124607
a partially applied function

e.g.
add(x,y) = x + y // the full function
add5(x) = add(x, 5) // partially applied
>>
>>52124607
Some stupid shit that functional programmers made up to meme about. It's useless in real code and doesn't optimize well. No serious programmer uses closures.
>>
>>52122405
>>C
>>not shit
>choose two

ftfy
>>
>>52124692
object oriented programming:

object.method(...)
=
objectype::method(&object, ...)

object.method is a closure that binds the first argument
>>
every row in pascal's triangle:
  pascal = iterate (\row -> zipWith (+) ([0] ++ row) (row ++ [0])) [1]
>>
>>52124739
OOP is a meme.
>>
>>52124766
10/10
>>
>>52124607
A closure is a lambda that captures some variable(s) from outside its scope.
int max = input();
// lambda captures "max", making it a closure
collection.filter(lambda(x) { return x <= max; });


>>52124660
Partial application is just one use of closures.

>>52124692
>doesn't optimize well
Literally a function pointer and a pointer to what C calls "userdata". You see it in C all the time, and you can't do any better if whatever is captured is not known at compile time.
>>
All primes, computed somewhat inefficiently (but still quick thanks to memoization):
primes = sieve [2..] where
sieve (p:xs) = p : sieve [ n | n <- xs, n `mod` p > 0 ]
>>
If you're using a language feature that you don't even know how to implement yourself in C, you're a shit programmer and lacking in fundamentals.
>>
>>52124607

This is the mathematical definition
>>52124660

The definition used in most languages are anonymous functions that capture variables from their scope. This is in Lua.
function example(a)
p = function(b)
return a + b
end
return p
end

In the code the function p is declared. It gets the value of a from the local scope, i.e. from the function parameter. The example function return p. So if you called example with 2 as an argument it returns a function that when called with an argument returns the argument plus 2.
>>
File: image.jpg (20 KB, 267x400) Image search: [Google]
image.jpg
20 KB, 267x400
>>52120780
>no Common Lisp
lol
>>
>>52124814
are you like the programming jesus or something

>>52124824
*assembly
>>
>>52124806
I suppose you could theoretically have a version of each higher order function for each possible type of data that you could capture. Most of the time it probably wouldn't be a gain over the void pointer, though.
>>
Why aren't compilers written in assembly? It seems like the goal of every compiler is to be "self-hosting" so that it can compile itself... but doesn't that mean your compiler is only as good as the language it's written in? If you wrote your C compiler in assembly, wouldn't it be better than a C compiler written in C?
>>
>>52124908
performance isn't the most important feature for a compiler, it's optimization (which is necessarily high level)

it's also kind of like a milestone for a language
>>
>>52123218
Ker(p_Z/2Z) = 2Z
>>
>>52124945
(and extensibility, correctness and other stuff ofc)
>>
>>52124945
So basically a C compiler written in Haskell is better than a C compiler written in C?
>>
>>52124908
It's extremely difficult to get better performance in assembly than in C, and even then the potential gains are so minimal that you might as well not have done it in the first place.

Also, what >>52124945 said. C is a horrible language for doing things that compilers have to do, like parsing text and manipulating trees. There isn't a super optimized way to do any of that that C would help you get vs. a higher level language.
>>
>>52124908
You have no idea what self-hosting means.
>>
>>52124766
lambda x: [math.factorial(x) / (math.factorial(x-i) * math.factorial(i)) for i in range(x+1)]
>>
there is literally nothing wrong with python
>>
>>52121697
>FLAC
>placebo
kill yourself
>>
File: George_Lucas_cropped_2009.jpg (143 KB, 604x797) Image search: [Google]
George_Lucas_cropped_2009.jpg
143 KB, 604x797
Is project Euler a meme? I have solved the first 20 problems in 3 hours. Many problems just require a line or two in Mathematica.
>>
>>52125017
Now do it in C. :^)
>>
File: 1450674660389.png (215 KB, 894x894) Image search: [Google]
1450674660389.png
215 KB, 894x894
>>52125013
>Not understanding the point of lossless audio
Kill yourself, pleb.
>>
>>52124972
It would probably run at an almost identical speed and take orders of magnitude less code.

@52125017
This is bait.
>>
>>52124972
Mostly. If it's really esoteric and hard for their developers to understand, maybe not.

Self hosting for languages that have already been self hosted before is kinda just like a nationalistic thing
>>
>>52125004
why is this so ugly
it even has a scrollbar
>>
>>52125035
Yeah, he won't be laughing in 20 years when the rotational velocidensity of his hard drives has reduced his MP3 to shit-tier quality.
>>
>>52125040
This. Self-hosting is just a way to make sure that the language itself is capable, not to necessarily write the best compiler.
>>
>>52125035
320 kbps mp3 sounds fine but 192 and below is shit

depends on the type of music of course
>>
>>52125066
Has someone written a language specifically for writing optimizing compilers in? It seems like it would be a good idea.
>>
>>52125017
the first 20 problems you could say are practice problems. now do the next few hundred.
>>
>>52124399
(define fib-stream
(cons-stream 0 (cons-stream 1 (map + fib-stream (tail fib-stream)))))
(define (fib n)
(define (fib-aux n stm)
(if (= n 0)
(head stm)
(fib-aux (-1+ n) (tail stm))))
(fib-aux n fib-stream))
; or without streams
(define (fib n)
(define (fib-aux a b n)
(if (= n 0)
a
(fib-aux b (+ a b) (-1+ n))))
(fib-aux 0 1 n))
>>
>>52125059
We're diverging from the point of this thread, but it allows you to transcode your stuff into more modern lossy codecs (or any future codecs) without incurring unnecessary losses.
I'll be enjoying my Opus while you're still stuck eating ancient shit.
Thread replies: 255
Thread images: 24

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

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.