Old thread: What are you working on, Sup Forums?
/dpt/ - Daily Programming Thread
Other urls found in this thread:
sarabander.github.io
docs.idris-lang.org
twitter.com
c++ is the greatest language of all time.
This is not a bizarro-/dpt/ thread, user.
Lua is weird
I need something thats as easy and light to embed into C as lua is, that's also portable.
Is there anything besides chibi scheme or guile?
Sad but true.
GIS homework, but I wanted to share the convoluted command used to extract raster classifications for a tree value analysis I'm doing
int("1"+str(!Value!)[1:3]+"00")
1. C preprocessor is garbage. Hence C++ macros are garbage.
2. No standard dependency management system. Shipping packages are a complete nightmare. Simple makefile is a unicorn and CMake is more embarrassing than make. Ninja written in python and misses the point entirely.
3. Standard library does not even have useful string manipulation functions like split, Capitalize, iterateByCodeUnit etc. Can't even switch over strings. Embarrassing!
3. Build times are massive.
4. No open language server. Clangd is not stable yet.
5. Compiler error messages are pointlessly dumb and verbose.
6. No modules. Useful Libraries like Qt will never get modules. Current modules TS is flawed by design.
7. No concept of metaclasses, does not support signals and slots.
first for mit-scheme is /comfy/
>python consistently throwing errors when attempting to index past (len/2)
If you mean you're actually indexing with (len/2 + i) then if len is odd your index will not be an integer.
no
a="abcde"
a[3], or a[4] returns an out of index error
so does a[-2] but not a[-1]
I hacked around it, but still
>C++ can't do real functional programming because a GC is required for that.
Is this true?
That should work, are you sure you don't have an error like a being a list a=['abcde'] or something? That happens sometimes with the returns of some library functions and can go unnoticed then use a[0][3] instead of a[3]
it's def a string, but it's not a pure python environment. it's within arcmap. but i made it work by adding a few extra characters to the end of each striing
Let me intruduce you to
std::shared_ptr
And
std::unique ptr
Reminder that C++ is one of the most inadequate programming languages ever conceived, and that it's been scientifically demonstrated that the average IQ of a C++ programmer is 87.
This. Modern C++ is reference counted. Memory management is a solved problem in C++.
>memory management is a solved problem in C++
Do you actually believe this, or are you just memeing? Have you ever heard of cycles of references?
>wtf is std:weak_ptr
>all references are owning references
You bug dum dum
>Have you ever heard of cycles of references?
Quit programming
Guess how I know you've never actually used reference counting in any real code.
>cycles of references
I don't know shit about C++, but generally speaking, how is this possible unless the programmer deliberately fucks things up?
It seems to me that if you stick with your language's version of the "duplicate" and "free" abstractions, your reference tree will never have cycles.
So I take it that the part about FP needing GC is true?
>durrrr j-just use weak_ptr
>hurrrr data structures with cycles don't exist
Holy shit, you people are retarded fucking monkeys... Can you conceive of something like [pic related]? All the nodes have the same type. Is the reference strong or weak, you mongrels? Calling a problem "solved" means you don't have to come up with ugly application-specific workarounds for this every time.
wait, so C++s GC is so shit it cant handle cycles? this has been solved decades ago in real GCed languages
C++ is a garbage language but has a lot of amazing features.
How come there are no C++ dialects that take the pain out of C++?
Like look at C++ syntax vs C# syntax:
class MyClass where T : SomeClass, new {}
vs
template
class MyClass {};
>C++s GC
this guy
wouldn't it be trivial to write a prebuild processor that compiles the C# like syntax to the C++ one?
Wren, JavaScript (via Duktape)
Trivial? No.
Doable? Yes.
Which is why I'm so damn surprised there are none.
Like not another language just a dialect. I know Elixir is a dialect of Erlang that does (more or less) the exact same thing as Erlang but is easier to write code in.
>wouldn't it be trivial to write a prebuild processor that compiles the C# like syntax to the C++ one?
Only for some trivial subset of all possible cases.
You are a trivial subset of all possible people.
>tfw you'd just use boehm gc and call it done
>tfw you're a meme programmer
message = fuck
key = FQ
how can i make key print so its prints to the length of the message
should be
FQFQ
not FQ(NULL)(NULL)
>she uses the absolute turd that is C++
>she uses a shitty, slow, conservative GC that leaks memory
That's not even the point, though. I knew the quality of C++ programmers is generally low, but I didn't know most of them were such inbred mongrels that they seriously thought weak references are a magic bullet that solves all the problems with reference counting.
depending on your language
key * 2
:^)
or just copy the string on itself
take (length message) $ cycle key
just iterate over message's characters and use the index of message mod length of "key" to print the right character of "key"
trust me im a professional fizzbuzzer
Good thing I'm not a programming language syntax, then, retard. How about instead of inventing specialized syntax for the tractable part of the self-inflicted problem that is C++, you just stop using C++?
My next project will not free memory ever, and I'll use a cronjob to kill the server every 30 minutes just to spite you, user.
if you dont have access to any good string or list handling methods:
string a = ""
for (int i = 0; i < message .Length; i++) {
a += key [i % key .Length];
}
>just iterate over message's characters and use the index of message mod length of "key" to print the right character of "key"
this is C but you guys are correct
but not for
message = FUCKYOUFAGGOT
key = FQ
FUCKYOUFAGGOT
FQFQFQFQFQFQF
Anyone knows where I can download a version of SICP without fucked up formulas?
The learning of HTML. duh.
this except for js
Download? Dunno
But this is pretty nice
sarabander.github.io
>this is C but you guys are correct
>but not for
>message = FUCKYOUFAGGOT
>key = FQ
what are you saying? that it doesnt work? pic related.
Heres a more efficient one anyway:
for (int i = 0; i < m.Length / k.Length; i++) {
a += k;
}
a += k.Substring(0, m.Length % k.Length);
>will not free memory ever, and I'll use a cronjob to kill the server every 30 minutes
That's unironically a better memory management strategy than anything C++ offers. Enjoy your low-IQ trashlang.
Just fucking buy the book. PDFs are a meme.
ignoring politics and judging the language itself, is rust a meme or worth learning?
Not for now, unless it gives you good ways to go around borrow checkers.
whats your fav lang then.
>is rust a meme or worth learning?
Rust is garbage, but give it a try and see for yourself. I wouldn't trust /dpt/ opinions if I were you.
>All the nodes have the same type
the relationships shown imply that either they shouldn't have the same type (differentiated by the difference in ownership semantics), or their memory should be owned/managed externally by a higher-level type. data structures with cycles *don't* really exist, they indicate erroneous misplacement of ownership. if ownership can not be fully expressed within a type or set of types at a particular level of abstraction, then some part of the ownership model obviously naturally belongs at a higher level of abstraction
>Calling a problem "solved" means you don't have to come up with ugly application-specific workarounds for this every time
optimal application-specific solutions are far more "solved" than suboptimal generalized solutions
The language by itself is OK, the problem is the compiler and libraries are utter shit.
No.
Idris already does it better.
docs.idris-lang.org
>she has a "fav lang"
I use whatever is best suited for the job. Sometimes it's C, sometimes it's CL, sometimes it's Lua, sometimes it's Nim, sometimes it's horrors like Bash and JS. It's never C++, though.
Sheeps not using functional language for everything
Hop off to you retarded frogposter.
>the relationships shown imply that either they shouldn't have the same type
Nothing about that picture implies that they shouldn't have the same type. The fact that reference counting can't handle it cleanly doesn't prove anything.
>data structures with cycles *don't* really exist, they indicate erroneous misplacement of ownership
Nice religious belief you've got there, but the fact remains that reference-counting doesn't solve the memory management problem in the given instance.
>optimal application-specific solutions are far more "solved" than suboptimal generalized solutions
No, you inbred mongrel. Optimal application-specific solutions are solutions to application-specific problems. Reference counting is not a solution to the general problem of memory management. A "suboptimal" generalized solution like a decent GC is. Why is this so difficult for your retarded religious cult ass to grasp?
>Schrödinger's cat
Dumb nigger doesn't understand lifetimes.
>Not mixing OOP, procedural, FP, DOD and anything else you can find to make the most performint, maintainable and readable code possible
gb2 india
All these faggots with their unique_illness need to fuck off C++ and go back to their GC lang.
>the lack of consistent design principles and coherence aids maintainability and readability
I guess that's the other side of the retard-coin, opposite to dogmatism?
In C++ RAII is a bandaid to circumvent broken exceptions.
Cheat engine is the best example of this.
pls explain
>aids maintainability and readability
It does, its only when it doesn't that its a problem.
>its only when it doesn't that its a problem
Alright, user. Tell me about all the instances where an incoherent solution without consistent design principles ended up being the best. Protip: your tiny Python script doesn't count.
What's wrong with Lua
Let's talk about package management. I don't know CMake. Is there a nice build script that handles dep management automatically?
For example, My project tree is something like:
/src/
|_local/main.cpp
|_foreign/
|_avTranscoder/[...]
|_jsoncpp/[...]
|_cereal/[...]
Each of foreign/ contains CMake managed library, I forked them in the git. I want CMake to build self/ and foreign/ automatically.
CMake is awful.
Also, bundling third party shit is stupid. Stop being an idiot and use pkg-config.
Just because the ideas are grouped under different names like OOP and FP doesn't mean its not consistent, I have never actually seen production code that purely used a single paradigm. take almost any game code and you will find that on a large scale they use OOP to encapsulate the different systems, FP to handle the UIs event based system inside one UI object, inside the main loop they will use DOD and procedural to maximize performance, and so on.
switch to another language if you want a proper package manager.
Whenever you have different modules where using a programming language over another is more important than consistency to make things easier and more understandable.
I cites cheat engine before. See the languages they use for gui, memory accessibility, pure functional tasks, scripting and kernel module (dbk sys)
>b-b-but muh paradigms are just labels
Nope.
>I have never actually seen production code that purely used a single paradigm
You have never seen any production code at all. In any case, this is not an argument.
>this project i saw on github once had some dot syntax sugar so it's obviously OOP, and it had some pure functions, so it's obviously FP as well, and it even had some procedures outside of classes, so it's DoD too
>wow this proves everything i said
Yeah, alright.
>Whenever you have different modules where using a programming language over another is more important than consistency
If you are outright using different languages, chances are that either your modules are so separate that this discussion is moot, or that your code is a complete and utter intermingled clusterfuck, which naturally means that your ideas about what's more "understandable" are irrelevant.
jesus /dpt/ went to shit lately.
>she thinks using different PLs in production code each where they shine most is not consistent and scares away shit pull requests for open source projects.
>Nothing about that picture implies that they shouldn't have the same type
as i said, it implies that *either* they should be of different type, or their memory should be managed externally. a difference in ownership semantics is a difference in type unless ownership semantics are external to the type in question. something is either external to a type, or part of the type. this should be obvious
>The fact that reference counting can't handle it cleanly doesn't prove anything
>but the fact remains that reference-counting doesn't solve the memory management problem in the given instance
>Reference counting is not a solution to the general problem of memory management
i never said i was talking about reference counting alone, you fucking moron. not sure how you got that impression. but GC is indeed suboptimal in most cases (since if there is a type/ownership/lifetime relationship to speak of, an optimized solution should be able to take advantage of such one way or another since it is informed by additional information which would otherwise simply be unknown - fewer and/or weaker guarantees limits the degree of optimization possible; this too should be obvious) where the semantics of C++ (which allow for high-level ownership/lifetime semantics including but not limited to reference counting) allow for more optimal (including theoretically ideal) solutions, subject of course to the limitations of current theoretical mathematics. the fact that the reference-counting-based semantics of the canonical set of smart pointers can solve the ownership model for many common data structures and/or localized systems of such doesn't somehow mean that the theoretical set of C++ ownership/lifetime semantics or their applications just stop there
>she didn't learn to not assume anyone's gender
>your modules are so seperate
How can you use two programming languages interchangeably in a module? (C/C++ is not answer)
Basically you have no idea what production code or any werking code looks like. Go add consts somewhere else.
>it implies that *either* they should be of different type, or their memory should be managed externally
I addressed both. One is clearly not the case, and the other is your arbitrary religious belief.
>i never said i was talking about reference counting alone
Then consider suicide, because the discussion was about reference counting. I hope you enjoyed writing that drivel.
Whats with all these people larping as 'real' programmers saying people they don't agree with them have never seen real code and only small open source programs, or is it one person spamming this in in these threads?
>she responds to some hallucination of hers that isn't actually part of my post
Good job.
>How can you use two programming languages interchangeably in a module?
Easily.
>you have no idea what production code or any werking code looks like
So your only "argument" is that all the "real" you've seen was an incoherent clusterfuck without any consistent design principles, and anyone who finds your claims dubious just isn't as professional as you are? Very strong case, but I think you can bolster even further with some more anecdotal claims and assumptions, sweetie. Why not? They're a dime a dozen.
>she is this autistic
>she thinks the only code that matters is purely academic code with no practical use
>she uses classes in C++
>she keeps memeing about imaginary code
>she still can't make a single argument
I hate to tell you, user, but most production code uses mainly one paradigm (no; the occasional pure function or use of map/filter doesn't make it FP), and still turns out a shitty and incoherent mess over time. What you're proposing only works in the fantasy world where everything is made of independent, encapsulated units, so that what goes on inside a particular unit is of no concern to the overall system, but at that point you can argue that from a system-wide perspective, your paradigm is OOP.
Cheat Engine isn't exactly the best example of a well-structured project...
im sad /dpt/
std::why
kek
Thanks, downloaded the EPUB from his Github and converted it into PDF :^)
>I addressed both. One is clearly not the case, and the other is your arbitrary religious belief.
how fucking stupid can you be? it's not remotely an "arbitrary religious belief", it's clearly true at the simplest of logical levels
>Then consider suicide, because the discussion was about reference counting
first, your post to which i responded didn't reply to anything. second, there's no point in arguing about reference counting alone (except as a strawman) because it's meaningless except in the broader context of ownership/lifetime semantics, wherein (in any case) a system of semantics that gives you more control allows for the formation of more/stronger guarantees will allow for more optimal solutions than a general case solution which is limited in the assumptions it can make. this is also obviously and unquestionably true. it doesn't matter if reference counting alone will not solve a problem unless a language is limited to reference counting alone, and C++ is obviously not. that would be ridiculous, considering there are many data structures/systems which can be solved without having to resort to something like reference counting at all (many can be solved optimally with unique_ptr and non-owning pointers/references alone - and in such cases, GC is obviously *especially* retarded)
It is actually well structured.
There are professional maintainers for every module and when they decide to change something they can just change the module without breaking everything or forgetting to change modules that use it.
It also scares away noobs so much no one will actually suggest making a variable const.
Unlike programming languages where everything is a cluster fuck of project managers that haven't got a clue what to do next or what to change.
Not everything has to be NPM-like.