[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: 16
File: 1451754656606.png (17 KB, 418x359) Image search: [Google]
1451754656606.png
17 KB, 418x359
are you working on anything /dpt/?

why not?
>>
>>52236960
Dumb frog poster
>>
>>52236960
Programmed all day so burned out atm famalama
>>
based pepe
>>
>>52236960
I need to build sfml for vs 2015 because I dont feel like using my Linux machine or downgrading. I just haven't been doing that.

I'm also building a small neural network in C++. I'm trying to do it without copying other people's code ir getting any help outside of books. Its not really working yet but it'll get there.
>>
File: 1446491311416.png (5 KB, 462x402) Image search: [Google]
1446491311416.png
5 KB, 462x402
Programming == Coding ???
Is writing html and css programming? If it is designing then actual work must come after design (like when you design house before building),so what comes here after design since you already finnished the work with just designing it.
>>
java
>>
java
>>
>>52237024
>>52237034
P O O
O I N
O N L O O
O
O
>>
>>52237014
you dont need to build it
>>
>>52237021
>Programming == Coding ???
no
>Is writing html and css programming?
no
>If it is designing then actual work must come after design
no. web devs don't do actual work. they just throw some shit design together using wordpress and hipster framework
>so what comes here after design since you already finnished the work with just designing it
you charge your client $1000+ for the"work"
>>
>>52237071
>>Programming == Coding ???
>no
Yes. It's the same thing.
>>
>>52237071
>they just throw some shit design together using wordpress and hipster framework
>>
>>52237085
coding html and css isn't programming
>>
Why didn't you guys tell me that you can write android apps in c++
>>
>Year of our Lord and Saviour Jesus Christ 2016
>Not calling yourself a Bit Wizard
What are you doing with your life?
>>
>>52237071
fug you man I write my shit without frameworks(excepts sometimes Bootstrap but thats nothing compared to wordpress or Dreamweaver gaylords)
>>
>>52237103
no one tells you anything useful when it comes to android, you have to look for things yourself
>>
>>52237101
For me it's not coding.
>>
It is recommended to programming on Mac OS X?
>>
Threadly reminder that you should not refer to the act of programming as coding. It is improper and makes you look like a 16 year old

You are a programmer, not a coder

Software Alchemist is GOAT
Developer is okay
Magician is okay
Software Engineer is okay
Software Architect is okay
Code Guru is okay

Archmage is reserved for only the most senior of programmers

Writing in HTML and CSS is not programming, therefor it should be refereed to as designing

oops on the code tag
>>
>>52237131
for the rest of society it is. Have fun with your own personal definitions of common terms though.
>>
>>52237054
>an example of nesting in java
>>
>>52237148
absolutely not unless you develop specifically for iOS
>>
>>52237153
If I ever saw "coder" on a resume, I would trash it immediately. Coder is improper.
>>
>>52237173
What country?

>No web designer dare to say that she/he is coding.
Even when they are writing code?
>>
>>52237071
Agreed on the html and css. There's a reason they have templates and c++ doesn't.
>>
File: SfFv0am.png (259 KB, 359x391) Image search: [Google]
SfFv0am.png
259 KB, 359x391
Threadly reminder that you should not refer to the act of programming as coding. It is improper and makes you look like a 16 year old

You are a programmer, not a coder

Software Alchemist is GOAT
Developer is okay
Magician is okay
Software Engineer is okay
Software Architect is okay
Code Guru is okay

Archmage is reserved for only the most senior of programmers

Writing in HTML and CSS is not programming, therefor it should be refereed to as designing.

All your code must follow NASA’s 10 rules for developing safety-critical code from the first day of development.
>>
>>52237149
>software engineer
Reminder that unless you took the FE or PE certification exams it's illegal to use that title.
>>
>>52237163
what about gnu&linux? Did I make a mistake for deleting Windows and switching exslusively to penguin?
>>
>>52237191
I wouldn't put it on my resume either, because primarily I'm a programmer. But when I'm writing up HTML, CSS or JSON, i am writing code, or coding.
>>
>>52237191
So, I SHOULD be putting hacker on my resume?
>>
File: Re200-41x41-staggered.png (79 KB, 800x600) Image search: [Google]
Re200-41x41-staggered.png
79 KB, 800x600
Writing a 2D Navier-Stokes Finite Difference solver in Python
>>
>>52237212
>not Computer Magus
Fuck off, pleb!
>>
>>52237196
France.

Yes even, otherwise, we, coders/developers/programers, will yell at that person. That words belong to us.

You can use it, when you're doing a transcription (changing of representation of information). But writing HTML or CSS is not changing representation of information.
>>
>>52237196
>web dev
>write code
Good one m8.
>>
>>52237217
gnu+linux is fine for programming
>>
>>52237217
If you want to write efficiently for .NET you are fucked. Other than that you are okay
>>
>>52237245
>non english speaking country giving shit about how english words should be used

>But writing HTML or CSS is not changing representation of information.
Code is encoded information. Which is what HTML and CSS are.
>>
>>52237217
No, you didn't. Just have fun doing nothing else but programming and watching animeme though.
>>
>>52237148
I wouldn't say it's "recommended," but it's not bad for programming. Better than Windows.
>>
>>52236960
Wrong board, frogposter, this isn't /b/.
>>
>>52237296
I do not care. I'm a coder and I will never tolerate that a wed designer usurp our profession.
>>
There is literally no reason to change your OS from Windows to Linux.

>Programing in Windows is better and more eficient
>The system is way more stable and faster
>Millions of programs made exclusively for it

Things that you can do better on linux than on windows = NaN
>>
>>52237331
>he fell for the tech evangelist "coder" scheme
>>
>>52237148
It's still unix with a proper terminal, so better than windows. Get used to making currysoft users butthurt.
>>
>>52237116
for example getAppVsyncOffsetNanos only has 96 search results on google
>>
>>52237331
>frogfag
>proud to be a bottom of the barrel "I was told I was a coder after I drag'n'dropped a few things" coder
Classic
>>
>>52237305
>doing nothing else but programming
what do you mean by this? This is programming thread anyway.
Or you are refering to video games? I stopped playing them while I was still with Windows but I see that many other ways are there to play games on gnu+linux,also the biggest video games platform,Steam,started to natively support gnu+linux, and that has to mean something.
>>
I am reading gopl and I don't particularly understand one paragraph in 6.2.
"If all the methods of a named type T have a receiver type of T itself (not *T), it is safe to copy instances of that type; calling any of its methods necessarily makes a copy. [...] But if any method has a pointer receiver, you should avoid copying instances of T because doing so may violate internal invariants. [...] Subsequent method calls would have unpredictable effects."

Why would this result in internal invariants?
I don't see how this is related to pointer method receivers.
I can see that if you copy a type which has a pointer member that you might cause internal invariants because both values reference the same underlying member, but I don't see how that means that each type which only has method receivers of type T and not of type *T is safe from this.
>>
>>52237331
>I'm a coder
There's nothing special about being a coder. Almost anyone can write code if they need to.

This elitist garbage is why no one likes France.
>>
>>52237345
So if I make a software on Mac OS X I can port it to many other devices like mobiles, PC, Linux, smart tv's and consoles?
>>
>>52237395
>There's nothing special about being a coder.
Yes, but being a fucking good one, is a thing.
>>
>>52237452
>Yes, but being a fucking good one, is a thing.
Agreed. But saying anyone who doesn't do it professionally can't refer to the act of doing it as "coding" is fucking retarded.
>>
>>52237478
Could you rephrase?
>>
>>52237377
Kind of mean video games. I also remember missing certain apps like Ida (although I just checked and they have a linux interface now). If you haven't had remorse switching after a week you'll be fine.
>>
>>52237163
>>52237263
Why is GNU/Linux fine for programming but OS X is not?
>>
>>52237487
It's retarded to claim that "coding" can only refer to people who code professionally.
>>
>>52237509
It's impossible to "code professionally".
>>
>>52237505
Because it's really easy to have a working gcc.

>>52237509
I used incorrectly the word profession. Amateur coders are coders too, but they are amateurs.
>>
Working on a method to convert between bases. I can do it out fine on paper but can't do it programmatically.

Say I wanted to convert 1524 (base 6) to base 10, get the first digit and multiply by 6:

1 * 6 = 6

Then add the next digit

6 + 5 = 11

Then multiply by 6
11 * 6 = 66

Then add the next digit

66 + 2 = 68

multiply by 6
68 * 6 = 408

add final digit
408 + 4 = 412

def b2d(num, base):    
r = 0
for n in str(num):
r += int(n)
r += int(n) * base
print r
print r

b2d(1524,6)


please help
>>
>>52237520
?
>>
>>52237232
Cool.
>>
>>52237504
yeah I am fine with it,I made the switch half a year ago kek
>>
What do people code outside of work/school. I hear people say that they work on personal projects. What kind of personal projects do people do?
>>
>>52237531
>Amateur coders are coders too, but they are amateurs.
So how are most web designers not going to be amateurs coders at worst? Assuming we are talking about designers that build HTML and CSS shit.
>>
>>52237531
It's really easy to have a working gcc on OS X too, and even easier to have a working clang. (not sure why you would want gcc when clang is available)
>>
I don't like the term "coding" either ... but is calling our code "code" acceptable? Personally, even that bothers me. Even more so when it's preceded by "computer," as in "computer code."

But I wouldn't know other word to use. "Program" is an executable, so that'd be incorrec to use.
>>
>>52237561
gayms
>>
>>52237532
def b2d(num, base):    
r = 0
for n in str(num):
r *= base
r += int(n)
print r


not tested
>>
>>52237565
They do not code. They design. GFY.

>>52237571
Working gcc on OS X? How? Downloading it from apple web site where you need a fucking login?
>>
>>52237561
>what do people code outside of work/school
I would prefer if you used the term program instead of code
>>
>>52237617
Just type gcc into a terminal and it will give you a prompt to install it.
>>
>>52237617
>They do not code. They design. GFY.
writing HTML and CSS is coding. Designing the look of the site in photoshop is designing. Designers are charged with doing both these days.
>>
>>52237647
OS X has changed. I will give it a try next time I encounter OS X. And it's a POSIX compliant gcc?
>>
>>52237232
That's pretty neat
>>
>>52237681
GFY
>>
>>52237713
?
>>
>>52237691
It's clang, but you can easily compile the latest gcc yourself afterwards.
>>
>>52237726
I believe that anon is telling you to copulate with yourself.
>>
>>52237726
Go fuck yourself.
>>
>>52237737
I do not understand. Is it easy to have a C compiler which is POSIX compliant (at least as compliant as gcc)?
>>
File: 1393438140456.jpg (179 KB, 1083x720) Image search: [Google]
1393438140456.jpg
179 KB, 1083x720
I /dpt/ would stop repeating itself every single thread.

What are you wearing, /dpt/?
>>
>>52237763
LLVM/Clang is POSIX compliant.
>>
>>52237845
OK. I will try it.
>>
>>52237748
>>52237749
hive
>>
>>52237830
I'm wrapped up on the couch in my jimmy jams :3
>>
>>52237763
>>52237691
>POSIX compiler
What? Isn't the C part of POSIX entirely in libc?
>>
>>52237873
Yes, but libc is Linux, not OS X.
>>
>>52237602
Thanks a lot, it has worked for everything I've thrown at it so far.
>>
>>52236960
Revising for an AI exam, and found out only half the textbook is exam material, I was fucking busting my ass trying to get through it.

Fucking sucks at the moment, have no time for programming anything, the most recent thing I have been working on is my final year project. It's a regression, lexicographic and collaborative filtering platform for online purchasing analysis
>>
>>52237901
>libc is Linux
It most definitely is not. You're probably thinking of glibc and even that runs on more platforms than just Linux.
>>
>>52237913
You're welcome young Padawan.
>>
>>52237901
What the fuck? You can't possibly be this retarded.
>>
>>52237927
Ha yes, you're right.
>>
Gonna need a good tutorial on C#. Spoonfeed me, /g/.
>>
>>52236960

trying to get this going.

Raspberry Pi b, with CY case (shows all the lights properly), 8GB SD card (boot), 16GB usb 2 flash drive. I control this device over ethernet using KODI's web interface. Works great on phone, or other pc's to start/stop things without getting up. OS: Kodi.
>>
>>52237963
google "c# tutorial"
>>
>>52237830
Dress socks, Jeans, waffle shirt writing my machine learning project for school
>>
Object a = 2; 
Object b = 4;
Object c = (Integer) a + (Integer) b;

dynamically typed Java
>>
If I don't need to worry about FILO or FIFO what is the best to use out of the following: List, Stack, or Queue
>>
>>52238060
List I guess. What do you need the data structure to do?
>>
>>52238060
It depends of the problem.
>>
>>52237963

edx
>>
>>52238091
>>52238092
It would be to parallel structures containing something that's like a problem/answer. But I can't use a dict in this context. I'm currently using a queue
>>
>>52238017
That's not dynamic typing.
>>
>>52238124
Yes it is
>>
>>52238135
There is no dynamic type in java.
>>
>>52238115
But what do you need - fast deletion, low memory usage, fast find, fast sort, good concurrency aspects, etc.
>>
>>52238135
The types are completely known at compile time. All you are doing is upcasting an Integer to an Object. That is not dynamic typing.
>>
>>52237830
What are YOU wearing, anon?
>>
>>52238176
I would say low memory usage if anything, and because of that I've strayed away from List<T>
>>
>>52237071
Shit man, there's nothing I hate more than CMSes (wordpress, Joomla etc.). I am a full time web dev and do my systems hombrew-style. Wtf man don't say those things!!!!!
>>
>>52238154
Object

>>52238193
No they aren't. All the compiler knows is that everything is an object. Which basically means, everything is "something". Just like dynamic typing.
>>
>>52238253
What language?
It is sometimes the case (for some language's standard implementations) that a Vector will outperform a list for most operations.
>>
>>52238284
C#
>>
>>52238253
>because of that I've strayed away from List

List is backed by an array, if you are worried about memory usage then change the Capacity property.
>>
typical 0101000001001111010011110100100101001110010011000100111101001111
>>
>>52238276
Object isn't a dynamic type.
>>
>>52238253
List<T> is pretty great for memory. What concerns you?
>>
>>52238303
POOINLOO?
>>
>>52238332
It is. Object means it can literally be anything. That's what a dynamic type is.
>>
>>52238358
No.
>>
File: 1451438836844.jpg (72 KB, 512x512) Image search: [Google]
1451438836844.jpg
72 KB, 512x512
>>52238358
>this is the type of person you post with on /g/
>>
>>52237154
Underrated post
>>
>>52238382
Yes I know. Sometime it's hard.
>>
How can we have 4-dimensional arrays when we live in a 3-dimensional universe?
>>
Should I learn erlang or haskell, /dpt/?
>>
>>52238357
T Y P I C A L
Y
P
I
C
A
L
>>
>>52238405
OCaml.
>>
>>52238380
>>52238382
What do you think a dynamic type is?

Some explanation as to why you think I'm wrong would be nice.
>>
>>52238405
F#.
>>
>>52238405
haskell

but really just stick with c

you'll use it more
>>
>>52238402
>he thinks there are only 3 dimensions!
>>
>>52238422
Type existing at runtime.
>>
>>52238431
But I don't even know C...
>>
>>52238431
C++

but really just stick with asm

you'll use it more
>>
\documentclass{standalone}
\begin{document}
\directlua{a={} b=3 for i=0,3 do a[i]=i%b end for i=0,#a do tex.print(a[i]) end}
\end{document}

>tfw compiling to pdf
>>
>>52238445
Types always exist in runtime, no matter the language. I'd call you ignorant, but even basic reasoning would inform you that that definition is wrong.
>>
>>52238422
> a = 5
> type(a)
<class 'int'>
> a = '5'
> type(a)
<class 'str'>


The type of a, b and c in your example will always be of type Object.
>>
>>52238481
>Types always exist in runtime, no matter the language.
Not in typeless languages.
>>
>>52238450
then learn c/c++ first
>>
>>52238481
You really suck at CS.
>>
>>52238495
such as?
>>
>>52238481
>Types always exist in runtime
No they don't. Look at the assembly output of a C program and tell me where you see type information.
>>
>>52238489
>The type of a, b and c in your example will always be of type Object.
at compile time yes, which means they can be literally anything. That's what all variables are fields are at compile time in dynamic languages. Understanding this yet?
>>
>>52238529
I'm actually excellent at it. You could be learning a thing or two right now.
>>
>>52238534
http://c2.com/cgi/wiki?TypelessVsDynamic
>>
I'm using Forney's swc library to make a tiling wayland compositor.

I don't know a fucking thing about C, so this will be interesting.
>>
>>52238549
>which means they can be literally anything
They cannot be primitive types. You cannot convert a, b or c to a byte, short, int, long, float, double, boolean or char.
>>
>>52238590
You must be jocking. You just made my day.
>>
Is it kosher to create a shared object that relies on another shared object to work?
e.g. a library that makes OpenCL calls

Would it introduce any problems other than requiring OpenCL to be linked in addition to the new library?

I'm using gcc btw
>>
>>52238600
>c2.com
Found the inbred.
>>
wait so, in C, because the types are verified as correct by the compiler at compile time, there's no type information in the assembly, therefore it doesn't need to check shit at runtime, so it's faster than dynamic languages?
>>
>>52238606
Enjoy your memory leaks out the aSegmentation fault.
>>
>>52238600
>I have never seen a purely typeless language
great article
>>
>>52238255
it's just bants, didn't mean to offend
>>
>>52238646
That's one facet of why it can be faster, yes.
>>
>>52238646
C literally has the nicest type paradigm
weakly typed, the user gets to play around as they see fit
>>
>>52238644
>>52238657
first result on google
>>
>>52238679
C literally has by a billion miles the most painful, worst type paradigm.
>>
>>52238679
C hardly has a type system at all, its notion of type is much more oriented around sizes, offsets, etc. than anything else.
>>
File: imgur-2016_01_05-03:00:19.png (65 KB, 768x412) Image search: [Google]
imgur-2016_01_05-03:00:19.png
65 KB, 768x412
>>52238679
>>
>>52238654
Why? What causes the segmentation fault in the swc library?
>>
>>52238688
>first result on google
Great job. Only one result to find out there's no such thing as a purely typeless language.
>>
>>52238646
Pretty much, yeah. Because C isn't oop at all, a 'type' is more or less just a combination of memory sizes and how operators work sometimes.
>>
>>52238706
C, senpai.
>>
>>52238707
Types have nothing to do with OOP.
>>
>>52238405
Elixir, Erlang is a DSL for telecomunications, Elixir is a general purpose programming language
>>
>>52238646
>because the types are verified as correct by the compiler at compile time

C's type system is static/weak and allows all kinds of explicit or implicit casting, the former of which is idiomatic C and mostly obviates the benefits of static typing. The verification it does is rudimentary. If you want a performant language that actually attempts to nix type errors you can use Rust or all kinds of C dialects engineered for that purpose, or more practially, C++.

The rest is all correct though.
>>
>>52238709
ok.. try adding a struct to an int. what happens?
>>
>>52238714
Sounds like you've never used a strongly-OOPed language.
In most 'true' OOP languages (ie languages that are OOP from the start, not just 'with oop elements') types are objects that have properties and whatnot. In non-OOP languages like C this isn't the case
>>
>>52238714
I'd say that's not strictly true, because a large part of OOP is introducing new types (through classes) and subtyping relations and things like that.

But yes, C having weak typing has nothing to do with C not being OOP.
>>
>>52238748
>c
>struct
TOP KEK
>>
>>52238748
void* desu
>>
>>52238755
Reflection has nothing to do with OOP.
>>
>>52238770
OOP is more of a state of mind than an actual programming paradigm.
>>
>>52238767
u ok?
>>
>>52238782
Yeah, and reflection has nothing to do with that.
>>
>>52238748
It causes a compiler error. To quote the reason this came up:
>Types always exist in runtime, no matter the language
>runtime
>>
>>52237341
windows stable
yeah sure of course it is
>>
Do any of you guys use an alternative implementation of malloc?
Seems like it would be an easy win of performance, especially on Windows

Most stuff I find don't seem to have been updated in the last 10 years, though I guess that malloc is malloc. It's just that I was looking for something that would scale with modern architectures, with thread-local caches for small allocations and shit
>>
>>52238755
>In non-OOP languages like C this isn't the case
That has nothing to do with C not being OOP. C is weakly typed by design.
>>52238756
I didn't say OOP has nothing to do with types. I said types have nothing to do with OOP.

You can have types without anything resembling OOP.
>>
>>52238833
>alternative implementation of malloc

You mean a custom memory manager? Ultimately you have to call malloc to get memory, the only difference is how often it gets called.
>>
File: delicious.png (122 KB, 512x511) Image search: [Google]
delicious.png
122 KB, 512x511
>>52238698
That comment.
>>
>>52238833
Why tho?
If you're in a situation where malloc would cause performance issues, you're probably working on an embedded system, the general rule in embedded programming is no dynamic memory allocation for any reason.
It leads to too many things that can go wrong, especially on embedded chips that require years of uptime or life critical shit.
>>
what's a language that is:
- strongly, statically typed
- type inference
- OOP from the ground up (i want to do cool shit like "asdf".length() )
- compiled ofc
>>
File: filter.png (18 KB, 512x512) Image search: [Google]
filter.png
18 KB, 512x512
Please rate my implementation of grep / filter

I wrote it in C++ because I anticipated pointer usage, however turns out I didn't need to use pointers at all, so this code could be changed to any language without much trouble.

Whole program, with more detailed comments, is on my website:
http://joeburger.ax.lt/cpp/fastFilter.txt

Here's the filter function:
 /*
* Precondition:
* - size is the number of elements in the array
* Postcondition:
* - size is the number of elements in the array which
* satisfy the callback function
* - array is sorted such that all elements which
* satisfy the callback function precede those that don't
*/
template <class T>
void filter(T * array, int & size,
std::function<bool(int)> callback) {
for (unsigned element = 0; element < size;)
if (!callback(array[element]))
std::swap(array[element], array[--size]);
else
element++;
}


You can download it @ http://joeburger.ax.lt/cpp/fastFilter.cpp
and run it with
g++ -std=c++11 -fpermissive fastFilter.cpp
>>
Is QTcreator a good IDE?
>>
>>52238888
nim maybe, haven't tried it myself but i think it looks p good
>>
>>52238859
>Ultimately you have to call malloc to get memory
That's not true, you can work with virtual memory from the OS.
>>
>>52238888
OCaml.
>>
>>52238895
Ah, forgot to ask, does anyone know a way such that I can pass in any function for callback?
I was thinking, maybe I would just make callback a void pointer, and then I cast it to <bool(T)>, however that syntax would look.
>>
>>52238859
I was looking more something that would link into my executable and replace malloc in the background without having the restructure all my shit
It's alright, I guess I'll have to implement those things myself when the time comes

>>52238882
I just wanted to make sure I wouldn't hit a performance spike. I'm working on a video game, so I can't take even a 0.5ms of freeze time due to kernel memory fetching shenanigans
>>
>>52238888
>- OOP from the ground up (i want to do cool shit like "asdf".length() )
I didn't know string literals were fucking objects. Also,

>.length() on a fucking constant
>>
>>52238882
>you're probably working on an embedded system

Missing the point. Malloc causes a program to switch between user mode and kernel mode. A lot of consecutive calls to malloc will call performance issues on almost any platform.
>>
>>52238888
What's wrong with length("asfd")?
It's less typing

Though I guess you don't get the neat auto-completion
>>
>>52238833
Hoard is pretty popular, although it's GPL and somewhat expensive if you want to use it in a proprietary application.
>>
>>52238931
Typically, video games (if performance is that important) just don't call malloc() on the fly at all. They allocate everything up front and use "custom allocators" to fit the specific use cases, like pools, stacks, heaps, etc.
>>
>>52238954
The engine is open source, though the game built on top of it probably won't be
I'm not sure if that would be a legal problem
Probably not?
>>
>>52238976
Yeah, that's the thing. As a game programmer, I want to be able to allocate as much as I want just as if I was coding in any other context
It would be neat if the custom allocators shit was implemented in the background
>>
>>52238979
>the game built on top of it probably won't be
Why?
>>
>>52238976
yup. A good example of this: https://community.bistudio.com/wiki/ArmA_2:_Custom_Memory_Allocator
>>
>>52239006
Meh, I don't mind it, it's just that I like keeping some secrets in a video game

Well, the secrets could be implemented in the data though, the code could be FOSS I guess
>>
>>52238901
yes
>>
>>52238976
Just wait for JAI.
>>
As far as I understand it, because in Haskell there are no side effects, in Haskell you can just compile with -threaded or something and you get free multithreading.

But what are the advantages of imperative? Is it just shit?
>>
>>52239029
much faster, much easier to learn, much less complex.
>>
>>52238979
You'd have to GPL the engine, but depending on how the game itself is specified you can get away with keeping it all proprietary. For example, if all the game code is in a scripting language, that counts as data and is not "infected" by the GPL.

>>52239003
It's pretty unlikely, if you separate the "engine code" and "game code" enough, that the quick and dirty "game code" will even need to do any allocation of its own.

>>52239029
It's supposedly easier, but I don't buy it. I think that's a nurture vs. nature issue.
>>
In C, which is better for performance? passing a boolean to a function as an int or as a char?
I'm writing a VM so it's important.
>>
>>52239058
char is 1 byte
>>
>>52239058
There are no boolean in C. But the fastest would be to pass it using word sized value, ie int.
>>
>>52239065
Yes, but parameters are passed on the stack, and the stack is word aligned.

>>52239071
>There are no boolean in C
You think i didn't know that?
I obviously meant a parameter that is only interpreted as true or false.
>>
>>52239053
open source the game engine, all the assets are still proprietary and copyrighted
>>
Anyone program with UE4 c++ yet?
>>
>>52239050
None of those points are true.
>>
>>52239050
I disagree that it's somehow inherently faster. There's nothing about functional programming that REQUIRES garbage collection or tons of laziness or anything else that makes existing functional languages slower.

You can have a functional language with pointers, malloc(), and free() just fine. And the advantage that a functional language has over an imperative language is that the type system can be far more expressive and it's possible to mostly automate static verification.
>>
>>52239091
>>52239053
Alternatively, put the memory management code in a dynamically loaded library which is GPL.
>>
>>52239144
or you know, just use regular malloc
>>
>>52238888
Crystal
>wanting OOP from the ground up
Absolutely disgusting.
>>
>>52239144
If you link to a GPL library your code must also be GPL. LGPL does not have this restriction.
>>
>>52239128
i don't think it's the garbage collection that is making it slow really
>>
>>52239155
That's not viable in most actual soft-realtime large-requirements production environments, to say nothing of hard-realtime ones.
>>
>>52239167
Then what is, exactly?
>>
>>52239163
False if it is linked dynamically.
>>
>>52238709
C is good, but it can't compile to PDF, so it's not really that useful.
>>
>>52239175
Moreover, it's often not clear if two programs which supposedly have the same functionality really do the same thing. Different languages sometimes require very different ways of expressing the same intent. Certain types of bug are rare in typical Haskell programs that are more common in other languages and vice versa, due to strong typing, automatic memory management and lazy evaluation.

Nonetheless, it is usually possible to write a Haskell program that performs as well as, or better than, the same program written in any other language. The main caveat is that you may have to modify your code significantly in order to improve its performance. Compilers such as GHC are good at eliminating layers of abstraction, but they aren't perfect, and often need some help.

There are many non-invasive techniques: compiler options, for example. Then there are techniques that require adding some small amounts of performance cruft to your program: strictness annotations, for example. If you still don't get the best performance, though, it might be necessary to resort to larger refactorings.


from haskell wiki
>>
>>52239192
You didn't answer my question.
>>
>>52239128
>I disagree that it's somehow inherently faster.
If not inherently, then certainly practically.

>There's nothing about functional programming that REQUIRES garbage collection
Yes there is, unless you use an insane amount of memory. You basically need GC to be able to avoid mutation in any meaningful way.

>You can have a functional language with pointers, malloc(), and free() just fine.
Not pure. If you want to mix imperative and functional there's plenty of languages for that.
>>
Why are C parameters passed on the fucking stack?
Why not pass them by register? if you have more parameters than registers then you can just pass the rest of them on the stack.
>>
>>52239202
gcc can do that optimization
look at the switches
>>
>>52239200
i don't know :(
>>
>>52239188
Static or dynamic, your code must also be GPL.

http://www.gnu.org/licenses/gpl-faq.en.html#GPLStaticVsDynamic

LGPL, as already mentioned, does not have this restriction.
>>
I just started a new job (first job with salary over 6 figures). I have a laptop and 2 other monitors: One is 19 inch and the other is 17, I think?

I use dual 27s at home. Even though my setup is technically 3 monitors it feels bitchmade because I'm used to a lot of screenspace.

Ugh.......
>>
Working on a parametric equation graphing utility in Java. Here some neat code.
private void draw()
{
Point2D p = curveFunction();

g.setStroke(Color.RED);

double newX = 400 + p.getX();
double newY = 300 + p.getY();

if(oldx != 400 && oldy !=300)
g.strokeLine(oldx, oldy, newX, newY);

//g.strokeOval(newX, newY, 1, 1);

oldx = newX;
oldy = newY;
}

private Point2D curveFunction()
{
double x = 4 * sin(t) * (pow(E, cos(t)) - 2 * cos(4*t) - pow(sin(t/12), 5));
double y = cos(t) * (pow(E, cos(t)) - 2 * cos(4*t) - pow(sin(t/12), 5));

return new Point2D(x,-y).multiply(50);
}
>>
>>52239238
>using java
It's probably find but /dpt/ will rip you open for this one.

This post is licensed under the terms of the GNU Free Documentation License, version 1.3.Permission is granted to copy, distribute and/or modify this document
under the terms of the License
or any later version published by the Free Software Foundation;
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
A copy of the license can be found at <https://gnu.org/licenses/fdl.html>.
>>
>>52239232
>over 6 figures

So a 7 figure salary in other words?
>>
>>52239275
no.
>>
>>52239273
>hurr durr meme language

It's the language I feel most comfortable in so fuck you.
>>
File: fff.jpg (43 KB, 236x252) Image search: [Google]
fff.jpg
43 KB, 236x252
>>52239189
>but it can't compile to PDF
>>
>>52239286
So a over 7 figure salary in other words?
>>
>>52239128
>the type system can be far more expressive and it's possible to mostly automate static verification.
That has nothing at all to do with functional programming. Haskell's type system can't even verify the monad laws. Most "functional" (actually self-hating imperative) languages are even worse.
>>
>>52239232
cucked hard

but seriously just ask for better monitors or ask if you can use your own monitors
>>
>>52239201
>You basically need GC to be able to avoid mutation in any meaningful way.
1. That's not true. See the Clean language, and linear types in general.
2. Avoiding mutation is not necessary, as long as it's quantified.

>Not pure.
Here we go again. It's okay to do anything that can be seen as a "side effect"; the types just have to be modeled such that the program will be correct under any evaluation strategy. That is the core principle of purity, and why it permits so many optimizations.

>>52239225
Then don't make generalizations like "functional is slower than imperative".

>>52239321
Haskell is just one functional language. I don't think Haskell is particularly safe at all, from a verification standpoint.
>>
>>52239128
In particular, linear types such as in ATS completely eliminate the need for garbage collection without impacting the functional-ity of the language; while also ensuring there is no memory-related error in a compiled program.

>>52239175
Usually it's the write barrier or bad allocation strategies which are caused by bad code; othertimes it's because the wrong parameters were given to the GC (such as having a very small minor heap for a program that generates large ephemeral objects). Another possible issue is compaction: if you fragment the GC-managed memory areas too much, a compaction pass must be applied; thus doing many weirdly-sized allocations can impact performance a lot. Those are all e.g. bad gc parameters rather than the gc itself being an issue.
There's also many GC implementations, ranging widely in terms of speed and latency. There are even so-called realtime garbage collectors.

That said, compiling is not an easy task, and most likely the largest chunk of reduce performance wrt non-C languages comes from lacking optimizations in the compiler, especially full-program and link-time optimizers, as a lot of them want to support a rapid development cycle using a REPL. Specialized compilers like mlton and the ocaml flambda branch try to address that, but needless to say, that shit isn't easy to develop.

Notice that even java and its mediocre GC perform quite well, and that ATS is an example of a functional programming language that is blazing fast (despite very little development effort going into it).
>>
>>52239301
PDFs are, by definition, more portable than binary executable. It's only natural that a so-called 'portable' language such as C should compile to it.

This post is licensed under the terms of the GNU Free Documentation License, Version 1.3. Permissions is granted to copy, distribute, and/or modify this document under the terms of the License or any later version published by the Free Software Foundation. A copy of the License can be found at https://gnu.org/licenses/fdl.html.
>>
>>52239232
Multi-monitor setups are complete shit unless they are all the same model.

The colours never fucking match up no matter what you tweak, unless they have exactly the same configuration.
and even if you do get one or two background colours to match, the rest wont.
>>
>>52239347
Not sure why all this was directed at me.

>That said, compiling is not an easy task, and most likely the largest chunk of reduce performance wrt non-C languages comes from lacking optimizations in the compiler, especially full-program and link-time optimizers
LLVM can support functional languages just fine.
>>
>>52239353
>tfw you're too frugal to buy triple color-calibrated 4k monitors and a high-end work chair
>>
>>52239344
Purity means no side-effects. The following function is not pure:
let fn () =
let x = ref 0 in
for i = 0 to 10 do
x := i + !x
done;
Printf.printf "%d%!" x

And neither is the following:
let fn j =
let x = ref 0 in
for i = j to 10 do
x := i + !x
done;
!x
>>
built a chat system for the console using socket io.

open up dev tools on this 404 page and type msg('hi')

http://cht.run

suggestions welcome
>>
File: 16286409295_ffda04216e_o.gif (469 KB, 480x228) Image search: [Google]
16286409295_ffda04216e_o.gif
469 KB, 480x228
>>52239350
>>
>>52239387
The second is pure for the outside world. Not the first one.
>>
>>52239344
>Then don't make generalizations like "functional is slower than imperative".
i'm not that guy
>>
>>52239382
LLVM is designed so you have to go out of your way to even implement mutation (by putting allocas everywhere), but that doesn't make LLVM actually fast. One needs to design many complex transformation passes that do not come with LLVM to get anywhere near the ballpark; and non-shit compilers like GCC go a hell of a lot further with C, with complex static analysis, statistical analysis, code pre and post transformation, etc.
LLVM gives you theoretical portability and that's it.
>>
>>52239413
Neither are pure.
>muh outside world
>>>/ooptardland/
Thread replies: 255
Thread images: 16

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.