4 ms·
Is there any language where string handling doesn't suck? (No script languages please, because they cheat by implementing the hard things on C or C++) From mem
by oscargrouch 6y ago
Is there any language where string handling doesn't suck?
(No script languages please, because they cheat by implementing the hard things on C or C++)
From memory the less horrible experience i had was with Go, but there's help for the slices on the runtime which let the difficult parts hidden and also the batteries-included std library, which is one of the most well designed standard libraries out there.
Buffer management is one of the things that sucks the most in any language, and the ones that dont its because the complexity is hidden in another fundamental layer.
- philipkglass 6y agoI think it's pretty nice in Scala. I don't know if "no virtual machines" was implied as part of the "no script languages" request, though. scala> "Mary had a little lamb. The lamb was in federal witness protection.".split("lamb") res0: Array[String] = Array("Mary had a little ", ". The ", " was in federal witness protection.")
- oscargrouch 6y agoNo, its ok and not part of that category. I meant for languages where the hard parts are delegated to another like Python and Javascript (C and C++ respectively).
- mehrdadn 6y agoC# and Python... "a, b".Split(", ") // C# "a, b".split(", ") # Python
- Measter 6y agoIn Rust: "a, b".split(", ")
- sasaf5 6y agoI would risk to mention Tcl as a good candidate, which might be unfair because the language is designed for strings. split "foo.bar" . => foo bar
- kkdaemas 6y ago> implementing the hard things on C or C++ This misses the point. I don't care how the language implements the functionality if it meets my performance requirements and it is convenient to use.
- oscargrouch 6y ago> This misses the point. I don't care how the language implements the functionality if it meets my performance requirements and it is convenient to use. I dont think it does, because it meant you are working on a simple language that can only afford to be simple delegating the harder parts to other languages that took the effort to be designed to deal with everything. The convenience is payed by someone else, and the language that pay for the hard stuff are the ones that are complex, because they need to work well with any sort of algorithms.
- mhh__ 6y agoStrings in D are pretty nice, along with the extremely expressive range algorithms. Unicode is a slight pain (it's explicitly supported and works fine but it was designed before UTF8 dominated so there's baggage)
- chromatin 6y agoRanges are an absolute pleasure to use, and besides the great template system, my favorite part of D